From 0b5a7d6132164994221fd83f70e705772337137e Mon Sep 17 00:00:00 2001
From: Peter Varga <pvarga@inf.u-szeged.hu>
Date: Tue, 21 Oct 2014 13:50:27 +0200
Subject: [PATCH] Disable error page while testing loadFail signal of Quick API

Error page should be disabled while testing loadFail signal since
testing signals of the internal error page is not possible yet.

Change-Id: I07f0bb6378fcbf5d18634197808801c94606803c
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
---
 .../auto/quick/qmltests/data/tst_loadFail.qml | 39 ++++++++++++-------
 .../auto/quick/qmltests/data/tst_loadUrl.qml  |  5 ++-
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/tests/auto/quick/qmltests/data/tst_loadFail.qml b/tests/auto/quick/qmltests/data/tst_loadFail.qml
index 7b0a1849e..694547863 100644
--- a/tests/auto/quick/qmltests/data/tst_loadFail.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadFail.qml
@@ -42,38 +42,49 @@
 import QtQuick 2.0
 import QtTest 1.0
 import QtWebEngine 1.0
+import QtWebEngine.experimental 1.0
 
 TestWebEngineView {
     id: webEngineView
     width: 400
     height: 300
 
-    property variant testUrl
-
-    SignalSpy {
-        id: spyIconChanged
-        target: webEngineView
-        signalName: "iconChanged"
-    }
+    property variant unavailableUrl
 
     TestCase {
         id: test
         name: "WebEngineViewLoadFail"
+
+        function initTestCase() {
+            WebEngine.settings.errorPageEnabled = false
+        }
+
         function test_fail() {
-            testUrl = Qt.resolvedUrl("file_that_does_not_exist.html")
-            webEngineView.url = testUrl
+            unavailableUrl = Qt.resolvedUrl("file_that_does_not_exist.html")
+            webEngineView.url = unavailableUrl
             verify(webEngineView.waitForLoadFailed())
-            spyIconChanged.clear()
+        }
 
-            // If this testcase finishes too early, we can not handle the received replacement content.
-            // So we should wait to ignore this error page.
-            spyIconChanged.wait()
+        function test_fail_url() {
+            var url = Qt.resolvedUrl("test1.html")
+            webEngineView.url = url
+            compare(webEngineView.url, url)
+            verify(webEngineView.waitForLoadSucceeded())
+            compare(webEngineView.url, url)
+
+            unavailableUrl = Qt.resolvedUrl("file_that_does_not_exist.html")
+            webEngineView.url = unavailableUrl
+            compare(webEngineView.url, unavailableUrl)
+            verify(webEngineView.waitForLoadFailed())
+            // When error page is disabled in case of LoadFail the entry of the unavailable page is not stored.
+            // We expect the url of the previously loaded page here.
+            compare(webEngineView.url, url)
         }
     }
 
     onLoadingChanged: {
         if (loadRequest.status == WebEngineView.LoadFailedStatus) {
-            test.compare(loadRequest.url, testUrl)
+            test.compare(loadRequest.url, unavailableUrl)
             test.compare(loadRequest.errorDomain, WebEngineView.InternalErrorDomain)
         }
     }
diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
index 5f51e9036..e0e185eb0 100644
--- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
@@ -42,6 +42,7 @@
 import QtQuick 2.0
 import QtTest 1.0
 import QtWebEngine 1.0
+import QtWebEngine.experimental 1.0
 
 TestWebEngineView {
     id: webEngineView
@@ -106,6 +107,8 @@ TestWebEngineView {
         }
 
         function test_urlProperty() {
+            WebEngine.settings.errorPageEnabled = false
+
             var url = Qt.resolvedUrl("test1.html")
 
             webEngineView.url = url
@@ -117,7 +120,7 @@ TestWebEngineView {
             webEngineView.url = bogusSite
             compare(webEngineView.url, bogusSite)
             verify(webEngineView.waitForLoadFailed())
-            compare(webEngineView.url, bogusSite)
+            compare(webEngineView.url, url)
 
             webEngineView.url = "about:blank" // Reset from previous test
             verify(webEngineView.waitForLoadSucceeded())
-- 
GitLab