diff options
Diffstat (limited to 'tests/auto/quick/qmltests')
14 files changed, 287 insertions, 30 deletions
diff --git a/tests/auto/quick/qmltests/data/favicon-misc.html b/tests/auto/quick/qmltests/data/favicon-misc.html new file mode 100644 index 000000000..9e788bdf4 --- /dev/null +++ b/tests/auto/quick/qmltests/data/favicon-misc.html @@ -0,0 +1,11 @@ +<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/unavailable.ico" /> + </head> + <body> + <h1>Favicon Test</h1> + </body> +</html> diff --git a/tests/auto/quick/qmltests/data/favicon-shortcut.html b/tests/auto/quick/qmltests/data/favicon-shortcut.html new file mode 100644 index 000000000..786cdb816 --- /dev/null +++ b/tests/auto/quick/qmltests/data/favicon-shortcut.html @@ -0,0 +1,10 @@ +<html> + <head> + <title>Favicon Test</title> + <link rel="shortcut icon" href="icons/qt32.ico" /> + <link rel="shortcut icon" href="icons/qt144.png" /> + </head> + <body> + <h1>Favicon Test</h1> + </body> +</html> diff --git a/tests/auto/quick/qmltests/data/favicon-single.html b/tests/auto/quick/qmltests/data/favicon-single.html new file mode 100644 index 000000000..eb4675c75 --- /dev/null +++ b/tests/auto/quick/qmltests/data/favicon-single.html @@ -0,0 +1,9 @@ +<html> + <head> + <title>Favicon Test</title> + <link rel="shortcut icon" href="icons/qt32.ico" /> + </head> + <body> + <h1>Favicon Test</h1> + </body> +</html> diff --git a/tests/auto/quick/qmltests/data/favicon-touch.html b/tests/auto/quick/qmltests/data/favicon-touch.html new file mode 100644 index 000000000..271783434 --- /dev/null +++ b/tests/auto/quick/qmltests/data/favicon-touch.html @@ -0,0 +1,10 @@ +<html> + <head> + <title>Favicon Test</title> + <link rel="apple-touch-icon" href="icons/qt32.ico" /> + <link rel="apple-touch-icon" href="icons/qt144.png" /> + </head> + <body> + <h1>Favicon Test</h1> + </body> +</html> diff --git a/tests/auto/quick/qmltests/data/favicon-unavailable.html b/tests/auto/quick/qmltests/data/favicon-unavailable.html new file mode 100644 index 000000000..c45664294 --- /dev/null +++ b/tests/auto/quick/qmltests/data/favicon-unavailable.html @@ -0,0 +1,9 @@ +<html> + <head> + <title>Favicon Test</title> + <link rel="shortcut icon" href="icons/unavailable.ico" /> + </head> + <body> + <h1>Favicon Test</h1> + </body> +</html> diff --git a/tests/auto/quick/qmltests/data/favicon.html b/tests/auto/quick/qmltests/data/favicon.html index c9f225c52..9823fa323 100644 --- a/tests/auto/quick/qmltests/data/favicon.html +++ b/tests/auto/quick/qmltests/data/favicon.html @@ -1,10 +1,10 @@ <html> <head> </head> -<link type="image/png" href="favicon.png" sizes="48x48" rel="icon" /> +<link type="image/png" href="icons/favicon.png" sizes="48x48" rel="icon" /> <body> <p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p> <p>The favicon looks like this:</p> -<img src="favicon.png"/> +<img src="icons/favicon.png"/> </body> </html> diff --git a/tests/auto/quick/qmltests/data/favicon2.html b/tests/auto/quick/qmltests/data/favicon2.html index 5548b867f..81c2690fe 100644 --- a/tests/auto/quick/qmltests/data/favicon2.html +++ b/tests/auto/quick/qmltests/data/favicon2.html @@ -1,10 +1,10 @@ <html> <head> </head> -<link type="image/png" href="small-favicon.png" sizes="16x16" rel="icon" /> +<link type="image/png" href="icons/small-favicon.png" sizes="16x16" rel="icon" /> <body> <p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p> <p>The favicon looks like this:</p> -<img src="small-favicon.png"/> +<img src="icons/small-favicon.png"/> </body> </html> diff --git a/tests/auto/quick/qmltests/data/favicon.png b/tests/auto/quick/qmltests/data/icons/favicon.png Binary files differindex 35717cca5..35717cca5 100644 --- a/tests/auto/quick/qmltests/data/favicon.png +++ b/tests/auto/quick/qmltests/data/icons/favicon.png diff --git a/tests/auto/quick/qmltests/data/icons/qt144.png b/tests/auto/quick/qmltests/data/icons/qt144.png Binary files differnew file mode 100644 index 000000000..050b1e066 --- /dev/null +++ b/tests/auto/quick/qmltests/data/icons/qt144.png diff --git a/tests/auto/quick/qmltests/data/icons/qt32.ico b/tests/auto/quick/qmltests/data/icons/qt32.ico Binary files differnew file mode 100644 index 000000000..2f6fcb5bc --- /dev/null +++ b/tests/auto/quick/qmltests/data/icons/qt32.ico diff --git a/tests/auto/quick/qmltests/data/small-favicon.png b/tests/auto/quick/qmltests/data/icons/small-favicon.png Binary files differindex 4462752a5..4462752a5 100644 --- a/tests/auto/quick/qmltests/data/small-favicon.png +++ b/tests/auto/quick/qmltests/data/icons/small-favicon.png diff --git a/tests/auto/quick/qmltests/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml new file mode 100644 index 000000000..fab2e9755 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_favicon.qml @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** 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 QtWebEngine.testsupport 1.0 + +TestWebEngineView { + id: webEngineView + width: 200 + height: 400 + + testSupport: WebEngineTestSupport { + property var errorPageLoadStatus: null + + function waitForErrorPageLoadSucceeded() { + var success = _waitFor(function() { return testSupport.errorPageLoadStatus == WebEngineView.LoadSucceededStatus }) + testSupport.errorPageLoadStatus = null + return success + } + + errorPage.onLoadingChanged: { + errorPageLoadStatus = loadRequest.status + } + } + + SignalSpy { + id: iconChangedSpy + target: webEngineView + signalName: "iconChanged" + } + + TestCase { + id: test + name: "WebEngineFavicon" + when: windowShown + + function init() { + 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 test_noFavicon() { + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("test1.html") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + var iconUrl = webEngineView.icon + compare(iconUrl, Qt.resolvedUrl("")) + } + + function test_aboutBlank() { + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("about:blank") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + var iconUrl = webEngineView.icon + compare(iconUrl, Qt.resolvedUrl("")) + } + + function test_unavailableFavicon() { + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("favicon-unavailable.html") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + var iconUrl = webEngineView.icon + compare(iconUrl, Qt.resolvedUrl("icons/unavailable.ico")) + } + + function test_errorPageEnabled() { + skip("Error page does not work properly: QTBUG-48995") + WebEngine.settings.errorPageEnabled = true + + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("http://non.existent/url") + webEngineView.url = url + verify(webEngineView.testSupport.waitForErrorPageLoadSucceeded()) + + iconChangedSpy.wait() + // Icon is reseted at load start. + // Load is started twice: once for unavailale page then error page + compare(iconChangedSpy.count, 2) + + var iconUrl = webEngineView.icon + compare(iconUrl, Qt.resolvedUrl("")) + } + + function test_errorPageDisabled() { + WebEngine.settings.errorPageEnabled = false + + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("http://non.existent/url") + webEngineView.url = url + verify(webEngineView.waitForLoadFailed()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + var iconUrl = webEngineView.icon + compare(iconUrl, Qt.resolvedUrl("")) + } + + function test_touchIcon() { + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("favicon-touch.html") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + var iconUrl = webEngineView.icon + compare(iconUrl, Qt.resolvedUrl("")) + } + } +} diff --git a/tests/auto/quick/qmltests/data/tst_favIconLoad.qml b/tests/auto/quick/qmltests/data/tst_faviconImage.qml index 2527cc740..603f76954 100644 --- a/tests/auto/quick/qmltests/data/tst_favIconLoad.qml +++ b/tests/auto/quick/qmltests/data/tst_faviconImage.qml @@ -28,7 +28,7 @@ import QtQuick 2.0 import QtTest 1.0 -import QtWebEngine 1.2 +import QtWebEngine 1.3 TestWebEngineView { id: webEngineView @@ -36,25 +36,19 @@ TestWebEngineView { height: 400 SignalSpy { - id: spy + id: iconChangedSpy target: webEngineView signalName: "iconChanged" } - // FIXME: This test is flaky if the loading of the icon image is asynchronous, - // because the iconChanged signal is emitted before the image has been downloaded. - // We can set this property to true after we have some kind of favicon downloading - // logic in the WebEngine. - Image { - id: favicon - asynchronous: false + id: faviconImage source: webEngineView.icon } TestCase { id: test - name: "WebEngineViewLoadFavIcon" + name: "WebEngineFaviconImage" when: windowShown function init() { @@ -62,31 +56,70 @@ TestWebEngineView { // 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()) - spy.wait() + iconChangedSpy.wait() } - spy.clear() + + iconChangedSpy.clear() } - function test_favIconLoad() { - compare(spy.count, 0) + function test_faviconImageLoad() { + compare(iconChangedSpy.count, 0) + var url = Qt.resolvedUrl("favicon.html") webEngineView.url = url verify(webEngineView.waitForLoadSucceeded()) - spy.wait() - compare(spy.count, 1) - compare(favicon.width, 48) - compare(favicon.height, 48) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + compare(faviconImage.width, 48) + compare(faviconImage.height, 48) } - function test_favIconLoadEncodedUrl() { - compare(spy.count, 0) + function test_faviconImageLoadEncodedUrl() { + compare(iconChangedSpy.count, 0) + var url = Qt.resolvedUrl("favicon2.html?favicon=load should work with#whitespace!") webEngineView.url = url verify(webEngineView.waitForLoadSucceeded()) - spy.wait() - compare(spy.count, 1) - compare(favicon.width, 16) - compare(favicon.height, 16) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + compare(faviconImage.width, 16) + compare(faviconImage.height, 16) + } + + function test_bestFaviconImage() { + compare(iconChangedSpy.count, 0) + var url, iconUrl + + url = Qt.resolvedUrl("favicon-misc.html") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + iconUrl = webEngineView.icon + // Touch icon is ignored + compare(iconUrl, Qt.resolvedUrl("icons/qt32.ico")) + compare(faviconImage.width, 32) + compare(faviconImage.height, 32) + + iconChangedSpy.clear() + + url = Qt.resolvedUrl("favicon-shortcut.html") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + iconUrl = webEngineView.icon + compare(iconUrl, Qt.resolvedUrl("icons/qt144.png")) + compare(faviconImage.width, 144) + compare(faviconImage.height, 144) } } } diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index 57649384d..d1849d020 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -15,8 +15,12 @@ OTHER_FILES += \ $$PWD/data/confirmclose.html \ $$PWD/data/directoryupload.html \ $$PWD/data/favicon.html \ - $$PWD/data/favicon.png \ $$PWD/data/favicon2.html \ + $$PWD/data/favicon-misc.html \ + $$PWD/data/favicon-single.html \ + $$PWD/data/favicon-shortcut.html \ + $$PWD/data/favicon-touch.html \ + $$PWD/data/favicon-unavailable.html \ $$PWD/data/forms.html \ $$PWD/data/geolocation.html \ $$PWD/data/javascript.html \ @@ -34,7 +38,8 @@ OTHER_FILES += \ $$PWD/data/titleupdate.js \ $$PWD/data/tst_desktopBehaviorLoadHtml.qml \ $$PWD/data/tst_download.qml \ - $$PWD/data/tst_favIconLoad.qml \ + $$PWD/data/tst_favicon.qml \ + $$PWD/data/tst_faviconImage.qml \ $$PWD/data/tst_filePicker.qml \ $$PWD/data/tst_formValidation.qml \ $$PWD/data/tst_geopermission.qml \ @@ -55,6 +60,10 @@ OTHER_FILES += \ $$PWD/data/tst_userScripts.qml \ $$PWD/data/tst_webchannel.qml \ $$PWD/data/tst_keyboardModifierMapping.qml \ + $$PWD/data/icons/favicon.png \ + $$PWD/data/icons/small-favicon.png \ + $$PWD/data/icons/qt144.png \ + $$PWD/data/icons/qt32.ico \ $$PWD/mock-delegates/QtWebEngine/UIDelegates/AlertDialog.qml \ $$PWD/mock-delegates/QtWebEngine/UIDelegates/ConfirmDialog.qml \ $$PWD/mock-delegates/QtWebEngine/UIDelegates/FilePicker.qml \ |