summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2020-06-19 11:17:50 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-06-04 18:41:41 +0200
commit881339e9d9054c46f2621119246de7a13c83761a (patch)
tree77db7d7188c4ac61cab939c2ccd7a9610d4a01f4 /tests
parent4d67b9f639114ddec0521980495ba27921800e39 (diff)
Replace FaviconManager with Chromium's Favicon Component
Task-number: QTBUG-51184 Change-Id: Ie050cb23f2c86841a66ec384bfbcdf0713cffa7c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp10
-rw-r--r--tests/auto/quick/qmltests/CMakeLists.txt3
-rw-r--r--tests/auto/quick/qmltests/data/favicon-misc.html4
-rw-r--r--tests/auto/quick/qmltests/data/tst_favicon.qml337
-rw-r--r--tests/auto/quick/qmltests/data/tst_faviconDownload.qml121
-rw-r--r--tests/auto/widgets/CMakeLists.txt2
-rw-r--r--tests/auto/widgets/favicon/CMakeLists.txt (renamed from tests/auto/widgets/faviconmanager/CMakeLists.txt)10
-rw-r--r--tests/auto/widgets/favicon/favicon.pro (renamed from tests/auto/widgets/faviconmanager/faviconmanager.pro)0
-rw-r--r--tests/auto/widgets/favicon/resources/favicon-misc.html (renamed from tests/auto/widgets/faviconmanager/resources/favicon-misc.html)4
-rw-r--r--tests/auto/widgets/favicon/resources/favicon-multi.html (renamed from tests/auto/widgets/faviconmanager/resources/favicon-multi.html)2
-rw-r--r--tests/auto/widgets/favicon/resources/favicon-shortcut.html (renamed from tests/auto/widgets/faviconmanager/resources/favicon-shortcut.html)0
-rw-r--r--tests/auto/widgets/favicon/resources/favicon-single.html (renamed from tests/auto/widgets/faviconmanager/resources/favicon-single.html)0
-rw-r--r--tests/auto/widgets/favicon/resources/favicon-touch.html (renamed from tests/auto/widgets/faviconmanager/resources/favicon-touch.html)0
-rw-r--r--tests/auto/widgets/favicon/resources/favicon-unavailable.html (renamed from tests/auto/widgets/faviconmanager/resources/favicon-unavailable.html)0
-rw-r--r--tests/auto/widgets/favicon/resources/icons/qt144.png (renamed from tests/auto/widgets/faviconmanager/resources/icons/qt144.png)bin8315 -> 8315 bytes
-rw-r--r--tests/auto/widgets/favicon/resources/icons/qt32.ico (renamed from tests/auto/widgets/faviconmanager/resources/icons/qt32.ico)bin4286 -> 4286 bytes
-rw-r--r--tests/auto/widgets/favicon/resources/icons/qtmulti.ico (renamed from tests/auto/widgets/faviconmanager/resources/icons/qtmulti.ico)bin22382 -> 22382 bytes
-rw-r--r--tests/auto/widgets/favicon/resources/test1.html (renamed from tests/auto/widgets/faviconmanager/resources/test1.html)0
-rw-r--r--tests/auto/widgets/favicon/tst_favicon.cpp (renamed from tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp)282
-rw-r--r--tests/auto/widgets/favicon/tst_favicon.qrc (renamed from tests/auto/widgets/faviconmanager/tst_faviconmanager.qrc)0
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp6
-rw-r--r--tests/manual/quick/faviconbrowser/AddressBar.qml102
-rw-r--r--tests/manual/quick/faviconbrowser/FaviconPanel.qml234
-rw-r--r--tests/manual/quick/faviconbrowser/faviconbrowser.pro23
-rw-r--r--tests/manual/quick/faviconbrowser/faviconbrowser.qrc17
-rw-r--r--tests/manual/quick/faviconbrowser/main.cpp54
-rw-r--r--tests/manual/quick/faviconbrowser/main.qml170
-rw-r--r--tests/manual/quick/faviconbrowser/utils.h49
28 files changed, 380 insertions, 1050 deletions
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 @@
<html>
<head>
<title>Favicon Test</title>
- <link rel="shortcut icon" href="icons/qt32.ico" />
- <link rel="apple-touch-icon" href="icons/qt144.png" />
+ <link rel="shortcut icon" href="icons/qt32.ico" sizes="32x32" />
+ <link rel="apple-touch-icon" href="icons/qt144.png" sizes="144x144"/>
<link rel="shortcut icon" href="icons/unavailable.ico" />
</head>
<body>
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/faviconmanager/CMakeLists.txt b/tests/auto/widgets/favicon/CMakeLists.txt
index 89bee5a2a..64c4efc91 100644
--- a/tests/auto/widgets/faviconmanager/CMakeLists.txt
+++ b/tests/auto/widgets/favicon/CMakeLists.txt
@@ -1,14 +1,14 @@
include(../../util/util.cmake)
-qt_internal_add_test(tst_faviconmanager
+qt_internal_add_test(tst_favicon
SOURCES
- tst_faviconmanager.cpp
+ tst_favicon.cpp
LIBRARIES
Qt::WebEngineWidgets
Test::Util
)
-set(tst_faviconmanager_resource_files
+set(tst_favicon_resource_files
"resources/favicon-misc.html"
"resources/favicon-multi.html"
"resources/favicon-shortcut.html"
@@ -21,9 +21,9 @@ set(tst_faviconmanager_resource_files
"resources/test1.html"
)
-qt_add_resource(tst_faviconmanager "tst_faviconmanager"
+qt_add_resource(tst_favicon "tst_favicon"
PREFIX
"/"
FILES
- ${tst_faviconmanager_resource_files}
+ ${tst_favicon_resource_files}
)
diff --git a/tests/auto/widgets/faviconmanager/faviconmanager.pro b/tests/auto/widgets/favicon/favicon.pro
index e99c7f493..e99c7f493 100644
--- a/tests/auto/widgets/faviconmanager/faviconmanager.pro
+++ b/tests/auto/widgets/favicon/favicon.pro
diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-misc.html b/tests/auto/widgets/favicon/resources/favicon-misc.html
index 9e788bdf4..ea587886f 100644
--- a/tests/auto/widgets/faviconmanager/resources/favicon-misc.html
+++ b/tests/auto/widgets/favicon/resources/favicon-misc.html
@@ -1,8 +1,8 @@
<html>
<head>
<title>Favicon Test</title>
- <link rel="shortcut icon" href="icons/qt32.ico" />
- <link rel="apple-touch-icon" href="icons/qt144.png" />
+ <link rel="shortcut icon" href="icons/qt32.ico" sizes="32x32" />
+ <link rel="apple-touch-icon" href="icons/qt144.png" sizes="144x144" />
<link rel="shortcut icon" href="icons/unavailable.ico" />
</head>
<body>
diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-multi.html b/tests/auto/widgets/favicon/resources/favicon-multi.html
index cc5f3fd66..56eeca8c4 100644
--- a/tests/auto/widgets/faviconmanager/resources/favicon-multi.html
+++ b/tests/auto/widgets/favicon/resources/favicon-multi.html
@@ -1,7 +1,7 @@
<html>
<head>
<title>Multi-sized Favicon Test</title>
- <link rel="shortcut icon" sizes="16x16 32x23 64x64" href="icons/qtmulti.ico" />
+ <link rel="shortcut icon" sizes="16x16 32x32 64x64" href="icons/qtmulti.ico" />
</head>
<body>
<h1>Multi-sized Favicon Test</h1>
diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-shortcut.html b/tests/auto/widgets/favicon/resources/favicon-shortcut.html
index 786cdb816..786cdb816 100644
--- a/tests/auto/widgets/faviconmanager/resources/favicon-shortcut.html
+++ b/tests/auto/widgets/favicon/resources/favicon-shortcut.html
diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-single.html b/tests/auto/widgets/favicon/resources/favicon-single.html
index eb4675c75..eb4675c75 100644
--- a/tests/auto/widgets/faviconmanager/resources/favicon-single.html
+++ b/tests/auto/widgets/favicon/resources/favicon-single.html
diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-touch.html b/tests/auto/widgets/favicon/resources/favicon-touch.html
index 271783434..271783434 100644
--- a/tests/auto/widgets/faviconmanager/resources/favicon-touch.html
+++ b/tests/auto/widgets/favicon/resources/favicon-touch.html
diff --git a/tests/auto/widgets/faviconmanager/resources/favicon-unavailable.html b/tests/auto/widgets/favicon/resources/favicon-unavailable.html
index c45664294..c45664294 100644
--- a/tests/auto/widgets/faviconmanager/resources/favicon-unavailable.html
+++ b/tests/auto/widgets/favicon/resources/favicon-unavailable.html
diff --git a/tests/auto/widgets/faviconmanager/resources/icons/qt144.png b/tests/auto/widgets/favicon/resources/icons/qt144.png
index 050b1e066..050b1e066 100644
--- a/tests/auto/widgets/faviconmanager/resources/icons/qt144.png
+++ b/tests/auto/widgets/favicon/resources/icons/qt144.png
Binary files differ
diff --git a/tests/auto/widgets/faviconmanager/resources/icons/qt32.ico b/tests/auto/widgets/favicon/resources/icons/qt32.ico
index 2f6fcb5bc..2f6fcb5bc 100644
--- a/tests/auto/widgets/faviconmanager/resources/icons/qt32.ico
+++ b/tests/auto/widgets/favicon/resources/icons/qt32.ico
Binary files differ
diff --git a/tests/auto/widgets/faviconmanager/resources/icons/qtmulti.ico b/tests/auto/widgets/favicon/resources/icons/qtmulti.ico
index 81e5a22e8..81e5a22e8 100644
--- a/tests/auto/widgets/faviconmanager/resources/icons/qtmulti.ico
+++ b/tests/auto/widgets/favicon/resources/icons/qtmulti.ico
Binary files differ
diff --git a/tests/auto/widgets/faviconmanager/resources/test1.html b/tests/auto/widgets/favicon/resources/test1.html
index b323f966e..b323f966e 100644
--- a/tests/auto/widgets/faviconmanager/resources/test1.html
+++ b/tests/auto/widgets/favicon/resources/test1.html
diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp b/tests/auto/widgets/favicon/tst_favicon.cpp
index 8e9bb2470..377699aaa 100644
--- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp
+++ b/tests/auto/widgets/favicon/tst_favicon.cpp
@@ -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.
@@ -29,13 +29,13 @@
#include <QtTest/QtTest>
#include <util.h>
-#include <qwebenginepage.h>
-#include <qwebengineprofile.h>
-#include <qwebenginesettings.h>
-#include <qwebengineview.h>
+#include <QWebEnginePage>
+#include <QWebEngineProfile>
+#include <QWebEngineSettings>
+#include <QWebEngineView>
-
-class tst_FaviconManager : public QObject {
+class tst_Favicon : public QObject
+{
Q_OBJECT
public Q_SLOTS:
@@ -48,15 +48,14 @@ private Q_SLOTS:
void faviconLoad();
void faviconLoadFromResources();
void faviconLoadEncodedUrl();
+ void faviconLoadAfterHistoryNavigation();
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();
@@ -70,8 +69,7 @@ private:
QWebEngineProfile *m_profile;
};
-
-void tst_FaviconManager::init()
+void tst_Favicon::init()
{
m_profile = new QWebEngineProfile(this);
m_view = new QWebEngineView();
@@ -79,23 +77,17 @@ void tst_FaviconManager::init()
m_view->setPage(m_page);
}
+void tst_Favicon::initTestCase() { }
-void tst_FaviconManager::initTestCase()
-{
-}
-
-void tst_FaviconManager::cleanupTestCase()
-{
-}
-
+void tst_Favicon::cleanupTestCase() { }
-void tst_FaviconManager::cleanup()
+void tst_Favicon::cleanup()
{
delete m_view;
delete m_profile;
}
-void tst_FaviconManager::faviconLoad()
+void tst_Favicon::faviconLoad()
{
if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists())
W_QSKIP(QString("This test requires access to resources found in '%1'")
@@ -125,12 +117,12 @@ void tst_FaviconManager::faviconLoad()
const QIcon &icon = m_page->icon();
QVERIFY(!icon.isNull());
- QCOMPARE(icon.availableSizes().count(), 1);
- QSize iconSize = icon.availableSizes().first();
- QCOMPARE(iconSize, QSize(32, 32));
+ QCOMPARE(icon.availableSizes().count(), 2);
+ QVERIFY(icon.availableSizes().contains(QSize(16, 16)));
+ QVERIFY(icon.availableSizes().contains(QSize(32, 32)));
}
-void tst_FaviconManager::faviconLoadFromResources()
+void tst_Favicon::faviconLoadFromResources()
{
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
@@ -150,12 +142,12 @@ void tst_FaviconManager::faviconLoadFromResources()
const QIcon &icon = m_page->icon();
QVERIFY(!icon.isNull());
- QCOMPARE(icon.availableSizes().count(), 1);
- QSize iconSize = icon.availableSizes().first();
- QCOMPARE(iconSize, QSize(32, 32));
+ QCOMPARE(icon.availableSizes().count(), 2);
+ QVERIFY(icon.availableSizes().contains(QSize(16, 16)));
+ QVERIFY(icon.availableSizes().contains(QSize(32, 32)));
}
-void tst_FaviconManager::faviconLoadEncodedUrl()
+void tst_Favicon::faviconLoadEncodedUrl()
{
if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists())
W_QSKIP(QString("This test requires access to resources found in '%1'")
@@ -187,12 +179,43 @@ void tst_FaviconManager::faviconLoadEncodedUrl()
const QIcon &icon = m_page->icon();
QVERIFY(!icon.isNull());
- QCOMPARE(icon.availableSizes().count(), 1);
- QSize iconSize = icon.availableSizes().first();
- QCOMPARE(iconSize, QSize(32, 32));
+ 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_FaviconManager::noFavicon()
+void tst_Favicon::noFavicon()
{
if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists())
W_QSKIP(QString("This test requires access to resources found in '%1'")
@@ -217,7 +240,7 @@ void tst_FaviconManager::noFavicon()
QVERIFY(m_page->icon().isNull());
}
-void tst_FaviconManager::aboutBlank()
+void tst_Favicon::aboutBlank()
{
QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl)));
@@ -234,7 +257,7 @@ void tst_FaviconManager::aboutBlank()
QVERIFY(m_page->icon().isNull());
}
-void tst_FaviconManager::unavailableFavicon()
+void tst_Favicon::unavailableFavicon()
{
if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists())
W_QSKIP(QString("This test requires access to resources found in '%1'")
@@ -259,7 +282,7 @@ void tst_FaviconManager::unavailableFavicon()
QVERIFY(m_page->icon().isNull());
}
-void tst_FaviconManager::errorPageEnabled()
+void tst_Favicon::errorPageEnabled()
{
m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true);
@@ -278,7 +301,7 @@ void tst_FaviconManager::errorPageEnabled()
QVERIFY(m_page->icon().isNull());
}
-void tst_FaviconManager::errorPageDisabled()
+void tst_Favicon::errorPageDisabled()
{
m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
@@ -297,80 +320,7 @@ void tst_FaviconManager::errorPageDisabled()
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()
+void tst_Favicon::touchIcon()
{
if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists())
W_QSKIP(QString("This test requires access to resources found in '%1'")
@@ -395,7 +345,7 @@ void tst_FaviconManager::touchIcon()
QVERIFY(m_page->icon().isNull());
}
-void tst_FaviconManager::multiIcon()
+void tst_Favicon::multiIcon()
{
if (!QDir(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()).exists())
W_QSKIP(QString("This test requires access to resources found in '%1'")
@@ -410,61 +360,60 @@ void tst_FaviconManager::multiIcon()
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);
- QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString();
+ 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();
+ icon = m_page->icon();
QVERIFY(!icon.isNull());
- QCOMPARE(icon.availableSizes().count(), 3);
+ QCOMPARE(icon.availableSizes().count(), 2);
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)));
+ // 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();
- QUrl url = QUrl::fromLocalFile(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath()
- + QLatin1String("/resources/favicon-shortcut.html"));
+ // 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);
- QUrl iconUrl = iconUrlChangedSpy.at(0).at(0).toString();
+ 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")));
+ + QLatin1String("/resources/icons/qtmulti.ico")));
- const QIcon &icon = m_page->icon();
+ 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)));
+ QCOMPARE(icon.availableSizes().count(), 1);
+ QVERIFY(icon.availableSizes().contains(QSize(64, 64)));
}
-void tst_FaviconManager::downloadIconsDisabled_data()
+void tst_Favicon::downloadIconsDisabled_data()
{
QTest::addColumn<QUrl>("url");
QTest::newRow("misc") << QUrl("qrc:/resources/favicon-misc.html");
@@ -474,7 +423,7 @@ void tst_FaviconManager::downloadIconsDisabled_data()
QTest::newRow("unavailable") << QUrl("qrc:/resources/favicon-unavailable.html");
}
-void tst_FaviconManager::downloadIconsDisabled()
+void tst_Favicon::downloadIconsDisabled()
{
QFETCH(QUrl, url);
@@ -494,18 +443,22 @@ void tst_FaviconManager::downloadIconsDisabled()
QVERIFY(m_page->icon().isNull());
}
-void tst_FaviconManager::downloadTouchIconsEnabled_data()
+void tst_Favicon::downloadTouchIconsEnabled_data()
{
QTest::addColumn<QUrl>("url");
QTest::addColumn<QUrl>("expectedIconUrl");
QTest::addColumn<QSize>("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);
+ 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()
+void tst_Favicon::downloadTouchIconsEnabled()
{
QFETCH(QUrl, url);
QFETCH(QUrl, expectedIconUrl);
@@ -530,23 +483,27 @@ void tst_FaviconManager::downloadTouchIconsEnabled()
const QIcon &icon = m_page->icon();
QVERIFY(!icon.isNull());
- QVERIFY(icon.availableSizes().count() >= 1);
- QVERIFY(icon.availableSizes().contains(expectedIconSize));
+ QCOMPARE(icon.availableSizes().count(), 1);
+ QCOMPARE(icon.availableSizes().first(), expectedIconSize);
}
-void tst_FaviconManager::dynamicFavicon()
+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<Qt::GlobalColor, QString> colors;
- colors.insert(Qt::red, QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg=="));
- colors.insert(Qt::green, QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg=="));
- colors.insert(Qt::blue, QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg=="));
+ colors.insert(Qt::red,
+ QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg=="));
+ colors.insert(Qt::green,
+ QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg=="));
+ colors.insert(Qt::blue,
+ QString("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg=="));
m_page->setHtml("<html>"
- "<link rel='icon' type='image/png' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII='/>"
+ "<link rel='icon' type='image/png' "
+ "href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII='/>"
"</html>");
QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 30000);
QTRY_COMPARE(iconUrlChangedSpy.count(), 1);
@@ -556,14 +513,17 @@ void tst_FaviconManager::dynamicFavicon()
for (Qt::GlobalColor color : colors.keys()) {
iconChangedSpy.clear();
- evaluateJavaScriptSync(m_page, "document.getElementsByTagName('link')[0].href = 'data:image/png;base64," + colors[color] + "';");
+ 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]));
+ 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()
+void tst_Favicon::touchIconWithSameURL()
{
m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, false);
@@ -578,7 +538,8 @@ void tst_FaviconManager::touchIconWithSameURL()
"</html>");
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.
+ // 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);
@@ -592,14 +553,13 @@ void tst_FaviconManager::touchIconWithSameURL()
"</html>");
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.
+ // 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)
+QTEST_MAIN(tst_Favicon)
-#include "tst_faviconmanager.moc"
+#include "tst_favicon.moc"
diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.qrc b/tests/auto/widgets/favicon/tst_favicon.qrc
index a352f8a83..a352f8a83 100644
--- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.qrc
+++ b/tests/auto/widgets/favicon/tst_favicon.qrc
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<QIcon>(), pageFrom->icon());
+ QCOMPARE(spyIcon.last().value(0).value<QIcon>().availableSizes(),
+ pageFrom->icon().availableSizes());
}
QScopedPointer<QWebEnginePage> 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<QIcon>(), pageTo->icon());
+ QCOMPARE(spyIcon.last().value(0).value<QIcon>().availableSizes(),
+ pageTo->icon().availableSizes());
}
// verify no emits on destroy with the same number of signals in spy
diff --git a/tests/manual/quick/faviconbrowser/AddressBar.qml b/tests/manual/quick/faviconbrowser/AddressBar.qml
deleted file mode 100644
index c79b74f30..000000000
--- a/tests/manual/quick/faviconbrowser/AddressBar.qml
+++ /dev/null
@@ -1,102 +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.5
-import QtQuick.Controls 1.4
-import QtQuick.Controls.Styles 1.4
-
-Rectangle {
- id: root
-
- property int progress: 0
- property url iconUrl: ""
- property url pageUrl: ""
-
- signal accepted(url addressUrl)
-
- clip: true
-
- onActiveFocusChanged: {
- if (activeFocus)
- addressField.forceActiveFocus();
- }
-
- Rectangle {
- width: addressField.width / 100 * root.progress
- height: root.height
-
- visible: root.progress < 100
-
- color: "#b6dca6"
- radius: root.radius
- }
-
- TextField {
- id: addressField
- anchors.fill: parent
-
- Image {
- anchors.verticalCenter: addressField.verticalCenter
- x: 5; z: parent.z + 1
- width: 16; height: 16
- sourceSize: Qt.size(width, height)
- source: root.iconUrl
- visible: root.progress == 100
- }
-
- Text {
- text: root.progress < 0 ? "" : root.progress + "%"
- x: 5; z: parent.z + 1
- font.bold: true
- anchors.verticalCenter: parent.verticalCenter
-
- visible: root.progress < 100
- }
-
- style: TextFieldStyle {
- padding.left: 30
-
- background: Rectangle {
- color: "transparent"
- border.color: "black"
- border.width: 1
- radius: root.radius
- }
- }
-
- onActiveFocusChanged: {
- if (activeFocus)
- selectAll();
- else
- deselect();
- }
-
- text: root.pageUrl
- onAccepted: root.accepted(utils.fromUserInput(text))
- }
-}
diff --git a/tests/manual/quick/faviconbrowser/FaviconPanel.qml b/tests/manual/quick/faviconbrowser/FaviconPanel.qml
deleted file mode 100644
index 857019d9a..000000000
--- a/tests/manual/quick/faviconbrowser/FaviconPanel.qml
+++ /dev/null
@@ -1,234 +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.5
-import QtQuick.Controls 1.4
-import QtQuick.Controls.Styles 1.4
-import QtQuick.Layouts 1.1
-
-Item {
- id: root
-
- property url iconUrl: ""
- property int iconSize: 128
- property int iconMinimumSize: 8
- property int iconMaximumSize: 256
-
- RowLayout {
- anchors.fill: parent
- spacing: 2
-
- Rectangle {
- Layout.fillWidth: true
- Layout.fillHeight: true
-
- RowLayout {
- anchors.fill: parent
- spacing: 2
-
- Rectangle {
- Layout.fillHeight: true
- Layout.preferredWidth: (parent.width - 2 * parent.spacing) / 3
-
- border.color: "black"
- border.width: 1
- clip: true
-
- Text {
- z: parent.z + 1
- anchors.top: parent.top
- anchors.topMargin: 5
- anchors.left: parent.left
- anchors.leftMargin: 5
- font.bold: true
-
- text: "faviconImage"
- }
-
- Image {
- id: faviconImage
- anchors.centerIn: parent
-
- width: root.iconSize
- height: width
- sourceSize: Qt.size(width, height)
-
- source: root.iconUrl
-
- onStatusChanged: {
- if (status == Image.Ready) {
- grabToImage(function(result) {
- grabImage.source = result.url;
- });
- }
-
- if (status == Image.Null)
- grabImage.source = "";
- }
- }
- }
-
- Rectangle {
- Layout.fillHeight: true
- Layout.preferredWidth: (parent.width - 2 * parent.spacing) / 3
-
- border.color: "black"
- border.width: 1
- clip: true
-
- Text {
- z: parent.z + 1
- anchors.top: parent.top
- anchors.topMargin: 5
- anchors.left: parent.left
- anchors.leftMargin: 5
- font.bold: true
-
- text: "grabImage"
- }
-
- Image {
- id: grabImage
- anchors.centerIn: parent
-
- width: root.iconSize
- height: width
-
- onStatusChanged: {
- if (status == Image.Ready || status == Image.Null)
- faviconCanvas.requestPaint();
- }
- }
- }
-
- Rectangle {
- Layout.fillHeight: true
- Layout.preferredWidth: (parent.width - 2 * parent.spacing) / 3
-
- border.color: "black"
- border.width: 1
- clip: true
-
- Text {
- z: parent.z + 1
- anchors.top: parent.top
- anchors.topMargin: 5
- anchors.left: parent.left
- anchors.leftMargin: 5
- font.bold: true
-
- text: "faviconCanvas"
- }
-
- Canvas {
- id: faviconCanvas
- anchors.centerIn: parent
-
- width: root.iconSize
- height: width
-
- onPaint: {
- var ctx = getContext("2d");
- ctx.reset();
- ctx.clearRect(0, 0, width, height);
-
- if (grabImage.source == "")
- return;
-
- ctx.drawImage(grabImage, 0, 0, width, height);
-
- var imageData = ctx.getImageData(width/2, height/2, width/2, height/2);
- var pixel = imageData.data;
-
- verbose.append("pixel(" + width/2 + ", " + height/2 + "): " + pixel[0] + ", " + pixel[1] + ", " + pixel[2]);
- }
- }
- }
- }
- }
-
- Rectangle {
- Layout.fillHeight: true
- Layout.preferredWidth: 100
-
- Slider {
- id: faviconSizeSlider
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- anchors.bottom: faviconSizeSpin.top
-
- orientation: Qt.Vertical
- minimumValue: root.iconMinimumSize
- maximumValue: root.iconMaximumSize
- stepSize: 1
- tickmarksEnabled: true
- value: root.iconSize
-
- onValueChanged: {
- if (pressed && value != root.iconSize)
- root.iconSize = value;
- }
- }
-
- SpinBox {
- id: faviconSizeSpin
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
-
- minimumValue: root.iconMinimumSize
- maximumValue: root.iconMaximumSize
- value: root.iconSize
-
- onEditingFinished: {
- if (value != root.iconSize)
- root.iconSize = value;
- }
- }
- }
-
- TextArea {
- id: verbose
-
- Layout.fillHeight: true
- Layout.preferredWidth: 310
-
- readOnly: true
- tabChangesFocus: true
-
- font.family: "Monospace"
- font.pointSize: 12
-
- textFormat: TextEdit.RichText
- frameVisible: false
-
- style: TextAreaStyle {
- backgroundColor: "lightgray"
- }
- }
- }
-}
diff --git a/tests/manual/quick/faviconbrowser/faviconbrowser.pro b/tests/manual/quick/faviconbrowser/faviconbrowser.pro
deleted file mode 100644
index d997d6322..000000000
--- a/tests/manual/quick/faviconbrowser/faviconbrowser.pro
+++ /dev/null
@@ -1,23 +0,0 @@
-QT += qml quick webenginequick
-qtHaveModule(widgets) {
- QT += widgets # QApplication is required to get native styling with QtQuickControls
-}
-
-TARGET = faviconbrowser
-TEMPLATE = app
-
-
-SOURCES = \
- main.cpp
-
-HEADERS = \
- utils.h
-
-OTHER_FILES += \
- main.qml \
- AddressBar.qml \
- FaviconPanel.qml
-
-RESOURCES += \
- faviconbrowser.qrc
-
diff --git a/tests/manual/quick/faviconbrowser/faviconbrowser.qrc b/tests/manual/quick/faviconbrowser/faviconbrowser.qrc
deleted file mode 100644
index b641fa2fa..000000000
--- a/tests/manual/quick/faviconbrowser/faviconbrowser.qrc
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
- <qresource prefix="/">
- <file>main.qml</file>
- <file>AddressBar.qml</file>
- <file>FaviconPanel.qml</file>
- </qresource>
- <qresource prefix="test">
- <file alias="favicon-multi-gray.html">../../../auto/quick/qmltests2/data/favicon-multi-gray.html</file>
- <file alias="favicon-candidates-gray.html">../../../auto/quick/qmltests2/data/favicon-candidates-gray.html</file>
- <file alias="icons/grayicons.ico">../../../auto/quick/qmltests2/data/icons/grayicons.ico</file>
- <file alias="icons/gray16.png">../../../auto/quick/qmltests2/data/icons/gray16.png</file>
- <file alias="icons/gray32.png">../../../auto/quick/qmltests2/data/icons/gray32.png</file>
- <file alias="icons/gray64.png">../../../auto/quick/qmltests2/data/icons/gray64.png</file>
- <file alias="icons/gray128.png">../../../auto/quick/qmltests2/data/icons/gray128.png</file>
- <file alias="icons/gray255.png">../../../auto/quick/qmltests2/data/icons/gray255.png</file>
- </qresource>
-</RCC>
diff --git a/tests/manual/quick/faviconbrowser/main.cpp b/tests/manual/quick/faviconbrowser/main.cpp
deleted file mode 100644
index d1faadfa0..000000000
--- a/tests/manual/quick/faviconbrowser/main.cpp
+++ /dev/null
@@ -1,54 +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 "utils.h"
-
-#ifndef QT_NO_WIDGETS
-#include <QtWidgets/QApplication>
-typedef QApplication Application;
-#else
-#include <QtGui/QGuiApplication>
-typedef QGuiApplication Application;
-#endif
-#include <QtQml/QQmlApplicationEngine>
-#include <QtQml/QQmlContext>
-#include <QtWebEngineQuick/qtwebengineglobal.h>
-
-int main(int argc, char **argv)
-{
- Application app(argc, argv);
-
- QtWebEngine::initialize();
-
- QQmlApplicationEngine appEngine;
- Utils utils;
- appEngine.rootContext()->setContextProperty("utils", &utils);
- appEngine.load(QUrl("qrc:/main.qml"));
-
- return app.exec();
-}
diff --git a/tests/manual/quick/faviconbrowser/main.qml b/tests/manual/quick/faviconbrowser/main.qml
deleted file mode 100644
index c8e2bdbd5..000000000
--- a/tests/manual/quick/faviconbrowser/main.qml
+++ /dev/null
@@ -1,170 +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.5
-import QtQuick.Controls 1.4
-import QtQuick.Layouts 1.1
-import QtWebEngine 1.3
-import Qt.labs.settings 1.0
-
-ApplicationWindow {
- width: 1300
- height: 900
- visible: true
-
- Item {
- id: bookmarkUrls
-
- property url multiTest: Qt.resolvedUrl("qrc:/test/favicon-multi-gray.html")
- property url candidatesTest: Qt.resolvedUrl("qrc:/test/favicon-candidates-gray.html")
- property url aboutBlank: Qt.resolvedUrl("about:blank")
- property url qtHome: Qt.resolvedUrl("http://www.qt.io/")
- }
-
- Settings {
- id: appSettings
-
- property alias autoLoadIconsForPage: autoLoadIconsForPage.checked
- property alias touchIconsEnabled: touchIconsEnabled.checked
- }
-
- SplitView {
- anchors.fill: parent
- orientation: Qt.Vertical
-
- FaviconPanel {
- id: faviconPanel
-
- Layout.fillWidth: true
- Layout.minimumHeight: 200
-
- Layout.margins: 2
-
- iconUrl: webEngineView && webEngineView.icon
- }
-
- ColumnLayout {
- Layout.fillWidth: true
- Layout.fillHeight: true
- Layout.topMargin: 2
-
- AddressBar {
- id: addressBar
-
- Layout.fillWidth: true
- Layout.leftMargin: 5
- Layout.rightMargin: 5
- height: 25
-
- color: "white"
- radius: 4
-
- progress: webEngineView && webEngineView.loadProgress
- iconUrl: webEngineView && webEngineView.icon
- pageUrl: webEngineView && webEngineView.url
-
- onAccepted: webEngineView.url = addressUrl
- }
-
- Rectangle {
- id: toolBar
-
- Layout.fillWidth: true
- Layout.leftMargin: 5
- Layout.rightMargin: 5
- Layout.preferredHeight: 25
-
- RowLayout {
- anchors.verticalCenter: parent.verticalCenter
-
- Button {
- text: "Multi-sized Favicon Test"
- onClicked: webEngineView.url = bookmarkUrls.multiTest
- enabled: webEngineView.url != bookmarkUrls.multiTest
- }
-
- Button {
- text: "Candidate Favicons Test"
- onClicked: webEngineView.url = bookmarkUrls.candidatesTest
- enabled: webEngineView.url != bookmarkUrls.candidatesTest
- }
-
- Button {
- text: "About Blank"
- onClicked: webEngineView.url = bookmarkUrls.aboutBlank
- enabled: webEngineView.url != bookmarkUrls.aboutBlank
- }
-
- Button {
- text: "Qt Home Page"
- onClicked: webEngineView.url = bookmarkUrls.qtHome
- enabled: webEngineView.url != bookmarkUrls.qtHome
- }
- }
-
- ToolButton {
- anchors.verticalCenter: parent.verticalCenter
- anchors.right: parent.right
-
- menu: Menu {
- MenuItem {
- id: autoLoadIconsForPage
- text: "Icons On"
- checkable: true
- checked: WebEngine.settings.autoLoadIconsForPage
-
- onCheckedChanged: webEngineView.reload()
- }
-
- MenuItem {
- id: touchIconsEnabled
- text: "Touch Icons On"
- checkable: true
- checked: WebEngine.settings.touchIconsEnabled
- enabled: autoLoadIconsForPage.checked
-
- onCheckedChanged: webEngineView.reload()
- }
- }
- }
- }
-
- WebEngineView {
- id: webEngineView
-
- Layout.fillWidth: true
- Layout.fillHeight: true
-
- settings.autoLoadIconsForPage: appSettings.autoLoadIconsForPage
- settings.touchIconsEnabled: appSettings.touchIconsEnabled
-
- Component.onCompleted: webEngineView.url = bookmarkUrls.multiTest
- }
- }
- }
-}
diff --git a/tests/manual/quick/faviconbrowser/utils.h b/tests/manual/quick/faviconbrowser/utils.h
deleted file mode 100644
index 9deef0b61..000000000
--- a/tests/manual/quick/faviconbrowser/utils.h
+++ /dev/null
@@ -1,49 +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$
-**
-****************************************************************************/
-
-#ifndef UTILS_H
-#define UTILS_H
-
-#include <QtCore/QFileInfo>
-#include <QtCore/QUrl>
-
-class Utils : public QObject {
- Q_OBJECT
-public:
- Q_INVOKABLE static QUrl fromUserInput(const QString& userInput);
-};
-
-inline QUrl Utils::fromUserInput(const QString& userInput)
-{
- QFileInfo fileInfo(userInput);
- if (fileInfo.exists())
- return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
- return QUrl::fromUserInput(userInput);
-}
-
-#endif // UTILS_H