Changeset 9e426c1 in sasview for src/sas/qtgui/UnitTesting/MainWindowTest.py
- Timestamp:
- Jun 21, 2016 8:07:33 AM (8 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:
- f82ab8c
- Parents:
- 1042dba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/UnitTesting/MainWindowTest.py
rf721030 r9e426c1 2 2 import unittest 3 3 4 from PyQt4 .QtGui import *5 from PyQt4 .QtTest import QTest6 from PyQt4 .QtCore import *4 from PyQt4 import QtGui 5 from PyQt4 import QtTest 6 from PyQt4 import QtCore 7 7 from mock import MagicMock 8 8 … … 11 11 from MainWindow import SplashScreen 12 12 13 app = Q Application(sys.argv)13 app = QtGui.QApplication(sys.argv) 14 14 15 15 class MainWindowTest(unittest.TestCase): 16 '''Test the Main Window GUI'''16 """Test the Main Window GUI""" 17 17 def setUp(self): 18 '''Create the GUI'''18 """Create the GUI""" 19 19 20 20 self.widget = MainSasViewWindow(None) 21 21 22 22 def tearDown(self): 23 '''Destroy the GUI''' 24 self.widget.close() 23 """Destroy the GUI""" 25 24 self.widget = None 26 25 27 26 def testDefaults(self): 28 '''Test the GUI in its default state'''29 self.assertIsInstance(self.widget, Q MainWindow)30 self.assertIsInstance(self.widget.centralWidget(), Q Workspace)27 """Test the GUI in its default state""" 28 self.assertIsInstance(self.widget, QtGui.QMainWindow) 29 self.assertIsInstance(self.widget.centralWidget(), QtGui.QWorkspace) 31 30 32 31 def testSplashScreen(self): 32 """ Test the splash screen """ 33 splash = SplashScreen() 34 self.assertIsInstance(splash, QtGui.QSplashScreen) 35 36 def testExit(self): 33 37 """ 38 Test that the custom exit method is called on shutdown 34 39 """ 35 splash = SplashScreen() 36 self.assertIsInstance(splash, QSplashScreen) 40 # Must mask sys.exit, otherwise the whole testing process stops. 41 sys.exit = MagicMock() 42 QtGui.QMessageBox.question = MagicMock(return_value=QtGui.QMessageBox.Yes) 43 44 # Open, then close the main window 45 tmp_main = MainSasViewWindow(None) 46 tmp_main.close() 47 48 # See that the MessageBox method got called 49 self.assertTrue(QtGui.QMessageBox.question.called) 37 50 38 51 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.