343
|
1 import sys
|
189
|
2 import unittest
|
343
|
3
|
351
|
4 try:
|
|
5 import hexedit
|
|
6 #import ide
|
343
|
7
|
351
|
8 from PyQt5.QtWidgets import QApplication
|
|
9 from PyQt5.QtTest import QTest
|
|
10 from PyQt5.QtCore import Qt
|
|
11 skip_it = False
|
|
12 except ImportError as e:
|
|
13 skip_it = True
|
189
|
14
|
287
|
15
|
343
|
16 class HexEditorTest(unittest.TestCase):
|
189
|
17 def setUp(self):
|
351
|
18 if skip_it:
|
|
19 self.skipTest('No qt5')
|
|
20 return
|
189
|
21 self.app = QApplication(sys.argv)
|
|
22 self.ui = hexedit.HexEditor()
|
|
23 self.bv = self.ui.he.bv
|
|
24 # Provide some random data:
|
|
25 self.bv.Data = bytearray(range(10)) * 8 + b'x'
|
287
|
26
|
203
|
27 def tearDown(self):
|
|
28 self.app.processEvents()
|
|
29 self.app.quit()
|
287
|
30
|
343
|
31 def tstOpenFile(self):
|
|
32 pass
|
|
33 #self.ui.actionOpen.trigger()
|
|
34 #w = self.app.activeWindow()
|
|
35 #print(w)
|
|
36 #QTest.keyClick(self.ui, Qt.Key_Escape)
|
|
37
|
|
38 def tstDataInView(self):
|
287
|
39 self.assertEqual(0, self.bv.CursorPosition)
|
343
|
40 QTest.mouseClick(self.bv, Qt.LeftButton)
|
|
41 self.assertEqual(154, self.bv.CursorPosition)
|
189
|
42 QTest.keyClick(self.bv, Qt.Key_Left)
|
343
|
43 self.assertEqual(153, self.bv.CursorPosition)
|
189
|
44 QTest.keyClick(self.bv, Qt.Key_Up)
|
343
|
45 self.assertEqual(137, self.bv.CursorPosition)
|
287
|
46
|
189
|
47
|
|
48 if __name__ == '__main__':
|
|
49 unittest.main()
|