source: orange/Orange/OrangeCanvas/application/tests/test_canvastooldock.py @ 11120:20723dda0497

Revision 11120:20723dda0497, 2.2 KB checked in by Ales Erjavec <ales.erjavec@…>, 19 months ago (diff)

Added canvas dock component widgets.

Line 
1"""
2Test for canvas toolbox.
3"""
4
5from PyQt4.QtGui import QWidget, QToolBar, QTextEdit, QSplitter
6from PyQt4.QtCore import Qt
7
8from ...registry import global_registry
9from ...registry.qt import QtWidgetRegistry
10from ...gui.dock import CollapsibleDockWidget
11
12from ..canvastooldock import WidgetToolBox, CanvasToolDock, SplitterResizer, \
13                             QuickCategoryToolbar
14
15from ...gui import test
16
17
18class TestCanvasDockWidget(test.QAppTestCase):
19    def test_dock(self):
20        reg = global_registry()
21        reg = QtWidgetRegistry(reg)
22
23        toolbox = WidgetToolBox()
24        toolbox.setObjectName("widgets-toolbox")
25        toolbox.setModel(reg.model())
26        text = QTextEdit()
27        splitter = QSplitter()
28        splitter.setOrientation(Qt.Vertical)
29
30        splitter.addWidget(toolbox)
31        splitter.addWidget(text)
32
33        dock = CollapsibleDockWidget()
34        dock.setExpandedWidget(splitter)
35
36        toolbar = QToolBar()
37        toolbar.addAction("1")
38        toolbar.setOrientation(Qt.Vertical)
39        toolbar.setMovable(False)
40        toolbar.setFloatable(False)
41        dock.setCollapsedWidget(toolbar)
42
43        dock.show()
44        self.app.exec_()
45
46    def test_canvas_tool_dock(self):
47        reg = global_registry()
48        reg = QtWidgetRegistry(reg)
49
50        dock = CanvasToolDock()
51        dock.toolbox.setModel(reg.model())
52
53        dock.show()
54        self.app.exec_()
55
56    def test_splitter_resizer(self):
57        w = QSplitter(orientation=Qt.Vertical)
58        w.addWidget(QWidget())
59        text = QTextEdit()
60        w.addWidget(text)
61        resizer = SplitterResizer(w)
62        resizer.setSplitterAndWidget(w, text)
63
64        def toogle():
65            if resizer.size() == 0:
66                resizer.open()
67            else:
68                resizer.close()
69            self.singleShot(1000, toogle)
70
71        w.show()
72        self.singleShot(0, toogle)
73        self.app.exec_()
74
75    def test_category_toolbar(self):
76        reg = global_registry()
77        reg = QtWidgetRegistry(reg)
78
79        w = QuickCategoryToolbar()
80        w.setModel(reg.model())
81        w.show()
82
83        def p(action):
84            print action.text()
85
86        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.