annotate test/testhexedit.py @ 389:2ec730e45ea1

Added check for recursive struct
author Windel Bouwman
date Fri, 16 May 2014 12:29:31 +0200
parents 62803b073d11
children
rev   line source
343
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
1 import sys
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
2 import unittest
343
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
3
351
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
4 try:
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
5 import hexedit
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
6 #import ide
343
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
7
351
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
8 from PyQt5.QtWidgets import QApplication
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
9 from PyQt5.QtTest import QTest
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
10 from PyQt5.QtCore import Qt
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
11 skip_it = False
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
12 except ImportError as e:
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
13 skip_it = True
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
14
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 203
diff changeset
15
343
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
16 class HexEditorTest(unittest.TestCase):
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
17 def setUp(self):
351
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
18 if skip_it:
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
19 self.skipTest('No qt5')
62803b073d11 Add conditional qt5 test
Windel Bouwman
parents: 343
diff changeset
20 return
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
21 self.app = QApplication(sys.argv)
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
22 self.ui = hexedit.HexEditor()
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
23 self.bv = self.ui.he.bv
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
24 # Provide some random data:
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
25 self.bv.Data = bytearray(range(10)) * 8 + b'x'
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 203
diff changeset
26
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 190
diff changeset
27 def tearDown(self):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 190
diff changeset
28 self.app.processEvents()
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 190
diff changeset
29 self.app.quit()
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 203
diff changeset
30
343
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
31 def tstOpenFile(self):
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
32 pass
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
33 #self.ui.actionOpen.trigger()
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
34 #w = self.app.activeWindow()
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
35 #print(w)
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
36 #QTest.keyClick(self.ui, Qt.Key_Escape)
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
37
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
38 def tstDataInView(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 203
diff changeset
39 self.assertEqual(0, self.bv.CursorPosition)
343
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
40 QTest.mouseClick(self.bv, Qt.LeftButton)
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
41 self.assertEqual(154, self.bv.CursorPosition)
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
42 QTest.keyClick(self.bv, Qt.Key_Left)
343
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
43 self.assertEqual(153, self.bv.CursorPosition)
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
44 QTest.keyClick(self.bv, Qt.Key_Up)
343
11c5a8a70c02 Fix ide
Windel Bouwman
parents: 287
diff changeset
45 self.assertEqual(137, self.bv.CursorPosition)
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 203
diff changeset
46
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
47
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
48 if __name__ == '__main__':
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
49 unittest.main()