aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-06-15 17:53:16 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-06-22 18:37:52 +0200
commit0a1e4cc7ec7548f6273befff9cdddb0bc7a58961 (patch)
treebf8b7ae725ac332fa59bd9058cc479018aca147d /tests/auto/quick
parent4e266103ad8b75d71fb176a2f774faf71997123d (diff)
Do not resolve URLs when assigning them to a property
We don't know in advance if a URL is part of the source code and should be relative to the current element, or if it is part of the application data and should not be touched. [ChangeLog][QtQml][Important Behavior Changes] URLs are not resolved or intercepted anymore when assigning them to a "url" property. Instead they are resolved and possibly intercepted when used to access an actual resource. Fixes: QTBUG-76879 Change-Id: Iaa2385aff2c13aa71a12e57385d9afb5dc60a073 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp2
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp19
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp2
3 files changed, 9 insertions, 14 deletions
diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
index 858a685796..504d476dfa 100644
--- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
+++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
@@ -429,7 +429,7 @@ void tst_qquickborderimage::statusChanges_data()
QTest::newRow("localfile") << testFileUrl("colors.png").toString() << 1 << false << QQuickImageBase::Ready;
QTest::newRow("nofile") << "" << 0 << false << QQuickImageBase::Null;
QTest::newRow("nonexistent") << testFileUrl("thisfiledoesnotexist.png").toString() << 1 << false << QQuickImageBase::Error;
- QTest::newRow("noprotocol") << QString("thisfiledoesnotexisteither.png") << 2 << false << QQuickImageBase::Error;
+ QTest::newRow("noprotocol") << QString("thisfiledoesnotexisteither.png") << 1 << false << QQuickImageBase::Error;
QTest::newRow("remote") << "/colors.png" << 2 << true << QQuickImageBase::Ready;
}
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index a204be8d59..047ca81186 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -214,18 +214,13 @@ void tst_QQuickLoader::sourceOrComponent_data()
QTest::addColumn<QUrl>("sourceUrl");
QTest::addColumn<QString>("errorString");
- auto encodedTestFileUrl = [&](const char *file)
- {
- return dataDirectoryUrl().resolved(QUrl(file));
- };
-
- QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << "";
- QTest::newRow("source with subdir") << "source" << "source: 'subdir/Test.qml'\n" << testFileUrl("subdir/Test.qml") << "";
- QTest::newRow("source with encoded subdir literal") << "source" << "source: 'subdir%2fTest.qml'\n" << encodedTestFileUrl("subdir%2FTest.qml") << "";
- QTest::newRow("source with encoded subdir optimized binding") << "source" << "source: 'subdir' + '%2fTest.qml'\n" << encodedTestFileUrl("subdir%2FTest.qml") << "";
- QTest::newRow("source with encoded subdir binding") << "source" << "source: encodeURIComponent('subdir/Test.qml')\n" << encodedTestFileUrl("subdir%2FTest.qml") << "";
+ QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << QUrl("Rect120x60.qml") << "";
+ QTest::newRow("source with subdir") << "source" << "source: 'subdir/Test.qml'\n" << QUrl("subdir/Test.qml") << "";
+ QTest::newRow("source with encoded subdir literal") << "source" << "source: 'subdir%2fTest.qml'\n" << QUrl("subdir%2FTest.qml") << "";
+ QTest::newRow("source with encoded subdir optimized binding") << "source" << "source: 'subdir' + '%2fTest.qml'\n" << QUrl("subdir%2FTest.qml") << "";
+ QTest::newRow("source with encoded subdir binding") << "source" << "source: encodeURIComponent('subdir/Test.qml')\n" << QUrl("subdir%2FTest.qml") << "";
QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
- QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml")
+ QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << QUrl("IDontExist.qml")
<< QString(testFileUrl("IDontExist.qml").toString() + ": No such file or directory");
}
@@ -809,7 +804,7 @@ void tst_QQuickLoader::deleteComponentCrash()
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
QCoreApplication::processEvents();
QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QCOMPARE(loader->source(), testFileUrl("BlueRect.qml"));
+ QCOMPARE(loader->source(), QUrl("BlueRect.qml"));
}
void tst_QQuickLoader::nonItem()
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
index d5fea3cb28..e8ea6b5f1a 100644
--- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -1360,7 +1360,7 @@ void tst_qquickstates::urlResolution()
QVERIFY(myType != nullptr && image1 != nullptr && image2 != nullptr && image3 != nullptr);
QQuickItemPrivate::get(myType)->setState("SetImageState");
- QUrl resolved = testFileUrl("Implementation/images/qt-logo.png");
+ QUrl resolved = QUrl("images/qt-logo.png");
QCOMPARE(image1->source(), resolved);
QCOMPARE(image2->source(), resolved);
QCOMPARE(image3->source(), resolved);