add hover tests
This commit is contained in:
parent
2b9f613eab
commit
c1de24e825
@ -1,6 +1,6 @@
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtTest, QtGui, QtCore
|
||||
from pyqtgraph.tests import mouseDrag
|
||||
from pyqtgraph.tests import mouseDrag, mouseMove
|
||||
pg.mkQApp()
|
||||
|
||||
qWait = QtTest.QTest.qWait
|
||||
@ -18,6 +18,8 @@ def test_mouseInteraction():
|
||||
# test horizontal drag
|
||||
pos = plt.plotItem.vb.mapViewToScene(pg.Point(0,5)).toPoint()
|
||||
pos2 = pos - QtCore.QPoint(200, 200)
|
||||
mouseMove(plt, pos)
|
||||
assert vline.mouseHovering is True and hline.mouseHovering is False
|
||||
mouseDrag(plt, pos, pos2, QtCore.Qt.LeftButton)
|
||||
px = vline.pixelLength(pg.Point(1, 0), ortho=True)
|
||||
assert abs(vline.value() - plt.plotItem.vb.mapSceneToView(pos2).x()) <= px
|
||||
@ -26,12 +28,16 @@ def test_mouseInteraction():
|
||||
pos = plt.plotItem.vb.mapViewToScene(pg.Point(5,0)).toPoint()
|
||||
pos = pos + QtCore.QPoint(0, 6)
|
||||
pos2 = pos + QtCore.QPoint(-20, -20)
|
||||
mouseMove(plt, pos)
|
||||
assert vline.mouseHovering is False and hline.mouseHovering is False
|
||||
mouseDrag(plt, pos, pos2, QtCore.Qt.LeftButton)
|
||||
assert hline.value() == 0
|
||||
|
||||
# test vertical drag
|
||||
pos = plt.plotItem.vb.mapViewToScene(pg.Point(5,0)).toPoint()
|
||||
pos2 = pos - QtCore.QPoint(50, 50)
|
||||
mouseMove(plt, pos)
|
||||
assert vline.mouseHovering is False and hline.mouseHovering is True
|
||||
mouseDrag(plt, pos, pos2, QtCore.Qt.LeftButton)
|
||||
px = hline.pixelLength(pg.Point(1, 0), ortho=True)
|
||||
assert abs(hline.value() - plt.plotItem.vb.mapSceneToView(pos2).y()) <= px
|
||||
|
Loading…
Reference in New Issue
Block a user