aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-06-14 14:59:26 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-06-14 15:15:47 -0300
commit569d1ab60e9b2227b2f4ed407718d17cc179d265 (patch)
treefa1e9a335c6c0b0101462a11a42659800ea08a4d /tests/QtGui
parent4284ae6cc69f6281140d960cfd6d62a94066bf36 (diff)
Fixed parent function return ownership.
Fixed QMainWindow functions ownership. Fixes #241. Reviewer: Hugo Parente Lima <hugo.lima@openbossa.org>, Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests/QtGui')
-rw-r--r--tests/QtGui/qmainwindow_test.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/QtGui/qmainwindow_test.py b/tests/QtGui/qmainwindow_test.py
index fce145d53..372018cb3 100644
--- a/tests/QtGui/qmainwindow_test.py
+++ b/tests/QtGui/qmainwindow_test.py
@@ -17,6 +17,14 @@ class MainWindow(QtGui.QMainWindow):
pointerToolbar = self.addToolBar("Pointer type")
pointerToolbar.addWidget(pointerButton)
+class MyButton(QtGui.QPushButton):
+ def __init__(self, parent=None):
+ QtGui.QPushButton.__init__(self)
+ self._called = False
+
+ def myCallback(self):
+ self._called = True
+
class TestMainWindow(UsesQApplication):
@@ -26,6 +34,40 @@ class TestMainWindow(UsesQApplication):
QtCore.QTimer.singleShot(1000, self.app.quit)
self.app.exec_()
+ def testRefCountToNull(self):
+ w = QtGui.QMainWindow()
+ c = QtGui.QWidget()
+ self.assertEqual(sys.getrefcount(c), 2)
+ w.setCentralWidget(c)
+ self.assertEqual(sys.getrefcount(c), 3)
+ w.setCentralWidget(None)
+ self.assertEqual(sys.getrefcount(c), 2)
+
+ def testRefCountToAnother(self):
+ w = QtGui.QMainWindow()
+ c = QtGui.QWidget()
+ self.assertEqual(sys.getrefcount(c), 2)
+ w.setCentralWidget(c)
+ self.assertEqual(sys.getrefcount(c), 3)
+
+ c2 = QtGui.QWidget()
+ w.setCentralWidget(c2)
+ self.assertEqual(sys.getrefcount(c), 2)
+ self.assertEqual(sys.getrefcount(c2), 3)
+
+ def testSignalDisconect(self):
+ w = QtGui.QMainWindow()
+ b = MyButton("button")
+ b.clicked.connect(b.myCallback)
+ w.setCentralWidget(b)
+
+ b = MyButton("button")
+ b.clicked.connect(b.myCallback)
+ w.setCentralWidget(b)
+
+ b.click()
+ self.assertEqual(b._called, True)
+
if __name__ == '__main__':
unittest.main()