comparison python/testhexedit.py @ 189:5334b86ac1db

Added pyqt unittest
author Windel Bouwman
date Sat, 25 May 2013 15:04:44 +0200
parents
children
comparison
equal deleted inserted replaced
188:1113da536872 189:5334b86ac1db
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'
15 def testOpenButton(self):
16 QTest.mouseClick(self.bv, Qt.LeftButton)
17 self.assertEqual(self.bv.CursorPosition, 161)
18 QTest.keyClick(self.bv, Qt.Key_Left)
19 self.assertEqual(self.bv.CursorPosition, 160)
20 QTest.keyClick(self.bv, Qt.Key_Up)
21 self.assertEqual(self.bv.CursorPosition, 128)
22
23 if __name__ == '__main__':
24 unittest.main()