aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui/add_action_test.py
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-06-07 14:43:45 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-06-07 16:57:11 -0300
commitab918abc1e103e0ca86939f7d057e8a44ac8a4ef (patch)
tree53c6f57d089dcf5e145d766b1ceef704714046d8 /tests/QtGui/add_action_test.py
parent471486732b03cbb42b884158604a59d5a18e8a35 (diff)
Created new unittest model.
Separete unittest for module. Only run unittest for compiled modules. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>, Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/QtGui/add_action_test.py')
-rw-r--r--tests/QtGui/add_action_test.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/QtGui/add_action_test.py b/tests/QtGui/add_action_test.py
new file mode 100644
index 000000000..7e20c459d
--- /dev/null
+++ b/tests/QtGui/add_action_test.py
@@ -0,0 +1,44 @@
+
+'''Tests for QMenuBar.addAction(identifier, callback) calls'''
+
+import unittest
+
+from PySide.QtCore import SLOT
+from PySide.QtGui import QMenuBar, QAction, QPushButton
+
+from helper import UsesQApplication
+
+
+class AddActionTest(UsesQApplication):
+ '''QMenuBar addAction'''
+
+ def tearDown(self):
+ try:
+ del self.called
+ except AttributeError:
+ pass
+ super(AddActionTest, self).tearDown()
+
+ def _callback(self):
+ self.called = True
+
+ def testBasic(self):
+ '''QMenuBar.addAction(id, callback)'''
+ menubar = QMenuBar()
+ action = menubar.addAction("Accounts", self._callback)
+ action.activate(QAction.Trigger)
+ self.assert_(self.called)
+
+ def testWithCppSlot(self):
+ '''QMenuBar.addAction(id, object, slot)'''
+ menubar = QMenuBar()
+ widget = QPushButton()
+ widget.setCheckable(True)
+ widget.setChecked(False)
+ action = menubar.addAction("Accounts", widget, SLOT("toggle()"))
+ action.activate(QAction.Trigger)
+ self.assert_(widget.isChecked())
+
+if __name__ == '__main__':
+ unittest.main()
+