aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2012-06-22 16:56:27 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-25 04:50:01 +0200
commite76ba402bfe309022a0be29c6bc8223f8f3f94b3 (patch)
tree88f48d90e036f547d1f075feb99934a45d3fe0e7 /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
parentfd754674d04625ebf254ce2a96cbe39b3d7652d8 (diff)
qmlRegisterRevision clashes with qmlRegisterUncreatableType
Add template<typename T, int metaObjectRevision> qmlRegisterUncreatableType() in order to register an uncreatable type for a particular revision. Task-number: QTBUG-23278 Change-Id: Ic165e41c8176916929cf19eb9bf6eef4b5bee1eb Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com> Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 6349cd343f..2f2f0a78d4 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -176,6 +176,9 @@ private slots:
void revisions();
void revisionOverloads();
+ void subclassedUncreateableRevision_data();
+ void subclassedUncreateableRevision();
+
void propertyInit();
void remoteLoadCrash();
void signalWithDefaultArg();
@@ -2540,6 +2543,59 @@ void tst_qqmllanguage::revisionOverloads()
}
}
+void tst_qqmllanguage::subclassedUncreateableRevision_data()
+{
+ QTest::addColumn<QString>("version");
+ QTest::addColumn<QString>("prop");
+ QTest::addColumn<bool>("shouldWork");
+
+ QTest::newRow("prop1 exists in 1.0") << "1.0" << "prop1" << true;
+ QTest::newRow("prop2 does not exist in 1.0") << "1.0" << "prop2" << false;
+ QTest::newRow("prop3 does not exist in 1.0") << "1.0" << "prop3" << false;
+
+ QTest::newRow("prop1 exists in 1.1") << "1.1" << "prop1" << true;
+ QTest::newRow("prop2 works because it's re-declared in Derived") << "1.1" << "prop2" << true;
+ QTest::newRow("prop3 only works if the Base REVISION 1 is picked up") << "1.1" << "prop3" << true;
+
+}
+
+void tst_qqmllanguage::subclassedUncreateableRevision()
+{
+ QFETCH(QString, version);
+ QFETCH(QString, prop);
+ QFETCH(bool, shouldWork);
+
+ {
+ QQmlEngine engine;
+ QString qml = QString("import QtQuick 2.0\nimport Test %1\nMyUncreateableBaseClass {}").arg(version);
+ QQmlComponent c(&engine);
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ c.setData(qml.toUtf8(), QUrl::fromLocalFile(QDir::currentPath()));
+ QObject *obj = c.create();
+ QCOMPARE(obj, static_cast<QObject*>(0));
+ QCOMPARE(c.errors().count(), 1);
+ QCOMPARE(c.errors().first().description(), QString("Cannot create MyUncreateableBaseClass"));
+ }
+
+ QQmlEngine engine;
+ QString qml = QString("import QtQuick 2.0\nimport Test %1\nMyCreateableDerivedClass {\n%3: true\n}").arg(version).arg(prop);
+ QQmlComponent c(&engine);
+ if (!shouldWork)
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ c.setData(qml.toUtf8(), QUrl::fromLocalFile(QDir::currentPath()));
+ QObject *obj = c.create();
+ if (!shouldWork) {
+ QCOMPARE(obj, static_cast<QObject*>(0));
+ return;
+ }
+
+ QVERIFY(obj);
+ MyUncreateableBaseClass *base = qobject_cast<MyUncreateableBaseClass*>(obj);
+ QVERIFY(base);
+ QCOMPARE(base->property(prop.toLatin1()).toBool(), true);
+ delete obj;
+}
+
void tst_qqmllanguage::initTestCase()
{
QString testdataDir = QFileInfo(QFINDTESTDATA("data")).absolutePath();