summaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-23 11:40:19 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-23 11:56:45 -0300
commit418a56668c8a587530e6bc2a2745b4e385cff5f6 (patch)
tree304e2c247662629a631032769570ff9a17e49804 /tests/samplebinding
parentfb6366565ee8a6718ca72589d0833498285ba048 (diff)
downloadshiboken-418a56668c8a587530e6bc2a2745b4e385cff5f6.tar.gz
shiboken-418a56668c8a587530e6bc2a2745b4e385cff5f6.tar.xz
shiboken-418a56668c8a587530e6bc2a2745b4e385cff5f6.zip
Created debug function on samle bindings.
This function 'cacheSize()' can be used to check how many objects still registered on BindingManager. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'tests/samplebinding')
-rw-r--r--tests/samplebinding/protected_test.py29
-rw-r--r--tests/samplebinding/typesystem_sample.xml5
2 files changed, 29 insertions, 5 deletions
diff --git a/tests/samplebinding/protected_test.py b/tests/samplebinding/protected_test.py
index 88ac5b59..e9d8b81e 100644
--- a/tests/samplebinding/protected_test.py
+++ b/tests/samplebinding/protected_test.py
@@ -27,7 +27,9 @@
'''Test cases for protected methods.'''
import unittest
+import sys
+from sample import cacheSize
from sample import ProtectedNonPolymorphic, ProtectedVirtualDestructor
from sample import ProtectedPolymorphic, ProtectedPolymorphicDaughter, ProtectedPolymorphicGrandDaughter
from sample import ProtectedProperty, ProtectedEnumClass
@@ -68,6 +70,9 @@ class ExtendedProtectedVirtualDestructor(ProtectedVirtualDestructor):
class ProtectedNonPolymorphicTest(unittest.TestCase):
'''Test cases for protected method in a class without virtual methods.'''
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
def testProtectedCall(self):
'''Calls a non-virtual protected method.'''
p = ProtectedNonPolymorphic('NonPoly')
@@ -92,6 +97,9 @@ class ProtectedNonPolymorphicTest(unittest.TestCase):
class ProtectedPolymorphicTest(unittest.TestCase):
'''Test cases for protected method in a class with virtual methods.'''
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
def testProtectedCall(self):
'''Calls a virtual protected method.'''
p = ProtectedNonPolymorphic('Poly')
@@ -113,7 +121,6 @@ class ProtectedPolymorphicTest(unittest.TestCase):
self.assert_(p.protectedName_called)
self.assertEqual(p.protectedName(), name)
self.assertEqual(ProtectedPolymorphic.protectedName(p), original_name)
-
class ProtectedPolymorphicDaugherTest(unittest.TestCase):
'''Test cases for protected method in a class inheriting for a class with virtual methods.'''
@@ -128,15 +135,18 @@ class ProtectedPolymorphicDaugherTest(unittest.TestCase):
original_name = 'Poly'
p = ExtendedProtectedPolymorphicDaughter(original_name)
name = p.callProtectedName()
- print "MyName:", name
self.assert_(p.protectedName_called)
self.assertEqual(p.protectedName(), name)
self.assertEqual(ProtectedPolymorphicDaughter.protectedName(p), original_name)
+
class ProtectedPolymorphicGrandDaugherTest(unittest.TestCase):
'''Test cases for protected method in a class inheriting for a class that inherits from
another with protected virtual methods.'''
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
def testProtectedCallWithInstanceCreatedOnCpp(self):
'''Calls a virtual protected method from parent class on an instance created in C++.'''
p = ProtectedPolymorphicGrandDaughter.create()
@@ -158,6 +168,9 @@ class ProtectedVirtualDtorTest(unittest.TestCase):
def setUp(self):
ProtectedVirtualDestructor.resetDtorCounter()
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
def testVirtualProtectedDtor(self):
'''Original protected virtual destructor is being called.'''
dtor_called = ProtectedVirtualDestructor.dtorCalled()
@@ -198,6 +211,9 @@ class ExtendedProtectedEnumClass(ProtectedEnumClass):
class ProtectedEnumTest(unittest.TestCase):
'''Test cases for protected enum.'''
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
def testProtectedMethodWithProtectedEnumArgument(self):
'''Calls protected method with protected enum argument.'''
obj = ProtectedEnumClass()
@@ -250,6 +266,9 @@ class ProtectedEnumTest(unittest.TestCase):
class ProtectedPropertyTest(unittest.TestCase):
'''Test cases for a class with a protected property (or field in C++).'''
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
def testProtectedProperty(self):
'''Writes and reads a protected property.'''
obj = ProtectedProperty()
@@ -257,10 +276,12 @@ class ProtectedPropertyTest(unittest.TestCase):
obj.protectedProperty = 3
self.assertEqual(obj.protectedProperty, 3)
-
class PrivateDtorProtectedMethodTest(unittest.TestCase):
'''Test cases for classes with private destructors and protected methods.'''
+ def tearDown(self):
+ self.assertEqual(cacheSize(), 0)
+
def testProtectedMethod(self):
'''Calls protected method of a class with a private destructor.'''
obj = PrivateDtor.instance()
@@ -268,12 +289,10 @@ class PrivateDtorProtectedMethodTest(unittest.TestCase):
self.assertEqual(type(obj), PrivateDtor)
self.assertEqual(obj.instanceCalls(), 1)
self.assertEqual(obj.instanceCalls(), obj.protectedInstanceCalls())
-
obj = PrivateDtor.instance()
self.assertEqual(obj.instanceCalls(), 2)
self.assertEqual(obj.instanceCalls(), obj.protectedInstanceCalls())
-
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index 37fa4742..b0fff8dc 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -45,6 +45,11 @@
<include file-name="map" location="global"/>
</container-type>
<container-type name="List" type="list" />
+ <add-function signature="cacheSize()" return-type="int">
+ <inject-code class="target">
+ %PYARG_0 = %CONVERTTOPYTHON[int](Shiboken::BindingManager::instance().getAllPyObjects().size());
+ </inject-code>
+ </add-function>
<function signature="sumComplexPair(std::pair&lt;Complex, Complex>)" />
<function signature="gimmeComplexList()" />