summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2013-01-03 01:22:47 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-07 12:06:00 +0100
commit21d607c81af0cd285e9bb3869ac3cd18358f1c8f (patch)
tree9ab2a2d135084474aa23cfc45871573c2b13196e /tests/auto/tools
parent6769e0783ac0fc54aa542232b24166afc082412e (diff)
Automatically register method types in QSignalSpy.
Change-Id: I3655291dca6dbd3d8d09ee835b85983caa911b64 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'tests/auto/tools')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index e3ed473978..76607ccf4e 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -553,6 +553,7 @@ private slots:
void explicitOverrideControl();
void autoPropertyMetaTypeRegistration();
void autoMethodArgumentMetaTypeRegistration();
+ void autoSignalSpyMetaTypeRegistration();
void parseDefines();
void preprocessorOnly();
@@ -2388,6 +2389,7 @@ struct CustomObject8 {};
struct CustomObject9 {};
struct CustomObject10 {};
struct CustomObject11 {};
+struct CustomObject12 {};
Q_DECLARE_METATYPE(CustomObject3)
Q_DECLARE_METATYPE(CustomObject4)
@@ -2398,6 +2400,7 @@ Q_DECLARE_METATYPE(CustomObject8)
Q_DECLARE_METATYPE(CustomObject9)
Q_DECLARE_METATYPE(CustomObject10)
Q_DECLARE_METATYPE(CustomObject11)
+Q_DECLARE_METATYPE(CustomObject12)
class AutoRegistrationObject : public QObject
{
@@ -2520,6 +2523,9 @@ public slots:
void ref2(QList<int>&) {}
void ref3(CustomQObject2&) {}
void ref4(QSharedPointer<CustomQObject2>&) {}
+
+signals:
+ void someSignal(CustomObject12);
};
void tst_Moc::autoPropertyMetaTypeRegistration()
@@ -2583,6 +2589,16 @@ void tst_Moc::autoMethodArgumentMetaTypeRegistration()
int i = metaObject->methodOffset(); // Start after QObject built-in slots;
+ while (i < metaObject->methodCount()) {
+ // Skip over signals so we start at the first slot.
+ const QMetaMethod method = metaObject->method(i);
+ if (method.methodType() == QMetaMethod::Signal)
+ ++i;
+ else
+ break;
+
+ }
+
#define TYPE_LOOP(TYPE) \
{ \
const QMetaMethod method = metaObject->method(i); \
@@ -2709,6 +2725,26 @@ void tst_Moc::autoMethodArgumentMetaTypeRegistration()
}
+void tst_Moc::autoSignalSpyMetaTypeRegistration()
+{
+ AutoRegistrationObject aro;
+
+ QVector<int> methodArgMetaTypeIds;
+
+ const QMetaObject *metaObject = aro.metaObject();
+
+ int i = metaObject->indexOfSignal(QMetaObject::normalizedSignature("someSignal(CustomObject12)"));
+
+ QVERIFY(i > 0);
+
+ QCOMPARE(QMetaType::type("CustomObject12"), (int)QMetaType::UnknownType);
+
+ QSignalSpy spy(&aro, SIGNAL(someSignal(CustomObject12)));
+
+ QVERIFY(QMetaType::type("CustomObject12") != QMetaType::UnknownType);
+ QCOMPARE(QMetaType::type("CustomObject12"), qMetaTypeId<CustomObject12>());
+}
+
void tst_Moc::parseDefines()
{
const QMetaObject *mo = &PD_NAMESPACE::PD_CLASSNAME::staticMetaObject;