diff options
Diffstat (limited to 'tests/auto/quick/qmltests/data/tst_favicon.qml')
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_favicon.qml | 98 |
1 files changed, 81 insertions, 17 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml index fab2e9755..8448960dd 100644 --- a/tests/auto/quick/qmltests/data/tst_favicon.qml +++ b/tests/auto/quick/qmltests/data/tst_favicon.qml @@ -56,6 +56,11 @@ TestWebEngineView { signalName: "iconChanged" } + Image { + id: favicon + source: webEngineView.icon + } + TestCase { id: test name: "WebEngineFavicon" @@ -72,16 +77,43 @@ TestWebEngineView { iconChangedSpy.clear() } - function test_noFavicon() { + function test_faviconLoad() { compare(iconChangedSpy.count, 0) - var url = Qt.resolvedUrl("test1.html") + var url = Qt.resolvedUrl("favicon.html") webEngineView.url = url verify(webEngineView.waitForLoadSucceeded()) iconChangedSpy.wait() compare(iconChangedSpy.count, 1) + compare(favicon.width, 48) + compare(favicon.height, 48) + } + + function test_faviconLoadEncodedUrl() { + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("favicon2.html?favicon=load should work with#whitespace!") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + compare(iconChangedSpy.count, 1) + + compare(favicon.width, 16) + compare(favicon.height, 16) + } + + function test_noFavicon() { + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("test1.html") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + compare(iconChangedSpy.count, 0) + var iconUrl = webEngineView.icon compare(iconUrl, Qt.resolvedUrl("")) } @@ -93,8 +125,7 @@ TestWebEngineView { webEngineView.url = url verify(webEngineView.waitForLoadSucceeded()) - iconChangedSpy.wait() - compare(iconChangedSpy.count, 1) + compare(iconChangedSpy.count, 0) var iconUrl = webEngineView.icon compare(iconUrl, Qt.resolvedUrl("")) @@ -107,11 +138,10 @@ TestWebEngineView { webEngineView.url = url verify(webEngineView.waitForLoadSucceeded()) - iconChangedSpy.wait() - compare(iconChangedSpy.count, 1) + compare(iconChangedSpy.count, 0) var iconUrl = webEngineView.icon - compare(iconUrl, Qt.resolvedUrl("icons/unavailable.ico")) + compare(iconUrl, Qt.resolvedUrl("")) } function test_errorPageEnabled() { @@ -120,14 +150,11 @@ TestWebEngineView { compare(iconChangedSpy.count, 0) - var url = Qt.resolvedUrl("http://non.existent/url") + var url = Qt.resolvedUrl("invalid://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) + compare(iconChangedSpy.count, 0) var iconUrl = webEngineView.icon compare(iconUrl, Qt.resolvedUrl("")) @@ -138,27 +165,64 @@ TestWebEngineView { compare(iconChangedSpy.count, 0) - var url = Qt.resolvedUrl("http://non.existent/url") + var url = Qt.resolvedUrl("invalid://url") webEngineView.url = url verify(webEngineView.waitForLoadFailed()) - iconChangedSpy.wait() - compare(iconChangedSpy.count, 1) + compare(iconChangedSpy.count, 0) var iconUrl = webEngineView.icon compare(iconUrl, Qt.resolvedUrl("")) } - function test_touchIcon() { + function test_bestFavicon() { compare(iconChangedSpy.count, 0) + var url, iconUrl - var url = Qt.resolvedUrl("favicon-touch.html") + 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(favicon.width, 32) + compare(favicon.height, 32) + + iconChangedSpy.clear() + + url = Qt.resolvedUrl("favicon-shortcut.html") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + iconChangedSpy.wait() + verify(iconChangedSpy.count >= 1) + iconUrl = 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 = webEngineView.icon + } + + compare(iconUrl, Qt.resolvedUrl("icons/qt144.png")) + compare(favicon.width, 144) + compare(favicon.height, 144) + } + + function test_touchIcon() { + compare(iconChangedSpy.count, 0) + + var url = Qt.resolvedUrl("favicon-touch.html") + webEngineView.url = url + verify(webEngineView.waitForLoadSucceeded()) + + compare(iconChangedSpy.count, 0) + var iconUrl = webEngineView.icon compare(iconUrl, Qt.resolvedUrl("")) } |