source: sasview/src/sas/qtgui/Plotting/UnitTesting/ScalePropertiesTest.py @ 304d082

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 304d082 was 464cd07, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Use singleton QApplication in unit tests to avoid issues on Ubuntu. SASVIEW-485

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[6d05e1d]1import sys
2import unittest
3
4from PyQt4 import QtGui
5
6# set up import paths
[83eb5208]7import sas.qtgui.path_prepare
[6d05e1d]8
9# Local
[83eb5208]10from sas.qtgui.Plotting.ScaleProperties import ScaleProperties
[6d05e1d]11
[464cd07]12if not QtGui.QApplication.instance():
13    app = QtGui.QApplication(sys.argv)
[6d05e1d]14
15class 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     
60if __name__ == "__main__":
61    unittest.main()
Note: See TracBrowser for help on using the repository browser.