aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/otherbinding
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-28 07:51:22 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-28 09:34:35 +0000
commit2a2a0827fa54b2eeb48e0e2090dfc503492ef33e (patch)
tree4311f7ad34ff98fabcbe4c34e59a970ae4ff4bcf /sources/shiboken6/tests/otherbinding
parentfb1c0f204e09ba29fa3d360d72231d4ed468c1e4 (diff)
Rename shiboken2 to shiboken6
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I4cb5ee4c8df539546014b08202a7b1e98ed3ff07 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/tests/otherbinding')
-rw-r--r--sources/shiboken6/tests/otherbinding/CMakeLists.txt49
-rw-r--r--sources/shiboken6/tests/otherbinding/collector_external_operator_test.py64
-rw-r--r--sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py79
-rw-r--r--sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py70
-rw-r--r--sources/shiboken6/tests/otherbinding/global.h36
-rw-r--r--sources/shiboken6/tests/otherbinding/module_reload_test.py62
-rw-r--r--sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py62
-rw-r--r--sources/shiboken6/tests/otherbinding/objtypehashes_test.py59
-rw-r--r--sources/shiboken6/tests/otherbinding/other-binding.txt.in20
-rw-r--r--sources/shiboken6/tests/otherbinding/otherderived_test.py125
-rw-r--r--sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py62
-rw-r--r--sources/shiboken6/tests/otherbinding/signature_test.py54
-rw-r--r--sources/shiboken6/tests/otherbinding/smartptr_test.py61
-rw-r--r--sources/shiboken6/tests/otherbinding/test_module_template.py40
-rw-r--r--sources/shiboken6/tests/otherbinding/typediscovery_test.py72
-rw-r--r--sources/shiboken6/tests/otherbinding/typesystem_other.xml24
-rw-r--r--sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py58
-rw-r--r--sources/shiboken6/tests/otherbinding/wrongctor_test.py59
18 files changed, 1056 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/otherbinding/CMakeLists.txt b/sources/shiboken6/tests/otherbinding/CMakeLists.txt
new file mode 100644
index 000000000..7c8562abc
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/CMakeLists.txt
@@ -0,0 +1,49 @@
+project(other)
+
+set(other_TYPESYSTEM
+${CMAKE_CURRENT_SOURCE_DIR}/typesystem_other.xml
+)
+
+set(other_SRC
+${CMAKE_CURRENT_BINARY_DIR}/other/extendsnoimplicitconversion_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/number_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/otherderived_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/othermultiplederived_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/otherobjecttype_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/othervaluewithunituser_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/sharedptr_str_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/smartptrtester_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/other_module_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/valuewithunitintinch_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/other/valuewithunitintmillimeter_wrapper.cpp
+)
+
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/other-binding.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/other-binding.txt" @ONLY)
+
+add_custom_command(
+OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mjb_rejected_classes.log"
+BYPRODUCTS ${other_SRC}
+COMMAND shiboken6 --project-file=${CMAKE_CURRENT_BINARY_DIR}/other-binding.txt ${GENERATOR_EXTRA_FLAGS}
+DEPENDS ${other_TYPESYSTEM} ${CMAKE_CURRENT_SOURCE_DIR}/global.h shiboken6
+WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+COMMENT "Running generator for 'other' test binding..."
+)
+
+add_library(other MODULE ${other_SRC})
+target_include_directories(other PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ ${sample_BINARY_DIR}/sample
+ ${smart_BINARY_DIR}/smart)
+target_link_libraries(other PUBLIC libother libsample libsmart libshiboken)
+set_property(TARGET other PROPERTY PREFIX "")
+set_property(TARGET other PROPERTY OUTPUT_NAME "other${PYTHON_EXTENSION_SUFFIX}")
+
+if(WIN32)
+ set_property(TARGET other PROPERTY SUFFIX ".pyd")
+endif()
+
+
+add_dependencies(other sample smart)
+create_generator_target(other)
+
diff --git a/sources/shiboken6/tests/otherbinding/collector_external_operator_test.py b/sources/shiboken6/tests/otherbinding/collector_external_operator_test.py
new file mode 100644
index 000000000..6014b8a59
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/collector_external_operator_test.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for Collector shift operators defined in other modules.'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from sample import Collector, ObjectType
+from other import OtherObjectType
+
+class CollectorOtherObjectType(unittest.TestCase):
+ '''Test cases for Collector << OtherObjectType'''
+
+ def testLShiftWithExpectedType(self):
+ '''Collector << ObjectType # libsample << operator'''
+ collector = Collector()
+ obj = ObjectType()
+ collector << obj
+ self.assertEqual(collector.items()[0], obj.identifier())
+
+ def testOtherReversal(self):
+ '''Collector << OtherObjectType # libother << operator'''
+ collector = Collector()
+ obj = OtherObjectType()
+ collector << obj
+ self.assertEqual(collector.items()[0], obj.identifier() * 2)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py b/sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py
new file mode 100644
index 000000000..1e992ebc8
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests calling NoImplicitConversion using a ExtendsNoImplicitConversion parameter,
+ being that the latter defines a new conversion operator for the former, and this one
+ has no implicit conversions.'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from sample import NoImplicitConversion
+from other import ExtendsNoImplicitConversion
+
+class ConversionOperatorForClassWithoutImplicitConversionsTest(unittest.TestCase):
+ '''Tests calling NoImplicitConversion constructor using a ExtendsNoImplicitConversion parameter.'''
+
+ def testNoImplicitConversion(self):
+ '''Basic test to see if the NoImplicitConversion is Ok.'''
+ obj = NoImplicitConversion(123)
+ # NoImplicitConversion.receivesNoImplicitConversionByValue(NoImplicitConversion)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByValue(obj))
+ # NoImplicitConversion.receivesNoImplicitConversionByPointer(NoImplicitConversion*)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByPointer(obj))
+ # NoImplicitConversion.receivesNoImplicitConversionByReference(NoImplicitConversion&)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByReference(obj))
+
+ def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByValue(self):
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by value.'''
+ obj = ExtendsNoImplicitConversion(123)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByValue(obj))
+
+ def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByReference(self):
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by reference.'''
+ obj = ExtendsNoImplicitConversion(123)
+ self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByReference(obj))
+
+ def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByPointer(self):
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by pointer.
+ This should not be accepted, since pointers should not be converted.'''
+ obj = ExtendsNoImplicitConversion(123)
+ self.assertRaises(TypeError, NoImplicitConversion.receivesNoImplicitConversionByPointer, obj)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py b/sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py
new file mode 100644
index 000000000..5ad4763b7
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for libsample's Point multiply operator defined in libother module.'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from sample import Point
+from other import Number
+
+class PointOperationsWithNumber(unittest.TestCase):
+ '''Test cases for libsample's Point multiply operator defined in libother module.'''
+
+ def testPointTimesInt(self):
+ '''sample.Point * int'''
+ pt1 = Point(2, 7)
+ num = 3
+ pt2 = Point(pt1.x() * num, pt1.y() * num)
+ self.assertEqual(pt1 * num, pt2)
+
+ def testIntTimesPoint(self):
+ '''int * sample.Point'''
+ pt1 = Point(2, 7)
+ num = 3
+ pt2 = Point(pt1.x() * num, pt1.y() * num)
+ self.assertEqual(num * pt1, pt2)
+
+ def testPointTimesNumber(self):
+ '''sample.Point * other.Number'''
+ pt = Point(2, 7)
+ num = Number(11)
+ self.assertEqual(pt * num.value(), pt * 11)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken6/tests/otherbinding/global.h b/sources/shiboken6/tests/otherbinding/global.h
new file mode 100644
index 000000000..702fb9287
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/global.h
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../samplebinding/global.h"
+#include "extendsnoimplicitconversion.h"
+#include "number.h"
+#include "otherderived.h"
+#include "otherobjecttype.h"
+#include "othermultiplederived.h"
+#include "othertypesystypedef.h"
+#include "smartptrtester.h"
diff --git a/sources/shiboken6/tests/otherbinding/module_reload_test.py b/sources/shiboken6/tests/otherbinding/module_reload_test.py
new file mode 100644
index 000000000..c63af188e
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/module_reload_test.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from importlib import reload
+import os
+import shutil
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+
+orig_path = os.path.join(os.path.dirname(__file__))
+workdir = os.getcwd()
+src = os.path.join(orig_path, 'test_module_template.py')
+dst = os.path.join(workdir, 'test_module.py')
+shutil.copyfile(src, dst)
+sys.path.append(workdir)
+
+class TestModuleReloading(unittest.TestCase):
+
+ def testModuleReloading(self):
+ '''Test module reloading with on-the-fly modifications.'''
+ import test_module
+ for i in range(3):
+ oldObject = test_module.obj
+ self.assertTrue(oldObject is test_module.obj)
+ reload(test_module)
+ self.assertFalse(oldObject is test_module.obj)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py b/sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py
new file mode 100644
index 000000000..84dfe9839
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests calling Str constructor using a Number parameter, being that number defines a cast operator to Str.'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from sample import Str
+from other import Number
+
+class NewCtorOperatorTest(unittest.TestCase):
+ '''Tests calling Str constructor using a Number parameter, being that number defines a cast operator to Str.'''
+
+ def testNumber(self):
+ '''Basic test to see if the Number class is Ok.'''
+ value = 123
+ num = Number(value)
+ self.assertEqual(num.value(), value)
+
+ def testStrCtorWithNumberArgument(self):
+ '''Try to build a Str from 'sample' module with a Number argument from 'other' module.'''
+ value = 123
+ num = Number(value)
+ string = Str(num)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken6/tests/otherbinding/objtypehashes_test.py b/sources/shiboken6/tests/otherbinding/objtypehashes_test.py
new file mode 100644
index 000000000..dc3ae1eb0
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/objtypehashes_test.py
@@ -0,0 +1,59 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+from sample import *
+from other import *
+import shiboken6 as shiboken
+
+class TestHashFuncs (unittest.TestCase):
+
+ def testIt(self):
+ obj1 = HandleHolder()
+ obj2 = HandleHolder()
+
+ hash1 = hash(obj1)
+ hash2 = hash(obj2)
+ self.assertNotEqual(hash1, hash2)
+
+ # Now invalidate the object and test its hash. It shouldn't segfault.
+ shiboken.invalidate(obj1)
+
+ hash1_2 = hash(obj1)
+ self.assertEqual(hash1_2, hash1)
+
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/other-binding.txt.in b/sources/shiboken6/tests/otherbinding/other-binding.txt.in
new file mode 100644
index 000000000..dbe935a9f
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/other-binding.txt.in
@@ -0,0 +1,20 @@
+[generator-project]
+
+generator-set = shiboken
+
+header-file = @CMAKE_CURRENT_SOURCE_DIR@/global.h
+typesystem-file = @other_TYPESYSTEM@
+
+output-directory = @CMAKE_CURRENT_BINARY_DIR@
+
+include-path = @libother_SOURCE_DIR@
+include-path = @libsmart_SOURCE_DIR@
+include-path = @libsample_SOURCE_DIR@
+include-path = @libsample_SOURCE_DIR@/..
+
+typesystem-path = @CMAKE_CURRENT_SOURCE_DIR@
+typesystem-path = @sample_SOURCE_DIR@
+typesystem-path = @smart_SOURCE_DIR@
+
+enable-parent-ctor-heuristic
+
diff --git a/sources/shiboken6/tests/otherbinding/otherderived_test.py b/sources/shiboken6/tests/otherbinding/otherderived_test.py
new file mode 100644
index 000000000..d8dc9b686
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/otherderived_test.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for OtherDerived class'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from sample import Abstract, Derived
+from other import OtherDerived, Number
+
+class Multiple(Derived, Number):
+ def __init__(self):
+ Derived.__init__(self, 42)
+ Number.__init__(self, 42)
+
+ def testCall(self):
+ return True
+
+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 MultipleTest(unittest.TestCase):
+ '''Test case for Multiple derived class'''
+
+ def testConstructor(self):
+ o = Multiple()
+ self.assertTrue(isinstance(o, Multiple))
+ self.assertTrue(isinstance(o, Number))
+ self.assertTrue(isinstance(o, Derived))
+ del o
+
+ def testMethodCall(self):
+ o = Multiple()
+ self.assertTrue(o.id_(), 42)
+ self.assertTrue(o.value(), 42)
+ self.assertTrue(o.testCall())
+
+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.assertTrue(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.assertTrue(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.assertTrue(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/sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py b/sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py
new file mode 100644
index 000000000..aafeb4973
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2020 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test case for a class that holds a void pointer.'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from other import (OtherValueWithUnitUser, ValueWithUnitIntInch,
+ ValueWithUnitIntMillimeter)
+from sample import (ValueWithUnitDoubleMillimeter)
+
+
+class OtherTypeSysTypeDefTest(unittest.TestCase):
+ '''Test case type system typedefs across modules.'''
+
+ def test(self):
+ # Exercise existing typedefs from "sample"
+ mm_value = ValueWithUnitDoubleMillimeter(2540)
+ inch_value = OtherValueWithUnitUser.doubleMillimeterToInch(mm_value)
+ self.assertEqual(int(inch_value.value()), 10)
+ # Exercise typedefs in "other"
+ mm_value = ValueWithUnitIntMillimeter(2540)
+ inch_value = OtherValueWithUnitUser.intMillimeterToInch(mm_value)
+ self.assertEqual(inch_value.value(), 10)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/signature_test.py b/sources/shiboken6/tests/otherbinding/signature_test.py
new file mode 100644
index 000000000..f3b712d04
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/signature_test.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2019 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for functions signature'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from other import OtherObjectType
+from shiboken_test_helper import objectFullname
+
+class SignatureTest(unittest.TestCase):
+
+ # Check if the argument of 'OtherObjectType::enumAsInt(SampleNamespace::SomeClass::PublicScopedEnum value)'
+ # has the correct representation
+ def testNamespaceFromOtherModule(self):
+ argType = OtherObjectType.enumAsInt.__signature__.parameters['value'].annotation
+ self.assertEqual(objectFullname(argType), 'sample.SampleNamespace.SomeClass.PublicScopedEnum')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/smartptr_test.py b/sources/shiboken6/tests/otherbinding/smartptr_test.py
new file mode 100644
index 000000000..04f657757
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/smartptr_test.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2020 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for the SmartPtrTester class'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from smart import Integer
+from sample import Str
+from other import SmartPtrTester
+
+
+class SmartPtrTest(unittest.TestCase):
+ '''Test case for the SmartPtrTester class'''
+
+ def test(self):
+ tester = SmartPtrTester()
+
+ integerPtr = tester.createSharedPtrInteger(42)
+ self.assertEqual(tester.valueOfSharedPtrInteger(integerPtr), 42)
+
+ strPtr = tester.createSharedPtrStr('hello')
+ self.assertEqual(tester.valueOfSharedPtrStr(strPtr), 'hello')
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/test_module_template.py b/sources/shiboken6/tests/otherbinding/test_module_template.py
new file mode 100644
index 000000000..5d08944f3
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/test_module_template.py
@@ -0,0 +1,40 @@
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+from other import *
+from sample import *
+
+
+class MyObjectType(ObjectType):
+ pass
+
+class MyOtherObjectType(OtherObjectType):
+ value = 10
+
+
+obj = MyObjectType()
diff --git a/sources/shiboken6/tests/otherbinding/typediscovery_test.py b/sources/shiboken6/tests/otherbinding/typediscovery_test.py
new file mode 100644
index 000000000..200d091b0
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/typediscovery_test.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Test cases for type discovery'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+
+from sample import Abstract, Base1, Derived, MDerived1, MDerived3, SonOfMDerived1
+from other import OtherMultipleDerived
+
+class TypeDiscoveryTest(unittest.TestCase):
+
+ def testPureVirtualsOfImpossibleTypeDiscovery(self):
+ a = Derived.triggerImpossibleTypeDiscovery()
+ self.assertEqual(type(a), Abstract)
+ # call some pure virtual method
+ a.pureVirtual()
+
+ def testAnotherImpossibleTypeDiscovery(self):
+ a = Derived.triggerAnotherImpossibleTypeDiscovery()
+ self.assertEqual(type(a), Derived)
+
+ def testMultipleInheritance(self):
+ obj = OtherMultipleDerived.createObject("Base1");
+ self.assertEqual(type(obj), Base1)
+ # PYSIDE-868: In case of multiple inheritance, a factory
+ # function will return the base class wrapper.
+ obj = OtherMultipleDerived.createObject("MDerived1");
+ self.assertEqual(type(obj), Base1)
+ obj = OtherMultipleDerived.createObject("SonOfMDerived1");
+ self.assertEqual(type(obj), Base1)
+ obj = OtherMultipleDerived.createObject("MDerived3");
+ self.assertEqual(type(obj), Base1)
+ obj = OtherMultipleDerived.createObject("OtherMultipleDerived");
+ self.assertEqual(type(obj), Base1)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/typesystem_other.xml b/sources/shiboken6/tests/otherbinding/typesystem_other.xml
new file mode 100644
index 000000000..4081548fc
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/typesystem_other.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<typesystem package="other">
+ <load-typesystem name="typesystem_sample.xml" generate="no" />
+ <load-typesystem name="typesystem_smart.xml" generate="no" />
+
+ <object-type name="OtherObjectType" />
+ <object-type name="OtherDerived" />
+ <object-type name="OtherMultipleDerived" />
+
+ <value-type name="ExtendsNoImplicitConversion" />
+ <value-type name="Number" />
+
+ <smart-pointer-type name="SharedPtr" type="shared" getter="data" ref-count-method="useCount"
+ instantiations="Str"/>
+ <value-type name="SmartPtrTester"/>
+
+ <typedef-type name="ValueWithUnitIntInch" source="ValueWithUnit&lt;int,LengthUnit::Inch&gt;"/>
+ <typedef-type name="ValueWithUnitIntMillimeter" source="ValueWithUnit&lt;int,LengthUnit::Millimeter&gt;"/>
+ <value-type name="OtherValueWithUnitUser"/>
+
+ <suppress-warning text="signature 'operator!=(ByteArray,const char*)' for function modification in 'ByteArray' not found." />
+ <suppress-warning text="signature 'operator+(ByteArray,const char*)' for function modification in 'ByteArray' not found." />
+ <suppress-warning text="signature 'operator==(ByteArray,const char*)' for function modification in 'ByteArray' not found." />
+</typesystem>
diff --git a/sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py b/sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py
new file mode 100644
index 000000000..a69ee23f0
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Tests user defined primitive type from a required module.'''
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+from other import Number
+
+class UserDefinedPrimitiveTypeFromRequiredModuleTest(unittest.TestCase):
+
+ def testUsersPrimitiveFromRequiredModuleAsArgument(self):
+ '''static Number Number::fromComplex(Complex)'''
+ cpx = complex(3.0, 1.2)
+ number = Number.fromComplex(cpx)
+ self.assertEqual(number.value(), int(cpx.real))
+
+ def testUsersPrimitiveFromRequiredModuleAsReturnValue(self):
+ '''Complex Number::toComplex()'''
+ number = Number(12)
+ cpx = number.toComplex()
+ self.assertEqual(number.value(), int(cpx.real))
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/wrongctor_test.py b/sources/shiboken6/tests/otherbinding/wrongctor_test.py
new file mode 100644
index 000000000..29d085315
--- /dev/null
+++ b/sources/shiboken6/tests/otherbinding/wrongctor_test.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import os
+import sys
+import unittest
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from shiboken_paths import init_paths
+init_paths()
+from sample import *
+from other import *
+
+class Foo(OtherDerived):
+ def __init__(self):
+ Abstract.__init__(self, 2) # this should raise an exception
+
+class Foo2(ObjectType, OtherDerived):
+ def __init__(self):
+ ObjectType.__init__(self)
+ Abstract.__init__(self, 2) # this should raise an exception
+
+
+class WrongCtorTest(unittest.TestCase):
+ def testIt(self):
+ self.assertRaises(TypeError, Foo)
+ self.assertRaises(TypeError, Foo2)
+
+
+if __name__ == '__main__':
+ unittest.main()