view test/testhexedit.py @ 409:8fe299cd2d55 devel

Close devel branch
author Windel Bouwman
date Sat, 21 Feb 2015 12:20:10 +0100
parents 11c5a8a70c02
children 62803b073d11
line wrap: on
line source

import sys
import unittest

import hexedit
#import ide

from PyQt5.QtWidgets import QApplication
from PyQt5.QtTest import QTest
from PyQt5.QtCore import Qt


class HexEditorTest(unittest.TestCase):
    def setUp(self):
        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()