aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui/qmainwindow_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/QtGui/qmainwindow_test.py')
-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()