summaryrefslogtreecommitdiff
path: root/silx/gui/plot/test/testMaskToolsWidget.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/plot/test/testMaskToolsWidget.py')
-rw-r--r--silx/gui/plot/test/testMaskToolsWidget.py38
1 files changed, 16 insertions, 22 deletions
diff --git a/silx/gui/plot/test/testMaskToolsWidget.py b/silx/gui/plot/test/testMaskToolsWidget.py
index 0c11928..191bbe0 100644
--- a/silx/gui/plot/test/testMaskToolsWidget.py
+++ b/silx/gui/plot/test/testMaskToolsWidget.py
@@ -26,7 +26,7 @@
__authors__ = ["T. Vincent"]
__license__ = "MIT"
-__date__ = "24/01/2017"
+__date__ = "01/09/2017"
import logging
@@ -37,8 +37,9 @@ import numpy
from silx.gui import qt
from silx.test.utils import temp_dir, ParametricTestCase
-from silx.gui.test.utils import TestCaseQt, getQToolButtonFromAction
+from silx.gui.test.utils import getQToolButtonFromAction
from silx.gui.plot import PlotWindow, MaskToolsWidget
+from .utils import PlotWidgetTestCase
try:
import fabio
@@ -46,33 +47,24 @@ except ImportError:
fabio = None
-logging.basicConfig()
_logger = logging.getLogger(__name__)
-class TestMaskToolsWidget(TestCaseQt, ParametricTestCase):
+class TestMaskToolsWidget(PlotWidgetTestCase, ParametricTestCase):
"""Basic test for MaskToolsWidget"""
+ def _createPlot(self):
+ return PlotWindow()
+
def setUp(self):
super(TestMaskToolsWidget, self).setUp()
- self.plot = PlotWindow()
-
self.widget = MaskToolsWidget.MaskToolsDockWidget(plot=self.plot, name='TEST')
self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, self.widget)
-
- self.plot.show()
- self.qWaitForWindowExposed(self.plot)
-
self.maskWidget = self.widget.widget()
def tearDown(self):
del self.maskWidget
del self.widget
-
- self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
- self.plot.close()
- del self.plot
-
super(TestMaskToolsWidget, self).tearDown()
def testEmptyPlot(self):
@@ -85,7 +77,7 @@ class TestMaskToolsWidget(TestCaseQt, ParametricTestCase):
def _drag(self):
"""Drag from plot center to offset position"""
- plot = self.plot.centralWidget()
+ plot = self.plot.getWidgetHandle()
xCenter, yCenter = plot.width() // 2, plot.height() // 2
offset = min(plot.width(), plot.height()) // 10
@@ -99,7 +91,7 @@ class TestMaskToolsWidget(TestCaseQt, ParametricTestCase):
def _drawPolygon(self):
"""Draw a star polygon in the plot"""
- plot = self.plot.centralWidget()
+ plot = self.plot.getWidgetHandle()
x, y = plot.width() // 2, plot.height() // 2
offset = min(plot.width(), plot.height()) // 10
@@ -107,16 +99,17 @@ class TestMaskToolsWidget(TestCaseQt, ParametricTestCase):
(x - offset, y - offset),
(x + offset, y),
(x - offset, y),
- (x + offset, y - offset)]
+ (x + offset, y - offset),
+ (x, y + offset)] # Close polygon
+ self.mouseMove(plot, pos=(0, 0))
for pos in star:
self.mouseMove(plot, pos=pos)
- btn = qt.Qt.LeftButton if pos != star[-1] else qt.Qt.RightButton
- self.mouseClick(plot, btn, pos=pos)
+ self.mouseClick(plot, qt.Qt.LeftButton, pos=pos)
def _drawPencil(self):
"""Draw a star polygon in the plot"""
- plot = self.plot.centralWidget()
+ plot = self.plot.getWidgetHandle()
x, y = plot.width() // 2, plot.height() // 2
offset = min(plot.width(), plot.height()) // 10
@@ -126,9 +119,10 @@ class TestMaskToolsWidget(TestCaseQt, ParametricTestCase):
(x - offset, y),
(x + offset, y - offset)]
+ self.mouseMove(plot, pos=(0, 0))
self.mouseMove(plot, pos=star[0])
self.mousePress(plot, qt.Qt.LeftButton, pos=star[0])
- for pos in star:
+ for pos in star[1:]:
self.mouseMove(plot, pos=pos)
self.mouseRelease(
plot, qt.Qt.LeftButton, pos=star[-1])