aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-08 11:24:48 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-12-29 15:42:30 -0300
commitef1d065f23b6e9c206cb44b5fd2c36708bb238ca (patch)
treee5329086a9dc5c4e8dfaa9d92af42ea4b86cd0e2
parente67ea3ffab7c161785636b78c41f3b624ec0f5ab (diff)
Adds "libother" as a new test library.
New test library and corresponding binding were added to check for intermodule problems. The CMake linkage type for the modules had to be changed from MODULE to SHARED. Reviewed by Hugo Parente <hugo.lima@openbossa.org>
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/libother/CMakeLists.txt15
-rw-r--r--tests/libother/otherderived.cpp61
-rw-r--r--tests/libother/otherderived.h57
-rw-r--r--tests/otherbinding/CMakeLists.txt44
-rw-r--r--tests/otherbinding/global.h3
-rwxr-xr-xtests/otherbinding/otherderived_test.py91
-rw-r--r--tests/otherbinding/typesystem_other.xml8
-rw-r--r--tests/samplebinding/CMakeLists.txt2
9 files changed, 283 insertions, 2 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 74f89a731..0336154a1 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,9 @@
add_subdirectory(libsample)
+add_subdirectory(libother)
add_subdirectory(samplebinding)
+add_subdirectory(otherbinding)
-file(GLOB TEST_FILES samplebinding/*_test.py)
+file(GLOB TEST_FILES samplebinding/*_test.py otherbinding/*_test.py)
set(test_blacklist "")
diff --git a/tests/libother/CMakeLists.txt b/tests/libother/CMakeLists.txt
new file mode 100644
index 000000000..be64a0ebf
--- /dev/null
+++ b/tests/libother/CMakeLists.txt
@@ -0,0 +1,15 @@
+project(libother)
+
+set(libother_SRC
+otherderived.cpp
+)
+
+add_definitions("-DLIBOTHER_BUILD")
+add_library(libother SHARED ${libother_SRC})
+set_property(TARGET libother PROPERTY PREFIX "")
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${libsample_SOURCE_DIR}
+ ${libsample_SOURCE_DIR}/..)
+target_link_libraries(libother libsample)
+
diff --git a/tests/libother/otherderived.cpp b/tests/libother/otherderived.cpp
new file mode 100644
index 000000000..10529ee2d
--- /dev/null
+++ b/tests/libother/otherderived.cpp
@@ -0,0 +1,61 @@
+/*
+ * This file is part of the Shiboken Python Binding Generator project.
+ *
+ * Copyright (C) 2009 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.
+ *
+ * As a special exception to the GNU Lesser General Public License
+ * version 2.1, the object code form of a "work that uses the Library"
+ * may incorporate material from a header file that is part of the
+ * Library. You may distribute such object code under terms of your
+ * choice, provided that the incorporated material (i) does not exceed
+ * more than 5% of the total size of the Library; and (ii) is limited to
+ * numerical parameters, data structure layouts, accessors, macros,
+ * inline functions and templates.
+ *
+ * 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
+ */
+
+#include "otherderived.h"
+
+OtherDerived::OtherDerived(int id) : Abstract(id)
+{
+}
+
+OtherDerived::~OtherDerived()
+{
+}
+
+Abstract*
+OtherDerived::createObject()
+{
+ static int id = 100;
+ return new OtherDerived(id++);
+}
+
+void
+OtherDerived::pureVirtual()
+{
+}
+
+void
+OtherDerived::unpureVirtual()
+{
+}
+
diff --git a/tests/libother/otherderived.h b/tests/libother/otherderived.h
new file mode 100644
index 000000000..e449e29af
--- /dev/null
+++ b/tests/libother/otherderived.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the Shiboken Python Binding Generator project.
+ *
+ * Copyright (C) 2009 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.
+ *
+ * As a special exception to the GNU Lesser General Public License
+ * version 2.1, the object code form of a "work that uses the Library"
+ * may incorporate material from a header file that is part of the
+ * Library. You may distribute such object code under terms of your
+ * choice, provided that the incorporated material (i) does not exceed
+ * more than 5% of the total size of the Library; and (ii) is limited to
+ * numerical parameters, data structure layouts, accessors, macros,
+ * inline functions and templates.
+ *
+ * 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
+ */
+
+#ifndef OTHERDERIVED_H
+#define OTHERDERIVED_H
+
+#include <libsample/libsamplemacros.h>
+#include <libsample/abstract.h>
+
+class LIBSAMPLE_API OtherDerived : public Abstract
+{
+public:
+ OtherDerived(int id = -1);
+ virtual ~OtherDerived();
+ virtual void pureVirtual();
+ virtual void unpureVirtual();
+
+ // factory method
+ static Abstract* createObject();
+
+protected:
+ const char* getClassName() { return className(); }
+ virtual const char* className() { return "OtherDerived"; }
+};
+#endif // OTHERDERIVED_H
+
diff --git a/tests/otherbinding/CMakeLists.txt b/tests/otherbinding/CMakeLists.txt
new file mode 100644
index 000000000..164870c02
--- /dev/null
+++ b/tests/otherbinding/CMakeLists.txt
@@ -0,0 +1,44 @@
+project(other)
+
+set(other_TYPESYSTEM
+${CMAKE_CURRENT_SOURCE_DIR}/typesystem_other.xml
+)
+
+set(other_SRC
+${CMAKE_CURRENT_BINARY_DIR}/other/otherderived_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/other_module_wrapper.cpp
+)
+
+find_program(GENERATOR generatorrunner REQUIRED)
+
+add_custom_command(OUTPUT ${other_SRC}
+COMMAND ${GENERATOR} --generatorSet=${shiboken_BINARY_DIR}/shiboken_generator --enable-parent-ctor-heuristic
+ ${CMAKE_CURRENT_SOURCE_DIR}/global.h
+ --include-paths=${libother_SOURCE_DIR}:${libsample_SOURCE_DIR}:${libsample_SOURCE_DIR}/..
+ --typesystem-paths=${CMAKE_CURRENT_SOURCE_DIR}:${sample_SOURCE_DIR}
+ --output-directory=${CMAKE_CURRENT_BINARY_DIR}
+ ${other_TYPESYSTEM}
+WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+COMMENT "Running generator for test binding..."
+)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}
+ ${PYTHON_INCLUDE_PATH}
+ ${libother_SOURCE_DIR}
+ ${libsample_SOURCE_DIR}
+ ${libsample_SOURCE_DIR}/..
+ ${sample_BINARY_DIR}
+ ${sample_BINARY_DIR}/sample
+ ${libshiboken_SOURCE_DIR})
+add_library(other SHARED ${other_SRC})
+set_property(TARGET other PROPERTY PREFIX "")
+target_link_libraries(other
+ libother
+ libsample
+ sample
+ ${PYTHON_LIBRARIES}
+ libshiboken)
+
+add_dependencies(other sample shiboken_generator)
+
diff --git a/tests/otherbinding/global.h b/tests/otherbinding/global.h
new file mode 100644
index 000000000..c8bfcfb4b
--- /dev/null
+++ b/tests/otherbinding/global.h
@@ -0,0 +1,3 @@
+#include "../samplebinding/global.h"
+#include "otherderived.h"
+
diff --git a/tests/otherbinding/otherderived_test.py b/tests/otherbinding/otherderived_test.py
new file mode 100755
index 000000000..7e8880c33
--- /dev/null
+++ b/tests/otherbinding/otherderived_test.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# This file is part of the Shiboken Python Bindings Generator project.
+#
+# Copyright (C) 2009 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
+
+'''Test cases for OtherDerived class'''
+
+import sys
+import unittest
+
+from sample import Abstract
+from other import OtherDerived
+
+class OtherDeviant(OtherDerived):
+ def __init__(self):
+ OtherDerived.__init__(self)
+ self.pure_virtual_called = False
+ self.unpure_virtual_called = False
+
+ def pureVirtual(self):
+ self.pure_virtual_called = True
+
+ def unpureVirtual(self):
+ self.unpure_virtual_called = True
+
+ def className(self):
+ return 'OtherDeviant'
+
+class OtherDerivedTest(unittest.TestCase):
+ '''Test case for OtherDerived class'''
+
+ def testParentClassMethodsAvailability(self):
+ '''Test if OtherDerived class really inherits its methods from parent.'''
+ inherited_methods = set(['callPureVirtual', 'callUnpureVirtual',
+ 'id_', 'pureVirtual', 'unpureVirtual'])
+ self.assert_(inherited_methods.issubset(dir(OtherDerived)))
+
+ def testReimplementedPureVirtualMethodCall(self):
+ '''Test if a Python override of a implemented pure virtual method is correctly called from C++.'''
+ d = OtherDeviant()
+ d.callPureVirtual()
+ self.assert_(d.pure_virtual_called)
+
+ def testReimplementedVirtualMethodCall(self):
+ '''Test if a Python override of a reimplemented virtual method is correctly called from C++.'''
+ d = OtherDeviant()
+ d.callUnpureVirtual()
+ self.assert_(d.unpure_virtual_called)
+
+ def testVirtualMethodCallString(self):
+ '''Test virtual method call returning string.'''
+ d = OtherDerived()
+ self.assertEqual(d.className(), 'OtherDerived')
+ self.assertEqual(d.getClassName(), 'OtherDerived')
+
+ def testReimplementedVirtualMethodCallReturningString(self):
+ '''Test if a Python override of a reimplemented virtual method is correctly called from C++.'''
+ d = OtherDeviant()
+ self.assertEqual(d.className(), 'OtherDeviant')
+ self.assertEqual(d.getClassName(), 'OtherDeviant')
+
+ def testCallToMethodWithAbstractArgument(self):
+ '''Call to method that expects an Abstract argument.'''
+ objId = 123
+ d = OtherDerived(objId)
+ self.assertEqual(Abstract.getObjectId(d), objId)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/tests/otherbinding/typesystem_other.xml b/tests/otherbinding/typesystem_other.xml
new file mode 100644
index 000000000..6bcc7c1a1
--- /dev/null
+++ b/tests/otherbinding/typesystem_other.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<typesystem package="other">
+ <load-typesystem name="typesystem_sample.xml" generate="no" />
+
+ <object-type name="OtherDerived" />
+
+</typesystem>
+
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index 8ff8087e1..fee52d267 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -79,7 +79,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${PYTHON_INCLUDE_PATH}
${libsample_SOURCE_DIR}
${libshiboken_SOURCE_DIR})
-add_library(sample MODULE ${sample_SRC})
+add_library(sample SHARED ${sample_SRC})
set_property(TARGET sample PROPERTY PREFIX "")
target_link_libraries(sample
libsample