summaryrefslogtreecommitdiff
path: root/silx/gui/plot/test/testPlotInteraction.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/plot/test/testPlotInteraction.py')
-rw-r--r--silx/gui/plot/test/testPlotInteraction.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/silx/gui/plot/test/testPlotInteraction.py b/silx/gui/plot/test/testPlotInteraction.py
index 25f57a9..335b1e4 100644
--- a/silx/gui/plot/test/testPlotInteraction.py
+++ b/silx/gui/plot/test/testPlotInteraction.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2016 European Synchrotron Radiation Facility
+# Copyright (c) 2016=2017 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -26,12 +26,12 @@
__authors__ = ["T. Vincent"]
__license__ = "MIT"
-__date__ = "13/10/2016"
+__date__ = "01/09/2017"
import unittest
from silx.gui import qt
-from silx.gui.plot.test.testPlotWidget import _PlotWidgetTest
+from .utils import PlotWidgetTestCase
class _SignalDump(object):
@@ -49,7 +49,7 @@ class _SignalDump(object):
return list(self._received)
-class TestSelectPolygon(_PlotWidgetTest):
+class TestSelectPolygon(PlotWidgetTestCase):
"""Test polygon selection interaction"""
def _interactionModeChanged(self, source):
@@ -59,17 +59,16 @@ class TestSelectPolygon(_PlotWidgetTest):
def _draw(self, polygon):
"""Draw a polygon in the plot
- :param polygon: List of points (x, y) of the polygon (not closed)
+ :param polygon: List of points (x, y) of the polygon (closed)
"""
- plot = self.plot.centralWidget()
+ plot = self.plot.getWidgetHandle()
dump = _SignalDump()
self.plot.sigPlotSignal.connect(dump)
for pos in polygon:
self.mouseMove(plot, pos=pos)
- btn = qt.Qt.LeftButton if pos != polygon[-1] else qt.Qt.RightButton
- self.mouseClick(plot, btn, pos=pos)
+ self.mouseClick(plot, qt.Qt.LeftButton, pos=pos)
self.plot.sigPlotSignal.disconnect(dump)
return [args[0] for args in dump.received]
@@ -89,7 +88,7 @@ class TestSelectPolygon(_PlotWidgetTest):
self.plot.sigInteractiveModeChanged.disconnect(
self._interactionModeChanged)
- plot = self.plot.centralWidget()
+ plot = self.plot.getWidgetHandle()
xCenter, yCenter = plot.width() // 2, plot.height() // 2
offset = min(plot.width(), plot.height()) // 10
@@ -98,7 +97,8 @@ class TestSelectPolygon(_PlotWidgetTest):
(xCenter - offset, yCenter - offset),
(xCenter + offset, yCenter),
(xCenter - offset, yCenter),
- (xCenter + offset, yCenter - offset)]
+ (xCenter + offset, yCenter - offset),
+ (xCenter, yCenter + offset)] # Close polygon
# Draw while dumping signals
events = self._draw(star)
@@ -113,7 +113,8 @@ class TestSelectPolygon(_PlotWidgetTest):
largeSquare = [(xCenter - offset, yCenter - offset),
(xCenter + offset, yCenter - offset),
(xCenter + offset, yCenter + offset),
- (xCenter - offset, yCenter + offset)]
+ (xCenter - offset, yCenter + offset),
+ (xCenter - offset, yCenter - offset)] # Close polygon
# Draw while dumping signals
events = self._draw(largeSquare)
@@ -128,7 +129,7 @@ class TestSelectPolygon(_PlotWidgetTest):
thinRectX = [(xCenter, yCenter - offset),
(xCenter, yCenter + offset),
(xCenter + 1, yCenter + offset),
- (xCenter + 1, yCenter - offset)]
+ (xCenter + 1, yCenter - offset)] # Close polygon
# Draw while dumping signals
events = self._draw(thinRectX)
@@ -143,7 +144,7 @@ class TestSelectPolygon(_PlotWidgetTest):
thinRectY = [(xCenter - offset, yCenter),
(xCenter + offset, yCenter),
(xCenter + offset, yCenter + 1),
- (xCenter - offset, yCenter + 1)]
+ (xCenter - offset, yCenter + 1)] # Close polygon
# Draw while dumping signals
events = self._draw(thinRectY)