Windows: Fix file URL issues in declarative autotests
authorMiikka Heikkinen <miikka.heikkinen@digia.com>
Wed, 14 Mar 2012 14:42:58 +0000 (16:42 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 15 Mar 2012 10:25:36 +0000 (11:25 +0100)
Fixed by using testFileUrl() shared utility function where appropriate
instead of testFile() or various other ways file URLs were being
incorrectly used.

Task-number: QTBUG-24779
Change-Id: I48cbd297d419238f42ea45132344b7e5a487b6f1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>

tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
tests/auto/quick/qquickloader/tst_qquickloader.cpp
tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
tests/auto/quick/rendernode/tst_rendernode.cpp

index 3bbbc2c..79eaa33 100644 (file)
@@ -3112,7 +3112,7 @@ void tst_qqmlecmascript::moduleApi_data()
     QTest::newRow("qobject, writing + readonly constraints")
             << testFileUrl("moduleapi/qobjectModuleApiWriting.qml")
             << QString()
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
+            << (QStringList() << QString(testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toString() + QLatin1String(":15: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
             << (QStringList() << "readOnlyProperty" << "writableProperty" << "writableFinalProperty")
             << (QVariantList() << 20 << 50 << 10)
             << (QStringList() << "firstProperty" << "secondProperty")
@@ -3123,7 +3123,7 @@ void tst_qqmlecmascript::moduleApi_data()
     QTest::newRow("script, writing + readonly constraints")
             << testFileUrl("moduleapi/scriptModuleApiWriting.qml")
             << QString()
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
+            << (QStringList() << QString(testFileUrl("moduleapi/scriptModuleApiWriting.qml").toString() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
             << (QStringList() << "readBack" << "unchanged")
             << (QVariantList() << 13 << 42)
             << (QStringList() << "firstProperty" << "secondProperty")
@@ -3232,35 +3232,35 @@ void tst_qqmlecmascript::importScripts_data()
     QTest::newRow("parent scope shouldn't be inherited by import with imports")
             << testFileUrl("jsimportfail/failOne.qml")
             << QString()
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined")))
+            << (QStringList() << QString(testFileUrl("jsimportfail/failOne.qml").toString() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined")))
             << (QStringList() << QLatin1String("importScriptFunctionValue"))
             << (QVariantList() << QVariant(QString()));
 
     QTest::newRow("javascript imports in an import should be private to the import scope")
             << testFileUrl("jsimportfail/failTwo.qml")
             << QString()
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: ImportOneJs is not defined")))
+            << (QStringList() << QString(testFileUrl("jsimportfail/failTwo.qml").toString() + QLatin1String(":6: ReferenceError: ImportOneJs is not defined")))
             << (QStringList() << QLatin1String("importScriptFunctionValue"))
             << (QVariantList() << QVariant(QString()));
 
     QTest::newRow("module imports in an import should be private to the import scope")
             << testFileUrl("jsimportfail/failThree.qml")
             << QString()
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined")))
+            << (QStringList() << QString(testFileUrl("jsimportfail/failThree.qml").toString() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined")))
             << (QStringList() << QLatin1String("importedModuleAttachedPropertyValue"))
             << (QVariantList() << QVariant(false));
 
     QTest::newRow("typenames in an import should be private to the import scope")
             << testFileUrl("jsimportfail/failFour.qml")
             << QString()
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: JsQtTest is not defined")))
+            << (QStringList() << QString(testFileUrl("jsimportfail/failFour.qml").toString() + QLatin1String(":6: ReferenceError: JsQtTest is not defined")))
             << (QStringList() << QLatin1String("importedModuleEnumValue"))
             << (QVariantList() << QVariant(0));
 
     QTest::newRow("import with imports has it's own activation scope")
             << testFileUrl("jsimportfail/failFive.qml")
             << QString()
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Component is not defined")))
+            << (QStringList() << QString(testFileUrl("jsimportfail/importWithImports.js").toString() + QLatin1String(":8: ReferenceError: Component is not defined")))
             << (QStringList() << QLatin1String("componentError"))
             << (QVariantList() << QVariant(0));
 
@@ -3274,7 +3274,7 @@ void tst_qqmlecmascript::importScripts_data()
     QTest::newRow("pragma library imports shouldn't inherit parent imports or scope")
             << testFileUrl("jsimportfail/testImportPragmaLibrary.qml")
             << QString()
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Component is not defined")))
+            << (QStringList() << QString(testFileUrl("jsimportfail/importPragmaLibrary.js").toString() + QLatin1String(":6: ReferenceError: Component is not defined")))
             << (QStringList() << QLatin1String("testValue"))
             << (QVariantList() << QVariant(0));
 
index d8f368c..f99c268 100644 (file)
@@ -116,7 +116,7 @@ void tst_qquickfontloader::namedFont()
 
 void tst_qquickfontloader::localFont()
 {
-    QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }";
+    QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("tarzeau_ocr_a.ttf").toString() + "\" }";
     QQmlComponent component(&engine);
     component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
     QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
index 928151d..a282d55 100644 (file)
@@ -5186,7 +5186,7 @@ void tst_QQuickGridView::asynchronous()
     QQmlIncubationController controller;
     canvas->engine()->setIncubationController(&controller);
 
-    canvas->setSource(testFile("asyncloader.qml"));
+    canvas->setSource(testFileUrl("asyncloader.qml"));
 
     QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
     QVERIFY(rootObject);
index 44d0d6d..4847dd3 100644 (file)
@@ -53,10 +53,10 @@ class tst_QQuickItemLayer: public QQmlDataTest
 public:
     tst_QQuickItemLayer();
 
-    QImage runTest(const QString &url)
+    QImage runTest(const QString &fileName)
     {
         QQuickView view;
-        view.setSource(QUrl(url));
+        view.setSource(testFileUrl(fileName));
 
         view.show();
         QTest::qWaitForWindowShown(&view);
@@ -135,7 +135,7 @@ void tst_QQuickItemLayer::layerSmooth()
 {
     if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
         QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-    QImage fb = runTest(testFile("Smooth.qml"));
+    QImage fb = runTest("Smooth.qml");
     QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
     QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
 
@@ -154,7 +154,7 @@ void tst_QQuickItemLayer::layerEnabled()
 {
     if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
         QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-    QImage fb = runTest(testFile("Enabled.qml"));
+    QImage fb = runTest("Enabled.qml");
     // Verify the banding
     QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1));
     // Verify the gradient
@@ -170,7 +170,7 @@ void tst_QQuickItemLayer::layerMipmap()
 {
     if (m_isMesaSoftwareRasterizer)
         QSKIP("Mipmapping does not work with the Mesa Software Rasterizer.");
-    QImage fb = runTest(testFile("Mipmap.qml"));
+    QImage fb = runTest("Mipmap.qml");
     QVERIFY(fb.pixel(0, 0) != 0xff000000);
     QVERIFY(fb.pixel(0, 0) != 0xffffffff);
 }
@@ -184,7 +184,7 @@ void tst_QQuickItemLayer::layerEffect()
 {
     if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
         QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-    QImage fb = runTest(testFile("Effect.qml"));
+    QImage fb = runTest("Effect.qml");
     QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
     QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
 }
@@ -199,7 +199,7 @@ void tst_QQuickItemLayer::layerSourceRect()
     if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
         QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
 
-    QImage fb = runTest(testFile("SourceRect.qml"));
+    QImage fb = runTest("SourceRect.qml");
 
     // Check that the edges are converted to blue
     QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
@@ -219,7 +219,7 @@ void tst_QQuickItemLayer::layerIsTextureProvider()
 {
     if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
         QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-    QImage fb = runTest(testFile("TextureProvider.qml"));
+    QImage fb = runTest("TextureProvider.qml");
     QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
     QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
 }
@@ -257,7 +257,7 @@ void tst_QQuickItemLayer::layerVisibility()
     QFETCH(qreal, opacity);
 
     QQuickView view;
-    view.setSource(testFile("Visible.qml"));
+    view.setSource(testFileUrl("Visible.qml"));
 
     QQuickItem *child = view.rootItem()->childItems().at(0);
     child->setProperty("layerVisible", visible);
@@ -303,7 +303,7 @@ void tst_QQuickItemLayer::layerZOrder()
     QFETCH(bool, effect);
 
     QQuickView view;
-    view.setSource(testFile("ZOrder.qml"));
+    view.setSource(testFileUrl("ZOrder.qml"));
 
     QQuickItem *child = view.rootItem()->childItems().at(0);
     child->setProperty("layerEffect", effect);
@@ -338,7 +338,7 @@ void tst_QQuickItemLayer::changeZOrder()
     QFETCH(bool, effect);
 
     QQuickView view;
-    view.setSource(testFile("ZOrderChange.qml"));
+    view.setSource(testFileUrl("ZOrderChange.qml"));
 
     QQuickItem *child = view.rootItem()->childItems().at(0);
     child->setProperty("layerEnabled", layered);
@@ -388,20 +388,20 @@ void tst_QQuickItemLayer::changeZOrder()
 void tst_QQuickItemLayer::toggleLayerAndEffect()
 {
     // This test passes if it doesn't crash.
-    runTest(testFile("ToggleLayerAndEffect.qml"));
+    runTest("ToggleLayerAndEffect.qml");
 }
 
 void tst_QQuickItemLayer::disableLayer()
 {
     // This test passes if it doesn't crash.
-    runTest(testFile("DisableLayer.qml"));
+    runTest("DisableLayer.qml");
 }
 
 void tst_QQuickItemLayer::changeSamplerName()
 {
     if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
         QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-    QImage fb = runTest(testFile("SamplerNameChange.qml"));
+    QImage fb = runTest("SamplerNameChange.qml");
     QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
 }
 
@@ -409,7 +409,7 @@ void tst_QQuickItemLayer::itemEffect()
 {
     if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
         QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-    QImage fb = runTest(testFile("ItemEffect.qml"));
+    QImage fb = runTest("ItemEffect.qml");
     QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
     QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
     QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
@@ -418,7 +418,7 @@ void tst_QQuickItemLayer::itemEffect()
 
 void tst_QQuickItemLayer::rectangleEffect()
 {
-    QImage fb = runTest(testFile("RectangleEffect.qml"));
+    QImage fb = runTest("RectangleEffect.qml");
     QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
     QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
     QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
index b388243..bdf47fa 100644 (file)
@@ -653,7 +653,7 @@ void tst_QQuickLoader::initialPropertyValues_data()
             << (QVariantList() << 2 << 0);
 
     QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml")
-            << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null")))
+            << (QStringList() << QString(testFileUrl("initialPropertyValues.3.qml").toString() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null")))
             << (QStringList())
             << (QVariantList());
 
index 8181eb8..6816566 100644 (file)
@@ -6,4 +6,6 @@ SOURCES += tst_qquickmultipointtoucharea.cpp
 
 TESTDATA = data/*
 
+include(../../shared/util.pri)
+
 QT += core-private gui-private qml-private quick-private testlib
index 507612f..1e0cd4e 100644 (file)
 #include <private/qquickmultipointtoucharea_p.h>
 #include <private/qquickflickable_p.h>
 #include <QtQuick/qquickview.h>
+#include "../../shared/util.h"
 
-class tst_QQuickMultiPointTouchArea: public QObject
+class tst_QQuickMultiPointTouchArea : public QQmlDataTest
 {
     Q_OBJECT
 public:
     tst_QQuickMultiPointTouchArea() : device(0) { }
 private slots:
     void initTestCase() {
+        QQmlDataTest::initTestCase();
         if (!device) {
             device = new QTouchDevice;
             device->setType(QTouchDevice::TouchScreen);
@@ -714,7 +716,7 @@ void tst_QQuickMultiPointTouchArea::invisible()
 QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file)
 {
     QQuickView *canvas = new QQuickView(0);
-    canvas->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QLatin1String("/data/") + file));
+    canvas->setSource(testFileUrl(file));
     canvas->show();
     canvas->requestActivateWindow();
     QTest::qWaitForWindowShown(canvas);
index 8f517a4..ab24fbe 100644 (file)
@@ -532,7 +532,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName)
     ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
     ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
     ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
-    canvas->setSource(testFile("transitions.qml"));
+    canvas->setSource(testFileUrl("transitions.qml"));
     canvas->show();
     qApp->processEvents();
 
@@ -641,7 +641,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName)
     ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
     ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
     ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
-    canvas->setSource(testFile("transitions.qml"));
+    canvas->setSource(testFileUrl("transitions.qml"));
     canvas->show();
     qApp->processEvents();
 
index b456a59..f3832b4 100644 (file)
@@ -54,10 +54,10 @@ class tst_rendernode: public QQmlDataTest
 public:
     tst_rendernode();
 
-    QImage runTest(const QString &url)
+    QImage runTest(const QString &fileName)
     {
         QQuickView view;
-        view.setSource(QUrl(url));
+        view.setSource(testFileUrl(fileName));
 
         view.show();
         QTest::qWaitForWindowShown(&view);
@@ -194,7 +194,7 @@ static void fuzzyCompareColor(QRgb x, QRgb y)
 
 void tst_rendernode::renderOrder()
 {
-    QImage fb = runTest(testFile("RenderOrder.qml"));
+    QImage fb = runTest("RenderOrder.qml");
     int x1 = fb.width() / 8;
     int x2 = fb.width() * 3 / 8;
     int x3 = fb.width() * 5 / 8;
@@ -216,7 +216,7 @@ void tst_rendernode::renderOrder()
 
 void tst_rendernode::messUpState()
 {
-    QImage fb = runTest(testFile("MessUpState.qml"));
+    QImage fb = runTest("MessUpState.qml");
     int x1 = 0;
     int x2 = fb.width() / 2;
     int x3 = fb.width() - 1;