[6d05e1d] | 1 | import sys |
---|
| 2 | import unittest |
---|
| 3 | |
---|
| 4 | from PyQt4 import QtGui |
---|
| 5 | |
---|
| 6 | # set up import paths |
---|
[83eb5208] | 7 | import sas.qtgui.path_prepare |
---|
[6d05e1d] | 8 | |
---|
| 9 | # Local |
---|
[83eb5208] | 10 | from sas.qtgui.Plotting.ScaleProperties import ScaleProperties |
---|
[6d05e1d] | 11 | |
---|
[464cd07] | 12 | if not QtGui.QApplication.instance(): |
---|
| 13 | app = QtGui.QApplication(sys.argv) |
---|
[6d05e1d] | 14 | |
---|
| 15 | class ScalePropertiesTest(unittest.TestCase): |
---|
| 16 | '''Test the ScaleProperties''' |
---|
| 17 | def setUp(self): |
---|
| 18 | '''Create the ScaleProperties''' |
---|
| 19 | |
---|
| 20 | self.widget = ScaleProperties(None) |
---|
| 21 | |
---|
| 22 | def tearDown(self): |
---|
| 23 | '''Destroy the GUI''' |
---|
| 24 | self.widget.close() |
---|
| 25 | self.widget = None |
---|
| 26 | |
---|
| 27 | def testDefaults(self): |
---|
| 28 | '''Test the GUI in its default state''' |
---|
| 29 | self.assertIsInstance(self.widget, QtGui.QDialog) |
---|
| 30 | self.assertEqual(self.widget.windowTitle(), "Scale Properties") |
---|
| 31 | self.assertEqual(self.widget.cbX.count(), 6) |
---|
| 32 | self.assertEqual(self.widget.cbY.count(), 12) |
---|
| 33 | self.assertEqual(self.widget.cbView.count(), 6) |
---|
| 34 | |
---|
| 35 | def testGetValues(self): |
---|
| 36 | '''Test the values returned''' |
---|
| 37 | self.assertEqual(self.widget.getValues(), ("x", "y")) |
---|
| 38 | self.widget.cbX.setCurrentIndex(2) |
---|
| 39 | self.widget.cbY.setCurrentIndex(4) |
---|
| 40 | self.assertEqual(self.widget.getValues(), ("x^(4)", "y*x^(2)")) |
---|
| 41 | |
---|
| 42 | def testSettingView(self): |
---|
| 43 | '''Test various settings of view''' |
---|
| 44 | self.widget.cbView.setCurrentIndex(1) |
---|
| 45 | self.assertEqual(self.widget.getValues(), ("x", "y")) |
---|
| 46 | self.widget.cbView.setCurrentIndex(5) |
---|
| 47 | self.assertEqual(self.widget.getValues(), ("x", "y*x^(2)")) |
---|
| 48 | |
---|
| 49 | # Assure the View combobox resets on the x index changes |
---|
| 50 | self.assertNotEqual(self.widget.cbView.currentIndex(), 0) |
---|
| 51 | self.widget.cbX.setCurrentIndex(2) |
---|
| 52 | self.assertEqual(self.widget.cbView.currentIndex(), 0) |
---|
| 53 | |
---|
| 54 | # Same for Y |
---|
| 55 | self.widget.cbView.setCurrentIndex(6) |
---|
| 56 | self.assertNotEqual(self.widget.cbView.currentIndex(), 0) |
---|
| 57 | self.widget.cbY.setCurrentIndex(2) |
---|
| 58 | self.assertEqual(self.widget.cbView.currentIndex(), 0) |
---|
| 59 | |
---|
| 60 | if __name__ == "__main__": |
---|
| 61 | unittest.main() |
---|