summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp')
-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;