aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qrcqml/tst_qrcqml.cpp
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2012-07-23 10:59:30 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-27 03:29:12 +0200
commit73842034aac7b9788add4f1ba6cf7a9ec6057598 (patch)
tree0ac7d6316e3b1e0f5ae2118bd96606d53fd3d443 /tests/auto/qml/qrcqml/tst_qrcqml.cpp
parent3a045419ba588107d7730978c14643d68340f24b (diff)
Fix QML import paths in Qt resources.
Allow adding qrc: urls as import paths. Store an import path of the form :/import/path as qrc:/import/path which is expected by other parts of the code. Update documentation for QQmlEngine::addImportPath() to explicitly state what types of paths are supported. Add auto tests to check that importing a module from a Qt resource works. Change-Id: If0e75c75078a608b20d7a5c4080bccf6241e97f6 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml/qrcqml/tst_qrcqml.cpp')
-rw-r--r--tests/auto/qml/qrcqml/tst_qrcqml.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qml/qrcqml/tst_qrcqml.cpp b/tests/auto/qml/qrcqml/tst_qrcqml.cpp
index a09c908069..37a7e7860f 100644
--- a/tests/auto/qml/qrcqml/tst_qrcqml.cpp
+++ b/tests/auto/qml/qrcqml/tst_qrcqml.cpp
@@ -57,6 +57,8 @@ public:
private slots:
void basicLoad_data();
void basicLoad();
+ void qrcImport_data();
+ void qrcImport();
};
tst_qrcqml::tst_qrcqml()
@@ -101,6 +103,35 @@ void tst_qrcqml::basicLoad()
delete o;
}
+void tst_qrcqml::qrcImport_data()
+{
+ QTest::addColumn<QString>("importPath");
+ QTest::addColumn<QString>("token");
+
+ QTest::newRow("qrc path")
+ << ":/imports"
+ << "foo";
+
+ QTest::newRow("qrc url")
+ << "qrc:/imports"
+ << "foo";
+}
+
+void tst_qrcqml::qrcImport()
+{
+ QFETCH(QString, importPath);
+ QFETCH(QString, token);
+
+ QQmlEngine e;
+ e.addImportPath(importPath);
+ QQmlComponent c(&e, QUrl("qrc:///importtest.qml"));
+ QVERIFY(c.isReady());
+ QObject *o = c.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("tokenProperty").toString(), token);
+ delete o;
+}
+
QTEST_MAIN(tst_qrcqml)
#include "tst_qrcqml.moc"