aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Ehresman <jpe@wingware.com>2012-06-07 20:44:19 -0400
committerMarcelo Lira <marcelo.lira@openbossa.org>2012-06-14 20:20:21 +0200
commite40e993cecd1663636e2f0d33b3e2a6204d64984 (patch)
tree172ed7dbfc535fd6113c8707a82e02647aaec7dc /tests
parent54cce10fa8a9942450c9e1a9d9a9d2a1b688f243 (diff)
Find function modifications defined in the 2nd+ base class.
Fixes bug PYSIDE-54 Change-Id: Ic5c341741170cc77e8ebb59c46c746211582ddeb Reviewed-by: Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/objecttype.cpp14
-rw-r--r--tests/libsample/objecttype.h14
-rw-r--r--tests/samplebinding/CMakeLists.txt2
-rw-r--r--tests/samplebinding/ownership_invalidate_after_use_test.py20
-rw-r--r--tests/samplebinding/typesystem_sample.xml4
5 files changed, 53 insertions, 1 deletions
diff --git a/tests/libsample/objecttype.cpp b/tests/libsample/objecttype.cpp
index c253c610f..02ea7badc 100644
--- a/tests/libsample/objecttype.cpp
+++ b/tests/libsample/objecttype.cpp
@@ -289,3 +289,17 @@ std::size_t ObjectType::createObjectType()
void* addr = new ObjectType();
return (std::size_t) addr;
}
+
+OtherBase::~OtherBase()
+{
+}
+
+ObjectTypeDerived::~ObjectTypeDerived()
+{
+}
+
+bool
+ObjectTypeDerived::event(Event* event)
+{
+ return true;
+}
diff --git a/tests/libsample/objecttype.h b/tests/libsample/objecttype.h
index 84812a8d6..78cbf8f5a 100644
--- a/tests/libsample/objecttype.h
+++ b/tests/libsample/objecttype.h
@@ -144,5 +144,19 @@ private:
LIBSAMPLE_API unsigned int objectTypeHash(const ObjectType* objectType);
+class LIBSAMPLE_API OtherBase {
+public:
+ OtherBase() {};
+ virtual ~OtherBase();
+};
+
+class LIBSAMPLE_API ObjectTypeDerived: public ObjectType, public OtherBase {
+public:
+ ObjectTypeDerived(): ObjectType(), OtherBase() {};
+
+ virtual bool event(Event* event);
+ virtual ~ObjectTypeDerived();
+};
+
#endif // OBJECTTYPE_H
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index 601b12692..f0d973088 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -50,6 +50,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/objectmodel_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttype_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypebyvalue_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeholder_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypederived_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypelayout_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeptrlist_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeoperators_wrapper.cpp
@@ -57,6 +58,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/objectview_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objtypereference_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/oddbooluser_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/onlycopy_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/otherbase_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/overload_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/overload2_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/pairuser_wrapper.cpp
diff --git a/tests/samplebinding/ownership_invalidate_after_use_test.py b/tests/samplebinding/ownership_invalidate_after_use_test.py
index 5a03fc470..194c7e77e 100644
--- a/tests/samplebinding/ownership_invalidate_after_use_test.py
+++ b/tests/samplebinding/ownership_invalidate_after_use_test.py
@@ -29,7 +29,7 @@
import sys
import unittest
-from sample import ObjectType, Event
+from sample import ObjectType, ObjectTypeDerived, Event
class ExtObjectType(ObjectType):
@@ -59,6 +59,16 @@ class MyObjectType (ObjectType):
def invalidateEvent(self, ev):
pass
+class ExtObjectTypeDerived(ObjectTypeDerived):
+ def __init__(self):
+ ObjectTypeDerived.__init__(self)
+ self.type_of_last_event = None
+ self.last_event = None
+ def event(self, event):
+ self.last_event = event
+ self.type_of_last_event = event.eventType()
+ return True
+
class OwnershipInvalidateAfterUseTest(unittest.TestCase):
'''Ownership tests for cases of invalidation of Python wrapper after use.'''
@@ -82,6 +92,14 @@ class OwnershipInvalidateAfterUseTest(unittest.TestCase):
obj.causeEvent(Event.BASIC_EVENT)
self.assertFalse(obj.fail)
+ def testInvalidateAfterUseInDerived(self):
+ '''Invalidate was failing in a derived C++ class that also inherited
+ other base classes'''
+ eot = ExtObjectTypeDerived()
+ eot.causeEvent(Event.SOME_EVENT)
+ self.assertEqual(eot.type_of_last_event, Event.SOME_EVENT)
+ self.assertRaises(RuntimeError, eot.last_event.eventType)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index ac9202a16..f7c0645d8 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -727,6 +727,10 @@
</modify-argument>
</modify-function>
</object-type>
+
+ <object-type name="OtherBase" />
+ <object-type name="ObjectTypeDerived" />
+
<object-type name="ObjectTypeLayout">
<modify-function signature="create()">
<modify-argument index="return">