summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-11-09 15:23:52 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2020-11-10 11:23:55 +0100
commit16d412da4c0d7ef4776604b906fccb8132a7712d (patch)
tree608c3c2824a1f6d70f87b4cd086e2c1913e76c65 /tests/auto/testlib
parentf95691b8afa5e73fc31ab1d654bfceb4bddb53a0 (diff)
QSignalSpy: Use QMetaType instead of metatype id in initArgs
The RegisterMethodArgumentMetaType had been changed to take a QMetaType instead of a type id in 0161f00e5043090f22b23de9822c09062b17d675. Unfortunately, the usage of it in QSignalSpy was missed. This patch adjusts the metacall to correctly use a QMetaType. Moreover, use parameterMetaType instead of parameterType to benefit from metatypes which are already resolved at compile time. Task-number: QTBUG-88260 Fixes: QTBUG-88356 Change-Id: Id8fa46581a005d62818971ea24d8aa2e39dcd6d0 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/testlib')
-rw-r--r--tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
index 9555c2a844..fcd33f5af4 100644
--- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
+++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
@@ -57,6 +57,7 @@ private slots:
void spyFunctionPointerWithBasicArgs();
void spyFunctionPointerWithPointers();
void spyFunctionPointerWithQtClasses();
+ void spyFunctionPointerWithCustomClass();
void spyFunctionPointerWithBasicQtClasses();
void spyFunctionPointerWithQtTypedefs();
@@ -72,6 +73,8 @@ private slots:
void spyOnMetaMethod_invalid_data();
};
+struct CustomType {};
+
class QtTestObject: public QObject
{
Q_OBJECT
@@ -152,6 +155,8 @@ void tst_QSignalSpy::spyWithPointers()
QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2);
}
+struct CustomType2;
+
class QtTestObject2: public QObject
{
Q_OBJECT
@@ -163,6 +168,8 @@ signals:
void sig3(QObject *o);
void sig4(QChar c);
void sig5(const QVariant &v);
+ void sig6(CustomType );
+ void sig7(CustomType2 *);
};
void tst_QSignalSpy::spyWithBasicQtClasses()
@@ -383,6 +390,23 @@ void tst_QSignalSpy::spyFunctionPointerWithQtClasses()
QCOMPARE(qvariant_cast<QChar>(spy3.value(0).value(0)), QChar('A'));
}
+void tst_QSignalSpy::spyFunctionPointerWithCustomClass()
+{
+ QtTestObject2 obj;
+ {
+ QSignalSpy spy(&obj, &QtTestObject2::sig6);
+ emit obj.sig6({});
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).count(), 1);
+ QCOMPARE(spy.at(0).at(0).typeName(), "CustomType");
+ }
+
+ {
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QSignalSpy: Unable to handle parameter '' of type 'CustomType2*' of method 'sig7', use qRegisterMetaType to register it.");
+ QSignalSpy spy(&obj, &QtTestObject2::sig7);
+ }
+}
+
void tst_QSignalSpy::spyFunctionPointerWithQtTypedefs()
{
QtTestObject3 obj;