diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-03-26 16:39:00 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-29 00:36:49 +0200 |
commit | e4baefacff3e04ea3b599c5279e883d75d2ad489 (patch) | |
tree | dc78ce14db08c0aa771ddff9df8c23da8b8919ba /tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp | |
parent | 5de103291d8159a236cabcc689caade265de1bd5 (diff) |
Re-order imports statements to import nested imports later
Re-order the imports for a script by increasing order of URI length.
This ensures that an import of the type 'import X.Y' is processed
after the import of 'import X' which contains the type definitions for
the namespace X.Y.
Task-number: QTBUG-24369
Change-Id: I1b06e9d114a97c9f47279f8f33383a27e0efb4bb
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp')
-rw-r--r-- | tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index b574bad595..c110ce71d3 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -70,6 +70,8 @@ private slots: void versionNotInstalled_data(); void implicitQmldir(); void implicitQmldir_data(); + void importsNested(); + void importsNested_data(); private: QString m_importsDirectory; @@ -347,6 +349,47 @@ void tst_qqmlmoduleplugin::implicitQmldir() delete obj; } +void tst_qqmlmoduleplugin::importsNested_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QString>("errorFile"); + + // Note: specific order required to induce failure (no other test case should import the + // plugin used for this test, or the alternate order test will pass spuriously) + QTest::newRow("alternateOrder") << "importsNested.1.qml" << QString(); + QTest::newRow("expectedOrder") << "importsNested.2.qml" << QString(); + QTest::newRow("missingImport") << "importsNested.3.qml" << "importsNested.3.errors.txt"; + QTest::newRow("invalidVersion") << "importsNested.4.qml" << "importsNested.4.errors.txt"; +} +void tst_qqmlmoduleplugin::importsNested() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + + // Note: because imports are cached between test case data rows (and the plugins remain loaded), + // these tests should really be run in new instances of the app... + + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + + if (!errorFile.isEmpty()) { + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + } + + QQmlComponent component(&engine, testFile(file)); + QObject *obj = component.create(); + + if (errorFile.isEmpty()) { + if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) + qWarning() << "Unexpected Errors:" << component.errors(); + QVERIFY(obj); + delete obj; + } else { + QList<QQmlError> errors = component.errors(); + VERIFY_ERRORS(errorFile.toLatin1().constData()); + QVERIFY(!obj); + } +} QTEST_MAIN(tst_qqmlmoduleplugin) |