From 5adcc37b75ad423452a1fb11cafd8534062cf812 Mon Sep 17 00:00:00 2001
From: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
Date: Wed, 10 Jun 2020 16:40:35 -0300
Subject: [PATCH] Unit test for class that derive from a typedefined type

---
 .../shiboken2/tests/libsample/CMakeLists.txt  |  1 +
 .../tests/libsample/typedefclass.cpp          | 36 ++++++++++++
 .../shiboken2/tests/libsample/typedefclass.h  | 43 ++++++++++++++
 .../tests/samplebinding/CMakeLists.txt        |  1 +
 .../shiboken2/tests/samplebinding/global.h    |  1 +
 .../tests/samplebinding/typedefclass_test.py  | 56 +++++++++++++++++++
 .../tests/samplebinding/typesystem_sample.xml |  2 +
 7 files changed, 140 insertions(+)
 create mode 100644 sources/shiboken2/tests/libsample/typedefclass.cpp
 create mode 100644 sources/shiboken2/tests/libsample/typedefclass.h
 create mode 100644 sources/shiboken2/tests/samplebinding/typedefclass_test.py

diff --git a/sources/shiboken2/tests/libsample/CMakeLists.txt b/sources/shiboken2/tests/libsample/CMakeLists.txt
index ae13cd9f..0e8d65ad 100644
--- a/sources/shiboken2/tests/libsample/CMakeLists.txt
+++ b/sources/shiboken2/tests/libsample/CMakeLists.txt
@@ -47,6 +47,7 @@ str.cpp
 strlist.cpp
 templateptr.cpp
 transform.cpp
+typedefclass.cpp
 virtualmethods.cpp
 expression.cpp
 filter.cpp
diff --git a/sources/shiboken2/tests/libsample/typedefclass.cpp b/sources/shiboken2/tests/libsample/typedefclass.cpp
new file mode 100644
index 00000000..f21f93bf
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/typedefclass.cpp
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "typedefclass.h"
+
+TypeDefClass::TypeDefClass()
+{}
+
+TypeDefClass::~TypeDefClass()
+{}
+
diff --git a/sources/shiboken2/tests/libsample/typedefclass.h b/sources/shiboken2/tests/libsample/typedefclass.h
new file mode 100644
index 00000000..33d4d8c7
--- /dev/null
+++ b/sources/shiboken2/tests/libsample/typedefclass.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#pragma once
+
+#include "sample.h"
+#include "libsamplemacros.h"
+
+
+using TypeDefType = sample::sample;
+
+class LIBSAMPLE_API TypeDefClass : public TypeDefType
+{
+public:
+    TypeDefClass();
+    ~TypeDefClass();
+};
+
diff --git a/sources/shiboken2/tests/samplebinding/CMakeLists.txt b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
index b65068dc..2ef7cc19 100644
--- a/sources/shiboken2/tests/samplebinding/CMakeLists.txt
+++ b/sources/shiboken2/tests/samplebinding/CMakeLists.txt
@@ -113,6 +113,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/sample/str_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/strlist_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/time_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/templateptr_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/typedefclass_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/unremovednamespace_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/virtualdaughter_wrapper.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/sample/virtualdaughter2_wrapper.cpp
diff --git a/sources/shiboken2/tests/samplebinding/global.h b/sources/shiboken2/tests/samplebinding/global.h
index f4e20b74..345d9144 100644
--- a/sources/shiboken2/tests/samplebinding/global.h
+++ b/sources/shiboken2/tests/samplebinding/global.h
@@ -86,6 +86,7 @@
 #include "sometime.h"
 #include "templateptr.h"
 #include "transform.h"
+#include "typedefclass.h"
 #include "virtualmethods.h"
 #include "voidholder.h"
 #include "valueandvirtual.h"
diff --git a/sources/shiboken2/tests/samplebinding/typedefclass_test.py b/sources/shiboken2/tests/samplebinding/typedefclass_test.py
new file mode 100644
index 00000000..c64a1465
--- /dev/null
+++ b/sources/shiboken2/tests/samplebinding/typedefclass_test.py
@@ -0,0 +1,56 @@
+#!/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 if TypeDefClass is derived of Sample'''
+
+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 TypeDefClass, sample
+
+class TypeDefClassTest(unittest.TestCase):
+    '''Test if TypeDefClass is derived of Sample'''
+
+    def testInstantiation(self):
+        obj = TypeDefClass()
+        self.assertTrue(isinstance(obj, object))
+        self.assertTrue(isinstance(obj, TypeDefClass))
+        self.assertTrue(isinstance(obj, sample.sample))
+        self.assertEqual(obj.value(), 0)
+
+if __name__ == '__main__':
+    unittest.main()
+
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
index 32df8fd7..068c9a4c 100644
--- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -2446,6 +2446,8 @@
     <value-type name="ToBeRenamedValue" target-lang-name="RenamedValue"/>
     <value-type name="RenamedUser"/>
 
+    <object-type name="TypeDefClass"/>
+
     <suppress-warning text="horribly broken type '__off64_t'" />
     <suppress-warning text="enum '__codecvt_result' does not have a type entry or is not an enum" />
     <suppress-warning text="Pure virtual method &quot;Abstract::hideFunction(HideType*)&quot; must be implement but was completely removed on typesystem." />
-- 
2.25.1

