summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuciano Wolf <luciano.wolf@openbossa.org>2009-11-27 18:29:07 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-27 19:21:35 -0300
commit1dffc65e80f7ed87d51322de10492c7aec7106ca (patch)
treecdaa8a5d97d60881e1005381924ca8926ee9fb1c
parent5d2e5cd85ec6950f5bb848fe08e66cd8520cf29d (diff)
downloadshiboken-1dffc65e80f7ed87d51322de10492c7aec7106ca.tar.gz
shiboken-1dffc65e80f7ed87d51322de10492c7aec7106ca.tar.xz
shiboken-1dffc65e80f7ed87d51322de10492c7aec7106ca.zip
Fix objects/points methods to return a list + fix example using them.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--tests/libsample/blackbox.cpp25
-rw-r--r--tests/libsample/blackbox.h4
-rwxr-xr-xtests/samplebinding/ownership_transference_test.py14
3 files changed, 34 insertions, 9 deletions
diff --git a/tests/libsample/blackbox.cpp b/tests/libsample/blackbox.cpp
index 4cad76ad..f917d786 100644
--- a/tests/libsample/blackbox.cpp
+++ b/tests/libsample/blackbox.cpp
@@ -107,3 +107,28 @@ BlackBox::disposePoint(int ticket)
delete point;
}
+
+std::list<ObjectType*>
+BlackBox::objects()
+{
+ std::list<ObjectType*> l;
+ map<int, ObjectType*>::iterator it;
+
+ for ( it = m_objects.begin() ; it != m_objects.end(); it++ )
+ l.push_back((*it).second);
+
+ return l;
+}
+
+std::list<Point*>
+BlackBox::points()
+{
+ std::list<Point*> l;
+ map<int, Point*>::iterator it;
+
+ for ( it = m_points.begin() ; it != m_points.end(); it++ )
+ l.push_back((*it).second);
+
+ return l;
+}
+
diff --git a/tests/libsample/blackbox.h b/tests/libsample/blackbox.h
index c683c82d..9050822d 100644
--- a/tests/libsample/blackbox.h
+++ b/tests/libsample/blackbox.h
@@ -57,8 +57,8 @@ public:
Point* retrievePoint(int ticket);
void disposePoint(int ticket);
- ObjectTypeMap objects() { return m_objects; }
- PointMap points() { return m_points; }
+ std::list<ObjectType*> objects();
+ std::list<Point*> points();
private:
ObjectTypeMap m_objects;
diff --git a/tests/samplebinding/ownership_transference_test.py b/tests/samplebinding/ownership_transference_test.py
index 426d11ae..1a8682da 100755
--- a/tests/samplebinding/ownership_transference_test.py
+++ b/tests/samplebinding/ownership_transference_test.py
@@ -43,14 +43,14 @@ class BlackBoxTest(unittest.TestCase):
o2.setObjectName('object2')
o2_refcnt = sys.getrefcount(o2)
bb = BlackBox()
- bb.keepObjectType(o1)
- bb.keepObjectType(o2)
- self.assertEqual(bb.objects(), [o1, o2])
+ o1_ticket = bb.keepObjectType(o1)
+ o2_ticket = bb.keepObjectType(o2)
+ self.assertEqual(set(bb.objects()), set([o1, o2]))
self.assertEqual(str(o1.objectName()), 'object1')
self.assertEqual(str(o2.objectName()), 'object2')
self.assertEqual(sys.getrefcount(o1), o1_refcnt)
self.assertEqual(sys.getrefcount(o2), o2_refcnt)
- o2 = bb.retrieveObjectType(o2)
+ o2 = bb.retrieveObjectType(o2_ticket)
self.assertEqual(sys.getrefcount(o2), o2_refcnt)
del bb
self.assertRaises(RuntimeError, o1.objectName)
@@ -62,8 +62,8 @@ class BlackBoxTest(unittest.TestCase):
o1 = ObjectType()
o2 = ObjectType()
bb = BlackBox()
- bb.keepObjectType(o1)
- o3 = bb.retrieveObjectType(o2)
+ o1_ticket = bb.keepObjectType(o1)
+ o3 = bb.retrieveObjectType(-5)
self.assertEqual(o3, None)
def testOwnershipTransferenceCppCreated(self):
@@ -72,7 +72,7 @@ class BlackBoxTest(unittest.TestCase):
o1.setObjectName('object1')
o1_refcnt = sys.getrefcount(o1)
bb = BlackBox()
- bb.keepObjectType(o1)
+ o1_ticket = bb.keepObjectType(o1)
self.assertRaises(RuntimeError, o1.objectName)
if __name__ == '__main__':