Mercurial > lcfOS
diff test/testdiagrameditor.py @ 390:b77f3290ac79
Added diagram editor tests
author | Windel Bouwman |
---|---|
date | Fri, 16 May 2014 10:12:16 +0200 |
parents | |
children | bb4289c84907 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/testdiagrameditor.py Fri May 16 10:12:16 2014 +0200 @@ -0,0 +1,61 @@ + +import unittest +import os +import sys +import time + +try: + otherpath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'python','other')) + sys.path.insert(0, otherpath) + import diagrameditor + + from PyQt5.QtWidgets import QApplication + from PyQt5.QtTest import QTest + from PyQt5.QtCore import Qt, QTimer + skip_it = False + + # When creating an app per testcase, this fails horribly.. + app = QApplication(sys.argv) +except ImportError as e: + skip_it = True + + + +class DiagramEditorTestCase(unittest.TestCase): + def setUp(self): + if skip_it: + self.skipTest('No qt5 or X server') + return + #print('Instance:', QApplication.instance()) + self.main = diagrameditor.Main() + self.main.show() + QTest.qWaitForWindowActive(self.main) + + def tearDown(self): + QTimer.singleShot(100, app.quit) + app.exec_() + + def cmdNewModel(self): + # Press ctrl+N: + QTest.keyClick(self.main, Qt.Key_N, Qt.ControlModifier) + + def dragItemIntoScene(self): + library = self.main.findChild(diagrameditor.LibraryWidget, 'LibraryWidget') + editor = self.main.findChild(diagrameditor.EditorGraphicsView, 'Editor') + #ilibrary. + QTest.mousePress(library, Qt.LeftButton) + print(editor, type(editor)) + QTest.mouseMove(editor) + QTest.mouseRelease(editor, Qt.LeftButton) + + def testScenario1(self): + self.cmdNewModel() + self.dragItemIntoScene() + + def testB(self): + print('b') + + +if __name__ == '__main__': + unittest.main() +