aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding/objecttypelayout_test.py
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-01 18:33:45 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-12-01 18:55:38 -0300
commit0f8b230fd2dbc1c618ce8fcc84efa5d741ce1a0f (patch)
tree698d2e7cc8595683eab2b81ac547944358a3f4c6 /tests/samplebinding/objecttypelayout_test.py
parent95ee90a0c334b587860d4e54b7bf8c079379d7c6 (diff)
Improved tests for the QLayout-like ObjectTypeLayout.
In the new test case an ObjectType uses a layout that contains another layout, both created in C++, and then get deleted. Custom code was used to achieve the correct parentship handling Reviewed by Hugo Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'tests/samplebinding/objecttypelayout_test.py')
-rwxr-xr-xtests/samplebinding/objecttypelayout_test.py103
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/samplebinding/objecttypelayout_test.py b/tests/samplebinding/objecttypelayout_test.py
index a21b03d00..444ee8b5d 100755
--- a/tests/samplebinding/objecttypelayout_test.py
+++ b/tests/samplebinding/objecttypelayout_test.py
@@ -141,6 +141,51 @@ class ObjectTypeLayoutTest(unittest.TestCase):
self.assertEqual(l1.parent(), p1)
self.assertEqual(l2.parent(), l1)
+ del p1
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, c4.objectName)
+ self.assertRaises(RuntimeError, l1.objectName)
+ self.assertRaises(RuntimeError, l2.objectName)
+
+ def testObjectTypeLayoutInsideAnotherLayoutAndEveryoneCreatedInCpp(self):
+ '''Adds one ObjectTypeLayout to another and sets the parent to an ObjectType. All the objects are created in C++.'''
+ p1 = ObjectType.create()
+
+ l1 = ObjectTypeLayout.create()
+ c1 = ObjectType.create()
+ l1.addObject(c1)
+ c2 = ObjectType.create()
+ l1.addObject(c2)
+
+ l2 = ObjectTypeLayout.create()
+ c3 = ObjectType.create()
+ l2.addObject(c3)
+ c4 = ObjectType.create()
+ l2.addObject(c4)
+
+ l1.addObject(l2)
+
+ p1.setLayout(l1)
+
+ self.assertEqual(c1.parent(), p1)
+ self.assertEqual(c2.parent(), p1)
+ self.assertEqual(c3.parent(), p1)
+ self.assertEqual(c4.parent(), p1)
+ self.assertEqual(l1.parent(), p1)
+ self.assertEqual(l2.parent(), l1)
+
+ del p1
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, c4.objectName)
+ self.assertRaises(RuntimeError, l1.objectName)
+ self.assertRaises(RuntimeError, l2.objectName)
+
def testTransferNestedLayoutsBetweenObjects(self):
'''Adds one ObjectTypeLayout to another, sets the parent to an ObjectType and then transfer it to another object.'''
p1 = ObjectType()
@@ -179,6 +224,64 @@ class ObjectTypeLayoutTest(unittest.TestCase):
self.assertEqual(l1.parent(), p2)
self.assertEqual(l2.parent(), l1)
+ del p2
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, c4.objectName)
+ self.assertRaises(RuntimeError, l1.objectName)
+ self.assertRaises(RuntimeError, l2.objectName)
+
+ def testTransferNestedLayoutsBetweenObjectsAndEveryoneCreatedInCpp(self):
+ '''Adds one ObjectTypeLayout to another, sets the parent to an ObjectType and then transfer it to another object.
+ All the objects are created in C++.'''
+ p1 = ObjectType.create()
+ p2 = ObjectType.create()
+
+ l1 = ObjectTypeLayout.create()
+ c1 = ObjectType.create()
+ l1.addObject(c1)
+ c2 = ObjectType.create()
+ l1.addObject(c2)
+
+ l2 = ObjectTypeLayout.create()
+ c3 = ObjectType.create()
+ l2.addObject(c3)
+ c4 = ObjectType.create()
+ l2.addObject(c4)
+
+ l1.addObject(l2)
+
+ p1.setLayout(l1)
+
+ self.assertEqual(c1.parent(), p1)
+ self.assertEqual(c2.parent(), p1)
+ self.assertEqual(c3.parent(), p1)
+ self.assertEqual(c4.parent(), p1)
+ self.assertEqual(l1.parent(), p1)
+ self.assertEqual(l2.parent(), l1)
+
+ p2.setLayout(l1)
+ del p1
+
+ self.assertEqual(c1.parent(), p2)
+ self.assertEqual(c2.parent(), p2)
+ self.assertEqual(c3.parent(), p2)
+ self.assertEqual(c4.parent(), p2)
+ self.assertEqual(l1.parent(), p2)
+ self.assertEqual(l2.parent(), l1)
+
+ del p2
+
+ self.assertRaises(RuntimeError, c1.objectName)
+ self.assertRaises(RuntimeError, c2.objectName)
+ self.assertRaises(RuntimeError, c3.objectName)
+ self.assertRaises(RuntimeError, c4.objectName)
+ self.assertRaises(RuntimeError, l1.objectName)
+ self.assertRaises(RuntimeError, l2.objectName)
+
+
if __name__ == '__main__':
unittest.main()