diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2015-02-07 14:12:30 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2015-02-12 07:11:04 +0000 |
commit | 3cf8e426f49ee6adb1090865854506aa92316ce3 (patch) | |
tree | a69e8a3a2f62783075b5a5175f480a3870ddd95a /tests | |
parent | 071716f2daebaebab562b7f49c29f281c5536bbc (diff) |
QMetaType: Automatic registration of Q_GADGET and Q_ENUM types
Change-Id: If43dcc2b77fea5ae3ec40cc847467fc21fbd2c83
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 8da96c0977..717a7633f5 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -136,6 +136,11 @@ public: : QObject(parent) { } + enum CustomQEnum { Val1, Val2 }; + Q_ENUM(CustomQEnum) +}; +class CustomGadget { + Q_GADGET }; class CustomNonQObject {}; @@ -146,10 +151,13 @@ void tst_QMetaType::defined() QCOMPARE(int(QMetaTypeId2<Foo>::Defined), 0); QCOMPARE(int(QMetaTypeId2<void*>::Defined), 1); QCOMPARE(int(QMetaTypeId2<int*>::Defined), 0); - QVERIFY(QMetaTypeId2<CustomQObject*>::Defined); + QCOMPARE(int(QMetaTypeId2<CustomQObject::CustomQEnum>::Defined), 1); + QCOMPARE(int(QMetaTypeId2<CustomGadget>::Defined), 1); + QVERIFY(int(QMetaTypeId2<CustomQObject*>::Defined)); QVERIFY(!QMetaTypeId2<CustomQObject>::Defined); QVERIFY(!QMetaTypeId2<CustomNonQObject>::Defined); QVERIFY(!QMetaTypeId2<CustomNonQObject*>::Defined); + QVERIFY(!QMetaTypeId2<CustomGadget*>::Defined); } struct Bar @@ -378,6 +386,11 @@ void tst_QMetaType::typeName_data() QTest::newRow("QMap<int,int>") << static_cast<QMetaType::Type>(::qMetaTypeId<QMap<int, int> >()) << QString::fromLatin1("QMap<int,int>"); QTest::newRow("QVector<QList<int>>") << static_cast<QMetaType::Type>(::qMetaTypeId<QVector<QList<int> > >()) << QString::fromLatin1("QVector<QList<int> >"); QTest::newRow("QVector<QMap<int,int>>") << static_cast<QMetaType::Type>(::qMetaTypeId<QVector<QMap<int, int> > >()) << QString::fromLatin1("QVector<QMap<int,int> >"); + + QTest::newRow("CustomQObject*") << static_cast<QMetaType::Type>(::qMetaTypeId<CustomQObject*>()) << QString::fromLatin1("CustomQObject*"); + QTest::newRow("CustomGadget") << static_cast<QMetaType::Type>(::qMetaTypeId<CustomGadget>()) << QString::fromLatin1("CustomGadget"); + QTest::newRow("CustomQObject::CustomQEnum") << static_cast<QMetaType::Type>(::qMetaTypeId<CustomQObject::CustomQEnum>()) << QString::fromLatin1("CustomQObject::CustomQEnum"); + QTest::newRow("Qt::ArrowType") << static_cast<QMetaType::Type>(::qMetaTypeId<Qt::ArrowType>()) << QString::fromLatin1("Qt::ArrowType"); } void tst_QMetaType::typeName() |