summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp65
-rw-r--r--tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp2
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp2
-rw-r--r--tests/auto/tools/moc/forward-declared-param.h1
-rw-r--r--tests/auto/tools/moc/forwarddeclaredparam.h5
-rw-r--r--tests/auto/tools/moc/parse-defines.h1
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp16
-rw-r--r--tests/auto/tools/qdbuscpp2xml/test1.h9
8 files changed, 87 insertions, 14 deletions
diff --git a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
index 4584b6ce31..8450537019 100644
--- a/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
+++ b/tests/auto/corelib/kernel/qmetamethod/tst_qmetamethod.cpp
@@ -48,6 +48,9 @@ private slots:
void fromSignal();
void gadget();
+
+ void returnMetaType();
+ void parameterMetaType();
};
struct CustomType { };
@@ -378,10 +381,11 @@ void tst_QMetaMethod::method_data()
<< QMetaMethod::Public
<< QMetaMethod::Constructor;
+ // since Qt 6.0, parameter types get automatically registered
QTest::newRow("voidSignalCustomUnregisteredType")
<< QByteArray("voidSignalCustomUnregisteredType(CustomUnregisteredType)")
<< int(QMetaType::Void) << QByteArray("void")
- << (QList<int>() << 0)
+ << (QList<int>() << QMetaType::fromType<CustomUnregisteredType>().id())
<< (QList<QByteArray>() << QByteArray("CustomUnregisteredType"))
<< (QList<QByteArray>() << QByteArray("voidSignalCustomUnregisteredTypeArg"))
<< QMetaMethod::Public
@@ -390,7 +394,7 @@ void tst_QMetaMethod::method_data()
QTest::newRow("voidInvokableCustomUnregisteredType")
<< QByteArray("voidInvokableCustomUnregisteredType(CustomUnregisteredType)")
<< int(QMetaType::Void) << QByteArray("void")
- << (QList<int>() << 0)
+ << (QList<int>() << QMetaType::fromType<CustomUnregisteredType>().id())
<< (QList<QByteArray>() << QByteArray("CustomUnregisteredType"))
<< (QList<QByteArray>() << QByteArray("voidInvokableCustomUnregisteredTypeArg"))
<< QMetaMethod::Public
@@ -399,7 +403,7 @@ void tst_QMetaMethod::method_data()
QTest::newRow("voidSlotCustomUnregisteredType")
<< QByteArray("voidSlotCustomUnregisteredType(CustomUnregisteredType)")
<< int(QMetaType::Void) << QByteArray("void")
- << (QList<int>() << 0)
+ << (QList<int>() << QMetaType::fromType<CustomUnregisteredType>().id())
<< (QList<QByteArray>() << QByteArray("CustomUnregisteredType"))
<< (QList<QByteArray>() << QByteArray("voidSlotCustomUnregisteredTypeArg"))
<< QMetaMethod::Public
@@ -408,7 +412,7 @@ void tst_QMetaMethod::method_data()
QTest::newRow("MethodTestObject(CustomUnregisteredType)")
<< QByteArray("MethodTestObject(CustomUnregisteredType)")
<< int(QMetaType::UnknownType) << QByteArray("")
- << (QList<int>() << 0)
+ << (QList<int>() << QMetaType::fromType<CustomUnregisteredType>().id())
<< (QList<QByteArray>() << QByteArray("CustomUnregisteredType"))
<< (QList<QByteArray>() << QByteArray("constructorCustomUnregisteredTypeArg"))
<< QMetaMethod::Public
@@ -770,6 +774,59 @@ void tst_QMetaMethod::gadget()
}
}
+class MyTestClass : public QObject
+{
+ Q_OBJECT
+
+public:
+ MyTestClass() {};
+public Q_SLOTS:
+ MyGadget doStuff(int, float, MyGadget) {return {};}
+Q_SIGNALS:
+ QObject *mySignal();
+};
+
+void tst_QMetaMethod::returnMetaType()
+{
+ {
+ QMetaMethod mm = QMetaMethod::fromSignal(&MyTestClass::mySignal);
+ QCOMPARE(mm.returnMetaType(), QMetaType::fromType<QObject*>());
+ }
+ auto mo = MyTestClass::staticMetaObject;
+ {
+ const auto normalized = QMetaObject::normalizedSignature("doStuff(int, float, MyGadget)");
+ const int idx = mo.indexOfSlot(normalized);
+ QMetaMethod mm = mo.method(idx);
+ QVERIFY(mm.isValid());
+ QCOMPARE(mm.returnMetaType(), QMetaType::fromType<MyGadget>());
+ }
+ {
+ // access of parent class meta methods works, too
+ const auto normalized = QMetaObject::normalizedSignature("deleteLater()");
+ const int idx = mo.indexOfSlot(normalized);
+ QMetaMethod mm = mo.method(idx);
+ QVERIFY(mm.isValid());
+ QCOMPARE(mm.returnMetaType(), QMetaType::fromType<void>());
+ }
+}
+
+void tst_QMetaMethod::parameterMetaType()
+{
+ auto mo = MyTestClass::staticMetaObject;
+ const auto normalized = QMetaObject::normalizedSignature("doStuff(int, float, MyGadget)");
+ const int idx = mo.indexOfSlot(normalized);
+ QMetaMethod mm = mo.method(idx);
+ {
+ QVERIFY(!mm.parameterMetaType(-1).isValid());
+ QVERIFY(!mm.parameterMetaType(3).isValid());
+ }
+ {
+ QCOMPARE(mm.parameterMetaType(0), QMetaType::fromType<int>());
+ QCOMPARE(mm.parameterMetaType(1), QMetaType::fromType<float>());
+ QCOMPARE(mm.parameterMetaType(2), QMetaType::fromType<MyGadget>());
+ }
+}
+
QTEST_MAIN(tst_QMetaMethod)
#include "tst_qmetamethod.moc"
diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
index 14719f36f8..b8212ee6cf 100644
--- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
+++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
@@ -1391,7 +1391,7 @@ private:
};
QMetaObject TestObject::staticMetaObject = {
- { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }
+ { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}
};
TestObject::TestObject(QObject *parent)
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index b977761995..68d218d87b 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -5278,6 +5278,8 @@ void tst_QObject::connectForwardDeclare()
QVERIFY(connect(&ob, &ForwardDeclareArguments::mySignal, &ob, &ForwardDeclareArguments::mySlot, Qt::QueuedConnection));
}
+class ForwardDeclared {}; // complete definition for moc
+
class NoDefaultConstructor
{
Q_GADGET
diff --git a/tests/auto/tools/moc/forward-declared-param.h b/tests/auto/tools/moc/forward-declared-param.h
index 3c10b7be1f..484e546482 100644
--- a/tests/auto/tools/moc/forward-declared-param.h
+++ b/tests/auto/tools/moc/forward-declared-param.h
@@ -30,6 +30,7 @@
#define FORWARD_DECLARED_PARAM_H
#include <qobject.h>
#include <qmetatype.h>
+Q_MOC_INCLUDE("forwarddeclaredparam.h")
// test support for const refs to forward-declared structs in parameters
diff --git a/tests/auto/tools/moc/forwarddeclaredparam.h b/tests/auto/tools/moc/forwarddeclaredparam.h
new file mode 100644
index 0000000000..176f0c3356
--- /dev/null
+++ b/tests/auto/tools/moc/forwarddeclaredparam.h
@@ -0,0 +1,5 @@
+#ifndef FORWARDDECLAREDPARAM_H
+#define FORWARDDECLAREDPARAM_H
+struct ForwardDeclaredParam {};
+template <typename T> class ForwardDeclaredContainer {};
+#endif
diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h
index bd22b0b9af..b88fe63e4a 100644
--- a/tests/auto/tools/moc/parse-defines.h
+++ b/tests/auto/tools/moc/parse-defines.h
@@ -30,6 +30,7 @@
#define PARSE_DEFINES_H
#include <qobject.h>
+Q_MOC_INCLUDE(<QMap>)
// this is intentionally ugly to test moc's preprocessing capabilities
#define PD_NAMESPACE PD
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 2fe5f42609..d4e3a4e297 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -1773,14 +1773,20 @@ public slots:
QString const returnConstString2( QString const s) { return s; }
};
+
+struct science_constant {};
+struct science_const {};
+struct constconst {};
+struct const_ {};
+
class QTBUG9354_constInName: public QObject
{ Q_OBJECT
public slots:
- void slotChooseScientificConst0(struct science_constant const &) {};
- void foo(struct science_const const &) {};
- void foo(struct constconst const &) {};
- void foo(struct constconst *) {};
- void foo(struct const_ *) {};
+ void slotChooseScientificConst0(science_constant const &) {};
+ void foo(science_const const &) {};
+ void foo(constconst const &) {};
+ void foo(constconst *) {};
+ void foo(const_ *) {};
};
diff --git a/tests/auto/tools/qdbuscpp2xml/test1.h b/tests/auto/tools/qdbuscpp2xml/test1.h
index 0c7488cd7c..337fada86d 100644
--- a/tests/auto/tools/qdbuscpp2xml/test1.h
+++ b/tests/auto/tools/qdbuscpp2xml/test1.h
@@ -30,14 +30,15 @@
#define QDBUSCPP2XML_TEST1_H
#include <QObject>
-
-class QDBusObjectPath;
-class QDBusUnixFileDescriptor;
-class QDBusSignature;
+#include <QtDBus/QDBusSignature>
+#include <QtDBus/QDBusObjectPath>
+#include <QtDBus/QDBusUnixFileDescriptor>
class Test1 : public QObject
{
Q_OBJECT
+ Q_MOC_INCLUDE(<QtDBus/qdbusextratypes.h>)
+ Q_MOC_INCLUDE(<QtDBus/qdbusunixfiledescriptor.h>)
Q_CLASSINFO("D-Bus Interface", "org.qtProject.qdbuscpp2xmlTests.Test1")
Q_PROPERTY(int numProperty1 READ numProperty1 CONSTANT)
Q_PROPERTY(int numProperty2 READ numProperty2 WRITE setNumProperty2)