Changeset db5cd8d in sasview for src/sas/qtgui/UnitTesting/PlotPropertiesTest.py
- Timestamp:
- Jan 12, 2017 4:09:23 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 2e3e959
- Parents:
- 87cc73a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/UnitTesting/PlotPropertiesTest.py
r87cc73a rdb5cd8d 1 1 import sys 2 2 import unittest 3 from mock import MagicMock 3 4 4 5 from PyQt4 import QtGui … … 6 7 # set up import paths 7 8 import path_prepare 8 9 from UnitTesting.TestUtils import WarningNotImplemented10 9 11 10 # Local … … 19 18 '''Create the PlotProperties''' 20 19 21 self.widget = PlotProperties(None) 20 self.widget = PlotProperties(None, 21 color=1, 22 marker=3, 23 marker_size=10, 24 legend="LL") 22 25 23 26 def tearDown(self): … … 30 33 self.assertIsInstance(self.widget, QtGui.QDialog) 31 34 self.assertEqual(self.widget.windowTitle(), "Modify Plot Properties") 35 36 # Check the combo boxes 37 self.assertEqual(self.widget.cbColor.currentText(), "Green") 38 self.assertEqual(self.widget.cbShape.currentText(), "Triangle Down") 39 self.assertEqual(self.widget.txtLegend.text(), "LL") 40 self.assertEqual(self.widget.sbSize.value(), 10) 32 41 33 42 def testOnColorChange(self): 34 43 '''Test the response to color change event''' 35 WarningNotImplemented(sys._getframe().f_code.co_name) 44 # Accept the new color 45 QtGui.QColorDialog.getColor = MagicMock(return_value=QtGui.QColor(255, 0, 255)) 46 47 self.widget.onColorChange(None) 48 49 self.assertEqual(self.widget.color(), "#ff00ff") 50 self.assertTrue(self.widget.custom_color) 51 self.assertEqual(self.widget.cbColor.currentIndex(), 7) 52 self.assertEqual(self.widget.cbColor.currentText(), "Custom") 53 54 # Reset the color - this will remove "Custom" from the combobox 55 # and set its index to "Green" 56 self.widget.cbColor.setCurrentIndex(1) 57 self.assertEqual(self.widget.cbColor.currentText(), "Green") 58 59 # Cancel the dialog now 60 bad_color = QtGui.QColor() # constructs an invalid color 61 QtGui.QColorDialog.getColor = MagicMock(return_value=bad_color) 62 self.widget.onColorChange(None) 63 64 self.assertEqual(self.widget.color(), 1) 65 self.assertFalse(self.widget.custom_color) 66 self.assertEqual(self.widget.cbColor.currentIndex(), 1) 67 self.assertEqual(self.widget.cbColor.currentText(), "Green") 68 36 69 37 70 def testOnColorIndexChange(self): 38 71 '''Test the response to color index change event''' 39 WarningNotImplemented(sys._getframe().f_code.co_name) 40 72 # Intitial population of the color combo box 73 self.widget.onColorIndexChange(0) 74 self.assertEqual(self.widget.cbColor.count(), 7) 75 # Block the callback so we can update the cb 76 self.widget.cbColor.blockSignals(True) 77 # Add the Custom entry 78 self.widget.cbColor.addItems(["Custom"]) 79 # Unblock the callback 80 self.widget.cbColor.blockSignals(False) 81 # Assert the new CB 82 self.assertEqual(self.widget.cbColor.count(), 8) 83 # Call the method 84 self.widget.onColorIndexChange(0) 85 # see that the Custom entry disappeared 86 self.assertEqual(self.widget.cbColor.count(), 7) 87 self.assertEqual(self.widget.cbColor.findText("Custom"), -1) 41 88 42 89 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.