From 881339e9d9054c46f2621119246de7a13c83761a Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 19 Jun 2020 11:17:50 +0200 Subject: Replace FaviconManager with Chromium's Favicon Component Task-number: QTBUG-51184 Change-Id: Ie050cb23f2c86841a66ec384bfbcdf0713cffa7c Reviewed-by: Allan Sandfeld Jensen --- .../tst_qwebenginecookiestore.cpp | 10 +- tests/auto/quick/qmltests/CMakeLists.txt | 3 +- tests/auto/quick/qmltests/data/favicon-misc.html | 4 +- tests/auto/quick/qmltests/data/tst_favicon.qml | 337 ++++++++---- .../quick/qmltests/data/tst_faviconDownload.qml | 121 ----- tests/auto/widgets/CMakeLists.txt | 2 +- tests/auto/widgets/favicon/CMakeLists.txt | 29 + tests/auto/widgets/favicon/favicon.pro | 1 + .../widgets/favicon/resources/favicon-misc.html | 11 + .../widgets/favicon/resources/favicon-multi.html | 9 + .../favicon/resources/favicon-shortcut.html | 10 + .../widgets/favicon/resources/favicon-single.html | 9 + .../widgets/favicon/resources/favicon-touch.html | 10 + .../favicon/resources/favicon-unavailable.html | 9 + .../auto/widgets/favicon/resources/icons/qt144.png | Bin 0 -> 8315 bytes .../auto/widgets/favicon/resources/icons/qt32.ico | Bin 0 -> 4286 bytes .../widgets/favicon/resources/icons/qtmulti.ico | Bin 0 -> 22382 bytes tests/auto/widgets/favicon/resources/test1.html | 1 + tests/auto/widgets/favicon/tst_favicon.cpp | 565 +++++++++++++++++++ tests/auto/widgets/favicon/tst_favicon.qrc | 14 + tests/auto/widgets/faviconmanager/CMakeLists.txt | 29 - .../auto/widgets/faviconmanager/faviconmanager.pro | 1 - .../faviconmanager/resources/favicon-misc.html | 11 - .../faviconmanager/resources/favicon-multi.html | 9 - .../faviconmanager/resources/favicon-shortcut.html | 10 - .../faviconmanager/resources/favicon-single.html | 9 - .../faviconmanager/resources/favicon-touch.html | 10 - .../resources/favicon-unavailable.html | 9 - .../faviconmanager/resources/icons/qt144.png | Bin 8315 -> 0 bytes .../faviconmanager/resources/icons/qt32.ico | Bin 4286 -> 0 bytes .../faviconmanager/resources/icons/qtmulti.ico | Bin 22382 -> 0 bytes .../widgets/faviconmanager/resources/test1.html | 1 - .../widgets/faviconmanager/tst_faviconmanager.cpp | 605 --------------------- .../widgets/faviconmanager/tst_faviconmanager.qrc | 14 - .../widgets/qwebengineview/tst_qwebengineview.cpp | 6 +- 35 files changed, 919 insertions(+), 940 deletions(-) delete mode 100644 tests/auto/quick/qmltests/data/tst_faviconDownload.qml create mode 100644 tests/auto/widgets/favicon/CMakeLists.txt create mode 100644 tests/auto/widgets/favicon/favicon.pro create mode 100644 tests/auto/widgets/favicon/resources/favicon-misc.html create mode 100644 tests/auto/widgets/favicon/resources/favicon-multi.html create mode 100644 tests/auto/widgets/favicon/resources/favicon-shortcut.html create mode 100644 tests/auto/widgets/favicon/resources/favicon-single.html create mode 100644 tests/auto/widgets/favicon/resources/favicon-touch.html create mode 100644 tests/auto/widgets/favicon/resources/favicon-unavailable.html create mode 100644 tests/auto/widgets/favicon/resources/icons/qt144.png create mode 100644 tests/auto/widgets/favicon/resources/icons/qt32.ico create mode 100644 tests/auto/widgets/favicon/resources/icons/qtmulti.ico create mode 100644 tests/auto/widgets/favicon/resources/test1.html create mode 100644 tests/auto/widgets/favicon/tst_favicon.cpp create mode 100644 tests/auto/widgets/favicon/tst_favicon.qrc delete mode 100644 tests/auto/widgets/faviconmanager/CMakeLists.txt delete mode 100644 tests/auto/widgets/faviconmanager/faviconmanager.pro delete mode 100644 tests/auto/widgets/faviconmanager/resources/favicon-misc.html delete mode 100644 tests/auto/widgets/faviconmanager/resources/favicon-multi.html delete mode 100644 tests/auto/widgets/faviconmanager/resources/favicon-shortcut.html delete mode 100644 tests/auto/widgets/faviconmanager/resources/favicon-single.html delete mode 100644 tests/auto/widgets/faviconmanager/resources/favicon-touch.html delete mode 100644 tests/auto/widgets/faviconmanager/resources/favicon-unavailable.html delete mode 100644 tests/auto/widgets/faviconmanager/resources/icons/qt144.png delete mode 100644 tests/auto/widgets/faviconmanager/resources/icons/qt32.ico delete mode 100644 tests/auto/widgets/faviconmanager/resources/icons/qtmulti.ico delete mode 100644 tests/auto/widgets/faviconmanager/resources/test1.html delete mode 100644 tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp delete mode 100644 tests/auto/widgets/faviconmanager/tst_faviconmanager.qrc (limited to 'tests/auto') diff --git a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp index 0e8248508..ef3b84691 100644 --- a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp +++ b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp @@ -294,9 +294,9 @@ void tst_QWebEngineCookieStore::basicFilterOverHTTP() QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); QVERIFY(!cookieRequestHeader.isEmpty()); QTRY_COMPARE(cookieAddedSpy.count(), 1); - QTRY_COMPARE(accessTested.loadAcquire(), 7); + QTRY_COMPARE(accessTested.loadAcquire(), 6); - QTRY_COMPARE(serverSpy.count(), 6); + QTRY_COMPARE(serverSpy.count(), 5); client->deleteAllCookies(); QTRY_COMPARE(cookieRemovedSpy.count(), 1); @@ -313,9 +313,9 @@ void tst_QWebEngineCookieStore::basicFilterOverHTTP() // Test cookies are NOT added: QTest::qWait(100); QCOMPARE(cookieAddedSpy.count(), 1); - QTRY_COMPARE(accessTested.loadAcquire(), 11); + QTRY_COMPARE(accessTested.loadAcquire(), 9); - QTRY_COMPARE(serverSpy.count(), 9); + QTRY_COMPARE(serverSpy.count(), 7); page.triggerAction(QWebEnginePage::Reload); QTRY_COMPARE(loadSpy.count(), 1); @@ -324,7 +324,7 @@ void tst_QWebEngineCookieStore::basicFilterOverHTTP() QCOMPARE(cookieAddedSpy.count(), 1); // Wait for last GET /favicon.ico - QTRY_COMPARE(serverSpy.count(), 12); + QTRY_COMPARE(serverSpy.count(), 9); (void) httpServer.stop(); QCOMPARE(resourceFirstParty.size(), accessTested.loadAcquire()); diff --git a/tests/auto/quick/qmltests/CMakeLists.txt b/tests/auto/quick/qmltests/CMakeLists.txt index b5898cc2a..1c77e1a05 100644 --- a/tests/auto/quick/qmltests/CMakeLists.txt +++ b/tests/auto/quick/qmltests/CMakeLists.txt @@ -16,6 +16,7 @@ set(testList tst_activeFocusOnPress.qml tst_audioMuted.qml tst_desktopBehaviorLoadHtml.qml + tst_favicon.qml tst_findText.qml tst_focusOnNavigation.qml tst_fullScreenRequest.qml @@ -53,8 +54,6 @@ endif() if(QT_FEATURE_webengine_testsupport) list(APPEND testList - tst_favicon.qml - tst_faviconDownload.qml tst_inputMethod.qml tst_javaScriptDialogs.qml tst_linkHovered.qml diff --git a/tests/auto/quick/qmltests/data/favicon-misc.html b/tests/auto/quick/qmltests/data/favicon-misc.html index 9e788bdf4..03d1086ff 100644 --- a/tests/auto/quick/qmltests/data/favicon-misc.html +++ b/tests/auto/quick/qmltests/data/favicon-misc.html @@ -1,8 +1,8 @@ Favicon Test - - + + diff --git a/tests/auto/quick/qmltests/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml index fc8b90542..4d13d1e76 100644 --- a/tests/auto/quick/qmltests/data/tst_favicon.qml +++ b/tests/auto/quick/qmltests/data/tst_favicon.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWebEngine module of the Qt Toolkit. @@ -26,30 +26,26 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtTest 1.0 -import QtWebEngine 1.3 -import QtWebEngine.testsupport 1.0 -import QtQuick.Window 2.0 -import "../../qmltests/data" 1.0 +import QtQuick +import QtTest +import QtWebEngine +import Test.util +import "../../qmltests/data" TestWebEngineView { id: webEngineView width: 200 height: 400 - testSupport: WebEngineTestSupport { - property var errorPageLoadStatus: null + TempDir { id: tempDir } - function waitForErrorPageLoadSucceeded() { - var success = _waitFor(function() { return testSupport.errorPageLoadStatus == WebEngineView.LoadSucceededStatus }) - testSupport.errorPageLoadStatus = null - return success - } + property QtObject defaultProfile: WebEngineProfile { + offTheRecord: true + } - errorPage.onLoadingChanged: function(load) { - errorPageLoadStatus = load.status - } + property QtObject nonOTRProfile: WebEngineProfile { + persistentStoragePath: tempDir.path() + '/WebEngineFavicon' + offTheRecord: false } function removeFaviconProviderPrefix(url) { @@ -58,10 +54,10 @@ TestWebEngineView { function getFaviconPixel(faviconImage) { var grabImage = Qt.createQmlObject(" - import QtQuick 2.5\n + import QtQuick\n Image { }", testCase) var faviconCanvas = Qt.createQmlObject(" - import QtQuick 2.5\n + import QtQuick\n Canvas { }", testCase) testCase.tryVerify(function() { return faviconImage.status == Image.Ready }); @@ -104,12 +100,22 @@ TestWebEngineView { function init() { // It is worth to restore the initial state with loading a blank page before all test functions. - webEngineView.url = 'about:blank' - verify(webEngineView.waitForLoadSucceeded()) - iconChangedSpy.clear() + webEngineView.url = 'about:blank'; + verify(webEngineView.waitForLoadSucceeded()); + iconChangedSpy.clear(); + webEngineView.settings.touchIconsEnabled = false; + webEngineView.settings.autoLoadIconsForPage = true; } - function test_faviconLoad() { + function test_faviconLoad_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_faviconLoad(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) var url = Qt.resolvedUrl("favicon.html") @@ -119,11 +125,20 @@ TestWebEngineView { iconChangedSpy.wait() compare(iconChangedSpy.count, 1) - compare(favicon.width, 48) - compare(favicon.height, 48) + tryCompare(favicon, "status", Image.Ready) + compare(favicon.width, 32) + compare(favicon.height, 32) + } + + function test_faviconLoadEncodedUrl_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; } - function test_faviconLoadEncodedUrl() { + function test_faviconLoadEncodedUrl(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) var url = Qt.resolvedUrl("favicon2.html?favicon=load should work with#whitespace!") @@ -133,11 +148,62 @@ TestWebEngineView { iconChangedSpy.wait() compare(iconChangedSpy.count, 1) - compare(favicon.width, 16) - compare(favicon.height, 16) + tryCompare(favicon, "status", Image.Ready) + compare(favicon.width, 32) + compare(favicon.height, 32) } - function test_noFavicon() { + function test_faviconLoadAfterHistoryNavigation_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_faviconLoadAfterHistoryNavigation(row) { + webEngineView.profile = row.profile + compare(iconChangedSpy.count, 0) + + var iconUrl + + webEngineView.url = Qt.resolvedUrl("favicon.html") + verify(webEngineView.waitForLoadSucceeded()) + tryCompare(iconChangedSpy, "count", 1) + iconUrl = removeFaviconProviderPrefix(webEngineView.icon) + compare(iconUrl, Qt.resolvedUrl("icons/favicon.png")) + + iconChangedSpy.clear() + webEngineView.url = Qt.resolvedUrl("favicon-shortcut.html") + verify(webEngineView.waitForLoadSucceeded()) + tryCompare(iconChangedSpy, "count", 2) + iconUrl = removeFaviconProviderPrefix(webEngineView.icon) + compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico")) + + iconChangedSpy.clear() + webEngineView.goBack(); + verify(webEngineView.waitForLoadSucceeded()) + tryCompare(iconChangedSpy, "count", 2) + iconUrl = removeFaviconProviderPrefix(webEngineView.icon) + compare(iconUrl, Qt.resolvedUrl("icons/favicon.png")) + + iconChangedSpy.clear() + webEngineView.goForward(); + verify(webEngineView.waitForLoadSucceeded()) + tryCompare(iconChangedSpy, "count", 2) + iconUrl = removeFaviconProviderPrefix(webEngineView.icon) + compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico")) + } + + + function test_noFavicon_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_noFavicon(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) var url = Qt.resolvedUrl("test1.html") @@ -150,7 +216,15 @@ TestWebEngineView { compare(iconUrl, Qt.resolvedUrl("")) } - function test_aboutBlank() { + function test_aboutBlank_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_aboutBlank(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) var url = Qt.resolvedUrl("about:blank") @@ -163,7 +237,15 @@ TestWebEngineView { compare(iconUrl, Qt.resolvedUrl("")) } - function test_unavailableFavicon() { + function test_unavailableFavicon_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_unavailableFavicon(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) var url = Qt.resolvedUrl("favicon-unavailable.html") @@ -176,15 +258,25 @@ TestWebEngineView { compare(iconUrl, Qt.resolvedUrl("")) } - function test_errorPageEnabled() { - WebEngine.settings.errorPageEnabled = true + function test_errorPageEnabled_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_errorPageEnabled(row) { + webEngineView.profile = row.profile + webEngineView.settings.errorPageEnabled = true compare(iconChangedSpy.count, 0) var url = Qt.resolvedUrl("http://url.invalid") webEngineView.url = url verify(webEngineView.waitForLoadFailed(20000)) - verify(webEngineView.testSupport.waitForErrorPageLoadSucceeded()) + // FIXME: Wait for error page load to finish. + // This should be done without testSupport API. + wait(500) compare(iconChangedSpy.count, 0) @@ -192,8 +284,16 @@ TestWebEngineView { compare(iconUrl, Qt.resolvedUrl("")) } - function test_errorPageDisabled() { - WebEngine.settings.errorPageEnabled = false + function test_errorPageDisabled_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_errorPageDisabled(row) { + webEngineView.profile = row.profile + webEngineView.settings.errorPageEnabled = false compare(iconChangedSpy.count, 0) @@ -207,7 +307,15 @@ TestWebEngineView { compare(iconUrl, Qt.resolvedUrl("")) } - function test_bestFavicon() { + function test_bestFavicon_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_bestFavicon(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) var url, iconUrl @@ -221,6 +329,7 @@ TestWebEngineView { iconUrl = removeFaviconProviderPrefix(webEngineView.icon) // Touch icon is ignored compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico")) + tryCompare(favicon, "status", Image.Ready) compare(favicon.width, 32) compare(favicon.height, 32) @@ -230,23 +339,25 @@ TestWebEngineView { webEngineView.url = url verify(webEngineView.waitForLoadSucceeded()) - iconChangedSpy.wait() - verify(iconChangedSpy.count >= 1) + tryCompare(iconChangedSpy, "count", 2) iconUrl = removeFaviconProviderPrefix(webEngineView.icon) - // If the icon URL is empty we have to wait for - // the second iconChanged signal that propagates the expected URL - if (iconUrl == Qt.resolvedUrl("")) { - tryCompare(iconChangedSpy, "count", 2) - iconUrl = removeFaviconProviderPrefix(webEngineView.icon) - } + // If touch icon is disabled, FaviconHandler propagates the icon closest to size 16x16 + compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico")) + tryCompare(favicon, "status", Image.Ready) + compare(favicon.width, 32) + compare(favicon.height, 32) + } - compare(iconUrl, Qt.resolvedUrl("icons/qt144.png")) - compare(favicon.width, 144) - compare(favicon.height, 144) + function test_touchIcon_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; } - function test_touchIcon() { + function test_touchIcon(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) var url = Qt.resolvedUrl("favicon-touch.html") @@ -260,7 +371,7 @@ TestWebEngineView { compare(favicon.width, 0) compare(favicon.height, 0) - WebEngine.settings.touchIconsEnabled = true + webEngineView.settings.touchIconsEnabled = true url = Qt.resolvedUrl("favicon-touch.html") webEngineView.url = url @@ -270,11 +381,20 @@ TestWebEngineView { iconUrl = removeFaviconProviderPrefix(webEngineView.icon) compare(iconUrl, Qt.resolvedUrl("icons/qt144.png")) compare(iconChangedSpy.count, 1) + tryCompare(favicon, "status", Image.Ready) compare(favicon.width, 144) compare(favicon.height, 144) } - function test_multiIcon() { + function test_multiIcon_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_multiIcon(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) var url = Qt.resolvedUrl("favicon-multi.html") @@ -283,61 +403,24 @@ TestWebEngineView { iconChangedSpy.wait() compare(iconChangedSpy.count, 1) - compare(favicon.width, 64) - compare(favicon.height, 64) + tryCompare(favicon, "status", Image.Ready) + compare(favicon.width, 32) + compare(favicon.height, 32) } - function test_faviconProvider_data() { + function test_dynamicFavicon_data() { return [ - { tag: "multi 8x8", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 8, value: 16 }, - { tag: "multi 16x16", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 16, value: 16 }, - { tag: "multi 17x17", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 17, value: 32 }, - { tag: "multi 31x31", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 31, value: 32 }, - { tag: "multi 32x32", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 32, value: 32 }, - { tag: "multi 33x33", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 33, value: 64 }, - { tag: "multi 64x64", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 64, value: 64 }, - { tag: "multi 128x128", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 128, value: 128 }, - { tag: "multi 255x255", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 255, value: 255 }, - { tag: "multi 256x256", url: Qt.resolvedUrl("favicon-multi-gray.html"), size: 256, value: 255 }, - { tag: "candidate 8x8", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 8, value: 16 }, - { tag: "candidate 16x16", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 16, value: 16 }, - { tag: "candidate 17x17", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 17, value: 32 }, - { tag: "candidate 31x31", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 31, value: 32 }, - { tag: "candidate 32x32", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 32, value: 32 }, - { tag: "candidate 33x33", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 33, value: 64 }, - { tag: "candidate 64x64", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 64, value: 64 }, - { tag: "candidate 128x128", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 128, value: 128 }, - { tag: "candidate 255x255", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 255, value: 255 }, - { tag: "candidate 256x256", url: Qt.resolvedUrl("favicon-candidates-gray.html"), size: 256, value: 255 }, + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, ]; } - function test_faviconProvider(row) { - var faviconImage = Qt.createQmlObject(" - import QtQuick 2.5\n - Image { sourceSize: Qt.size(width, height) }", testCase) - + function test_dynamicFavicon(row) { + webEngineView.profile = row.profile compare(iconChangedSpy.count, 0) - webEngineView.url = row.url - verify(webEngineView.waitForLoadSucceeded()) - - iconChangedSpy.wait() - compare(iconChangedSpy.count, 1) - - faviconImage.width = row.size / Screen.devicePixelRatio - faviconImage.height = row.size / Screen.devicePixelRatio - faviconImage.source = webEngineView.icon - - var pixel = getFaviconPixel(faviconImage); - compare(pixel[0], row.value) - - faviconImage.destroy() - } - - function test_dynamicFavicon() { var faviconImage = Qt.createQmlObject(" - import QtQuick 2.5\n + import QtQuick\n Image { width: 16; height: 16; sourceSize: Qt.size(width, height); }", testCase) faviconImage.source = Qt.binding(function() { return webEngineView.icon; }); @@ -377,9 +460,17 @@ TestWebEngineView { faviconImage.destroy() } - function test_touchIconWithSameURL() + function test_touchIconWithSameURL_data() { + return [ + { tag: "OTR", profile: defaultProfile }, + { tag: "non-OTR", profile: nonOTRProfile }, + ]; + } + + function test_touchIconWithSameURL(row) { - WebEngine.settings.touchIconsEnabled = false; + webEngineView.profile = row.profile; + compare(iconChangedSpy.count, 0); var icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="; @@ -409,5 +500,53 @@ TestWebEngineView { tryCompare(iconChangedSpy, "count", 1); verify(!webEngineView.icon.toString().replace(/^image:\/\/favicon\//, '')); } + + function test_iconsDisabled_data() { + return [ + { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html") }, + { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html") }, + { tag: "single", url: Qt.resolvedUrl("favicon-single.html") }, + { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html") }, + { tag: "unavailable", url: Qt.resolvedUrl("favicon-unavailable.html") }, + ]; + } + + function test_iconsDisabled(row) { + webEngineView.settings.autoLoadIconsForPage = false + webEngineView.profile = defaultProfile + compare(iconChangedSpy.count, 0) + + webEngineView.url = row.url + verify(webEngineView.waitForLoadSucceeded()) + + compare(iconChangedSpy.count, 0) + + var iconUrl = webEngineView.icon + compare(iconUrl, Qt.resolvedUrl("")) + } + + function test_touchIconsEnabled_data() { + return [ + { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") }, + { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") }, + { tag: "single", url: Qt.resolvedUrl("favicon-single.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt32.ico") }, + { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") }, + ]; + } + + function test_touchIconsEnabled(row) { + webEngineView.settings.touchIconsEnabled = true + webEngineView.profile = defaultProfile + compare(iconChangedSpy.count, 0) + + webEngineView.url = row.url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + var iconUrl = removeFaviconProviderPrefix(webEngineView.icon) + compare(iconUrl, row.expectedIconUrl) + } } } diff --git a/tests/auto/quick/qmltests/data/tst_faviconDownload.qml b/tests/auto/quick/qmltests/data/tst_faviconDownload.qml deleted file mode 100644 index 7d9c39814..000000000 --- a/tests/auto/quick/qmltests/data/tst_faviconDownload.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtTest 1.0 -import QtWebEngine 1.3 -import "../../qmltests/data" 1.0 - -TestWebEngineView { - id: webEngineView - width: 200 - height: 400 - - function removeFaviconProviderPrefix(url) { - return url.toString().substring(16) - } - - SignalSpy { - id: iconChangedSpy - target: webEngineView - signalName: "iconChanged" - } - - TestCase { - id: testCase - name: "WebEngineFaviconDownload" - - function init() { - WebEngine.settings.autoLoadIconsForPage = true - WebEngine.settings.touchIconsEnabled = false - - if (webEngineView.icon != '') { - // If this is not the first test, then load a blank page without favicon, restoring the initial state. - webEngineView.url = 'about:blank' - verify(webEngineView.waitForLoadSucceeded()) - iconChangedSpy.wait() - } - - iconChangedSpy.clear() - } - - function cleanupTestCase() { - WebEngine.settings.autoLoadIconsForPage = true - WebEngine.settings.touchIconsEnabled = false - } - - function test_downloadIconsDisabled_data() { - return [ - { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html") }, - { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html") }, - { tag: "single", url: Qt.resolvedUrl("favicon-single.html") }, - { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html") }, - { tag: "unavailable", url: Qt.resolvedUrl("favicon-unavailable.html") }, - ]; - } - - function test_downloadIconsDisabled(row) { - WebEngine.settings.autoLoadIconsForPage = false - - compare(iconChangedSpy.count, 0) - - webEngineView.url = row.url - verify(webEngineView.waitForLoadSucceeded()) - - compare(iconChangedSpy.count, 0) - - var iconUrl = webEngineView.icon - compare(iconUrl, Qt.resolvedUrl("")) - } - - function test_downloadTouchIconsEnabled_data() { - return [ - { tag: "misc", url: Qt.resolvedUrl("favicon-misc.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") }, - { tag: "shortcut", url: Qt.resolvedUrl("favicon-shortcut.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") }, - { tag: "single", url: Qt.resolvedUrl("favicon-single.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt32.ico") }, - { tag: "touch", url: Qt.resolvedUrl("favicon-touch.html"), expectedIconUrl: Qt.resolvedUrl("icons/qt144.png") }, - ]; - } - - function test_downloadTouchIconsEnabled(row) { - WebEngine.settings.touchIconsEnabled = true - - compare(iconChangedSpy.count, 0) - - webEngineView.url = row.url - verify(webEngineView.waitForLoadSucceeded()) - - iconChangedSpy.wait() - compare(iconChangedSpy.count, 1) - - var iconUrl = removeFaviconProviderPrefix(webEngineView.icon) - compare(iconUrl, row.expectedIconUrl) - } - } -} - diff --git a/tests/auto/widgets/CMakeLists.txt b/tests/auto/widgets/CMakeLists.txt index 7072329c3..f7955b1f8 100644 --- a/tests/auto/widgets/CMakeLists.txt +++ b/tests/auto/widgets/CMakeLists.txt @@ -5,7 +5,7 @@ if(NOT boot2qt) add_subdirectory(qwebengineprofile) add_subdirectory(qwebengineview) endif() -add_subdirectory(faviconmanager) +add_subdirectory(favicon) add_subdirectory(loadsignals) add_subdirectory(origins) add_subdirectory(proxy) diff --git a/tests/auto/widgets/favicon/CMakeLists.txt b/tests/auto/widgets/favicon/CMakeLists.txt new file mode 100644 index 000000000..64c4efc91 --- /dev/null +++ b/tests/auto/widgets/favicon/CMakeLists.txt @@ -0,0 +1,29 @@ +include(../../util/util.cmake) + +qt_internal_add_test(tst_favicon + SOURCES + tst_favicon.cpp + LIBRARIES + Qt::WebEngineWidgets + Test::Util +) + +set(tst_favicon_resource_files + "resources/favicon-misc.html" + "resources/favicon-multi.html" + "resources/favicon-shortcut.html" + "resources/favicon-single.html" + "resources/favicon-touch.html" + "resources/favicon-unavailable.html" + "resources/icons/qt144.png" + "resources/icons/qt32.ico" + "resources/icons/qtmulti.ico" + "resources/test1.html" +) + +qt_add_resource(tst_favicon "tst_favicon" + PREFIX + "/" + FILES + ${tst_favicon_resource_files} +) diff --git a/tests/auto/widgets/favicon/favicon.pro b/tests/auto/widgets/favicon/favicon.pro new file mode 100644 index 000000000..e99c7f493 --- /dev/null +++ b/tests/auto/widgets/favicon/favicon.pro @@ -0,0 +1 @@ +include(../tests.pri) diff --git a/tests/auto/widgets/favicon/resources/favicon-misc.html b/tests/auto/widgets/favicon/resources/favicon-misc.html new file mode 100644 index 000000000..ea587886f --- /dev/null +++ b/tests/auto/widgets/favicon/resources/favicon-misc.html @@ -0,0 +1,11 @@ + + + Favicon Test + + + + + +

Favicon Test

+ + diff --git a/tests/auto/widgets/favicon/resources/favicon-multi.html b/tests/auto/widgets/favicon/resources/favicon-multi.html new file mode 100644 index 000000000..56eeca8c4 --- /dev/null +++ b/tests/auto/widgets/favicon/resources/favicon-multi.html @@ -0,0 +1,9 @@ + + + Multi-sized Favicon Test + + + +

Multi-sized Favicon Test

+ + diff --git a/tests/auto/widgets/favicon/resources/favicon-shortcut.html b/tests/auto/widgets/favicon/resources/favicon-shortcut.html new file mode 100644 index 000000000..786cdb816 --- /dev/null +++ b/tests/auto/widgets/favicon/resources/favicon-shortcut.html @@ -0,0 +1,10 @@ + + + Favicon Test + + + + +

Favicon Test

+ + diff --git a/tests/auto/widgets/favicon/resources/favicon-single.html b/tests/auto/widgets/favicon/resources/favicon-single.html new file mode 100644 index 000000000..eb4675c75 --- /dev/null +++ b/tests/auto/widgets/favicon/resources/favicon-single.html @@ -0,0 +1,9 @@ + + + Favicon Test + + + +

Favicon Test

+ + diff --git a/tests/auto/widgets/favicon/resources/favicon-touch.html b/tests/auto/widgets/favicon/resources/favicon-touch.html new file mode 100644 index 000000000..271783434 --- /dev/null +++ b/tests/auto/widgets/favicon/resources/favicon-touch.html @@ -0,0 +1,10 @@ + + + Favicon Test + + + + +

Favicon Test

+ + diff --git a/tests/auto/widgets/favicon/resources/favicon-unavailable.html b/tests/auto/widgets/favicon/resources/favicon-unavailable.html new file mode 100644 index 000000000..c45664294 --- /dev/null +++ b/tests/auto/widgets/favicon/resources/favicon-unavailable.html @@ -0,0 +1,9 @@ + + + Favicon Test + + + +

Favicon Test

+ + diff --git a/tests/auto/widgets/favicon/resources/icons/qt144.png b/tests/auto/widgets/favicon/resources/icons/qt144.png new file mode 100644 index 000000000..050b1e066 Binary files /dev/null and b/tests/auto/widgets/favicon/resources/icons/qt144.png differ diff --git a/tests/auto/widgets/favicon/resources/icons/qt32.ico b/tests/auto/widgets/favicon/resources/icons/qt32.ico new file mode 100644 index 000000000..2f6fcb5bc Binary files /dev/null and b/tests/auto/widgets/favicon/resources/icons/qt32.ico differ diff --git a/tests/auto/widgets/favicon/resources/icons/qtmulti.ico b/tests/auto/widgets/favicon/resources/icons/qtmulti.ico new file mode 100644 index 000000000..81e5a22e8 Binary files /dev/null and b/tests/auto/widgets/favicon/resources/icons/qtmulti.ico differ diff --git a/tests/auto/widgets/favicon/resources/test1.html b/tests/auto/widgets/favicon/resources/test1.html new file mode 100644 index 000000000..b323f966e --- /dev/null +++ b/tests/auto/widgets/favicon/resources/test1.html @@ -0,0 +1 @@ +

Some text 1

diff --git a/tests/auto/widgets/favicon/tst_favicon.cpp b/tests/auto/widgets/favicon/tst_favicon.cpp new file mode 100644 index 000000000..377699aaa --- /dev/null +++ b/tests/auto/widgets/favicon/tst_favicon.cpp @@ -0,0 +1,565 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include +#include + +class tst_Favicon : public QObject +{ + Q_OBJECT + +public Q_SLOTS: + void init(); + void initTestCase(); + void cleanupTestCase(); + void cleanup(); + +private Q_SLOTS: + void faviconLoad(); + void faviconLoadFromResources(); + void faviconLoadEncodedUrl(); + void faviconLoadAfterHistoryNavigation(); + void noFavicon(); + void aboutBlank(); + void unavailableFavicon(); + void errorPageEnabled(); + void errorPageDisabled(); + void touchIcon(); + void multiIcon(); + void downloadIconsDisabled_data(); + void downloadIconsDisabled(); + void downloadTouchIconsEnabled_data(); + void downloadTouchIconsEnabled(); + void dynamicFavicon(); + void touchIconWithSameURL(); + +private: + QWebEngineView *m_view; + QWebEnginePage *m_page; + QWebEngineProfile *m_profile; +}; + +void tst_Favicon::init() +{ + m_profile = new QWebEngineProfile(this); + m_view = new QWebEngineView(); + m_page = new QWebEnginePage(m_profile, m_view); + m_view->setPage(m_page); +} + +void tst_Favicon::initTestCase() { } + +void tst_Favicon::cleanupTestCase() { } + +void tst_Favicon::cleanup() +{ + delete m_view; + delete m_profile; +} + +void tst_Favicon::faviconLoad() +{ + if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'") + .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) + .toLatin1() + .constData(), + SkipAll); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/favicon-single.html")); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); + QCOMPARE(iconUrl, m_page->iconUrl()); + QCOMPARE(iconUrl, + QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/icons/qt32.ico"))); + + const QIcon &icon = m_page->icon(); + QVERIFY(!icon.isNull()); + + QCOMPARE(icon.availableSizes().count(), 2); + QVERIFY(icon.availableSizes().contains(QSize(16, 16))); + QVERIFY(icon.availableSizes().contains(QSize(32, 32))); +} + +void tst_Favicon::faviconLoadFromResources() +{ + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url("qrc:/resources/favicon-single.html"); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); + QCOMPARE(iconUrl, m_page->iconUrl()); + QCOMPARE(iconUrl, QUrl("qrc:/resources/icons/qt32.ico")); + + const QIcon &icon = m_page->icon(); + QVERIFY(!icon.isNull()); + + QCOMPARE(icon.availableSizes().count(), 2); + QVERIFY(icon.availableSizes().contains(QSize(16, 16))); + QVERIFY(icon.availableSizes().contains(QSize(32, 32))); +} + +void tst_Favicon::faviconLoadEncodedUrl() +{ + if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'") + .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) + .toLatin1() + .constData(), + SkipAll); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QString urlString = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/favicon-single.html")) + .toString(); + QUrl url(urlString + QLatin1String("?favicon=load should work with#whitespace!")); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); + QCOMPARE(m_page->iconUrl(), iconUrl); + QCOMPARE(iconUrl, + QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/icons/qt32.ico"))); + + const QIcon &icon = m_page->icon(); + QVERIFY(!icon.isNull()); + + QCOMPARE(icon.availableSizes().count(), 2); + QVERIFY(icon.availableSizes().contains(QSize(16, 16))); + QVERIFY(icon.availableSizes().contains(QSize(32, 32))); +} + +void tst_Favicon::faviconLoadAfterHistoryNavigation() +{ + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + m_page->load(QUrl("qrc:/resources/favicon-single.html")); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE(iconChangedSpy.count(), 1); + QCOMPARE(m_page->iconUrl(), QUrl("qrc:/resources/icons/qt32.ico")); + + m_page->load(QUrl("qrc:/resources/favicon-multi.html")); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 2, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 3); + QTRY_COMPARE(iconChangedSpy.count(), 3); + QCOMPARE(m_page->iconUrl(), QUrl("qrc:/resources/icons/qtmulti.ico")); + + m_page->triggerAction(QWebEnginePage::Back); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 3, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 5); + QTRY_COMPARE(iconChangedSpy.count(), 5); + QCOMPARE(m_page->iconUrl(), QUrl("qrc:/resources/icons/qt32.ico")); + + m_page->triggerAction(QWebEnginePage::Forward); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 4, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 7); + QTRY_COMPARE(iconChangedSpy.count(), 7); + QCOMPARE(m_page->iconUrl(), QUrl("qrc:/resources/icons/qtmulti.ico")); +} + +void tst_Favicon::noFavicon() +{ + if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'") + .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) + .toLatin1() + .constData(), + SkipAll); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/test1.html")); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QCOMPARE(iconUrlChangedSpy.count(), 0); + QCOMPARE(iconChangedSpy.count(), 0); + + QVERIFY(m_page->iconUrl().isEmpty()); + QVERIFY(m_page->icon().isNull()); +} + +void tst_Favicon::aboutBlank() +{ + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url("about:blank"); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QCOMPARE(iconUrlChangedSpy.count(), 0); + QCOMPARE(iconChangedSpy.count(), 0); + + QVERIFY(m_page->iconUrl().isEmpty()); + QVERIFY(m_page->icon().isNull()); +} + +void tst_Favicon::unavailableFavicon() +{ + if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'") + .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) + .toLatin1() + .constData(), + SkipAll); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/favicon-unavailable.html")); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QCOMPARE(iconUrlChangedSpy.count(), 0); + QCOMPARE(iconChangedSpy.count(), 0); + + QVERIFY(m_page->iconUrl().isEmpty()); + QVERIFY(m_page->icon().isNull()); +} + +void tst_Favicon::errorPageEnabled() +{ + m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url("http://url.invalid"); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QCOMPARE(iconUrlChangedSpy.count(), 0); + QCOMPARE(iconChangedSpy.count(), 0); + + QVERIFY(m_page->iconUrl().isEmpty()); + QVERIFY(m_page->icon().isNull()); +} + +void tst_Favicon::errorPageDisabled() +{ + m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url("http://url.invalid"); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QCOMPARE(iconUrlChangedSpy.count(), 0); + QCOMPARE(iconChangedSpy.count(), 0); + + QVERIFY(m_page->iconUrl().isEmpty()); + QVERIFY(m_page->icon().isNull()); +} + +void tst_Favicon::touchIcon() +{ + if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'") + .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) + .toLatin1() + .constData(), + SkipAll); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/favicon-touch.html")); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QCOMPARE(iconUrlChangedSpy.count(), 0); + QCOMPARE(iconChangedSpy.count(), 0); + + QVERIFY(m_page->iconUrl().isEmpty()); + QVERIFY(m_page->icon().isNull()); +} + +void tst_Favicon::multiIcon() +{ + if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'") + .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) + .toLatin1() + .constData(), + SkipAll); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/favicon-multi.html")); + QUrl iconUrl; + QIcon icon; + + // If touch icons are disabled, the favicon is provided in two sizes (16x16 and 32x32) according + // to the supported scale factors (100P, 200P). + m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, false); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); + QCOMPARE(m_page->iconUrl(), iconUrl); + QCOMPARE(iconUrl, + QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/icons/qtmulti.ico"))); + + icon = m_page->icon(); + QVERIFY(!icon.isNull()); + QCOMPARE(icon.availableSizes().count(), 2); + QVERIFY(icon.availableSizes().contains(QSize(16, 16))); + QVERIFY(icon.availableSizes().contains(QSize(32, 32))); + + // Reset + loadFinishedSpy.clear(); + m_page->load(QUrl("about:blank")); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + iconUrlChangedSpy.clear(); + iconChangedSpy.clear(); + loadFinishedSpy.clear(); + icon = QIcon(); + + // If touch icons are enabled, the largest icon is provided. + m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, true); + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); + QCOMPARE(m_page->iconUrl(), iconUrl); + QCOMPARE(iconUrl, + QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + + QLatin1String("/resources/icons/qtmulti.ico"))); + + icon = m_page->icon(); + QVERIFY(!icon.isNull()); + QCOMPARE(icon.availableSizes().count(), 1); + QVERIFY(icon.availableSizes().contains(QSize(64, 64))); +} + +void tst_Favicon::downloadIconsDisabled_data() +{ + QTest::addColumn("url"); + QTest::newRow("misc") << QUrl("qrc:/resources/favicon-misc.html"); + QTest::newRow("shortcut") << QUrl("qrc:/resources/favicon-shortcut.html"); + QTest::newRow("single") << QUrl("qrc:/resources/favicon-single.html"); + QTest::newRow("touch") << QUrl("qrc:/resources/favicon-touch.html"); + QTest::newRow("unavailable") << QUrl("qrc:/resources/favicon-unavailable.html"); +} + +void tst_Favicon::downloadIconsDisabled() +{ + QFETCH(QUrl, url); + + m_page->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QCOMPARE(iconUrlChangedSpy.count(), 0); + QCOMPARE(iconChangedSpy.count(), 0); + + QVERIFY(m_page->iconUrl().isEmpty()); + QVERIFY(m_page->icon().isNull()); +} + +void tst_Favicon::downloadTouchIconsEnabled_data() +{ + QTest::addColumn("url"); + QTest::addColumn("expectedIconUrl"); + QTest::addColumn("expectedIconSize"); + QTest::newRow("misc") << QUrl("qrc:/resources/favicon-misc.html") + << QUrl("qrc:/resources/icons/qt144.png") << QSize(144, 144); + QTest::newRow("shortcut") << QUrl("qrc:/resources/favicon-shortcut.html") + << QUrl("qrc:/resources/icons/qt144.png") << QSize(144, 144); + QTest::newRow("single") << QUrl("qrc:/resources/favicon-single.html") + << QUrl("qrc:/resources/icons/qt32.ico") << QSize(32, 32); + QTest::newRow("touch") << QUrl("qrc:/resources/favicon-touch.html") + << QUrl("qrc:/resources/icons/qt144.png") << QSize(144, 144); +} + +void tst_Favicon::downloadTouchIconsEnabled() +{ + QFETCH(QUrl, url); + QFETCH(QUrl, expectedIconUrl); + QFETCH(QSize, expectedIconSize); + + m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, true); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + m_page->load(url); + + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + const QUrl &iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); + QCOMPARE(m_page->iconUrl(), iconUrl); + QCOMPARE(iconUrl, expectedIconUrl); + + const QIcon &icon = m_page->icon(); + QVERIFY(!icon.isNull()); + + QCOMPARE(icon.availableSizes().count(), 1); + QCOMPARE(icon.availableSizes().first(), expectedIconSize); +} + +void tst_Favicon::dynamicFavicon() +{ + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + QMap colors; + colors.insert(Qt::red, + QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==")); + colors.insert(Qt::green, + QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg==")); + colors.insert(Qt::blue, + QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg==")); + + m_page->setHtml("" + "" + ""); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + QCOMPARE(m_page->icon().pixmap(1, 1).toImage().pixelColor(0, 0), QColor(Qt::black)); + + for (Qt::GlobalColor color : colors.keys()) { + iconChangedSpy.clear(); + evaluateJavaScriptSync( + m_page, + "document.getElementsByTagName('link')[0].href = 'data:image/png;base64," + colors[color] + "';"); + QTRY_COMPARE(iconChangedSpy.count(), 1); + QTRY_COMPARE(m_page->iconUrl().toString(), + QString("data:image/png;base64," + colors[color])); + QCOMPARE(m_page->icon().pixmap(1, 1).toImage().pixelColor(0, 0), QColor(color)); + } +} + +void tst_Favicon::touchIconWithSameURL() +{ + m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, false); + + const QString icon("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="); + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + m_page->setHtml("" + "" + "" + ""); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); + + // The default favicon has to be loaded even if its URL is also set as a touch icon while touch + // icons are disabled. + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QCOMPARE(m_page->iconUrl().toString(), icon); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + loadFinishedSpy.clear(); + iconUrlChangedSpy.clear(); + iconChangedSpy.clear(); + + m_page->setHtml("" + "" + ""); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + // This page only has a touch icon. With disabled touch icons we don't expect any icon to be + // shown even if the same icon was loaded previously. + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QVERIFY(m_page->iconUrl().toString().isEmpty()); + QTRY_COMPARE(iconChangedSpy.count(), 1); +} + +QTEST_MAIN(tst_Favicon) + +#include "tst_favicon.moc" diff --git a/tests/auto/widgets/favicon/tst_favicon.qrc b/tests/auto/widgets/favicon/tst_favicon.qrc new file mode 100644 index 000000000..a352f8a83 --- /dev/null +++ b/tests/auto/widgets/favicon/tst_favicon.qrc @@ -0,0 +1,14 @@ + + + resources/favicon-misc.html + resources/favicon-multi.html + resources/favicon-shortcut.html + resources/favicon-single.html + resources/favicon-touch.html + resources/favicon-unavailable.html + resources/icons/qt144.png + resources/icons/qt32.ico + resources/icons/qtmulti.ico + resources/test1.html + + diff --git a/tests/auto/widgets/faviconmanager/CMakeLists.txt b/tests/auto/widgets/faviconmanager/CMakeLists.txt deleted file mode 100644 index 89bee5a2a..000000000 --- a/tests/auto/widgets/faviconmanager/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -include(../../util/util.cmake) - -qt_internal_add_test(tst_faviconmanager - SOURCES - tst_faviconmanager.cpp - LIBRARIES - Qt::WebEngineWidgets - Test::Util -) - -set(tst_faviconmanager_resource_files - "resources/favicon-misc.html" - "resources/favicon-multi.html" - "resources/favicon-shortcut.html" - "resources/favicon-single.html" - "resources/favicon-touch.html" - "resources/favicon-unavailable.html" - "resources/icons/qt144.png" - "resources/icons/qt32.ico" - "resources/icons/qtmulti.ico" - "resources/test1.html" -) - -qt_add_resource(tst_faviconmanager "tst_faviconmanager" - PREFIX - "/" - FILES - ${tst_faviconmanager_resource_files} -) diff --git a/tests/auto/widgets/faviconmanager/faviconmanager.pro b/tests/auto/widgets/faviconmanager/faviconmanager.pro deleted file mode 100644 index e99c7f493..000000000 --- a/tests/auto/widgets/faviconmanager/faviconmanager.pro +++ /dev/null @@ -1 +0,0 @@ -include(../tests.pri) diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-misc.html b/tests/auto/widgets/faviconmanager/resources/favicon-misc.html deleted file mode 100644 index 9e788bdf4..000000000 --- a/tests/auto/widgets/faviconmanager/resources/favicon-misc.html +++ /dev/null @@ -1,11 +0,0 @@ - - - Favicon Test - - - - - -

Favicon Test

- - diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-multi.html b/tests/auto/widgets/faviconmanager/resources/favicon-multi.html deleted file mode 100644 index cc5f3fd66..000000000 --- a/tests/auto/widgets/faviconmanager/resources/favicon-multi.html +++ /dev/null @@ -1,9 +0,0 @@ - - - Multi-sized Favicon Test - - - -

Multi-sized Favicon Test

- - diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-shortcut.html b/tests/auto/widgets/faviconmanager/resources/favicon-shortcut.html deleted file mode 100644 index 786cdb816..000000000 --- a/tests/auto/widgets/faviconmanager/resources/favicon-shortcut.html +++ /dev/null @@ -1,10 +0,0 @@ - - - Favicon Test - - - - -

Favicon Test

- - diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-single.html b/tests/auto/widgets/faviconmanager/resources/favicon-single.html deleted file mode 100644 index eb4675c75..000000000 --- a/tests/auto/widgets/faviconmanager/resources/favicon-single.html +++ /dev/null @@ -1,9 +0,0 @@ - - - Favicon Test - - - -

Favicon Test

- - diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-touch.html b/tests/auto/widgets/faviconmanager/resources/favicon-touch.html deleted file mode 100644 index 271783434..000000000 --- a/tests/auto/widgets/faviconmanager/resources/favicon-touch.html +++ /dev/null @@ -1,10 +0,0 @@ - - - Favicon Test - - - - -

Favicon Test

- - diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-unavailable.html b/tests/auto/widgets/faviconmanager/resources/favicon-unavailable.html deleted file mode 100644 index c45664294..000000000 --- a/tests/auto/widgets/faviconmanager/resources/favicon-unavailable.html +++ /dev/null @@ -1,9 +0,0 @@ - - - Favicon Test - - - -

Favicon Test

- - diff --git a/tests/auto/widgets/faviconmanager/resources/icons/qt144.png b/tests/auto/widgets/faviconmanager/resources/icons/qt144.png deleted file mode 100644 index 050b1e066..000000000 Binary files a/tests/auto/widgets/faviconmanager/resources/icons/qt144.png and /dev/null differ diff --git a/tests/auto/widgets/faviconmanager/resources/icons/qt32.ico b/tests/auto/widgets/faviconmanager/resources/icons/qt32.ico deleted file mode 100644 index 2f6fcb5bc..000000000 Binary files a/tests/auto/widgets/faviconmanager/resources/icons/qt32.ico and /dev/null differ diff --git a/tests/auto/widgets/faviconmanager/resources/icons/qtmulti.ico b/tests/auto/widgets/faviconmanager/resources/icons/qtmulti.ico deleted file mode 100644 index 81e5a22e8..000000000 Binary files a/tests/auto/widgets/faviconmanager/resources/icons/qtmulti.ico and /dev/null differ diff --git a/tests/auto/widgets/faviconmanager/resources/test1.html b/tests/auto/widgets/faviconmanager/resources/test1.html deleted file mode 100644 index b323f966e..000000000 --- a/tests/auto/widgets/faviconmanager/resources/test1.html +++ /dev/null @@ -1 +0,0 @@ -

Some text 1

diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp deleted file mode 100644 index 8e9bb2470..000000000 --- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include -#include - - -class tst_FaviconManager : public QObject { - Q_OBJECT - -public Q_SLOTS: - void init(); - void initTestCase(); - void cleanupTestCase(); - void cleanup(); - -private Q_SLOTS: - void faviconLoad(); - void faviconLoadFromResources(); - void faviconLoadEncodedUrl(); - void noFavicon(); - void aboutBlank(); - void unavailableFavicon(); - void errorPageEnabled(); - void errorPageDisabled(); - void bestFavicon(); - void touchIcon(); - void multiIcon(); - void candidateIcon(); - void downloadIconsDisabled_data(); - void downloadIconsDisabled(); - void downloadTouchIconsEnabled_data(); - void downloadTouchIconsEnabled(); - void dynamicFavicon(); - void touchIconWithSameURL(); - -private: - QWebEngineView *m_view; - QWebEnginePage *m_page; - QWebEngineProfile *m_profile; -}; - - -void tst_FaviconManager::init() -{ - m_profile = new QWebEngineProfile(this); - m_view = new QWebEngineView(); - m_page = new QWebEnginePage(m_profile, m_view); - m_view->setPage(m_page); -} - - -void tst_FaviconManager::initTestCase() -{ -} - -void tst_FaviconManager::cleanupTestCase() -{ -} - - -void tst_FaviconManager::cleanup() -{ - delete m_view; - delete m_profile; -} - -void tst_FaviconManager::faviconLoad() -{ - if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'") - .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) - .toLatin1() - .constData(), - SkipAll); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/favicon-single.html")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); - QCOMPARE(iconUrl, m_page->iconUrl()); - QCOMPARE(iconUrl, - QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/icons/qt32.ico"))); - - const QIcon &icon = m_page->icon(); - QVERIFY(!icon.isNull()); - - QCOMPARE(icon.availableSizes().count(), 1); - QSize iconSize = icon.availableSizes().first(); - QCOMPARE(iconSize, QSize(32, 32)); -} - -void tst_FaviconManager::faviconLoadFromResources() -{ - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url("qrc:/resources/favicon-single.html"); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); - QCOMPARE(iconUrl, m_page->iconUrl()); - QCOMPARE(iconUrl, QUrl("qrc:/resources/icons/qt32.ico")); - - const QIcon &icon = m_page->icon(); - QVERIFY(!icon.isNull()); - - QCOMPARE(icon.availableSizes().count(), 1); - QSize iconSize = icon.availableSizes().first(); - QCOMPARE(iconSize, QSize(32, 32)); -} - -void tst_FaviconManager::faviconLoadEncodedUrl() -{ - if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'") - .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) - .toLatin1() - .constData(), - SkipAll); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QString urlString = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/favicon-single.html")) - .toString(); - QUrl url(urlString + QLatin1String("?favicon=load should work with#whitespace!")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); - QCOMPARE(m_page->iconUrl(), iconUrl); - QCOMPARE(iconUrl, - QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/icons/qt32.ico"))); - - const QIcon &icon = m_page->icon(); - QVERIFY(!icon.isNull()); - - QCOMPARE(icon.availableSizes().count(), 1); - QSize iconSize = icon.availableSizes().first(); - QCOMPARE(iconSize, QSize(32, 32)); -} - -void tst_FaviconManager::noFavicon() -{ - if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'") - .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) - .toLatin1() - .constData(), - SkipAll); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/test1.html")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QCOMPARE(iconUrlChangedSpy.count(), 0); - QCOMPARE(iconChangedSpy.count(), 0); - - QVERIFY(m_page->iconUrl().isEmpty()); - QVERIFY(m_page->icon().isNull()); -} - -void tst_FaviconManager::aboutBlank() -{ - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url("about:blank"); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QCOMPARE(iconUrlChangedSpy.count(), 0); - QCOMPARE(iconChangedSpy.count(), 0); - - QVERIFY(m_page->iconUrl().isEmpty()); - QVERIFY(m_page->icon().isNull()); -} - -void tst_FaviconManager::unavailableFavicon() -{ - if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'") - .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) - .toLatin1() - .constData(), - SkipAll); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/favicon-unavailable.html")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QCOMPARE(iconUrlChangedSpy.count(), 0); - QCOMPARE(iconChangedSpy.count(), 0); - - QVERIFY(m_page->iconUrl().isEmpty()); - QVERIFY(m_page->icon().isNull()); -} - -void tst_FaviconManager::errorPageEnabled() -{ - m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url("http://url.invalid"); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QCOMPARE(iconUrlChangedSpy.count(), 0); - QCOMPARE(iconChangedSpy.count(), 0); - - QVERIFY(m_page->iconUrl().isEmpty()); - QVERIFY(m_page->icon().isNull()); -} - -void tst_FaviconManager::errorPageDisabled() -{ - m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url("http://url.invalid"); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QCOMPARE(iconUrlChangedSpy.count(), 0); - QCOMPARE(iconChangedSpy.count(), 0); - - QVERIFY(m_page->iconUrl().isEmpty()); - QVERIFY(m_page->icon().isNull()); -} - -void tst_FaviconManager::bestFavicon() -{ - if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'") - .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) - .toLatin1() - .constData(), - SkipAll); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url, iconUrl; - QIcon icon; - QSize iconSize; - - url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/favicon-misc.html")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); - QCOMPARE(iconUrl, m_page->iconUrl()); - // Touch icon is ignored - QCOMPARE(iconUrl, - QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/icons/qt32.ico"))); - - icon = m_page->icon(); - QVERIFY(!icon.isNull()); - - QCOMPARE(icon.availableSizes().count(), 1); - iconSize = icon.availableSizes().first(); - QCOMPARE(iconSize, QSize(32, 32)); - - loadFinishedSpy.clear(); - iconUrlChangedSpy.clear(); - iconChangedSpy.clear(); - - url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/favicon-shortcut.html")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_VERIFY(iconUrlChangedSpy.count() >= 1); - QTRY_VERIFY(iconChangedSpy.count() >= 1); - - iconUrl = iconUrlChangedSpy.last().at(0).toString(); - - // If the icon URL is empty we have to wait for - // the second iconChanged signal that propagates the expected URL - if (iconUrl.isEmpty()) { - QTRY_COMPARE(iconUrlChangedSpy.count(), 2); - QTRY_COMPARE(iconChangedSpy.count(), 2); - iconUrl = iconUrlChangedSpy.last().at(0).toString(); - } - - QCOMPARE(iconUrl, m_page->iconUrl()); - QCOMPARE(iconUrl, - QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/icons/qt144.png"))); - - icon = m_page->icon(); - QVERIFY(!icon.isNull()); - - QVERIFY(icon.availableSizes().count() >= 1); - QVERIFY(icon.availableSizes().contains(QSize(144, 144))); -} - -void tst_FaviconManager::touchIcon() -{ - if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'") - .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) - .toLatin1() - .constData(), - SkipAll); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/favicon-touch.html")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QCOMPARE(iconUrlChangedSpy.count(), 0); - QCOMPARE(iconChangedSpy.count(), 0); - - QVERIFY(m_page->iconUrl().isEmpty()); - QVERIFY(m_page->icon().isNull()); -} - -void tst_FaviconManager::multiIcon() -{ - if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'") - .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) - .toLatin1() - .constData(), - SkipAll); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/favicon-multi.html")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); - QCOMPARE(m_page->iconUrl(), iconUrl); - QCOMPARE(iconUrl, - QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/icons/qtmulti.ico"))); - - const QIcon &icon = m_page->icon(); - QVERIFY(!icon.isNull()); - QCOMPARE(icon.availableSizes().count(), 3); - QVERIFY(icon.availableSizes().contains(QSize(16, 16))); - QVERIFY(icon.availableSizes().contains(QSize(32, 32))); - QVERIFY(icon.availableSizes().contains(QSize(64, 64))); -} - -void tst_FaviconManager::candidateIcon() -{ - if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists()) - W_QSKIP(QString("This test requires access to resources found in '%1'") - .arg(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()) - .toLatin1() - .constData(), - SkipAll); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/favicon-shortcut.html")); - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); - QCOMPARE(m_page->iconUrl(), iconUrl); - QCOMPARE(iconUrl, - QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() - + QLatin1String("/resources/icons/qt144.png"))); - - const QIcon &icon = m_page->icon(); - QVERIFY(!icon.isNull()); - QCOMPARE(icon.availableSizes().count(), 2); - QVERIFY(icon.availableSizes().contains(QSize(32, 32))); - QVERIFY(icon.availableSizes().contains(QSize(144, 144))); -} - -void tst_FaviconManager::downloadIconsDisabled_data() -{ - QTest::addColumn("url"); - QTest::newRow("misc") << QUrl("qrc:/resources/favicon-misc.html"); - QTest::newRow("shortcut") << QUrl("qrc:/resources/favicon-shortcut.html"); - QTest::newRow("single") << QUrl("qrc:/resources/favicon-single.html"); - QTest::newRow("touch") << QUrl("qrc:/resources/favicon-touch.html"); - QTest::newRow("unavailable") << QUrl("qrc:/resources/favicon-unavailable.html"); -} - -void tst_FaviconManager::downloadIconsDisabled() -{ - QFETCH(QUrl, url); - - m_page->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QCOMPARE(iconUrlChangedSpy.count(), 0); - QCOMPARE(iconChangedSpy.count(), 0); - - QVERIFY(m_page->iconUrl().isEmpty()); - QVERIFY(m_page->icon().isNull()); -} - -void tst_FaviconManager::downloadTouchIconsEnabled_data() -{ - QTest::addColumn("url"); - QTest::addColumn("expectedIconUrl"); - QTest::addColumn("expectedIconSize"); - QTest::newRow("misc") << QUrl("qrc:/resources/favicon-misc.html") << QUrl("qrc:/resources/icons/qt144.png") << QSize(144, 144); - QTest::newRow("shortcut") << QUrl("qrc:/resources/favicon-shortcut.html") << QUrl("qrc:/resources/icons/qt144.png") << QSize(144, 144); - QTest::newRow("single") << QUrl("qrc:/resources/favicon-single.html") << QUrl("qrc:/resources/icons/qt32.ico") << QSize(32, 32); - QTest::newRow("touch") << QUrl("qrc:/resources/favicon-touch.html") << QUrl("qrc:/resources/icons/qt144.png") << QSize(144, 144); -} - -void tst_FaviconManager::downloadTouchIconsEnabled() -{ - QFETCH(QUrl, url); - QFETCH(QUrl, expectedIconUrl); - QFETCH(QSize, expectedIconSize); - - m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, true); - - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - m_page->load(url); - - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - const QUrl &iconUrl = iconUrlChangedSpy.at(0).at(0).toString(); - QCOMPARE(m_page->iconUrl(), iconUrl); - QCOMPARE(iconUrl, expectedIconUrl); - - const QIcon &icon = m_page->icon(); - QVERIFY(!icon.isNull()); - - QVERIFY(icon.availableSizes().count() >= 1); - QVERIFY(icon.availableSizes().contains(expectedIconSize)); -} - -void tst_FaviconManager::dynamicFavicon() -{ - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - QMap colors; - colors.insert(Qt::red, QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==")); - colors.insert(Qt::green, QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg==")); - colors.insert(Qt::blue, QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg==")); - - m_page->setHtml("" - "" - ""); - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - QCOMPARE(m_page->icon().pixmap(1, 1).toImage().pixelColor(0, 0), QColor(Qt::black)); - - for (Qt::GlobalColor color : colors.keys()) { - iconChangedSpy.clear(); - evaluateJavaScriptSync(m_page, "document.getElementsByTagName('link')[0].href = 'data:image/png;base64," + colors[color] + "';"); - QTRY_COMPARE(iconChangedSpy.count(), 1); - QTRY_COMPARE(m_page->iconUrl().toString(), QString("data:image/png;base64," + colors[color])); - QCOMPARE(m_page->icon().pixmap(1, 1).toImage().pixelColor(0, 0), QColor(color)); - } -} - -void tst_FaviconManager::touchIconWithSameURL() -{ - m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, false); - - const QString icon("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="); - QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); - QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); - QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); - - m_page->setHtml("" - "" - "" - ""); - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000); - - // The default favicon has to be loaded even if its URL is also set as a touch icon while touch icons are disabled. - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QCOMPARE(m_page->iconUrl().toString(), icon); - QTRY_COMPARE(iconChangedSpy.count(), 1); - - loadFinishedSpy.clear(); - iconUrlChangedSpy.clear(); - iconChangedSpy.clear(); - - m_page->setHtml("" - "" - ""); - QTRY_COMPARE(loadFinishedSpy.count(), 1); - - // This page only has a touch icon. With disabled touch icons we don't expect any icon to be shown even if the same icon - // was loaded previously. - QTRY_COMPARE(iconUrlChangedSpy.count(), 1); - QVERIFY(m_page->iconUrl().toString().isEmpty()); - QTRY_COMPARE(iconChangedSpy.count(), 1); - -} - -QTEST_MAIN(tst_FaviconManager) - -#include "tst_faviconmanager.moc" diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.qrc b/tests/auto/widgets/faviconmanager/tst_faviconmanager.qrc deleted file mode 100644 index a352f8a83..000000000 --- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.qrc +++ /dev/null @@ -1,14 +0,0 @@ - - - resources/favicon-misc.html - resources/favicon-multi.html - resources/favicon-shortcut.html - resources/favicon-single.html - resources/favicon-touch.html - resources/favicon-unavailable.html - resources/icons/qt144.png - resources/icons/qt32.ico - resources/icons/qtmulti.ico - resources/test1.html - - diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 432a91224..170afaafc 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -311,7 +311,8 @@ void tst_QWebEngineView::changePage() if (!fromIsNullPage) { QVERIFY(!pageFrom->iconUrl().isEmpty()); QCOMPARE(spyIconUrl.last().value(0).toUrl(), pageFrom->iconUrl()); - QCOMPARE(spyIcon.last().value(0).value(), pageFrom->icon()); + QCOMPARE(spyIcon.last().value(0).value().availableSizes(), + pageFrom->icon().availableSizes()); } QScopedPointer pageTo(new QWebEnginePage); @@ -340,7 +341,8 @@ void tst_QWebEngineView::changePage() QCOMPARE(pageFrom->iconUrl() == pageTo->iconUrl(), iconIsSame); if (!iconIsSame) { QCOMPARE(spyIconUrl.last().value(0).toUrl(), pageTo->iconUrl()); - QCOMPARE(spyIcon.last().value(0).value(), pageTo->icon()); + QCOMPARE(spyIcon.last().value(0).value().availableSizes(), + pageTo->icon().availableSizes()); } // verify no emits on destroy with the same number of signals in spy -- cgit v1.2.3