aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlqt
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2021-12-13 14:27:17 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2021-12-17 13:43:13 +0200
commit36874e799ae5922e50d97ffcbc26532bebc0d06c (patch)
treece905c144fd9ea6bb93ec0a6d3e5b0889784766f /tests/auto/qml/qqmlqt
parent220a547aa440019ebcb1dd411ed95ecbf197e0f1 (diff)
Use the correct scheme in setUrlHandler() for openUrlExternally() tests
testFileUrl() can return a QUrl with either file or qrc scheme, so the handler need to register the correct scheme as well. Task-number: QTBUG-97056 Pick-to: 6.2 6.3 Change-Id: I87028f75bbaf267b5eb58d28497cd2bea593c02a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlqt')
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
index 6217751443..8e4849e2d6 100644
--- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -634,8 +634,9 @@ void tst_qqmlqt::openUrlExternally()
{
MyUrlHandler handler;
+ const QUrl htmlTestFile = testFileUrl("test.html");
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
- QDesktopServices::setUrlHandler("file", &handler, "noteCall");
+ QDesktopServices::setUrlHandler(htmlTestFile.scheme(), &handler, "noteCall");
QQmlComponent component(&engine, testFileUrl("openUrlExternally.qml"));
QScopedPointer<QObject> object(component.create());
@@ -646,18 +647,19 @@ void tst_qqmlqt::openUrlExternally()
object->setProperty("testFile", true);
QCOMPARE(handler.called,2);
- QCOMPARE(handler.last, testFileUrl("test.html"));
+ QCOMPARE(handler.last, htmlTestFile);
QDesktopServices::unsetUrlHandler("test");
- QDesktopServices::unsetUrlHandler("file");
+ QDesktopServices::unsetUrlHandler(htmlTestFile.scheme());
}
void tst_qqmlqt::openUrlExternally_pragmaLibrary()
{
MyUrlHandler handler;
+ const QUrl htmlTestFile = testFileUrl("test.html");
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
- QDesktopServices::setUrlHandler("file", &handler, "noteCall");
+ QDesktopServices::setUrlHandler(htmlTestFile.scheme(), &handler, "noteCall");
QQmlComponent component(&engine, testFileUrl("openUrlExternally_lib.qml"));
QScopedPointer<QObject> object(component.create());
@@ -668,10 +670,10 @@ void tst_qqmlqt::openUrlExternally_pragmaLibrary()
object->setProperty("testFile", true);
QCOMPARE(handler.called,2);
- QCOMPARE(handler.last, testFileUrl("test.html"));
+ QCOMPARE(handler.last, htmlTestFile);
QDesktopServices::unsetUrlHandler("test");
- QDesktopServices::unsetUrlHandler("file");
+ QDesktopServices::unsetUrlHandler(htmlTestFile.scheme());
}
void tst_qqmlqt::md5()