summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/tools/moc/allmocs_baseline_in.json59
-rw-r--r--tests/auto/tools/moc/fwdclass1.h38
-rw-r--r--tests/auto/tools/moc/fwdclass2.h38
-rw-r--r--tests/auto/tools/moc/fwdclass3.h38
-rw-r--r--tests/auto/tools/moc/moc.pro3
-rw-r--r--tests/auto/tools/moc/moc_include.h74
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp33
7 files changed, 279 insertions, 4 deletions
diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json
index c8abba6a8f..2a70a52587 100644
--- a/tests/auto/tools/moc/allmocs_baseline_in.json
+++ b/tests/auto/tools/moc/allmocs_baseline_in.json
@@ -1015,6 +1015,65 @@
{
"classes": [
{
+ "className": "TestFwdProperties",
+ "properties": [
+ {
+ "constant": false,
+ "designable": true,
+ "final": false,
+ "name": "prop1",
+ "read": "getProp1",
+ "scriptable": true,
+ "stored": true,
+ "type": "FwdClass1",
+ "user": false,
+ "write": "setProp1"
+ },
+ {
+ "constant": false,
+ "designable": true,
+ "final": false,
+ "name": "prop2",
+ "read": "getProp2",
+ "scriptable": true,
+ "stored": true,
+ "type": "FwdClass2",
+ "user": false,
+ "write": "setProp2"
+ },
+ {
+ "constant": false,
+ "designable": true,
+ "final": false,
+ "name": "prop3",
+ "read": "getProp3",
+ "scriptable": true,
+ "stored": true,
+ "type": "FwdClass3",
+ "user": false,
+ "write": "setProp3"
+ }
+ ],
+ "qualifiedClassName": "TestFwdProperties",
+ "superClasses": [
+ {
+ "access": "public",
+ "name": "QObject"
+ }
+ ]
+ },
+ {
+ "className": "SomeRandomNamespace",
+ "gadget": true,
+ "qualifiedClassName": "SomeRandomNamespace"
+ }
+ ],
+ "inputFile": "moc_include.h",
+ "outputRevision": 67
+ },
+ {
+ "classes": [
+ {
"className": "FooNamespace",
"enums": [
{
diff --git a/tests/auto/tools/moc/fwdclass1.h b/tests/auto/tools/moc/fwdclass1.h
new file mode 100644
index 0000000000..a8457cca77
--- /dev/null
+++ b/tests/auto/tools/moc/fwdclass1.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifdef FWDCLASS1_H
+#error "This file can only be included once"
+#endif
+#define FWDCLASS1_H
+
+class FwdClass1
+{
+public:
+ int x;
+};
diff --git a/tests/auto/tools/moc/fwdclass2.h b/tests/auto/tools/moc/fwdclass2.h
new file mode 100644
index 0000000000..650da18116
--- /dev/null
+++ b/tests/auto/tools/moc/fwdclass2.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifdef FWDCLASS2_H
+#error "This file can only be included once"
+#endif
+#define FWDCLASS2_H
+
+class FwdClass2
+{
+public:
+ int x;
+};
diff --git a/tests/auto/tools/moc/fwdclass3.h b/tests/auto/tools/moc/fwdclass3.h
new file mode 100644
index 0000000000..080ac0340d
--- /dev/null
+++ b/tests/auto/tools/moc/fwdclass3.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifdef FWDCLASS3_H
+#error "This file can only be included once"
+#endif
+#define FWDCLASS3_H
+
+class FwdClass3
+{
+public:
+ int x;
+};
diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro
index 93ca330126..094c76227b 100644
--- a/tests/auto/tools/moc/moc.pro
+++ b/tests/auto/tools/moc/moc.pro
@@ -30,7 +30,8 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n
related-metaobjects-in-gadget.h \
related-metaobjects-name-conflict.h \
namespace.h cxx17-namespaces.h \
- cxx-attributes.h
+ cxx-attributes.h \
+ moc_include.h
# No platform specifics in the JSON files, so that we can compare them
JSON_HEADERS = $$HEADERS
diff --git a/tests/auto/tools/moc/moc_include.h b/tests/auto/tools/moc/moc_include.h
new file mode 100644
index 0000000000..49b484a0c9
--- /dev/null
+++ b/tests/auto/tools/moc/moc_include.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef MOC_INCLUDE_H
+#define MOC_INCLUDE_H
+
+#include <QObject>
+
+class FwdClass1;
+class FwdClass2;
+class FwdClass3;
+
+Q_MOC_INCLUDE(fwdclass3.h)
+
+namespace SomeRandomNamespace {
+Q_MOC_INCLUDE("fwdclass1.h")
+Q_NAMESPACE
+}
+
+class TestFwdProperties : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(FwdClass1 prop1 WRITE setProp1 READ getProp1)
+ Q_PROPERTY(FwdClass2 prop2 WRITE setProp2 READ getProp2)
+ Q_PROPERTY(FwdClass3 prop3 WRITE setProp3 READ getProp3)
+public:
+ ~TestFwdProperties();
+
+ void setProp1(const FwdClass1 &val);
+ void setProp2(const FwdClass2 &val);
+ void setProp3(const FwdClass3 &val);
+ const FwdClass1 &getProp1() { return *prop1; }
+ const FwdClass2 &getProp2() { return *prop2; }
+ const FwdClass3 &getProp3() { return *prop3; }
+
+ QScopedPointer<FwdClass1> prop1;
+ QScopedPointer<FwdClass2> prop2;
+ QScopedPointer<FwdClass3> prop3;
+
+ Q_MOC_INCLUDE(
+ \
+ "fwdclass2.h"
+ )
+
+};
+
+Q_MOC_INCLUDE(<QString>)
+
+#endif // MOC_INCLUDE_H
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index e5de647930..2bad8f2e63 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
+** Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -27,8 +27,6 @@
**
****************************************************************************/
-
-
#include <QtTest/QtTest>
#include <stdio.h>
#include <qobject.h>
@@ -74,6 +72,11 @@
#include "cxx17-namespaces.h"
#include "cxx-attributes.h"
+#include "moc_include.h"
+#include "fwdclass1.h"
+#include "fwdclass2.h"
+#include "fwdclass3.h"
+
#ifdef Q_MOC_RUN
// check that moc can parse these constructs, they are being used in Windows winsock2.h header
#define STRING_HASH_HASH(x) ("foo" ## x ## "bar")
@@ -717,6 +720,7 @@ private slots:
void cxx17Namespaces();
void cxxAttributes();
void mocJsonOutput();
+ void mocInclude();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -4002,6 +4006,29 @@ void tst_Moc::mocJsonOutput()
QVERIFY2(actualOutput == expectedOutput, showPotentialDiff(actualOutput, expectedOutput).constData());
}
+void TestFwdProperties::setProp1(const FwdClass1 &v)
+{
+ prop1.reset(new FwdClass1(v));
+}
+void TestFwdProperties::setProp2(const FwdClass2 &v)
+{
+ prop2.reset(new FwdClass2(v));
+}
+void TestFwdProperties::setProp3(const FwdClass3 &v)
+{
+ prop3.reset(new FwdClass3(v));
+}
+TestFwdProperties::~TestFwdProperties() {}
+
+Q_DECLARE_METATYPE(FwdClass1);
+
+void tst_Moc::mocInclude()
+{
+ TestFwdProperties obj;
+ obj.setProperty("prop1", QVariant::fromValue(FwdClass1 { 45 }));
+ QCOMPARE(obj.prop1->x, 45);
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS