summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/moc/tst_moc.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2020-01-03 15:03:39 +0100
committerOlivier Goffart <ogoffart@woboq.com>2020-01-17 02:22:22 +0100
commit983432effdae888a372d814ff9516abbcb7a3c29 (patch)
treec93a17a50d71508b59f1bb22f48727ccaf2370d1 /tests/auto/tools/moc/tst_moc.cpp
parent4772a2da15ae0624633f3fc4d029d5f0e1e33892 (diff)
Introduce Q_MOC_INCLUDE
A new macro that can be added in the header file parsed by moc to tell moc to include that file in the generated file Change-Id: I03ad702c3fcd8380371015f226ee4b7456daf132 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp33
1 files changed, 30 insertions, 3 deletions
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