aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-23 11:40:19 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:08:59 -0300
commit73360b909285ebfd57a0d24b83c64232b4d05a95 (patch)
treee0899a3c38b52a391d7c739fa96d04bb2caa25eb /tests
parentd7e399febc75e708bbd34da48199291604f08659 (diff)
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')
-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 88ac5b59f..e9d8b81e7 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 37fa4742e..b0fff8dc6 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()" />