Ignore:
Timestamp:
Jun 21, 2016 8:07:33 AM (8 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
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
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/UnitTesting/MainWindowTest.py

    rf721030 r9e426c1  
    22import unittest 
    33 
    4 from PyQt4.QtGui import * 
    5 from PyQt4.QtTest import QTest 
    6 from PyQt4.QtCore import * 
     4from PyQt4 import QtGui 
     5from PyQt4 import QtTest 
     6from PyQt4 import QtCore 
    77from mock import MagicMock 
    88 
     
    1111from MainWindow import SplashScreen 
    1212 
    13 app = QApplication(sys.argv) 
     13app = QtGui.QApplication(sys.argv) 
    1414 
    1515class MainWindowTest(unittest.TestCase): 
    16     '''Test the Main Window GUI''' 
     16    """Test the Main Window GUI""" 
    1717    def setUp(self): 
    18         '''Create the GUI''' 
     18        """Create the GUI""" 
    1919 
    2020        self.widget = MainSasViewWindow(None) 
    2121 
    2222    def tearDown(self): 
    23         '''Destroy the GUI''' 
    24         self.widget.close() 
     23        """Destroy the GUI""" 
    2524        self.widget = None 
    2625 
    2726    def testDefaults(self): 
    28         '''Test the GUI in its default state''' 
    29         self.assertIsInstance(self.widget, QMainWindow) 
    30         self.assertIsInstance(self.widget.centralWidget(), QWorkspace) 
     27        """Test the GUI in its default state""" 
     28        self.assertIsInstance(self.widget, QtGui.QMainWindow) 
     29        self.assertIsInstance(self.widget.centralWidget(), QtGui.QWorkspace) 
    3130         
    3231    def testSplashScreen(self): 
     32        """ Test the splash screen """ 
     33        splash = SplashScreen() 
     34        self.assertIsInstance(splash, QtGui.QSplashScreen) 
     35 
     36    def testExit(self): 
    3337        """ 
     38        Test that the custom exit method is called on shutdown 
    3439        """ 
    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) 
    3750        
    3851if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.