aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-05 23:44:23 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:08 -0300
commitbaf2a5bf56620134d751b54a514159221d4e11d4 (patch)
tree9a73ccfd86b059a4ce2d6033d60c0d28715b66f2 /tests/samplebinding
parent50aef1dd4836b5019c60d31c54501ebcd37f72cd (diff)
Added a test dealing with a reference to an Object Type passed to Python.
The test is for an Object Type that didn't existed in Python and is passed to it as C++ reference through a virtual method.
Diffstat (limited to 'tests/samplebinding')
-rw-r--r--tests/samplebinding/CMakeLists.txt1
-rw-r--r--tests/samplebinding/global.h1
-rw-r--r--tests/samplebinding/objecttypereferenceasvirtualmethodargument_test.py44
-rw-r--r--tests/samplebinding/typesystem_sample.xml2
4 files changed, 48 insertions, 0 deletions
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index f63ecf981..382b9d13e 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -47,6 +47,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/noimplicitconversion_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/nondefaultctor_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objectmodel_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttype_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeholder_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypelayout_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objecttypeoperators_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/objectview_wrapper.cpp
diff --git a/tests/samplebinding/global.h b/tests/samplebinding/global.h
index 164e992a9..8b9b44ec4 100644
--- a/tests/samplebinding/global.h
+++ b/tests/samplebinding/global.h
@@ -24,6 +24,7 @@
#include "nondefaultctor.h"
#include "objectmodel.h"
#include "objecttype.h"
+#include "objecttypeholder.h"
#include "objecttypelayout.h"
#include "objecttypereference.h"
#include "objecttypeoperators.h"
diff --git a/tests/samplebinding/objecttypereferenceasvirtualmethodargument_test.py b/tests/samplebinding/objecttypereferenceasvirtualmethodargument_test.py
new file mode 100644
index 000000000..5a48a5d2a
--- /dev/null
+++ b/tests/samplebinding/objecttypereferenceasvirtualmethodargument_test.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# This file is part of the Shiboken Python Bindings Generator project.
+#
+# Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+#
+# Contact: PySide team <contact@pyside.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# version 2.1 as published by the Free Software Foundation. Please
+# review the following information to ensure the GNU Lesser General
+# Public License version 2.1 requirements will be met:
+# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+# #
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+import unittest
+from sample import ObjectTypeHolder
+
+class TestObjectTypeReferenceAsVirtualMethodArgument(unittest.TestCase):
+
+ def testBasic(self):
+ holder = ObjectTypeHolder('TheObjectFromC++')
+ self.assertEqual(holder.callPassObjectTypeAsReference(), 'TheObjectFromC++')
+
+ def testExtended(self):
+ class Holder(ObjectTypeHolder):
+ def passObjectTypeAsReference(self, objectType):
+ return objectType.objectName().prepend(('ThisIs'))
+ holder = Holder('TheObjectFromC++')
+ self.assertEqual(holder.callPassObjectTypeAsReference(), 'ThisIsTheObjectFromC++')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index 27c265f3f..add18c289 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -298,6 +298,8 @@
</modify-function>
</object-type>
+ <value-type name="ObjectTypeHolder"/>
+
<object-type name="ObjectModel">
<enum-type name="MethodCalled" />
<modify-function signature="data() const">