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>
This commit is contained in:
parent
220a547aa4
commit
36874e799a
|
@ -634,8 +634,9 @@ void tst_qqmlqt::openUrlExternally()
|
||||||
{
|
{
|
||||||
MyUrlHandler handler;
|
MyUrlHandler handler;
|
||||||
|
|
||||||
|
const QUrl htmlTestFile = testFileUrl("test.html");
|
||||||
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
|
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
|
||||||
QDesktopServices::setUrlHandler("file", &handler, "noteCall");
|
QDesktopServices::setUrlHandler(htmlTestFile.scheme(), &handler, "noteCall");
|
||||||
|
|
||||||
QQmlComponent component(&engine, testFileUrl("openUrlExternally.qml"));
|
QQmlComponent component(&engine, testFileUrl("openUrlExternally.qml"));
|
||||||
QScopedPointer<QObject> object(component.create());
|
QScopedPointer<QObject> object(component.create());
|
||||||
|
@ -646,18 +647,19 @@ void tst_qqmlqt::openUrlExternally()
|
||||||
object->setProperty("testFile", true);
|
object->setProperty("testFile", true);
|
||||||
|
|
||||||
QCOMPARE(handler.called,2);
|
QCOMPARE(handler.called,2);
|
||||||
QCOMPARE(handler.last, testFileUrl("test.html"));
|
QCOMPARE(handler.last, htmlTestFile);
|
||||||
|
|
||||||
QDesktopServices::unsetUrlHandler("test");
|
QDesktopServices::unsetUrlHandler("test");
|
||||||
QDesktopServices::unsetUrlHandler("file");
|
QDesktopServices::unsetUrlHandler(htmlTestFile.scheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_qqmlqt::openUrlExternally_pragmaLibrary()
|
void tst_qqmlqt::openUrlExternally_pragmaLibrary()
|
||||||
{
|
{
|
||||||
MyUrlHandler handler;
|
MyUrlHandler handler;
|
||||||
|
|
||||||
|
const QUrl htmlTestFile = testFileUrl("test.html");
|
||||||
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
|
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
|
||||||
QDesktopServices::setUrlHandler("file", &handler, "noteCall");
|
QDesktopServices::setUrlHandler(htmlTestFile.scheme(), &handler, "noteCall");
|
||||||
|
|
||||||
QQmlComponent component(&engine, testFileUrl("openUrlExternally_lib.qml"));
|
QQmlComponent component(&engine, testFileUrl("openUrlExternally_lib.qml"));
|
||||||
QScopedPointer<QObject> object(component.create());
|
QScopedPointer<QObject> object(component.create());
|
||||||
|
@ -668,10 +670,10 @@ void tst_qqmlqt::openUrlExternally_pragmaLibrary()
|
||||||
object->setProperty("testFile", true);
|
object->setProperty("testFile", true);
|
||||||
|
|
||||||
QCOMPARE(handler.called,2);
|
QCOMPARE(handler.called,2);
|
||||||
QCOMPARE(handler.last, testFileUrl("test.html"));
|
QCOMPARE(handler.last, htmlTestFile);
|
||||||
|
|
||||||
QDesktopServices::unsetUrlHandler("test");
|
QDesktopServices::unsetUrlHandler("test");
|
||||||
QDesktopServices::unsetUrlHandler("file");
|
QDesktopServices::unsetUrlHandler(htmlTestFile.scheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_qqmlqt::md5()
|
void tst_qqmlqt::md5()
|
||||||
|
|
Loading…
Reference in New Issue