Expand test case for qrc:/ URLs
authorMatthew Vogt <matthew.vogt@nokia.com>
Thu, 5 Jul 2012 05:00:24 +0000 (15:00 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 6 Jul 2012 03:31:13 +0000 (05:31 +0200)
Change-Id: Ibf8a04efbcb9d39938201f65c1fc0f236243a287
Reviewed-by: Martin Jones <martin.jones@nokia.com>
tests/auto/qml/qrcqml/data/SameDir.qml
tests/auto/qml/qrcqml/data/SameDir2.qml [new file with mode: 0644]
tests/auto/qml/qrcqml/data/SameDir3.qml [new file with mode: 0644]
tests/auto/qml/qrcqml/data/main.qml
tests/auto/qml/qrcqml/data/main2.qml [new file with mode: 0644]
tests/auto/qml/qrcqml/data/main3.qml [new file with mode: 0644]
tests/auto/qml/qrcqml/qrcqml.qrc
tests/auto/qml/qrcqml/tst_qrcqml.cpp

index b4950b9..1ee9b76 100644 (file)
@@ -1,5 +1,5 @@
 import QtQuick 2.0
 
 QtObject {
-    property string tokenProperty: "hello"
+    property string tokenProperty: "foo"
 }
diff --git a/tests/auto/qml/qrcqml/data/SameDir2.qml b/tests/auto/qml/qrcqml/data/SameDir2.qml
new file mode 100644 (file)
index 0000000..83d0673
--- /dev/null
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+    property string tokenProperty: "bar"
+}
diff --git a/tests/auto/qml/qrcqml/data/SameDir3.qml b/tests/auto/qml/qrcqml/data/SameDir3.qml
new file mode 100644 (file)
index 0000000..b1d08f4
--- /dev/null
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+QtObject {
+    property string tokenProperty: "baz"
+}
index e9069b5..339c6de 100644 (file)
@@ -1,6 +1,6 @@
 import QtQuick 2.0
-import "data" as Subdirectory
+import "../data" as Subdirectory
 
 SameDir {
-    property QtObject other: Subdirectory.SubDir{}
+    property QtObject other: Subdirectory.SubDir {}
 }
diff --git a/tests/auto/qml/qrcqml/data/main2.qml b/tests/auto/qml/qrcqml/data/main2.qml
new file mode 100644 (file)
index 0000000..b1eb73c
--- /dev/null
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import "data" as Subdirectory
+
+SameDir {
+    property QtObject other: Subdirectory.SubDir {}
+}
diff --git a/tests/auto/qml/qrcqml/data/main3.qml b/tests/auto/qml/qrcqml/data/main3.qml
new file mode 100644 (file)
index 0000000..b1eb73c
--- /dev/null
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import "data" as Subdirectory
+
+SameDir {
+    property QtObject other: Subdirectory.SubDir {}
+}
index 47b88ab..4ee303a 100644 (file)
@@ -1,7 +1,19 @@
 <!DOCTYPE RCC><RCC version="1.0">
 <qresource>
+    <file>data/main.qml</file>
+    <file>data/SameDir.qml</file>
     <file>data/SubDir.qml</file>
-    <file alias="main.qml">data/main.qml</file>
-    <file alias="SameDir.qml">data/SameDir.qml</file>
+</qresource>
+<qresource>
+    <!-- unspecified prefix seems to mean '/' -->
+    <file alias="main.qml">data/main2.qml</file>
+    <file alias="SameDir.qml">data/SameDir2.qml</file>
+</qresource>
+<qresource prefix="/search">
+    <file alias="main.qml">data/main3.qml</file>
+    <file alias="SameDir.qml">data/SameDir3.qml</file>
+</qresource>
+<qresource prefix="/search/data">
+    <file alias="SubDir.qml">data/SubDir.qml</file>
 </qresource>
 </RCC>
index b81fff0..a09c908 100644 (file)
@@ -55,6 +55,7 @@ public:
     tst_qrcqml();
 
 private slots:
+    void basicLoad_data();
     void basicLoad();
 };
 
@@ -62,16 +63,44 @@ tst_qrcqml::tst_qrcqml()
 {
 }
 
+void tst_qrcqml::basicLoad_data()
+{
+    QTest::addColumn<QString>("url");
+    QTest::addColumn<QString>("token");
+
+    QTest::newRow("simple")
+        << "qrc:/data/main.qml"
+        << "foo";
+
+    QTest::newRow("aliased")
+        << "qrc:/main.qml"
+        << "bar";
+
+    QTest::newRow("prefixed")
+        << "qrc:/search/main.qml"
+        << "baz";
+
+    /* This is not supported:
+    QTest::newRow("without qrc scheme")
+        << ":/data/main.qml"
+        << "hello";
+    */
+}
+
 void tst_qrcqml::basicLoad()
 {
+    QFETCH(QString, url);
+    QFETCH(QString, token);
+
     QQmlEngine e;
-    QQmlComponent c(&e, QUrl("qrc:/main.qml"));
+    QQmlComponent c(&e, QUrl(url));
     QVERIFY(c.isReady());
     QObject* o = c.create();
     QVERIFY(o);
-    QCOMPARE(o->property("tokenProperty").toString(), QLatin1String("hello"));
+    QCOMPARE(o->property("tokenProperty").toString(), token);
     delete o;
 }
+
 QTEST_MAIN(tst_qrcqml)
 
 #include "tst_qrcqml.moc"