source: orange/Orange/OrangeCanvas/application/tests/test_canvastooldock.py @ 11309:7b2804352bbe

Revision 11309:7b2804352bbe, 2.1 KB checked in by Ales Erjavec <ales.erjavec@…>, 14 months ago (diff)

Fix a test when the WidgetsToolBox widget outlives the model's actions.

Also added a warning to setModel's docstring about the life time of the
model.

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, parent=self.app)
22
23        toolbox = WidgetToolBox()
24        toolbox.setObjectName("widgets-toolbox")
25        toolbox.setModel(reg.model())
26
27        text = QTextEdit()
28        splitter = QSplitter()
29        splitter.setOrientation(Qt.Vertical)
30
31        splitter.addWidget(toolbox)
32        splitter.addWidget(text)
33
34        dock = CollapsibleDockWidget()
35        dock.setExpandedWidget(splitter)
36
37        toolbar = QToolBar()
38        toolbar.addAction("1")
39        toolbar.setOrientation(Qt.Vertical)
40        toolbar.setMovable(False)
41        toolbar.setFloatable(False)
42        dock.setCollapsedWidget(toolbar)
43
44        dock.show()
45        self.app.exec_()
46
47    def test_canvas_tool_dock(self):
48        reg = global_registry()
49        reg = QtWidgetRegistry(reg, parent=self.app)
50
51        dock = CanvasToolDock()
52        dock.toolbox.setModel(reg.model())
53
54        dock.show()
55        self.app.exec_()
56
57    def test_splitter_resizer(self):
58        w = QSplitter(orientation=Qt.Vertical)
59        w.addWidget(QWidget())
60        text = QTextEdit()
61        w.addWidget(text)
62        resizer = SplitterResizer(w)
63        resizer.setSplitterAndWidget(w, text)
64
65        def toogle():
66            if resizer.size() == 0:
67                resizer.open()
68            else:
69                resizer.close()
70            self.singleShot(1000, toogle)
71
72        w.show()
73        self.singleShot(0, toogle)
74        self.app.exec_()
75
76    def test_category_toolbar(self):
77        reg = global_registry()
78        reg = QtWidgetRegistry(reg, parent=self.app)
79
80        w = QuickCategoryToolbar()
81        w.setModel(reg.model())
82        w.show()
83
84        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.