Changeset 488c49d in sasview for src/sas/qtgui/UnitTesting
- Timestamp:
- Jun 8, 2016 9:56:28 AM (8 years ago)
- 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:
- 5032ea68
- Parents:
- f721030
- git-author:
- Piotr Rozyczko <piotr.rozyczko@…> (06/08/16 09:53:59)
- git-committer:
- Piotr Rozyczko <piotr.rozyczko@…> (06/08/16 09:56:28)
- Location:
- src/sas/qtgui/UnitTesting
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/UnitTesting/DataExplorerTest.py
rf721030 r488c49d 45 45 46 46 self.assertEqual(self.form.cbSelect.count(), 6) 47 self.assertEqual(self.form.cbSelect.currentIndex(), 0) 47 48 48 49 # Class is in the default state even without pressing OK … … 100 101 # Assure the model contains no items 101 102 103 def testDataSelection(self): 104 """ 105 Tests the functionality of the Selection Option combobox 106 """ 107 # Populate the model with 1d and 2d data 108 filename = ["cyl_400_20.txt", "Dec07031.ASC"] 109 self.form.readData(filename) 110 111 # Unselect all data 112 self.form.cbSelect.setCurrentIndex(1) 113 114 # Test the current selection 115 item1D = self.form.model.item(0) 116 item2D = self.form.model.item(1) 117 self.assertTrue(item1D.checkState() == QtCore.Qt.Unchecked) 118 self.assertTrue(item2D.checkState() == QtCore.Qt.Unchecked) 119 120 # Select all data 121 self.form.cbSelect.setCurrentIndex(0) 122 123 # Test the current selection 124 self.assertTrue(item1D.checkState() == QtCore.Qt.Checked) 125 self.assertTrue(item2D.checkState() == QtCore.Qt.Checked) 126 127 # select 1d data 128 self.form.cbSelect.setCurrentIndex(2) 129 130 # Test the current selection 131 self.assertTrue(item1D.checkState() == QtCore.Qt.Checked) 132 self.assertTrue(item2D.checkState() == QtCore.Qt.Unchecked) 133 134 # unselect 1d data 135 self.form.cbSelect.setCurrentIndex(3) 136 137 # Test the current selection 138 self.assertTrue(item1D.checkState() == QtCore.Qt.Unchecked) 139 self.assertTrue(item2D.checkState() == QtCore.Qt.Unchecked) 140 141 # select 2d data 142 self.form.cbSelect.setCurrentIndex(4) 143 144 # Test the current selection 145 self.assertTrue(item1D.checkState() == QtCore.Qt.Unchecked) 146 self.assertTrue(item2D.checkState() == QtCore.Qt.Checked) 147 148 # unselect 2d data 149 self.form.cbSelect.setCurrentIndex(5) 150 151 # Test the current selection 152 self.assertTrue(item1D.checkState() == QtCore.Qt.Unchecked) 153 self.assertTrue(item2D.checkState() == QtCore.Qt.Unchecked) 154 155 # choose impossible index and assure the code raises 156 #with self.assertRaises(Exception): 157 # self.form.cbSelect.setCurrentIndex(6) 158 102 159 def testReadData(self): 103 160 """ -
src/sas/qtgui/UnitTesting/GuiManagerTest.py
rf721030 r488c49d 1 import sys 2 import unittest 3 4 from PyQt4.QtGui import * 5 from PyQt4.QtTest import QTest 6 from PyQt4.QtCore import * 7 from mock import MagicMock 8 9 # Local 10 from GuiManager import GuiManager 11 12 #app = QApplication(sys.argv) 13 14 class GuiManagerTest(unittest.TestCase): 15 '''Test the WelcomePanel''' 16 def setUp(self): 17 '''Create the tested object''' 18 19 self.manager = GuiManager(None) 20 21 def tearDown(self): 22 '''Destroy the GUI''' 23 self.manager = None 24 25 def testDefaults(self): 26 '''Test the object in its default state''' 27 pass 28 29 def testUpdatePerspective(self): 30 """ 31 """ 32 pass 33 34 def testUpdateStatusBar(self): 35 """ 36 """ 37 pass 38 39 def testSetData(self): 40 """ 41 """ 42 pass 43 44 def testSetData(self): 45 """ 46 """ 47 pass 48 49 def testActions(self): 50 """ 51 """ 52 pass 53 54 # test each action separately 55 56 if __name__ == "__main__": 57 unittest.main() 58 -
src/sas/qtgui/UnitTesting/TestUtils.py
rf721030 r488c49d 12 12 super(QtSignalSpy, self).__init__(parent) 13 13 14 self._ connector = {}14 self._recorder = {} 15 15 self._count = 0 16 self._signal = [ None, None]16 self._signal = [] 17 17 18 18 # Assign our own slot to the emitted signal 19 if isinstance(signal, pyqtBoundSignal): 20 signal.connect(self.slot) 21 elif hasattr(widget, signal): 22 getattr(widget, signal).connect(self.slot) 23 else: 24 widget.signal.connect(slot) 19 try: 20 if isinstance(signal, pyqtBoundSignal): 21 signal.connect(self.slot) 22 elif hasattr(widget, signal): 23 getattr(widget, signal).connect(self.slot) 24 else: 25 widget.signal.connect(slot) 26 except AttributeError: 27 msg = "Wrong construction of QtSignalSpy instance" 28 raise RuntimeError, msg 25 29 26 30 def slot(self, *args, **kwargs): … … 28 32 Record emitted signal. 29 33 """ 30 self._ connector[self._count] = {34 self._recorder[self._count] = { 31 35 'args' : args, 32 36 'kwargs' : kwargs, … … 37 41 38 42 def signal(self, index=None): 39 """40 """41 43 if index == None: 42 44 return self._signal … … 45 47 46 48 def count(self): 47 """48 """49 49 return self._count 50 50 51 51 def called(self): 52 """ 53 """ 54 return self._connector 52 return self._recorder -
src/sas/qtgui/UnitTesting/WelcomePanelTest.py
rf721030 r488c49d 1 import sys 2 import unittest 3 4 from PyQt4.QtGui import * 5 from PyQt4.QtTest import QTest 6 from PyQt4.QtCore import * 7 8 # Local 9 from WelcomePanel import WelcomePanel 10 11 app = QApplication(sys.argv) 12 13 class WelcomePanelTest(unittest.TestCase): 14 '''Test the WelcomePanel''' 15 def setUp(self): 16 '''Create the WelcomePanel''' 17 18 self.widget = WelcomePanel(None) 19 20 def tearDown(self): 21 '''Destroy the GUI''' 22 self.widget.close() 23 self.widget = None 24 25 def testDefaults(self): 26 '''Test the GUI in its default state''' 27 self.assertIsInstance(self.widget, QDialog) 28 self.assertEqual(self.widget.windowTitle(), "Welcome") 29 30 def testVersion(self): 31 """ 32 """ 33 version = self.widget.lblVersion 34 self.assertIsInstance(version, QLabel) 35 ver_text = "\nSasView 4.0.0-alpha\nBuild: 1\n(c) 2009 - 2013, UTK, UMD, NIST, ORNL, ISIS, ESS and IL" 36 #self.assertEqual(str(version.text()), ver_text) 37 self.assertIn("SasView", str(version.text())) 38 self.assertIn("Build:", str(version.text())) 39 40 if __name__ == "__main__": 41 unittest.main()
Note: See TracChangeset
for help on using the changeset viewer.