source: sasview/src/sas/qtgui/UnitTesting/MainWindowTest.py @ e712ca5

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 e712ca5 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
Line 
1import sys
2import unittest
3
4from PyQt4 import QtGui
5from PyQt4 import QtTest
6from PyQt4 import QtCore
7from mock import MagicMock
8
9# set up import paths
10import path_prepare
11
12# Local
13from MainWindow import MainSasViewWindow
14from MainWindow import SplashScreen
15
16app = QtGui.QApplication(sys.argv)
17
18class MainWindowTest(unittest.TestCase):
19    """Test the Main Window GUI"""
20    def setUp(self):
21        """Create the GUI"""
22
23        self.widget = MainSasViewWindow(None)
24
25    def tearDown(self):
26        """Destroy the GUI"""
27        self.widget = None
28
29    def testDefaults(self):
30        """Test the GUI in its default state"""
31        self.assertIsInstance(self.widget, QtGui.QMainWindow)
32        self.assertIsInstance(self.widget.centralWidget(), QtGui.QWorkspace)
33       
34    def testSplashScreen(self):
35        """ Test the splash screen """
36        splash = SplashScreen()
37        self.assertIsInstance(splash, QtGui.QSplashScreen)
38
39    def testExit(self):
40        """
41        Test that the custom exit method is called on shutdown
42        """
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)
53       
54if __name__ == "__main__":
55    unittest.main()
Note: See TracBrowser for help on using the repository browser.