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

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 ba0dc71 was 9e426c1, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 8 years ago

More main window items, system close, update checker, doc viewer etc.

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