source: orange/Orange/OrangeCanvas/gui/tests/test_toolbar.py @ 11179:f7ee1338a997

Revision 11179:f7ee1338a997, 1.2 KB checked in by Ales Erjavec <ales.erjavec@…>, 17 months ago (diff)

More code cleanup.

Line 
1"""
2Test for DynamicResizeToolbar
3
4"""
5import logging
6
7from PyQt4.QtGui import QAction
8
9from PyQt4.QtCore import Qt
10
11from .. import test
12from .. import toolbar
13
14
15class ToolBoxTest(test.QAppTestCase):
16
17    def test_dynamic_toolbar(self):
18        logging.basicConfig(level=logging.DEBUG)
19
20        w = toolbar.DynamicResizeToolBar(None)
21        w.setStyleSheet("QToolButton { border: 1px solid red; }")
22
23        w.addAction(QAction("1", w))
24        w.addAction(QAction("2", w))
25        w.addAction(QAction("A long name", w))
26        actions = list(w.actions())
27
28        self.assertSequenceEqual([str(action.text()) for action in actions],
29                                 ["1", "2", "A long name"])
30
31        w.resize(100, 30)
32        w.show()
33
34        w.raise_()
35
36        w.removeAction(actions[1])
37        w.insertAction(actions[2], actions[1])
38
39        self.assertSequenceEqual(actions, list(w.actions()),
40                                 msg="insertAction does not preserve "
41                                     "action order")
42
43        self.singleShot(2000, lambda: w.setOrientation(Qt.Vertical))
44        self.singleShot(5000, lambda: w.removeAction(actions[1]))
45
46        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.