summaryrefslogtreecommitdiffstats
path: root/tests/auto/moc
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-12-06 14:23:47 +1000
committerMartin Jones <martin.jones@nokia.com>2011-01-05 13:15:43 +1000
commit3f80a24c5d375dd173d18c2a4227301f1afba2e3 (patch)
tree1d1a8ae2fb54082fa4e79a04263b44c6929d5f2a /tests/auto/moc
parent086f33dd4c70be03adcbc1703997afa27add920b (diff)
Allow a revision to be associated with properties and methods.
Allows a revision to be associated with properties via: Q_PROPERTY(int prop READ prop1 REVISION 1) Allows a revision to be associated with methods via either: public slots Q_REVISION(1): void method1(); or: public slots: Q_REVISION void method1(); Private revision() methods are added to QMetaProperty and QMetaMethod to access the revision info. This is private API for use by QML for now. Task-number: QTBUG-13451 Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/moc')
-rw-r--r--tests/auto/moc/tst_moc.cpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index bb23f497e2..a6343498cd 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -493,6 +493,7 @@ private slots:
void QTBUG5590_dummyProperty();
void QTBUG12260_defaultTemplate();
void notifyError();
+ void revisions();
signals:
void sigWithUnsignedArg(unsigned foo);
void sigWithSignedArg(signed foo);
@@ -507,6 +508,7 @@ private:
bool user2() { return false; };
bool user3() { return false; };
bool userFunction(){ return false; };
+ template <class T> void revisions_T();
private:
QString qtIncludePath;
@@ -1384,6 +1386,117 @@ void tst_Moc::notifyError()
#endif
}
+// If changed, update VersionTestNotify below
+class VersionTest : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int prop1 READ foo)
+ Q_PROPERTY(int prop2 READ foo REVISION 2)
+ Q_ENUMS(TestEnum);
+
+public:
+ int foo() const { return 0; }
+
+ Q_INVOKABLE void method1() {}
+ Q_INVOKABLE Q_REVISION(4) void method2() {}
+
+ enum TestEnum { One, Two };
+
+public slots:
+ void slot1() {}
+ Q_REVISION(3) void slot2() {}
+
+signals:
+ void signal1();
+ Q_REVISION(5) void signal2();
+
+public slots Q_REVISION(6):
+ void slot3() {}
+ void slot4() {}
+
+signals Q_REVISION(7):
+ void signal3();
+ void signal4();
+};
+
+// If changed, update VersionTest above
+class VersionTestNotify : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int prop1 READ foo NOTIFY fooChanged)
+ Q_PROPERTY(int prop2 READ foo REVISION 2)
+ Q_ENUMS(TestEnum);
+
+public:
+ int foo() const { return 0; }
+
+ Q_INVOKABLE void method1() {}
+ Q_INVOKABLE Q_REVISION(4) void method2() {}
+
+ enum TestEnum { One, Two };
+
+public slots:
+ void slot1() {}
+ Q_REVISION(3) void slot2() {}
+
+signals:
+ void fooChanged();
+ void signal1();
+ Q_REVISION(5) void signal2();
+
+public slots Q_REVISION(6):
+ void slot3() {}
+ void slot4() {}
+
+signals Q_REVISION(7):
+ void signal3();
+ void signal4();
+};
+
+template <class T>
+void tst_Moc::revisions_T()
+{
+ int idx = T::staticMetaObject.indexOfProperty("prop1");
+ QVERIFY(T::staticMetaObject.property(idx).revision() == 0);
+ idx = T::staticMetaObject.indexOfProperty("prop2");
+ QVERIFY(T::staticMetaObject.property(idx).revision() == 2);
+
+ idx = T::staticMetaObject.indexOfMethod("method1()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 0);
+ idx = T::staticMetaObject.indexOfMethod("method2()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 4);
+
+ idx = T::staticMetaObject.indexOfSlot("slot1()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 0);
+ idx = T::staticMetaObject.indexOfSlot("slot2()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 3);
+
+ idx = T::staticMetaObject.indexOfSlot("slot3()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 6);
+ idx = T::staticMetaObject.indexOfSlot("slot4()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 6);
+
+ idx = T::staticMetaObject.indexOfSignal("signal1()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 0);
+ idx = T::staticMetaObject.indexOfSignal("signal2()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 5);
+
+ idx = T::staticMetaObject.indexOfSignal("signal3()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 7);
+ idx = T::staticMetaObject.indexOfSignal("signal4()");
+ QVERIFY(T::staticMetaObject.method(idx).revision() == 7);
+
+ idx = T::staticMetaObject.indexOfEnumerator("TestEnum");
+ QCOMPARE(T::staticMetaObject.enumerator(idx).keyCount(), 2);
+ QCOMPARE(T::staticMetaObject.enumerator(idx).key(0), "One");
+}
+
+// test using both class that has properties with and without NOTIFY signals
+void tst_Moc::revisions()
+{
+ revisions_T<VersionTest>();
+ revisions_T<VersionTestNotify>();
+}
QTEST_APPLESS_MAIN(tst_Moc)
#include "tst_moc.moc"