summaryrefslogtreecommitdiff
path: root/silx/gui/dialog/test/test_colormapdialog.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/dialog/test/test_colormapdialog.py')
-rw-r--r--silx/gui/dialog/test/test_colormapdialog.py36
1 files changed, 10 insertions, 26 deletions
diff --git a/silx/gui/dialog/test/test_colormapdialog.py b/silx/gui/dialog/test/test_colormapdialog.py
index 6e50193..cbc9de1 100644
--- a/silx/gui/dialog/test/test_colormapdialog.py
+++ b/silx/gui/dialog/test/test_colormapdialog.py
@@ -26,13 +26,11 @@
__authors__ = ["T. Vincent"]
__license__ = "MIT"
-__date__ = "23/05/2018"
+__date__ = "09/11/2018"
-import doctest
import unittest
-from silx.gui.utils.testutils import qWaitForWindowExposedAndActivate
from silx.gui import qt
from silx.gui.dialog import ColormapDialog
from silx.gui.utils.testutils import TestCaseQt
@@ -47,23 +45,6 @@ import numpy.random
_qapp = qt.QApplication.instance() or qt.QApplication([])
-def _tearDownQt(docTest):
- """Tear down to use for test from docstring.
-
- Checks that dialog widget is displayed
- """
- dialogWidget = docTest.globs['dialog']
- qWaitForWindowExposedAndActivate(dialogWidget)
- dialogWidget.setAttribute(qt.Qt.WA_DeleteOnClose)
- dialogWidget.close()
- del dialogWidget
- _qapp.processEvents()
-
-
-cmapDocTestSuite = doctest.DocTestSuite(ColormapDialog, tearDown=_tearDownQt)
-"""Test suite of tests from the module's docstrings."""
-
-
class TestColormapDialog(TestCaseQt, ParametricTestCase):
"""Test the ColormapDialog."""
def setUp(self):
@@ -86,10 +67,12 @@ class TestColormapDialog(TestCaseQt, ParametricTestCase):
editing the same colormap"""
colormapDiag2 = ColormapDialog.ColormapDialog()
colormapDiag2.setColormap(self.colormap)
+ colormapDiag2.show()
self.colormapDiag.setColormap(self.colormap)
+ self.colormapDiag.show()
- self.colormapDiag._comboBoxColormap.setCurrentName('red')
- self.colormapDiag._normButtonLog.setChecked(True)
+ self.colormapDiag._comboBoxColormap._setCurrentName('red')
+ self.colormapDiag._normButtonLog.click()
self.assertTrue(self.colormap.getName() == 'red')
self.assertTrue(self.colormapDiag.getColormap().getName() == 'red')
self.assertTrue(self.colormap.getNormalization() == 'log')
@@ -178,6 +161,7 @@ class TestColormapDialog(TestCaseQt, ParametricTestCase):
def testSetColormapIsCorrect(self):
"""Make sure the interface fir the colormap when set a new colormap"""
self.colormap.setName('red')
+ self.colormapDiag.show()
for norm in (Colormap.NORMALIZATIONS):
for autoscale in (True, False):
if autoscale is True:
@@ -211,7 +195,7 @@ class TestColormapDialog(TestCaseQt, ParametricTestCase):
self.colormapDiag.show()
del self.colormap
self.assertTrue(self.colormapDiag.getColormap() is None)
- self.colormapDiag._comboBoxColormap.setCurrentName('blue')
+ self.colormapDiag._comboBoxColormap._setCurrentName('blue')
def testColormapEditedOutside(self):
"""Make sure the GUI is still up to date if the colormap is modified
@@ -274,7 +258,7 @@ class TestColormapDialog(TestCaseQt, ParametricTestCase):
cb = self.colormapDiag._comboBoxColormap
self.assertTrue(cb.getCurrentName() == colormapName)
cb.setCurrentIndex(0)
- index = cb.findColormap(colormapName)
+ index = cb.findLutName(colormapName)
assert index is not 0 # if 0 then the rest of the test has no sense
cb.setCurrentIndex(index)
self.assertTrue(cb.getCurrentName() == colormapName)
@@ -283,6 +267,7 @@ class TestColormapDialog(TestCaseQt, ParametricTestCase):
"""Test that the colormapDialog is correctly updated when changing the
colormap editable status"""
colormap = Colormap(normalization='linear', vmin=1.0, vmax=10.0)
+ self.colormapDiag.show()
self.colormapDiag.setColormap(colormap)
for editable in (True, False):
with self.subTest(editable=editable):
@@ -302,7 +287,7 @@ class TestColormapDialog(TestCaseQt, ParametricTestCase):
# False
self.colormapDiag.setModal(False)
colormap.setEditable(True)
- self.colormapDiag._normButtonLog.setChecked(True)
+ self.colormapDiag._normButtonLog.click()
resetButton = self.colormapDiag._buttonsNonModal.button(qt.QDialogButtonBox.Reset)
self.assertTrue(resetButton.isEnabled())
colormap.setEditable(False)
@@ -387,7 +372,6 @@ class TestColormapAction(TestCaseQt):
def suite():
test_suite = unittest.TestSuite()
- test_suite.addTest(cmapDocTestSuite)
for testClass in (TestColormapDialog, TestColormapAction):
test_suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(
testClass))