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 90d389d was
9e426c1,
checked in by Piotr Rozyczko <piotr.rozyczko@…>, 9 years ago
|
More main window items, system close, update checker, doc viewer etc.
|
-
Property mode set to
100755
|
File size:
1.4 KB
|
Line | |
---|
1 | import sys |
---|
2 | import unittest |
---|
3 | |
---|
4 | from PyQt4 import QtGui |
---|
5 | from PyQt4 import QtTest |
---|
6 | from PyQt4 import QtCore |
---|
7 | from mock import MagicMock |
---|
8 | |
---|
9 | # Local |
---|
10 | from MainWindow import MainSasViewWindow |
---|
11 | from MainWindow import SplashScreen |
---|
12 | |
---|
13 | app = QtGui.QApplication(sys.argv) |
---|
14 | |
---|
15 | class MainWindowTest(unittest.TestCase): |
---|
16 | """Test the Main Window GUI""" |
---|
17 | def setUp(self): |
---|
18 | """Create the GUI""" |
---|
19 | |
---|
20 | self.widget = MainSasViewWindow(None) |
---|
21 | |
---|
22 | def tearDown(self): |
---|
23 | """Destroy the GUI""" |
---|
24 | self.widget = None |
---|
25 | |
---|
26 | def testDefaults(self): |
---|
27 | """Test the GUI in its default state""" |
---|
28 | self.assertIsInstance(self.widget, QtGui.QMainWindow) |
---|
29 | self.assertIsInstance(self.widget.centralWidget(), QtGui.QWorkspace) |
---|
30 | |
---|
31 | def testSplashScreen(self): |
---|
32 | """ Test the splash screen """ |
---|
33 | splash = SplashScreen() |
---|
34 | self.assertIsInstance(splash, QtGui.QSplashScreen) |
---|
35 | |
---|
36 | def testExit(self): |
---|
37 | """ |
---|
38 | Test that the custom exit method is called on shutdown |
---|
39 | """ |
---|
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) |
---|
50 | |
---|
51 | if __name__ == "__main__": |
---|
52 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.