source: orange/Orange/OrangeCanvas/canvas/items/tests/test_annotationitem.py @ 11160:6bfea7812243

Revision 11160:6bfea7812243, 1.4 KB checked in by Ales Erjavec <ales.erjavec@…>, 18 months ago (diff)

Refactored GraphicsPathObject and ControlPoint/Rect/Line into two new modules.

Line 
1from PyQt4.QtCore import Qt, QRectF, QLineF
2
3from ..annotationitem import TextAnnotation, ArrowAnnotation, ArrowItem
4
5from . import TestItems
6
7
8class TestAnnotationItem(TestItems):
9    def test_textannotation(self):
10        text = "Annotation"
11        annot = TextAnnotation()
12        annot.setPlainText(text)
13        self.assertEqual(annot.toPlainText(), text)
14
15        annot2 = TextAnnotation()
16        self.assertEqual(annot2.toPlainText(), "")
17
18        text = "This is an annotation"
19        annot2.setPlainText(text)
20        self.assertEqual(annot2.toPlainText(), text)
21
22        annot2.setDefaultTextColor(Qt.red)
23        control_rect = QRectF(0, 0, 100, 200)
24        annot2.setGeometry(control_rect)
25        self.assertEqual(annot2.geometry(), control_rect)
26
27        annot.setTextInteractionFlags(Qt.TextEditorInteraction)
28        annot.setPos(400, 100)
29        annot.adjustSize()
30        annot._TextAnnotation__textItem.setFocus()
31        self.scene.addItem(annot)
32        self.scene.addItem(annot2)
33
34        self.app.exec_()
35
36    def test_arrowannotation(self):
37        item = ArrowItem()
38        self.scene.addItem(item)
39        item.setLine(QLineF(100, 100, 100, 200))
40        item.setLineWidth(5)
41
42        item = ArrowAnnotation()
43        item.setPos(10, 10)
44        item.setLine(QLineF(10, 10, 200, 400))
45
46        self.scene.addItem(item)
47        item.setLineWidth(5)
48
49        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.