aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-08-02 14:55:03 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-08-02 15:31:17 -0300
commit114bca41a21bf5504094b30d7c8735ac8483e50d (patch)
tree1af4f75845adbe04df25823116601e2f4ac39b8f /tests
parentefe8019eda0471baf99ed4372ceda4af06cbe3c1 (diff)
Created unit test to layout ref leak.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtGui/qlayout_ref_test.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/QtGui/qlayout_ref_test.py b/tests/QtGui/qlayout_ref_test.py
index 27c599c70..695e2f163 100644
--- a/tests/QtGui/qlayout_ref_test.py
+++ b/tests/QtGui/qlayout_ref_test.py
@@ -108,5 +108,45 @@ class MultipleAdd(UsesQApplication):
self.layout.addWidget(self.widget)
self.assertEqual(getrefcount(self.widget), 3)
+class InternalAdd(UsesQApplication):
+ def testInternalRef(self):
+ mw = QWidget()
+ w = QWidget()
+ ow = QWidget()
+
+ topLayout = QGridLayout()
+
+ # unique reference
+ self.assertEqual(getrefcount(w), 2)
+ self.assertEqual(getrefcount(ow), 2)
+
+ topLayout.addWidget(w, 0, 0)
+ topLayout.addWidget(ow, 1, 0)
+
+ # layout keep the referemce
+ self.assertEqual(getrefcount(w), 3)
+ self.assertEqual(getrefcount(ow), 3)
+
+ mainLayout = QGridLayout()
+
+ mainLayout.addLayout(topLayout, 1, 0, 1, 4)
+
+ # the same reference
+ self.assertEqual(getrefcount(w), 3)
+ self.assertEqual(getrefcount(ow), 3)
+
+ mw.setLayout(mainLayout)
+
+ # now trasfer the ownership to mw
+ self.assertEqual(getrefcount(w), 3)
+ self.assertEqual(getrefcount(ow), 3)
+
+ del mw
+
+ # remove the ref and invalidate the widget
+ self.assertEqual(getrefcount(w), 2)
+ self.assertEqual(getrefcount(ow), 2)
+
+
if __name__ == '__main__':
unittest.main()