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 9f25bce was
31c5b58,
checked in by Piotr Rozyczko <rozyczko@…>, 8 years ago
|
Refactored to allow running with run.py.
Minor fixes to plotting.
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[f721030] | 1 | import sys |
---|
| 2 | import unittest |
---|
| 3 | |
---|
[9e426c1] | 4 | from PyQt4 import QtGui |
---|
| 5 | from PyQt4 import QtTest |
---|
| 6 | from PyQt4 import QtCore |
---|
[f721030] | 7 | from mock import MagicMock |
---|
| 8 | |
---|
[31c5b58] | 9 | # set up import paths |
---|
| 10 | import path_prepare |
---|
| 11 | |
---|
[f721030] | 12 | # Local |
---|
| 13 | from MainWindow import MainSasViewWindow |
---|
| 14 | from MainWindow import SplashScreen |
---|
| 15 | |
---|
[9e426c1] | 16 | app = QtGui.QApplication(sys.argv) |
---|
[f721030] | 17 | |
---|
| 18 | class MainWindowTest(unittest.TestCase): |
---|
[9e426c1] | 19 | """Test the Main Window GUI""" |
---|
[f721030] | 20 | def setUp(self): |
---|
[9e426c1] | 21 | """Create the GUI""" |
---|
[f721030] | 22 | |
---|
| 23 | self.widget = MainSasViewWindow(None) |
---|
| 24 | |
---|
| 25 | def tearDown(self): |
---|
[9e426c1] | 26 | """Destroy the GUI""" |
---|
[f721030] | 27 | self.widget = None |
---|
| 28 | |
---|
| 29 | def testDefaults(self): |
---|
[9e426c1] | 30 | """Test the GUI in its default state""" |
---|
| 31 | self.assertIsInstance(self.widget, QtGui.QMainWindow) |
---|
| 32 | self.assertIsInstance(self.widget.centralWidget(), QtGui.QWorkspace) |
---|
[f721030] | 33 | |
---|
| 34 | def testSplashScreen(self): |
---|
[9e426c1] | 35 | """ Test the splash screen """ |
---|
| 36 | splash = SplashScreen() |
---|
| 37 | self.assertIsInstance(splash, QtGui.QSplashScreen) |
---|
| 38 | |
---|
| 39 | def testExit(self): |
---|
[f721030] | 40 | """ |
---|
[9e426c1] | 41 | Test that the custom exit method is called on shutdown |
---|
[f721030] | 42 | """ |
---|
[9e426c1] | 43 | # Must mask sys.exit, otherwise the whole testing process stops. |
---|
| 44 | sys.exit = MagicMock() |
---|
| 45 | QtGui.QMessageBox.question = MagicMock(return_value=QtGui.QMessageBox.Yes) |
---|
| 46 | |
---|
| 47 | # Open, then close the main window |
---|
| 48 | tmp_main = MainSasViewWindow(None) |
---|
| 49 | tmp_main.close() |
---|
| 50 | |
---|
| 51 | # See that the MessageBox method got called |
---|
| 52 | self.assertTrue(QtGui.QMessageBox.question.called) |
---|
[f721030] | 53 | |
---|
| 54 | if __name__ == "__main__": |
---|
| 55 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.