annotate python/thex.py @ 209:07bfea4c1ed7

Added codegen test
author Windel Bouwman
date Sat, 29 Jun 2013 10:08:46 +0200
parents ca1ea402f6a1
children
rev   line source
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
1 import unittest
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
2 import hexedit
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
3 from PyQt4.QtGui import QApplication
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
4 from PyQt4.QtTest import QTest
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
5 from PyQt4.QtCore import Qt
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
6 import sys
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
7
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
8 class HexTest(unittest.TestCase):
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
9 def setUp(self):
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
10 self.app = QApplication(sys.argv)
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
11 self.ui = hexedit.HexEditor()
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
12 self.bv = self.ui.he.bv
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
13 # Provide some random data:
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
14 self.bv.Data = bytearray(range(10)) * 8 + b'x'
203
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 190
diff changeset
15 def tearDown(self):
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 190
diff changeset
16 self.app.processEvents()
ca1ea402f6a1 Added some arm instructions
Windel Bouwman
parents: 190
diff changeset
17 self.app.quit()
189
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
18 def testOpenButton(self):
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
19 QTest.mouseClick(self.bv, Qt.LeftButton)
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
20 self.assertEqual(self.bv.CursorPosition, 161)
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
21 QTest.keyClick(self.bv, Qt.Key_Left)
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
22 self.assertEqual(self.bv.CursorPosition, 160)
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
23 QTest.keyClick(self.bv, Qt.Key_Up)
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
24 self.assertEqual(self.bv.CursorPosition, 128)
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
25
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
26 if __name__ == '__main__':
5334b86ac1db Added pyqt unittest
Windel Bouwman
parents:
diff changeset
27 unittest.main()