view test/testhexedit.py @ 396:fb3c1f029b30

Added baselexer into c3 lexer
author Windel Bouwman
date Tue, 27 May 2014 22:19:32 +0200
parents 62803b073d11
children
line wrap: on
line source

import sys
import unittest

try:
    import hexedit
    #import ide

    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtTest import QTest
    from PyQt5.QtCore import Qt
    skip_it = False
except ImportError as e:
    skip_it = True


class HexEditorTest(unittest.TestCase):
    def setUp(self):
        if skip_it:
            self.skipTest('No qt5')
            return
        self.app = QApplication(sys.argv)
        self.ui = hexedit.HexEditor()
        self.bv = self.ui.he.bv
        # Provide some random data:
        self.bv.Data = bytearray(range(10)) * 8 + b'x'

    def tearDown(self):
        self.app.processEvents()
        self.app.quit()

    def tstOpenFile(self):
        pass
        #self.ui.actionOpen.trigger()
        #w = self.app.activeWindow()
        #print(w)
        #QTest.keyClick(self.ui, Qt.Key_Escape)

    def tstDataInView(self):
        self.assertEqual(0, self.bv.CursorPosition)
        QTest.mouseClick(self.bv, Qt.LeftButton)
        self.assertEqual(154, self.bv.CursorPosition)
        QTest.keyClick(self.bv, Qt.Key_Left)
        self.assertEqual(153, self.bv.CursorPosition)
        QTest.keyClick(self.bv, Qt.Key_Up)
        self.assertEqual(137, self.bv.CursorPosition)


if __name__ == '__main__':
    unittest.main()