source: orange/Orange/OrangeCanvas/canvas/items/tests/test_annotationitem.py @ 11102:1ae099099c23

Revision 11102:1ae099099c23, 1.6 KB checked in by Ales Erjavec <ales.erjavec@…>, 19 months ago (diff)

Added GraphicsItems representing the items in the workflow scheme.

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