189
|
1 import unittest
|
|
2 import hexedit
|
|
3 from PyQt4.QtGui import QApplication
|
|
4 from PyQt4.QtTest import QTest
|
|
5 from PyQt4.QtCore import Qt
|
|
6 import sys
|
|
7
|
|
8 class HexTest(unittest.TestCase):
|
|
9 def setUp(self):
|
|
10 self.app = QApplication(sys.argv)
|
|
11 self.ui = hexedit.HexEditor()
|
|
12 self.bv = self.ui.he.bv
|
|
13 # Provide some random data:
|
|
14 self.bv.Data = bytearray(range(10)) * 8 + b'x'
|
203
|
15 def tearDown(self):
|
|
16 self.app.processEvents()
|
|
17 self.app.quit()
|
189
|
18 def testOpenButton(self):
|
|
19 QTest.mouseClick(self.bv, Qt.LeftButton)
|
|
20 self.assertEqual(self.bv.CursorPosition, 161)
|
|
21 QTest.keyClick(self.bv, Qt.Key_Left)
|
|
22 self.assertEqual(self.bv.CursorPosition, 160)
|
|
23 QTest.keyClick(self.bv, Qt.Key_Up)
|
|
24 self.assertEqual(self.bv.CursorPosition, 128)
|
|
25
|
|
26 if __name__ == '__main__':
|
|
27 unittest.main()
|