source: orange/Orange/OrangeCanvas/gui/tests/test_tooltree.py @ 11106:89363c45cb3d

Revision 11106:89363c45cb3d, 1.2 KB checked in by Ales Erjavec <ales.erjavec@…>, 19 months ago (diff)

Added a ToolTree class (a list of actions).

Line 
1"""
2Test for tooltree
3
4"""
5
6from PyQt4.QtGui import QStandardItemModel, QStandardItem, QAction
7
8from ..tooltree import ToolTree
9
10from ..test import QAppTestCase
11
12
13class TestToolTree(QAppTestCase):
14    def test_tooltree(self):
15        tree = ToolTree()
16        role = tree.actionRole()
17        model = QStandardItemModel()
18        tree.setModel(model)
19        item = QStandardItem("One")
20        item.setData(QAction("One", tree), role)
21        model.appendRow([item])
22
23        cat = QStandardItem("A Category")
24        item = QStandardItem("Two")
25        item.setData(QAction("Two", tree), role)
26        cat.appendRow([item])
27        item = QStandardItem("Three")
28        item.setData(QAction("Three", tree), role)
29        cat.appendRow([item])
30
31        model.appendRow([cat])
32
33        tree.show()
34
35        self.app.exec_()
36
37    def test_tooltree_registry(self):
38        from ...registry.qt import QtWidgetRegistry
39        from ...registry.tests import small_testing_registry
40        reg = QtWidgetRegistry(small_testing_registry())
41
42        tree = ToolTree()
43        tree.setModel(reg.model())
44        tree.setActionRole(reg.WIDGET_ACTION_ROLE)
45        tree.show()
46
47        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.