source: orange/Orange/OrangeCanvas/document/tests/test_editlinksdialog.py @ 11447:f2279307183c

Revision 11447:f2279307183c, 2.3 KB checked in by Ales Erjavec <ales.erjavec@…>, 13 months ago (diff)

Moved 'EditLinksWidget' from 'canvas' to 'document' subpackage.

Line 
1from PyQt4.QtGui import QGraphicsScene, QGraphicsView
2from PyQt4.QtCore import Qt
3
4from ...gui import test
5from ..editlinksdialog import EditLinksDialog, EditLinksNode, \
6                              GraphicsTextWidget
7from ...scheme import SchemeNode
8
9
10class TestLinksEditDialog(test.QAppTestCase):
11    def test_links_edit(self):
12        from ...registry.tests import small_testing_registry
13
14        dlg = EditLinksDialog()
15        reg = small_testing_registry()
16        file_desc = reg.widget("Orange.OrangeWidgets.Data.OWFile.OWFile")
17        bayes_desc = reg.widget("Orange.OrangeWidgets.Classify.OWNaiveBayes."
18                                "OWNaiveBayes")
19        source_node = SchemeNode(file_desc, title="This is File")
20        sink_node = SchemeNode(bayes_desc)
21
22        source_channel = source_node.output_channel("Data")
23        sink_channel = sink_node.input_channel("Data")
24        links = [(source_channel, sink_channel)]
25
26        dlg.setNodes(source_node, sink_node)
27
28        dlg.show()
29        dlg.setLinks(links)
30
31        self.assertSequenceEqual(dlg.links(), links)
32        status = dlg.exec_()
33
34        self.assertTrue(dlg.links() == [] or \
35                        dlg.links() == links)
36
37    def test_graphicstextwidget(self):
38        scene = QGraphicsScene()
39        view = QGraphicsView(scene)
40
41        text = GraphicsTextWidget()
42        text.setHtml("<center><b>a text</b></center><p>paragraph</p>")
43        scene.addItem(text)
44        view.show()
45        view.resize(400, 300)
46
47        self.app.exec_()
48
49    def test_editlinksnode(self):
50        from ...registry.tests import small_testing_registry
51
52        reg = small_testing_registry()
53        file_desc = reg.widget("Orange.OrangeWidgets.Data.OWFile.OWFile")
54        bayes_desc = reg.widget("Orange.OrangeWidgets.Classify.OWNaiveBayes."
55                                "OWNaiveBayes")
56        source_node = SchemeNode(file_desc, title="This is File")
57        sink_node = SchemeNode(bayes_desc)
58
59        scene = QGraphicsScene()
60        view = QGraphicsView(scene)
61
62        node = EditLinksNode(node=source_node)
63        scene.addItem(node)
64
65        node = EditLinksNode(direction=Qt.RightToLeft)
66        node.setSchemeNode(sink_node)
67
68        node.setPos(300, 0)
69        scene.addItem(node)
70
71        view.show()
72        view.resize(800, 300)
73        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.