From 6252f0231f85e5f4e6b887a6814d4968acae13bd Mon Sep 17 00:00:00 2001
From: Peter Varga <pvarga@inf.u-szeged.hu>
Date: Wed, 1 Feb 2017 11:34:27 +0100
Subject: [PATCH] Yet another speculative fix of linkHovered QML tests

When the test moves the mouse cursor out of the link area it positions
the cursor above an iframe. We should not expect linkHovered signal
above an iframe until its load is succeeded. Since we don't have API to
test iframes' loading state, remove the iframe from the test.
Moreover, increase signal timeout values to 12sec as it is used in other
tests too since the 55-based chromium update.

Task-number: QTBUG-55870
Change-Id: Id47494ac41a9d34f8a5bf4804fc5c157868cf923
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
---
 tests/auto/quick/qmltests/BLACKLIST                    |  6 ------
 tests/auto/quick/qmltests/data/test-iframe.html        |  9 +++++++++
 tests/auto/quick/qmltests/data/test2.html              |  3 ---
 tests/auto/quick/qmltests/data/tst_linkHovered.qml     |  8 ++++----
 .../quick/qmltests/data/tst_navigationRequested.qml    | 10 +++++-----
 tests/auto/quick/qmltests/qmltests.pro                 |  1 +
 6 files changed, 19 insertions(+), 18 deletions(-)
 create mode 100644 tests/auto/quick/qmltests/data/test-iframe.html

diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST
index 19d75dfb7..b7cd7042e 100644
--- a/tests/auto/quick/qmltests/BLACKLIST
+++ b/tests/auto/quick/qmltests/BLACKLIST
@@ -5,12 +5,6 @@ osx
 [WebViewGeopermission::test_geoPermissionRequest]
 osx
 
-[DesktopWebEngineViewLinkHovered::test_linkHovered]
-linux
-
-[DesktopWebEngineViewLinkHovered::test_linkHoveredDoesntEmitRepeated]
-linux
-
 [WebEngineViewSingleFileUpload::test_acceptDirectory]
 *
 
diff --git a/tests/auto/quick/qmltests/data/test-iframe.html b/tests/auto/quick/qmltests/data/test-iframe.html
new file mode 100644
index 000000000..710c4539a
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/test-iframe.html
@@ -0,0 +1,9 @@
+<html>
+<head><title>Test page with huge link area and iframe</title></head>
+<body>
+<a title="A title" href="test1.html"><img width=200 height=200></a>
+<div>
+    <iframe src="test1.html"></iframe>
+</div>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests/data/test2.html b/tests/auto/quick/qmltests/data/test2.html
index 8e20d7e9e..629c2a063 100644
--- a/tests/auto/quick/qmltests/data/test2.html
+++ b/tests/auto/quick/qmltests/data/test2.html
@@ -2,8 +2,5 @@
 <head><title>Test page with huge link area</title></head>
 <body>
 <a title="A title" href="test1.html"><img width=200 height=200></a>
-<div>
-    <iframe src="test1.html"></iframe>
-</div>
 </body>
 </html>
diff --git a/tests/auto/quick/qmltests/data/tst_linkHovered.qml b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
index 636d14335..d632452fe 100644
--- a/tests/auto/quick/qmltests/data/tst_linkHovered.qml
+++ b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
@@ -90,11 +90,11 @@ TestWebEngineView {
             loadVisuallyCommittedSpy.wait();
 
             mouseMove(webEngineView, 100, 100)
-            linkHoveredSpy.wait(10000);
+            linkHoveredSpy.wait(12000);
             compare(linkHoveredSpy.count, 2);
             compare(webEngineView.lastUrl, Qt.resolvedUrl("test1.html"))
             mouseMove(webEngineView, 100, 300)
-            linkHoveredSpy.wait(10000);
+            linkHoveredSpy.wait(12000);
             compare(linkHoveredSpy.count, 3);
             compare(webEngineView.lastUrl, "")
         }
@@ -115,14 +115,14 @@ TestWebEngineView {
             for (var i = 0; i < 100; i += 10)
                 mouseMove(webEngineView, 100, 100 + i)
 
-            linkHoveredSpy.wait(10000);
+            linkHoveredSpy.wait(12000);
             compare(linkHoveredSpy.count, 2);
             compare(webEngineView.lastUrl, Qt.resolvedUrl("test1.html"))
 
             for (var i = 0; i < 100; i += 10)
                 mouseMove(webEngineView, 100, 300 + i)
 
-            linkHoveredSpy.wait(10000);
+            linkHoveredSpy.wait(12000);
             compare(linkHoveredSpy.count, 3);
             compare(webEngineView.lastUrl, "")
         }
diff --git a/tests/auto/quick/qmltests/data/tst_navigationRequested.qml b/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
index b1c94e601..96128574e 100644
--- a/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
+++ b/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
@@ -92,9 +92,9 @@ TestWebEngineView {
         function test_navigationRequested() {
             // Test if we get notified about main frame and iframe loads
             compare(navigationSpy.count, 0)
-            webEngineView.url = Qt.resolvedUrl("test2.html")
+            webEngineView.url = Qt.resolvedUrl("test-iframe.html")
             navigationSpy.wait()
-            compare(attributes.mainUrl, Qt.resolvedUrl("test2.html"))
+            compare(attributes.mainUrl, Qt.resolvedUrl("test-iframe.html"))
             navigationSpy.wait()
             compare(attributes.iframeUrl, Qt.resolvedUrl("test1.html"))
             compare(navigationSpy.count, 2)
@@ -111,7 +111,7 @@ TestWebEngineView {
         function test_ignoreLinkClickedRequest() {
             // Test if we can ignore clicked link requests
             compare(navigationSpy.count, 0)
-            webEngineView.url = Qt.resolvedUrl("test2.html")
+            webEngineView.url = Qt.resolvedUrl("test-iframe.html")
             verify(webEngineView.waitForLoadSucceeded())
 
             shouldIgnoreLinkClicks = true
@@ -129,9 +129,9 @@ TestWebEngineView {
         function test_ignoreSubFrameRequest() {
             // Test if we can ignore sub frame requests
             shouldIgnoreSubFrameRequests = true
-            webEngineView.url = Qt.resolvedUrl("test2.html")
+            webEngineView.url = Qt.resolvedUrl("test-iframe.html")
             tryCompare(navigationSpy, "count", 2)
-            compare(attributes.mainUrl, Qt.resolvedUrl("test2.html"))
+            compare(attributes.mainUrl, Qt.resolvedUrl("test-iframe.html"))
             compare(attributes.iframeUrl, Qt.resolvedUrl("test1.html"))
             // We ignored the sub frame request, so
             // the main frame load should still succeed.
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
index 60c11addc..40fba4512 100644
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ b/tests/auto/quick/qmltests/qmltests.pro
@@ -38,6 +38,7 @@ OTHER_FILES += \
     $$PWD/data/test2.html \
     $$PWD/data/test3.html \
     $$PWD/data/test4.html \
+    $$PWD/data/test-iframe.html \
     $$PWD/data/keyboardModifierMapping.html \
     $$PWD/data/keyboardEvents.html \
     $$PWD/data/titleupdate.js \
-- 
GitLab