source: orange/Orange/OrangeCanvas/preview/tests/test_previewbrowser.py @ 11114:16262014a6ea

Revision 11114:16262014a6ea, 1.1 KB checked in by Ales Erjavec <ales.erjavec@…>, 18 months ago (diff)

Added preview browser widget and dialog.

Line 
1"""
2Unittests for PrewiewBrowser widget.
3
4"""
5
6from ...gui import test
7
8from ..previewbrowser import PreviewBrowser
9from ..previewmodel import PreviewItem, PreviewModel
10
11import pkg_resources
12
13svg1 = pkg_resources.resource_string("Orange.OrangeCanvas",
14                                     "icons/default-category.svg")
15
16svg2 = pkg_resources.resource_string("Orange.OrangeCanvas",
17                                     "icons/default-widget.svg")
18
19
20def construct_test_preview_model():
21    items = [("Name1", "A preview item 1", svg1, u"~/bla", ),
22             ("Name2", "A preview item 2" + "long text" * 5, svg2, "~/item")
23             ]
24
25    items = [PreviewItem(*arg[:-1], path=arg[-1]) for arg in items]
26    model = PreviewModel(items=items)
27    return model
28
29
30class TestPreviewBrowser(test.QAppTestCase):
31    def test_preview_browser(self):
32        w = PreviewBrowser()
33        model = construct_test_preview_model()
34        w.setModel(model)
35        w.show()
36
37        def p(index):
38            print index
39
40        w.currentIndexChanged.connect(p)
41        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.