diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-05-23 18:05:10 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-21 09:58:56 +0200 |
commit | 03342a435a88656d64d1445991a4421d244fcb45 (patch) | |
tree | c70121da638aed1d8ef1240cae8acf5fddf35dff /tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | |
parent | b89c6459d760e68c629c0d318d2afd494a2a415a (diff) |
Put basic language types into QtQml import
This import is automatically registered by the engine.
It provides basic language types (Component and QtObject).
Note that the QtQuick import still has these types registered into it,
so this commit doesn't break existing code.
Change-Id: I8ff190f057fc92969020cf8e896da1649ca3069b
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlengine/tst_qqmlengine.cpp')
-rw-r--r-- | tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 85c32d8118..c9d3e27afe 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -75,6 +75,8 @@ private slots: void outputWarningsToStandardError(); void objectOwnership(); void multipleEngines(); + void qtqmlModule_data(); + void qtqmlModule(); public slots: QObject *createAQObjectForOwnershipTest () @@ -565,6 +567,79 @@ void tst_qqmlengine::multipleEngines() } } +void tst_qqmlengine::qtqmlModule_data() +{ + QTest::addColumn<QUrl>("testFile"); + QTest::addColumn<QString>("expectedError"); + QTest::addColumn<QStringList>("expectedWarnings"); + + QTest::newRow("import QtQml of correct version (2.0)") + << testFileUrl("qtqmlModule.1.qml") + << QString() + << QStringList(); + + QTest::newRow("import QtQml of incorrect version (3.0)") + << testFileUrl("qtqmlModule.2.qml") + << QString(testFileUrl("qtqmlModule.2.qml").toString() + QLatin1String(":1 module \"QtQml\" version 3.0 is not installed\n")) + << QStringList(); + + QTest::newRow("import QtQml of incorrect version (1.0)") + << testFileUrl("qtqmlModule.3.qml") + << QString(testFileUrl("qtqmlModule.3.qml").toString() + QLatin1String(":1 module \"QtQml\" version 1.0 is not installed\n")) + << QStringList(); + + QTest::newRow("import QtQml of incorrect version (2.5)") + << testFileUrl("qtqmlModule.4.qml") + << QString(testFileUrl("qtqmlModule.4.qml").toString() + QLatin1String(":1 module \"QtQml\" version 2.5 is not installed\n")) + << QStringList(); + + QTest::newRow("QtQml 2.0 module provides Component and QtObject") + << testFileUrl("qtqmlModule.5.qml") + << QString() + << QStringList(); + + QTest::newRow("can import QtQml then QtQuick") + << testFileUrl("qtqmlModule.6.qml") + << QString() + << QStringList(); + + QTest::newRow("can import QtQuick then QtQml") + << testFileUrl("qtqmlModule.7.qml") + << QString() + << QStringList(); + + QTest::newRow("no import results in no QtObject availability") + << testFileUrl("qtqmlModule.8.qml") + << QString(testFileUrl("qtqmlModule.8.qml").toString() + QLatin1String(":4 QtObject is not a type\n")) + << QStringList(); + + QTest::newRow("importing QtQml only results in no Item availability") + << testFileUrl("qtqmlModule.9.qml") + << QString(testFileUrl("qtqmlModule.9.qml").toString() + QLatin1String(":4 Item is not a type\n")) + << QStringList(); +} + +// Test that the engine registers the QtQml module +void tst_qqmlengine::qtqmlModule() +{ + QFETCH(QUrl, testFile); + QFETCH(QString, expectedError); + QFETCH(QStringList, expectedWarnings); + + foreach (const QString &w, expectedWarnings) + QTest::ignoreMessage(QtWarningMsg, qPrintable(w)); + + QQmlEngine e; + QQmlComponent c(&e, testFile); + if (expectedError.isEmpty()) { + QObject *o = c.create(); + QVERIFY(o); + delete o; + } else { + QCOMPARE(c.errorString(), expectedError); + } +} + QTEST_MAIN(tst_qqmlengine) #include "tst_qqmlengine.moc" |