Mercurial > lcfOS
comparison test/testdiagrameditor.py @ 392:bb4289c84907
Added some sort of drop event test
author | Windel Bouwman |
---|---|
date | Fri, 16 May 2014 13:05:10 +0200 |
parents | b77f3290ac79 |
children | c0d9837acde8 |
comparison
equal
deleted
inserted
replaced
391:a139da1f44f6 | 392:bb4289c84907 |
---|---|
7 try: | 7 try: |
8 otherpath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'python','other')) | 8 otherpath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'python','other')) |
9 sys.path.insert(0, otherpath) | 9 sys.path.insert(0, otherpath) |
10 import diagrameditor | 10 import diagrameditor |
11 | 11 |
12 from PyQt5.QtWidgets import QApplication | 12 from PyQt5.QtWidgets import QApplication, QGraphicsItem |
13 from PyQt5.QtTest import QTest | 13 from PyQt5.QtTest import QTest |
14 from PyQt5.QtCore import Qt, QTimer | 14 from PyQt5.QtCore import Qt, QTimer, QMimeData, QPointF |
15 from PyQt5.QtGui import QDropEvent | |
15 skip_it = False | 16 skip_it = False |
16 | 17 |
17 # When creating an app per testcase, this fails horribly.. | 18 # When creating an app per testcase, this fails horribly.. |
18 app = QApplication(sys.argv) | 19 app = QApplication(sys.argv) |
19 except ImportError as e: | 20 except ImportError as e: |
45 #ilibrary. | 46 #ilibrary. |
46 QTest.mousePress(library, Qt.LeftButton) | 47 QTest.mousePress(library, Qt.LeftButton) |
47 print(editor, type(editor)) | 48 print(editor, type(editor)) |
48 QTest.mouseMove(editor) | 49 QTest.mouseMove(editor) |
49 QTest.mouseRelease(editor, Qt.LeftButton) | 50 QTest.mouseRelease(editor, Qt.LeftButton) |
51 mimedata = QMimeData() | |
52 mimedata.setData('component/name', 'Block:blk'.encode('ascii')) | |
53 de = QDropEvent(QPointF(10, 10), Qt.CopyAction, mimedata, | |
54 Qt.LeftButton, | |
55 Qt.NoModifier) | |
56 editor.dropEvent(de) | |
57 | |
58 def resizePlacedItem(self): | |
59 i = self.main.findChild(QGraphicsItem, "sizer_top_right") | |
60 print(i) | |
50 | 61 |
51 def testScenario1(self): | 62 def testScenario1(self): |
52 self.cmdNewModel() | 63 self.cmdNewModel() |
53 self.dragItemIntoScene() | 64 self.dragItemIntoScene() |
65 self.resizePlacedItem() | |
54 | 66 |
55 def testB(self): | 67 def testB(self): |
56 print('b') | 68 print('b') |
57 | 69 |
58 | 70 |
59 if __name__ == '__main__': | 71 if __name__ == '__main__': |
60 unittest.main() | 72 unittest.main() |
61 |