aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-29 11:02:23 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-29 18:00:49 +0200
commit043e74028e55319654685ad97ef5061eb2fda5d2 (patch)
tree6dda92bcc1089eb8579d2392ecb33a180dda061d
parent13df4451cce8147cad91011eaa4b21dd8d27f8ae (diff)
shiboken2: Consolidate tests for invisible namespaces
Move the tests for PYSIDE-1074 from samplenamespace.h to removednamespaces.h. The latter has also a test case for an invisible namespace under a visible namespace besides the invisible top level namespace test. Task-number: PYSIDE-1074 Task-number: PYSIDE-1075 Change-Id: I5d1c6428f6ceadf929063c2c69723a7871173f4e Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken2/tests/libother/otherobjecttype.cpp2
-rw-r--r--sources/shiboken2/tests/libother/otherobjecttype.h3
-rw-r--r--sources/shiboken2/tests/libsample/removednamespaces.h10
-rw-r--r--sources/shiboken2/tests/libsample/samplenamespace.h19
-rw-r--r--sources/shiboken2/tests/samplebinding/CMakeLists.txt2
-rw-r--r--sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py20
-rw-r--r--sources/shiboken2/tests/samplebinding/namespace_test.py20
-rw-r--r--sources/shiboken2/tests/samplebinding/typesystem_sample.xml6
8 files changed, 37 insertions, 45 deletions
diff --git a/sources/shiboken2/tests/libother/otherobjecttype.cpp b/sources/shiboken2/tests/libother/otherobjecttype.cpp
index 1f782ecd8..c7778e7c9 100644
--- a/sources/shiboken2/tests/libother/otherobjecttype.cpp
+++ b/sources/shiboken2/tests/libother/otherobjecttype.cpp
@@ -40,7 +40,7 @@ int OtherObjectType::enumAsInt(SampleNamespace::SomeClass::PublicScopedEnum valu
return static_cast<int>(value);
}
-int OtherObjectType::enumAsIntForInvisibleNamespace(Invisible::EnumOnNamespace value)
+int OtherObjectType::enumAsIntForInvisibleNamespace(RemovedNamespace1::RemovedNamespace1_Enum value)
{
return static_cast<int>(value);
}
diff --git a/sources/shiboken2/tests/libother/otherobjecttype.h b/sources/shiboken2/tests/libother/otherobjecttype.h
index efd394347..a9362c370 100644
--- a/sources/shiboken2/tests/libother/otherobjecttype.h
+++ b/sources/shiboken2/tests/libother/otherobjecttype.h
@@ -36,13 +36,14 @@
#include "objecttype.h"
#include "collector.h"
#include "samplenamespace.h"
+#include "removednamespaces.h"
class LIBOTHER_API OtherObjectType : public ObjectType
{
public:
static int enumAsInt(SampleNamespace::SomeClass::PublicScopedEnum value);
- static int enumAsIntForInvisibleNamespace(Invisible::EnumOnNamespace value);
+ static int enumAsIntForInvisibleNamespace(RemovedNamespace1::RemovedNamespace1_Enum value);
};
diff --git a/sources/shiboken2/tests/libsample/removednamespaces.h b/sources/shiboken2/tests/libsample/removednamespaces.h
index c9732f8a6..9ad798bf7 100644
--- a/sources/shiboken2/tests/libsample/removednamespaces.h
+++ b/sources/shiboken2/tests/libsample/removednamespaces.h
@@ -34,10 +34,18 @@
namespace RemovedNamespace1
{
-enum RemovedNamespace1_Enum { RemovedNamespace1_Enum_Value0 };
+enum RemovedNamespace1_Enum { RemovedNamespace1_Enum_Value0 = 0,
+ RemovedNamespace1_Enum_Value1 = 1 };
enum { RemovedNamespace1_AnonymousEnum_Value0 };
+struct ObjectOnInvisibleNamespace
+{
+ bool exists() const { return true; }
+ static int toInt(RemovedNamespace1_Enum e) { return static_cast<int>(e); }
+ static ObjectOnInvisibleNamespace consume(const ObjectOnInvisibleNamespace &other) { return other; }
+};
+
namespace RemovedNamespace2
{
diff --git a/sources/shiboken2/tests/libsample/samplenamespace.h b/sources/shiboken2/tests/libsample/samplenamespace.h
index 0d418de16..5fe269c5e 100644
--- a/sources/shiboken2/tests/libsample/samplenamespace.h
+++ b/sources/shiboken2/tests/libsample/samplenamespace.h
@@ -41,25 +41,6 @@ enum {
AnonymousGlobalEnum_Value1
};
-// Invisible namespace
-namespace Invisible
-{
-
-enum EnumOnNamespace {
- Option1 = 1,
- Option2 = 2,
- Option3 = 3
-};
-
-struct ObjectOnInvisibleNamespace
-{
- bool exists() const { return true; }
- static int toInt(EnumOnNamespace e) { return static_cast<int>(e); }
- static ObjectOnInvisibleNamespace consume(const ObjectOnInvisibleNamespace &other) { return other; }
-};
-
-};
-
namespace SampleNamespace
{
diff --git a/sources/shiboken2/tests/samplebinding/CMakeLists.txt b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
index ad52565ad..6bbfdb5bc 100644
--- a/sources/shiboken2/tests/samplebinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
@@ -97,6 +97,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/rectf_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/reference_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/referentmodelindex_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/toberenamedvalue_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/removednamespace1_objectoninvisiblenamespace_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/renameduser_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/sample_module_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/sample_wrapper.cpp
@@ -127,7 +128,6 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/filter_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/data_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/intersection_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/union_wrapper.cpp
-${CMAKE_CURRENT_BINARY_DIR}/sample/invisible_objectoninvisiblenamespace_wrapper.cpp
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sample-binding.txt.in"
diff --git a/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py b/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py
index 4b0866c4e..168a609dc 100644
--- a/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py
+++ b/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py
@@ -38,15 +38,33 @@ from shiboken_paths import init_paths
init_paths()
import sample
+from shiboken_test_helper import objectFullname
+
class TestEnumFromRemovedNamespace(unittest.TestCase):
def testEnumPromotedToGlobal(self):
sample.RemovedNamespace1_Enum
- sample.RemovedNamespace1_Enum_Value0
+ self.assertEqual(sample.RemovedNamespace1_Enum_Value0, 0)
+ self.assertEqual(sample.RemovedNamespace1_Enum_Value1, 1)
sample.RemovedNamespace1_AnonymousEnum_Value0
sample.RemovedNamespace2_Enum
sample.RemovedNamespace2_Enum_Value0
+ def testNames(self):
+ # Test if invisible namespace does not appear on type name
+ self.assertEqual(objectFullname(sample.RemovedNamespace1_Enum),
+ "sample.RemovedNamespace1_Enum")
+ self.assertEqual(objectFullname(sample.ObjectOnInvisibleNamespace),
+ "sample.ObjectOnInvisibleNamespace")
+
+ # Function arguments
+ signature = sample.ObjectOnInvisibleNamespace.toInt.__signature__
+ self.assertEqual(objectFullname(signature.parameters['e'].annotation),
+ "sample.RemovedNamespace1_Enum")
+ signature = sample.ObjectOnInvisibleNamespace.consume.__signature__
+ self.assertEqual(objectFullname(signature.parameters['other'].annotation),
+ "sample.ObjectOnInvisibleNamespace")
+
def testEnumPromotedToUpperNamespace(self):
sample.UnremovedNamespace
sample.UnremovedNamespace.RemovedNamespace3_Enum
diff --git a/sources/shiboken2/tests/samplebinding/namespace_test.py b/sources/shiboken2/tests/samplebinding/namespace_test.py
index 8171e0e43..807e7bfc9 100644
--- a/sources/shiboken2/tests/samplebinding/namespace_test.py
+++ b/sources/shiboken2/tests/samplebinding/namespace_test.py
@@ -43,20 +43,15 @@ from sample import *
from shiboken_test_helper import objectFullname
+# For tests of invisible namespaces, see
+# enumfromremovednamespace_test.py / removednamespaces.h
+
+
class TestVariablesUnderNamespace(unittest.TestCase):
def testIt(self):
self.assertEqual(SampleNamespace.variableInNamespace, 42)
-class TestEnumUnderNamespace(unittest.TestCase):
- def testInvisibleNamespace(self):
- o1 = EnumOnNamespace.Option1
- self.assertEqual(o1, 1)
- def testTpNames(self):
- self.assertEqual(objectFullname(EnumOnNamespace), "sample.EnumOnNamespace")
- self.assertEqual(str(EnumOnNamespace.Option1),
- "sample.EnumOnNamespace.Option1")
-
class TestClassesUnderNamespace(unittest.TestCase):
def testIt(self):
c1 = SampleNamespace.SomeClass()
@@ -87,14 +82,7 @@ class TestClassesUnderNamespace(unittest.TestCase):
"sample.SampleNamespace.InValue")
self.assertEqual(objectFullname(SampleNamespace.enumAsInt.__signature__.parameters['value'].annotation),
"sample.SampleNamespace.SomeClass.PublicScopedEnum")
- self.assertEqual(objectFullname(ObjectOnInvisibleNamespace.toInt.__signature__.parameters['e'].annotation),
- "sample.EnumOnNamespace")
- # Test if enum on namespace that was marked as not gerenated does not appear on type name
- self.assertEqual(objectFullname(ObjectOnInvisibleNamespace),
- "sample.ObjectOnInvisibleNamespace")
- self.assertEqual(objectFullname(ObjectOnInvisibleNamespace.consume.__signature__.parameters['other'].annotation),
- "sample.ObjectOnInvisibleNamespace")
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
index 17d4b11ec..3b74cb13b 100644
--- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -558,11 +558,6 @@
<enum-type identified-by-value="AnonymousGlobalEnum_Value0"/>
- <namespace-type name="Invisible" visible="no">
- <enum-type name="EnumOnNamespace" />
- <value-type name="ObjectOnInvisibleNamespace" />
- </namespace-type>
-
<namespace-type name="SampleNamespace">
<enum-type name="Option"/>
<enum-type name="InValue"/>
@@ -625,6 +620,7 @@
<namespace-type name="RemovedNamespace1" visible='false'>
<enum-type name="RemovedNamespace1_Enum" />
+ <value-type name="ObjectOnInvisibleNamespace" />
<namespace-type name="RemovedNamespace2" visible='false'>
<enum-type name="RemovedNamespace2_Enum" />
</namespace-type>