From c2c0c7d092ef3d07885eac7c8053d518d28b20c9 Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Wed, 28 Oct 2020 13:12:08 +0100 Subject: Fix tst_QWebEngineView flaky IME tests Add QTest::qWaitForWindowExposed() to make sure that the window is visible before the input event is sent. Change-Id: I72b02abaaf5970a1533f1d6f6dae59e47e891548 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 5e16361c5..cb73d7079 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -1283,6 +1283,7 @@ void tst_QWebEngineView::inputMethodsTextFormat() evaluateJavaScriptSync(view.page(), "document.getElementById('input1').focus()"); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QFETCH(QString, string); QFETCH(int, start); @@ -2051,6 +2052,7 @@ void tst_QWebEngineView::inputContextQueryInput() " " ""); QTRY_COMPARE(loadFinishedSpy.count(), 1); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QCOMPARE(testContext.infos.count(), 0); // Set focus on an input field. @@ -2202,6 +2204,7 @@ void tst_QWebEngineView::inputMethods() " " ""); QTRY_COMPARE(loadFinishedSpy.size(), 1); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QPoint textInputCenter = elementCenter(view.page(), "input1"); QTest::mouseClick(view.focusProxy(), Qt::LeftButton, {}, textInputCenter); @@ -2299,6 +2302,7 @@ void tst_QWebEngineView::textSelectionInInputField() " " ""); QVERIFY(loadFinishedSpy.wait()); + QVERIFY(QTest::qWaitForWindowExposed(&view)); // Tests for Selection when the Editor is NOT in Composition mode @@ -2508,6 +2512,7 @@ void tst_QWebEngineView::emptyInputMethodEvent() " " ""); QVERIFY(loadFinishedSpy.wait()); + QVERIFY(QTest::qWaitForWindowExposed(&view)); evaluateJavaScriptSync(view.page(), "var inputEle = document.getElementById('input1'); inputEle.focus(); inputEle.select();"); QTRY_COMPARE(selectionChangedSpy.count(), 1); @@ -2556,6 +2561,7 @@ void tst_QWebEngineView::imeComposition() " " ""); QVERIFY(loadFinishedSpy.wait()); + QVERIFY(QTest::qWaitForWindowExposed(&view)); evaluateJavaScriptSync(view.page(), "var inputEle = document.getElementById('input1'); inputEle.focus(); inputEle.select();"); QTRY_COMPARE(selectionChangedSpy.count(), 1); @@ -2773,6 +2779,7 @@ void tst_QWebEngineView::newlineInTextarea() " " ""); QVERIFY(loadFinishedSpy.wait()); + QVERIFY(QTest::qWaitForWindowExposed(&view)); evaluateJavaScriptSync(view.page(), "var inputEle = document.getElementById('input1'); inputEle.focus(); inputEle.select();"); QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.getElementById('input1').value").toString().isEmpty()); @@ -2897,6 +2904,7 @@ void tst_QWebEngineView::imeJSInputEvents() "
"
                          "");
     QVERIFY(loadFinishedSpy.wait());
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     evaluateJavaScriptSync(view.page(), "document.getElementById('input').focus()");
     QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input"));
@@ -3019,6 +3027,7 @@ void tst_QWebEngineView::imeCompositionQueryEvent()
                  "  "
                  "");
     QVERIFY(loadFinishedSpy.wait());
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     evaluateJavaScriptSync(view.page(), "document.getElementById('input1').focus()");
     QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1"));
-- 
cgit v1.2.3


From bbf7226ace4d9bbcff4d68c063dc598c2d3f2ff0 Mon Sep 17 00:00:00 2001
From: Tamas Zakor 
Date: Wed, 14 Oct 2020 14:56:47 +0200
Subject: Fix new view request handling

Ignore url loading if the request is not from a data
url and the Q(Quick)WebEngineNewViewRequest.openIn() is not
called on newViewRequested().

Set the missing Q(Quick)WebEngineNewViewRequest::requestedUrl
property.

Fixes: QTBUG-87378
Change-Id: Idddc9cf075db68dcf5825b3e746d16419d02cfa0
Reviewed-by: Tamas Zakor 
Reviewed-by: Peter Varga 
Reviewed-by: Allan Sandfeld Jensen 
---
 .../auto/quick/qmltests/data/TestWebEngineView.qml |  6 ++++--
 tests/auto/quick/qmltests/data/test2.html          |  2 +-
 .../quick/qmltests/data/tst_newViewRequest.qml     | 25 ++++++++++++++++++++++
 .../widgets/qwebenginepage/tst_qwebenginepage.cpp  |  9 +++++++-
 4 files changed, 38 insertions(+), 4 deletions(-)

(limited to 'tests')

diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
index 6db076ae8..f2bc09e4b 100644
--- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml
+++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
@@ -85,12 +85,14 @@ WebEngineView {
 
     function getElementCenter(element) {
             var center;
-            runJavaScript("(function() {" +
+            testCase.tryVerify(function() {
+                runJavaScript("(function() {" +
                           "   var elem = document.getElementById('" + element + "');" +
                           "   var rect = elem.getBoundingClientRect();" +
                           "   return { 'x': (rect.left + rect.right) / 2, 'y': (rect.top + rect.bottom) / 2 };" +
                           "})();", function(result) { center = result } );
-            testCase.tryVerify(function() { return center !== undefined; });
+                return center !== undefined;
+            });
             return center;
     }
 
diff --git a/tests/auto/quick/qmltests/data/test2.html b/tests/auto/quick/qmltests/data/test2.html
index 629c2a063..7a02bf1f2 100644
--- a/tests/auto/quick/qmltests/data/test2.html
+++ b/tests/auto/quick/qmltests/data/test2.html
@@ -1,6 +1,6 @@
 
 Test page with huge link area
 
-
+
 
 
diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
index 80389e9f8..08d63d956 100644
--- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
+++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
@@ -38,6 +38,13 @@ TestWebEngineView {
     property var newViewRequest: null
     property var dialog: null
     property string viewType: ""
+    property var loadRequestArray: []
+
+    onLoadingChanged: {
+        loadRequestArray.push({
+            "status": loadRequest.status,
+        });
+    }
 
     SignalSpy {
         id: newViewRequestedSpy
@@ -81,6 +88,7 @@ TestWebEngineView {
             newViewRequestedSpy.clear();
             newViewRequest = null;
             viewType = "";
+            loadRequestArray = [];
         }
 
         function cleanup() {
@@ -163,6 +171,23 @@ TestWebEngineView {
                 }
                 newViewRequestedSpy.clear();
             }
+
+            loadRequestArray = [];
+            compare(loadRequestArray.length, 0);
+            webEngineView.url = Qt.resolvedUrl("test2.html");
+            verify(webEngineView.waitForLoadSucceeded());
+            var center = getElementCenter("link");
+            mouseClick(webEngineView, center.x, center.y, Qt.LeftButton, Qt.ControlModifier);
+            tryCompare(newViewRequestedSpy, "count", 1);
+            compare(newViewRequest.requestedUrl, Qt.resolvedUrl("test1.html"));
+            compare(newViewRequest.destination, WebEngineView.NewViewInBackgroundTab);
+            verify(newViewRequest.userInitiated);
+            if (viewType === "" || viewType === "null") {
+                compare(loadRequestArray[0].status, WebEngineView.LoadStartedStatus);
+                compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus);
+                compare(loadRequestArray.length, 2);
+            }
+            newViewRequestedSpy.clear();
         }
     }
 }
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 040114258..55e888abf 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -3458,7 +3458,11 @@ void tst_QWebEnginePage::openLinkInNewPage_data()
     // the disposition and performing the navigation request normally.
 
     QTest::newRow("BlockPopup")     << Decision::ReturnNull  << Cause::TargetBlank << Effect::Blocked;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+    QTest::newRow("IgnoreIntent")   << Decision::ReturnNull  << Cause::MiddleClick << Effect::Blocked;
+#else
     QTest::newRow("IgnoreIntent")   << Decision::ReturnNull  << Cause::MiddleClick << Effect::LoadInSelf;
+#endif
     QTest::newRow("OverridePopup")  << Decision::ReturnSelf  << Cause::TargetBlank << Effect::LoadInSelf;
     QTest::newRow("OverrideIntent") << Decision::ReturnSelf  << Cause::MiddleClick << Effect::LoadInSelf;
     QTest::newRow("AcceptPopup")    << Decision::ReturnOther << Cause::TargetBlank << Effect::LoadInOther;
@@ -3535,7 +3539,10 @@ void tst_QWebEnginePage::openLinkInNewPage()
 
     switch (effect) {
     case Effect::Blocked:
-        // Nothing to test
+        // Test nothing new loaded
+        QTest::qWait(500);
+        QCOMPARE(page1.spy.count(), 0);
+        QCOMPARE(page2.spy.count(), 0);
         break;
     case Effect::LoadInSelf:
         QTRY_COMPARE(page1.spy.count(), 1);
-- 
cgit v1.2.3


From 8f093f4f9cc48df82d639906a0a6d13231e0d6e0 Mon Sep 17 00:00:00 2001
From: Tamas Zakor 
Date: Fri, 30 Oct 2020 09:42:56 +0100
Subject: Fix flaky tst_QWebEngineView::textSelectionOutOfInputField test

Change-Id: I86e873da822bb2af99c2b4f0771fe164d4342c8f
Reviewed-by: Allan Sandfeld Jensen 
---
 tests/auto/widgets/qwebengineview/BLACKLIST              | 3 ---
 tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'tests')

diff --git a/tests/auto/widgets/qwebengineview/BLACKLIST b/tests/auto/widgets/qwebengineview/BLACKLIST
index 266f08886..1aff12669 100644
--- a/tests/auto/widgets/qwebengineview/BLACKLIST
+++ b/tests/auto/widgets/qwebengineview/BLACKLIST
@@ -1,8 +1,5 @@
 [microFocusCoordinates]
 osx
 
-[textSelectionOutOfInputField]
-*
-
 [visibilityState3]
 windows
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 5e16361c5..04e4b3ada 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -2372,6 +2372,7 @@ void tst_QWebEngineView::textSelectionInInputField()
 void tst_QWebEngineView::textSelectionOutOfInputField()
 {
     QWebEngineView view;
+    view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
     view.resize(640, 480);
     view.show();
 
@@ -2381,6 +2382,7 @@ void tst_QWebEngineView::textSelectionOutOfInputField()
                  "  This is a text"
                  "");
     QVERIFY(loadFinishedSpy.wait());
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     QCOMPARE(selectionChangedSpy.count(), 0);
     QVERIFY(!view.hasSelection());
@@ -2429,6 +2431,7 @@ void tst_QWebEngineView::textSelectionOutOfInputField()
                  "  "
                  "");
     QVERIFY(loadFinishedSpy.wait());
+    QVERIFY(QTest::qWaitForWindowExposed(&view));
 
     QCOMPARE(selectionChangedSpy.count(), 0);
     QVERIFY(!view.hasSelection());
-- 
cgit v1.2.3


From 8d11edc26114e277285b4c88a6f2fa7924bd7e35 Mon Sep 17 00:00:00 2001
From: Kirill Burtsev 
Date: Fri, 16 Oct 2020 20:01:06 +0200
Subject: Move touch input tests to separate testcase

Since it's very distinct area and not very specific to view. Aggregate
test code in separate subfolder and simplify by removing duplications.

Change-Id: Iaaa28612b074245dc548553099e7e17a70327a37
Reviewed-by: Allan Sandfeld Jensen 
---
 .../widgets/qwebengineview/tst_qwebengineview.cpp  | 209 ---------------------
 tests/auto/widgets/touchinput/touchinput.pro       |   2 +
 tests/auto/widgets/touchinput/tst_touchinput.cpp   | 200 ++++++++++++++++++++
 tests/auto/widgets/util.h                          |  37 ++++
 tests/auto/widgets/widgets.pro                     |   3 +
 5 files changed, 242 insertions(+), 209 deletions(-)
 create mode 100644 tests/auto/widgets/touchinput/touchinput.pro
 create mode 100644 tests/auto/widgets/touchinput/tst_touchinput.cpp

(limited to 'tests')

diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 04e4b3ada..0b7356034 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -25,7 +25,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -60,44 +59,6 @@ do { \
     QCOMPARE((__expr), __expected); \
 } while (0)
 
-static QTouchDevice* s_touchDevice = nullptr;
-
-static QPoint elementCenter(QWebEnginePage *page, const QString &id)
-{
-    const QString jsCode(
-            "(function(){"
-            "   var elem = document.getElementById('" + id + "');"
-            "   var rect = elem.getBoundingClientRect();"
-            "   return [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2];"
-            "})()");
-    QVariantList rectList = evaluateJavaScriptSync(page, jsCode).toList();
-
-    if (rectList.count() != 2) {
-        qWarning("elementCenter failed.");
-        return QPoint();
-    }
-
-    return QPoint(rectList.at(0).toInt(), rectList.at(1).toInt());
-}
-
-static QRect elementGeometry(QWebEnginePage *page, const QString &id)
-{
-    const QString jsCode(
-                "(function() {"
-                "   var elem = document.getElementById('" + id + "');"
-                "   var rect = elem.getBoundingClientRect();"
-                "   return [rect.left, rect.top, rect.right, rect.bottom];"
-                "})()");
-    QVariantList coords = evaluateJavaScriptSync(page, jsCode).toList();
-
-    if (coords.count() != 4) {
-        qWarning("elementGeometry faield.");
-        return QRect();
-    }
-
-    return QRect(coords[0].toInt(), coords[1].toInt(), coords[2].toInt(), coords[3].toInt());
-}
-
 QT_BEGIN_NAMESPACE
 namespace QTest {
     int Q_TESTLIB_EXPORT defaultMouseDelay();
@@ -167,9 +128,6 @@ private Q_SLOTS:
     void keyboardEvents();
     void keyboardFocusAfterPopup();
     void mouseClick();
-    void touchTap();
-    void touchTapAndHold();
-    void touchTapAndHoldCancelled();
     void postData();
     void inputFieldOverridesShortcuts();
 
@@ -216,7 +174,6 @@ private Q_SLOTS:
 // It is only called once.
 void tst_QWebEngineView::initTestCase()
 {
-    s_touchDevice = QTest::createTouchDevice();
 }
 
 // This will be called after the last test function is executed.
@@ -1520,172 +1477,6 @@ void tst_QWebEngineView::mouseClick()
     QVERIFY(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString().isEmpty());
 }
 
-void tst_QWebEngineView::touchTap()
-{
-#if defined(Q_OS_MACOS)
-    QSKIP("Synthetic touch events are not supported on macOS");
-#endif
-
-    QWebEngineView view;
-    view.show();
-    view.resize(200, 200);
-    QVERIFY(QTest::qWaitForWindowExposed(&view));
-
-    QSignalSpy loadFinishedSpy(&view, &QWebEngineView::loadFinished);
-
-    view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
-    view.setHtml(""
-                 "

The Qt Company

" - "
" - "
" - ""); - QVERIFY(loadFinishedSpy.wait()); - QVERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - - auto singleTap = [](QWidget* target, const QPoint& tapCoords) -> void { - QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target); - QTest::touchEvent(target, s_touchDevice).stationary(1); - QTest::touchEvent(target, s_touchDevice).release(1, tapCoords, target); - }; - - // Single tap on text doesn't trigger a selection - singleTap(view.focusProxy(), elementCenter(view.page(), "text")); - QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - QTRY_VERIFY(!view.hasSelection()); - - // Single tap inside the input field focuses it without selecting the text - singleTap(view.focusProxy(), elementCenter(view.page(), "input")); - QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input")); - QTRY_VERIFY(!view.hasSelection()); - - // Single tap on the div clears the input field focus - singleTap(view.focusProxy(), elementCenter(view.page(), "notext")); - QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - - // Double tap on text still doesn't trigger a selection - singleTap(view.focusProxy(), elementCenter(view.page(), "text")); - singleTap(view.focusProxy(), elementCenter(view.page(), "text")); - QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - QTRY_VERIFY(!view.hasSelection()); - - // Double tap inside the input field focuses it and selects the word under it - singleTap(view.focusProxy(), elementCenter(view.page(), "input")); - singleTap(view.focusProxy(), elementCenter(view.page(), "input")); - QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input")); - QTRY_COMPARE(view.selectedText(), QStringLiteral("Company2")); - - // Double tap outside the input field behaves like a single tap: clears its focus and selection - singleTap(view.focusProxy(), elementCenter(view.page(), "notext")); - singleTap(view.focusProxy(), elementCenter(view.page(), "notext")); - QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - QTRY_VERIFY(!view.hasSelection()); -} - -void tst_QWebEngineView::touchTapAndHold() -{ -#if defined(Q_OS_MACOS) - QSKIP("Synthetic touch events are not supported on macOS"); -#endif - - QWebEngineView view; - view.show(); - view.resize(200, 200); - QVERIFY(QTest::qWaitForWindowExposed(&view)); - - QSignalSpy loadFinishedSpy(&view, &QWebEngineView::loadFinished); - - view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false); - view.setHtml("" - "

The Qt Company

" - "
" - "
" - ""); - QVERIFY(loadFinishedSpy.wait()); - QVERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - - auto tapAndHold = [](QWidget* target, const QPoint& tapCoords) -> void { - QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target); - QTest::touchEvent(target, s_touchDevice).stationary(1); - QTest::qWait(1000); - QTest::touchEvent(target, s_touchDevice).release(1, tapCoords, target); - }; - - // Tap-and-hold on text selects the word under it - tapAndHold(view.focusProxy(), elementCenter(view.page(), "text")); - QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - QTRY_COMPARE(view.selectedText(), QStringLiteral("Company")); - - // Tap-and-hold inside the input field focuses it and selects the word under it - tapAndHold(view.focusProxy(), elementCenter(view.page(), "input")); - QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input")); - QTRY_COMPARE(view.selectedText(), QStringLiteral("Company2")); - - // Only test the page context menu on Windows, as Linux doesn't handle context menus consistently - // and other non-desktop platforms like Android may not even support context menus at all -#if defined(Q_OS_WIN) - // Tap-and-hold clears the text selection and shows the page's context menu - QVERIFY(QApplication::activePopupWidget() == nullptr); - tapAndHold(view.focusProxy(), elementCenter(view.page(), "notext")); - QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - QTRY_VERIFY(!view.hasSelection()); - QTRY_VERIFY(QApplication::activePopupWidget() != nullptr); - - QApplication::activePopupWidget()->close(); - QVERIFY(QApplication::activePopupWidget() == nullptr); -#endif -} - -void tst_QWebEngineView::touchTapAndHoldCancelled() -{ -#if defined(Q_OS_MACOS) - QSKIP("Synthetic touch events are not supported on macOS"); -#endif - - QWebEngineView view; - view.show(); - view.resize(200, 200); - QVERIFY(QTest::qWaitForWindowExposed(&view)); - - QSignalSpy loadFinishedSpy(&view, &QWebEngineView::loadFinished); - - view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false); - view.setHtml("" - "

The Qt Company

" - "
" - "
" - ""); - QVERIFY(loadFinishedSpy.wait()); - QVERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); - - auto cancelledTapAndHold = [](QWidget* target, const QPoint& tapCoords) -> void { - QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target); - QTest::touchEvent(target, s_touchDevice).stationary(1); - QTest::qWait(1000); - QWindowSystemInterface::handleTouchCancelEvent(target->windowHandle(), s_touchDevice); - }; - - // A cancelled tap-and-hold should cancel text selection, but currently doesn't - cancelledTapAndHold(view.focusProxy(), elementCenter(view.page(), "text")); - QEXPECT_FAIL("", "Incorrect Chromium selection behavior when cancelling tap-and-hold on text", Continue); - QTRY_VERIFY_WITH_TIMEOUT(!view.hasSelection(), 100); - - // A cancelled tap-and-hold should cancel input field focusing and selection, but currently doesn't - cancelledTapAndHold(view.focusProxy(), elementCenter(view.page(), "input")); - QEXPECT_FAIL("", "Incorrect Chromium selection behavior when cancelling tap-and-hold on input field", Continue); - QTRY_VERIFY_WITH_TIMEOUT(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty(), 100); - QEXPECT_FAIL("", "Incorrect Chromium focus behavior when cancelling tap-and-hold on input field", Continue); - QTRY_VERIFY_WITH_TIMEOUT(!view.hasSelection(), 100); - - // Only test the page context menu on Windows, as Linux doesn't handle context menus consistently - // and other non-desktop platforms like Android may not even support context menus at all -#if defined(Q_OS_WIN) - // A cancelled tap-and-hold cancels the context menu - QVERIFY(QApplication::activePopupWidget() == nullptr); - cancelledTapAndHold(view.focusProxy(), elementCenter(view.page(), "notext")); - QVERIFY(QApplication::activePopupWidget() == nullptr); -#endif -} - void tst_QWebEngineView::postData() { QMap postData; diff --git a/tests/auto/widgets/touchinput/touchinput.pro b/tests/auto/widgets/touchinput/touchinput.pro new file mode 100644 index 000000000..d91c0074b --- /dev/null +++ b/tests/auto/widgets/touchinput/touchinput.pro @@ -0,0 +1,2 @@ +include(../tests.pri) +QT *= gui-private diff --git a/tests/auto/widgets/touchinput/tst_touchinput.cpp b/tests/auto/widgets/touchinput/tst_touchinput.cpp new file mode 100644 index 000000000..fb5272dbe --- /dev/null +++ b/tests/auto/widgets/touchinput/tst_touchinput.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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 "../util.h" + +#include +#include +#include +#include +#include +#include + +static QTouchDevice* s_touchDevice = nullptr; + +class TouchInputTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void initTestCase(); + void init(); + void cleanup(); + +private Q_SLOTS: + void touchTap(); + void touchTapAndHold(); + void touchTapAndHoldCancelled(); + +private: + QWebEngineView view; + QSignalSpy loadSpy { &view, &QWebEngineView::loadFinished }; + QPoint notextCenter, textCenter, inputCenter; + + QString activeElement() { return evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(); } +}; + +void TouchInputTest::initTestCase() +{ + s_touchDevice = QTest::createTouchDevice(); + + view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false); + + view.show(); view.resize(480, 320); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + view.setHtml("" + "

The Qt Company

" + "
" + "
" + ""); + QVERIFY(loadSpy.wait() && loadSpy.first().first().toBool()); + + notextCenter = elementCenter(view.page(), "notext"); + textCenter = elementCenter(view.page(), "text"); + inputCenter = elementCenter(view.page(), "input"); +} + +void TouchInputTest::init() +{ + QCOMPARE(activeElement(), QString()); +} + +void TouchInputTest::cleanup() +{ + evaluateJavaScriptSync(view.page(), "if (document.activeElement) document.activeElement.blur()"); +} + +void TouchInputTest::touchTap() +{ + auto singleTap = [target = view.focusProxy()] (const QPoint& tapCoords) -> void { + QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target); + QTest::touchEvent(target, s_touchDevice).stationary(1); + QTest::touchEvent(target, s_touchDevice).release(1, tapCoords, target); + }; + + // Single tap on text doesn't trigger a selection + singleTap(textCenter); + QTRY_COMPARE(activeElement(), QString()); + QTRY_VERIFY(!view.hasSelection()); + + // Single tap inside the input field focuses it without selecting the text + singleTap(inputCenter); + QTRY_COMPARE(activeElement(), QStringLiteral("input")); + QTRY_VERIFY(!view.hasSelection()); + + // Single tap on the div clears the input field focus + singleTap(notextCenter); + QTRY_COMPARE(activeElement(), QString()); + + // Double tap on text still doesn't trigger a selection + singleTap(textCenter); + singleTap(textCenter); + QTRY_COMPARE(activeElement(), QString()); + QTRY_VERIFY(!view.hasSelection()); + + // Double tap inside the input field focuses it and selects the word under it + singleTap(inputCenter); + singleTap(inputCenter); + QTRY_COMPARE(activeElement(), QStringLiteral("input")); + QTRY_COMPARE(view.selectedText(), QStringLiteral("Company2")); + + // Double tap outside the input field behaves like a single tap: clears its focus and selection + singleTap(notextCenter); + singleTap(notextCenter); + QTRY_COMPARE(activeElement(), QString()); + QTRY_VERIFY(!view.hasSelection()); +} + +void TouchInputTest::touchTapAndHold() +{ + auto tapAndHold = [target = view.focusProxy()] (const QPoint& tapCoords) -> void { + QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target); + QTest::touchEvent(target, s_touchDevice).stationary(1); + QTest::qWait(1000); + QTest::touchEvent(target, s_touchDevice).release(1, tapCoords, target); + }; + + // Tap-and-hold on text selects the word under it + tapAndHold(textCenter); + QTRY_COMPARE(activeElement(), QString()); + QTRY_COMPARE(view.selectedText(), QStringLiteral("Company")); + + // Tap-and-hold inside the input field focuses it and selects the word under it + tapAndHold(inputCenter); + QTRY_COMPARE(activeElement(), QStringLiteral("input")); + QTRY_COMPARE(view.selectedText(), QStringLiteral("Company2")); + + // Only test the page context menu on Windows, as Linux doesn't handle context menus consistently + // and other non-desktop platforms like Android may not even support context menus at all +#if defined(Q_OS_WIN) + // Tap-and-hold clears the text selection and shows the page's context menu + QVERIFY(QApplication::activePopupWidget() == nullptr); + tapAndHold(notextCenter); + QTRY_COMPARE(activeElement(), QString()); + QTRY_VERIFY(!view.hasSelection()); + QTRY_VERIFY(QApplication::activePopupWidget() != nullptr); + + QApplication::activePopupWidget()->close(); + QVERIFY(QApplication::activePopupWidget() == nullptr); +#endif +} + +void TouchInputTest::touchTapAndHoldCancelled() +{ + auto cancelledTapAndHold = [target = view.focusProxy()] (const QPoint& tapCoords) -> void { + QTest::touchEvent(target, s_touchDevice).press(1, tapCoords, target); + QTest::touchEvent(target, s_touchDevice).stationary(1); + QTest::qWait(1000); + QWindowSystemInterface::handleTouchCancelEvent(target->windowHandle(), s_touchDevice); + }; + + // A cancelled tap-and-hold should cancel text selection, but currently doesn't + cancelledTapAndHold(textCenter); + QEXPECT_FAIL("", "Incorrect Chromium selection behavior when cancelling tap-and-hold on text", Continue); + QTRY_VERIFY_WITH_TIMEOUT(!view.hasSelection(), 100); + + // A cancelled tap-and-hold should cancel input field focusing and selection, but currently doesn't + cancelledTapAndHold(inputCenter); + QEXPECT_FAIL("", "Incorrect Chromium selection behavior when cancelling tap-and-hold on input field", Continue); + QTRY_VERIFY_WITH_TIMEOUT(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty(), 100); + QEXPECT_FAIL("", "Incorrect Chromium focus behavior when cancelling tap-and-hold on input field", Continue); + QTRY_VERIFY_WITH_TIMEOUT(!view.hasSelection(), 100); + + // Only test the page context menu on Windows, as Linux doesn't handle context menus consistently + // and other non-desktop platforms like Android may not even support context menus at all +#if defined(Q_OS_WIN) + // A cancelled tap-and-hold cancels the context menu + QVERIFY(QApplication::activePopupWidget() == nullptr); + cancelledTapAndHold(notextCenter); + QVERIFY(QApplication::activePopupWidget() == nullptr); +#endif +} + +QTEST_MAIN(TouchInputTest) +#include "tst_touchinput.moc" diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h index af0b9bf6f..461baf9ac 100644 --- a/tests/auto/widgets/util.h +++ b/tests/auto/widgets/util.h @@ -184,6 +184,43 @@ static inline bool loadSync(QWebEngineView *view, const QUrl &url, bool ok = tru return loadSync(view->page(), url, ok); } +static inline QPoint elementCenter(QWebEnginePage *page, const QString &id) +{ + const QString jsCode( + "(function(){" + " var elem = document.getElementById('" + id + "');" + " var rect = elem.getBoundingClientRect();" + " return [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2];" + "})()"); + QVariantList rectList = evaluateJavaScriptSync(page, jsCode).toList(); + + if (rectList.count() != 2) { + qWarning("elementCenter failed."); + return QPoint(); + } + + return QPoint(rectList.at(0).toInt(), rectList.at(1).toInt()); +} + +static inline QRect elementGeometry(QWebEnginePage *page, const QString &id) +{ + const QString jsCode( + "(function() {" + " var elem = document.getElementById('" + id + "');" + " var rect = elem.getBoundingClientRect();" + " return [rect.left, rect.top, rect.right, rect.bottom];" + "})()"); + QVariantList coords = evaluateJavaScriptSync(page, jsCode).toList(); + + if (coords.count() != 4) { + qWarning("elementGeometry faield."); + return QRect(); + } + + return QRect(coords[0].toInt(), coords[1].toInt(), coords[2].toInt(), coords[3].toInt()); +} + + #define W_QSKIP(a, b) QSKIP(a) #define W_QTEST_MAIN(TestObject, params) \ diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro index 6d65eecb5..2dc1eefcd 100644 --- a/tests/auto/widgets/widgets.pro +++ b/tests/auto/widgets/widgets.pro @@ -22,6 +22,9 @@ SUBDIRS += \ qwebenginesettings \ qwebengineview +# Synthetic touch events are not supported on macOS +!macos: SUBDIRS += touchinput + qtConfig(accessibility) { SUBDIRS += accessibility } -- cgit v1.2.3 From fe9e71201590db3eac0d4be31f8a60887dfe4ef8 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 16 Oct 2020 21:07:10 +0200 Subject: Add touch input tests for scrolling and pinch zooming Change-Id: I44185766baa5c7edd0fd45b7ea10388ca25ae0de Reviewed-by: Allan Sandfeld Jensen --- tests/auto/widgets/touchinput/tst_touchinput.cpp | 94 +++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/touchinput/tst_touchinput.cpp b/tests/auto/widgets/touchinput/tst_touchinput.cpp index fb5272dbe..3eee6d824 100644 --- a/tests/auto/widgets/touchinput/tst_touchinput.cpp +++ b/tests/auto/widgets/touchinput/tst_touchinput.cpp @@ -50,6 +50,8 @@ private Q_SLOTS: void touchTap(); void touchTapAndHold(); void touchTapAndHoldCancelled(); + void scrolling(); + void pinchZoom(); private: QWebEngineView view; @@ -57,6 +59,55 @@ private: QPoint notextCenter, textCenter, inputCenter; QString activeElement() { return evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(); } + + void gestureScroll(bool down) { + auto target = view.focusProxy(); + QPoint p(target->width() / 2, target->height() / 4 * (down ? 3 : 1)); + + QTest::touchEvent(target, s_touchDevice).press(42, p, target); + + for (int i = 0; i < 3; ++i) { + down ? p -= QPoint(5, 15) : p += QPoint(5, 15); + QTest::qWait(100); // too fast and events are recognized as fling gesture + QTest::touchEvent(target, s_touchDevice).move(42, p, target); + } + + QTest::touchEvent(target, s_touchDevice).release(42, p, target); + } + + void gesturePinch(bool zoomIn) { + auto target = view.focusProxy(); + QPoint p(target->width() / 2, target->height() / 2); + auto t1 = p - QPoint(zoomIn ? 50 : 150, 10), t2 = p + QPoint(zoomIn ? 50 : 150, 10); + + QTest::touchEvent(target, s_touchDevice).press(42, t1, target); + QTest::touchEvent(target, s_touchDevice).stationary(42).press(24, t2, target); + + for (int i = 0; i < 3; ++i) { + if (zoomIn) { + t1 -= QPoint(25, 5); + t2 += QPoint(25, 5); + } else { + t1 += QPoint(35, 5); + t2 -= QPoint(35, 5); + } + QTest::qWait(100); // too fast and events are recognized as fling gesture + QTest::touchEvent(target, s_touchDevice).move(24, t1, target).move(42, t2, target); + } + + QTest::touchEvent(target, s_touchDevice).stationary(42).release(24, t2, target); + QTest::touchEvent(target, s_touchDevice).release(42, t1, target); + } + + int getScrollPosition(int *position = nullptr) { + int p = evaluateJavaScriptSync(view.page(), "window.scrollY").toInt(); + return position ? (*position = p) : p; + } + + double getScaleFactor(double *scale = nullptr) { + double s = evaluateJavaScriptSync(view.page(), "window.visualViewport.scale").toDouble(); + return scale ? (*scale = s) : s; + } }; void TouchInputTest::initTestCase() @@ -68,10 +119,14 @@ void TouchInputTest::initTestCase() view.show(); view.resize(480, 320); QVERIFY(QTest::qWaitForWindowExposed(&view)); - view.setHtml("" + view.setHtml("" "

The Qt Company

" "
" "
" + "" + "" + "" + "
BEFORE
AFTER
BEFORE
AFTER
BEFORE
AFTER
" ""); QVERIFY(loadSpy.wait() && loadSpy.first().first().toBool()); @@ -88,6 +143,8 @@ void TouchInputTest::init() void TouchInputTest::cleanup() { evaluateJavaScriptSync(view.page(), "if (document.activeElement) document.activeElement.blur()"); + evaluateJavaScriptSync(view.page(), "window.scrollTo(0, 0)"); + QTRY_COMPARE(getScrollPosition(), 0); } void TouchInputTest::touchTap() @@ -196,5 +253,40 @@ void TouchInputTest::touchTapAndHoldCancelled() #endif } +void TouchInputTest::scrolling() +{ + int p = getScrollPosition(); + QCOMPARE(p, 0); + + // scroll a bit down... + for (int i = 0; i < 3; ++i) { + gestureScroll(/* down = */true); + int positionBefore = p; + QTRY_VERIFY2(getScrollPosition(&p) > positionBefore, qPrintable(QString("i: %1, position: %2 -> %3").arg(i).arg(positionBefore).arg(p))); + } + + // ... and then scroll page again but in opposite direction + for (int i = 0; i < 3; ++i) { + gestureScroll(/* down = */false); + int positionBefore = p; + QTRY_VERIFY2(getScrollPosition(&p) < positionBefore, qPrintable(QString("i: %1, position: %2 -> %3").arg(i).arg(positionBefore).arg(p))); + } + + QTRY_COMPARE(getScrollPosition(), 0); +} + +void TouchInputTest::pinchZoom() +{ + double scale = getScaleFactor(); + QCOMPARE(scale, 1.0); + + for (int i = 0; i < 3; ++i) { + gesturePinch(/* zoomIn = */true); + QTRY_VERIFY2(getScaleFactor(&scale) > 1.5, qPrintable(QString("i: %1, scale: %2").arg(i).arg(scale))); + gesturePinch(/* zoomIn = */false); + QTRY_COMPARE(getScaleFactor(&scale), 1.0); + } +} + QTEST_MAIN(TouchInputTest) #include "tst_touchinput.moc" -- cgit v1.2.3 From 518cb95730dd1ac889cbe732fab11019085a5cd8 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 26 Nov 2020 19:29:02 +0100 Subject: Set custom headers from QWebEngineUrlRequestInfo before triggering redirect Fixes: QTBUG-88861 Change-Id: I7091aca70aaf87edf0b1e67ec3fa705a59c8192c Reviewed-by: Michal Klocek --- .../resources/content.html | 3 +- .../resources/content2.html | 6 ++ .../tst_qwebengineurlrequestinterceptor.cpp | 89 ++++++++++++++-------- 3 files changed, 67 insertions(+), 31 deletions(-) create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/content2.html (limited to 'tests') diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html index 360ad65ef..84bf55036 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html @@ -1,5 +1,6 @@ + -This is test content +Simple test page without favicon (meaning no separate request from http server) diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/content2.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content2.html new file mode 100644 index 000000000..84bf55036 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content2.html @@ -0,0 +1,6 @@ + + + +Simple test page without favicon (meaning no separate request from http server) + + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp index 20e191a4f..bf4acec14 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp @@ -70,8 +70,8 @@ private Q_SLOTS: void requestInterceptorByResourceType(); void firstPartyUrlHttp_data(); void firstPartyUrlHttp(); - void passRefererHeader_data(); - void passRefererHeader(); + void customHeaders_data(); + void customHeaders(); void initiator_data(); void initiator(); void jsServiceWorker_data(); @@ -116,36 +116,39 @@ struct RequestInfo { int resourceType; }; -static const QByteArray kHttpHeaderReferrerValue = QByteArrayLiteral("http://somereferrer.com/"); -static const QByteArray kHttpHeaderRefererName = QByteArrayLiteral("referer"); static const QUrl kRedirectUrl = QUrl("qrc:///resources/content.html"); +Q_LOGGING_CATEGORY(lc, "qt.webengine.tests") + class TestRequestInterceptor : public QWebEngineUrlRequestInterceptor { public: QList requestInfos; bool shouldRedirect = false; + QUrl redirectUrl; QMap> requestInitiatorUrls; QMap headers; void interceptRequest(QWebEngineUrlRequestInfo &info) override { QCOMPARE(QThread::currentThread() == QCoreApplication::instance()->thread(), !property("deprecated").toBool()); + qCDebug(lc) << this << "Type:" << info.resourceType() << info.requestMethod() << "Navigation:" << info.navigationType() + << info.requestUrl() << "Initiator:" << info.initiator(); // Since 63 we also intercept some unrelated blob requests.. if (info.requestUrl().scheme() == QLatin1String("blob")) return; bool block = info.requestMethod() != QByteArrayLiteral("GET"); - bool redirect = shouldRedirect && info.requestUrl() != kRedirectUrl; + bool redirect = shouldRedirect && info.requestUrl() != redirectUrl; + + // set additional headers if any required by test + for (auto it = headers.begin(); it != headers.end(); ++it) info.setHttpHeader(it.key(), it.value()); if (block) { info.block(true); } else if (redirect) { - info.redirect(kRedirectUrl); - } else { - // set additional headers if any required by test - for (auto it = headers.begin(); it != headers.end(); ++it) info.setHttpHeader(it.key(), it.value()); + info.redirect(redirectUrl); } requestInitiatorUrls[info.requestUrl()].insert(info.initiator()); @@ -195,8 +198,8 @@ public: return false; } - TestRequestInterceptor(bool redirect) - : shouldRedirect(redirect) + TestRequestInterceptor(bool redirect = false, const QUrl &url = kRedirectUrl) + : shouldRedirect(redirect), redirectUrl(url) { } }; @@ -627,43 +630,69 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlHttp() QCOMPARE(info.firstPartyUrl, firstPartyUrl); } -void tst_QWebEngineUrlRequestInterceptor::passRefererHeader_data() +void tst_QWebEngineUrlRequestInterceptor::customHeaders_data() { interceptRequest_data(); } -void tst_QWebEngineUrlRequestInterceptor::passRefererHeader() +void tst_QWebEngineUrlRequestInterceptor::customHeaders() { QFETCH(InterceptorSetter, setter); // Create HTTP Server to parse the request. HttpServer httpServer; - - if (!httpServer.start()) - QSKIP("Failed to start http server"); - - bool succeeded = false; - connect(&httpServer, &HttpServer::newRequest, [&succeeded](HttpReqRep *rr) { - const QByteArray headerValue = rr->requestHeader(kHttpHeaderRefererName); - QCOMPARE(headerValue, kHttpHeaderReferrerValue); - succeeded = headerValue == kHttpHeaderReferrerValue; - rr->sendResponse(); - }); + httpServer.setResourceDirs({ TESTS_SOURCE_DIR "qwebengineurlrequestinterceptor/resources" }); + QVERIFY(httpServer.start()); QWebEngineProfile profile; TestRequestInterceptor interceptor(false); - interceptor.headers.insert(kHttpHeaderRefererName, kHttpHeaderReferrerValue); (profile.*setter)(&interceptor); QWebEnginePage page(&profile); QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); - QWebEngineHttpRequest httpRequest; - QUrl requestUrl = httpServer.url(); - httpRequest.setUrl(requestUrl); - page.load(httpRequest); + interceptor.headers = { + { "referer", "http://somereferrer.com/" }, + { "from", "user@example.com" }, + { "user-agent", "mozilla/5.0 (x11; linux x86_64; rv:12.0) gecko/20100101 firefox/12.0" }, + }; + + QMap actual, expected; + connect(&httpServer, &HttpServer::newRequest, [&] (HttpReqRep *rr) { + for (auto it = expected.begin(); it != expected.end(); ++it) { + auto headerValue = rr->requestHeader(it.key()); + actual[it.key()] = headerValue; + QCOMPARE(headerValue, it.value()); + } + }); + + auto dumpHeaders = [&] () { + QString s; QDebug d(&s); + for (auto it = expected.begin(); it != expected.end(); ++it) + d << "\n\tHeader:" << it.key() << "| actual:" << actual[it.key()] << "expected:" << it.value(); + return s; + }; + + expected = interceptor.headers; + page.load(httpServer.url("/content.html")); + QVERIFY(spy.wait()); + QVERIFY2(actual == expected, qPrintable(dumpHeaders())); + + // test that custom headers are also applied on redirect + interceptor.shouldRedirect = true; + interceptor.redirectUrl = httpServer.url("/content2.html"); + interceptor.headers = { + { "referer", "http://somereferrer2.com/" }, + { "from", "user2@example.com" }, + { "user-agent", "mozilla/5.0 (compatible; googlebot/2.1; +http://www.google.com/bot.html)" }, + }; + + actual.clear(); + expected = interceptor.headers; + page.triggerAction(QWebEnginePage::Reload); QVERIFY(spy.wait()); + QVERIFY2(actual == expected, qPrintable(dumpHeaders())); + (void) httpServer.stop(); - QVERIFY(succeeded); } void tst_QWebEngineUrlRequestInterceptor::initiator_data() -- cgit v1.2.3 From 7adea5999b3eb1ac77adeb0580cb98ce35eb6ffd Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 16 Oct 2020 21:07:10 +0200 Subject: Fix handling of more than one finger for touch event This change addresses following wrong assumptions implemented earlier: * fix assert condition for custom MotionEventQt: pointer index is only reserved only for two distinct events POINTER_UP and POINTER_DOWN, which represent one single non first/last pointer up and down event. * MotionEvent API doesn't support delivering multiple touch point changes at once, hence code should send every touch point's up/down step by step to not confuse gesture detection classes in chromimum (ultimately fixing arising asserts which old code was triggering before). * MotionEvent shouldn't contain more touch points then were already forwarded or reported released, hence every step should contain only part of all touch points received in handleTouchEvent. Fixes: QTBUG-86389 Change-Id: I62275dc295494f88a6e44f36fe72f5f8227e37d4 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Michal Klocek --- tests/auto/widgets/touchinput/tst_touchinput.cpp | 63 +++++++++++++++++++++--- 1 file changed, 56 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/touchinput/tst_touchinput.cpp b/tests/auto/widgets/touchinput/tst_touchinput.cpp index 3eee6d824..d9381153d 100644 --- a/tests/auto/widgets/touchinput/tst_touchinput.cpp +++ b/tests/auto/widgets/touchinput/tst_touchinput.cpp @@ -51,7 +51,9 @@ private Q_SLOTS: void touchTapAndHold(); void touchTapAndHoldCancelled(); void scrolling(); + void pinchZoom_data(); void pinchZoom(); + void complexSequence(); private: QWebEngineView view; @@ -75,13 +77,17 @@ private: QTest::touchEvent(target, s_touchDevice).release(42, p, target); } - void gesturePinch(bool zoomIn) { + void gesturePinch(bool zoomIn, bool tapOneByOne = false) { auto target = view.focusProxy(); QPoint p(target->width() / 2, target->height() / 2); auto t1 = p - QPoint(zoomIn ? 50 : 150, 10), t2 = p + QPoint(zoomIn ? 50 : 150, 10); - QTest::touchEvent(target, s_touchDevice).press(42, t1, target); - QTest::touchEvent(target, s_touchDevice).stationary(42).press(24, t2, target); + if (tapOneByOne) { + QTest::touchEvent(target, s_touchDevice).press(42, t1, target); + QTest::touchEvent(target, s_touchDevice).stationary(42).press(24, t2, target); + } else { + QTest::touchEvent(target, s_touchDevice).press(42, t1, target).press(24, t2, target); + } for (int i = 0; i < 3; ++i) { if (zoomIn) { @@ -95,8 +101,12 @@ private: QTest::touchEvent(target, s_touchDevice).move(24, t1, target).move(42, t2, target); } - QTest::touchEvent(target, s_touchDevice).stationary(42).release(24, t2, target); - QTest::touchEvent(target, s_touchDevice).release(42, t1, target); + if (tapOneByOne) { + QTest::touchEvent(target, s_touchDevice).stationary(42).release(24, t2, target); + QTest::touchEvent(target, s_touchDevice).release(42, t1, target); + } else { + QTest::touchEvent(target, s_touchDevice).release(42, t1, target).release(24, t2, target); + } } int getScrollPosition(int *position = nullptr) { @@ -275,18 +285,57 @@ void TouchInputTest::scrolling() QTRY_COMPARE(getScrollPosition(), 0); } +void TouchInputTest::pinchZoom_data() +{ + QTest::addColumn("tapOneByOne"); + QTest::addRow("sequential") << true; + QTest::addRow("simultaneous") << false; +} + void TouchInputTest::pinchZoom() { + QFETCH(bool, tapOneByOne); double scale = getScaleFactor(); QCOMPARE(scale, 1.0); for (int i = 0; i < 3; ++i) { - gesturePinch(/* zoomIn = */true); + gesturePinch(/* zoomIn = */true, tapOneByOne); QTRY_VERIFY2(getScaleFactor(&scale) > 1.5, qPrintable(QString("i: %1, scale: %2").arg(i).arg(scale))); - gesturePinch(/* zoomIn = */false); + gesturePinch(/* zoomIn = */false, tapOneByOne); QTRY_COMPARE(getScaleFactor(&scale), 1.0); } } +void TouchInputTest::complexSequence() +{ + auto t = view.focusProxy(); + QPoint pc(view.width() / 2, view.height() / 2), p1 = pc - QPoint(50, 25), p2 = pc + QPoint(50, 25); + + for (int i = 0; i < 4; ++i) { + QTest::touchEvent(t, s_touchDevice).press(42, p1, t); QTest::qWait(50); + QTest::touchEvent(t, s_touchDevice).stationary(42).press(24, p2, t); QTest::qWait(50); + QTest::touchEvent(t, s_touchDevice).release(42, p1, t).release(24, p2, t); + + // for additional variablity add zooming in on even steps and zooming out on odd steps + // MEMO scroll position will always be 0 while viewport scale factor > 1.0, so do zoom in after scroll + bool zoomIn = i % 2 == 0; + + if (!zoomIn) { + gesturePinch(false); + QTRY_COMPARE(getScaleFactor(), 1.0); + } + + int p = getScrollPosition(), positionBefore = p; + gestureScroll(true); + QTRY_VERIFY2_WITH_TIMEOUT(getScrollPosition(&p) > positionBefore, qPrintable(QString("i: %1, position: %2 -> %3").arg(i).arg(positionBefore).arg(p)), 1000); + + if (zoomIn) { + double s = getScaleFactor(), scaleBefore = s; + gesturePinch(true); + QTRY_VERIFY2(getScaleFactor(&s) > scaleBefore, qPrintable(QString("i: %1, scale: %2").arg(i).arg(s))); + } + } +} + QTEST_MAIN(TouchInputTest) #include "tst_touchinput.moc" -- cgit v1.2.3 From b719da05c6429d72f4e0e0af44da0bf3f3e57984 Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Mon, 9 Nov 2020 16:28:04 +0100 Subject: Stabilize load signals emitting Make the WebContentsDelegateQt::EmitLoadStarted() and the WebContentsDelegateQt::EmitLoadFinished() independent from the WebContentsDelegateQt::LoadProgressChanged() by removing m_lastLoadProgress. Adapt the WebContentsDelegateQt::LoadProgressChanged() to send signal only if load is in progress. Add a new test based on the bugreport. Fix qmltests::WebEngineViewSource::test_viewSourceURL() flaky tests. Fixes: QTBUG-65223 Fixes: QTBUG-87089 Change-Id: I90af4d2e85105dba801beb8102991eb4ef14c6a3 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/quick/qmltests/BLACKLIST | 2 - tests/auto/quick/qmltests/data/tst_loadUrl.qml | 2 +- tests/auto/quick/qmltests/data/tst_viewSource.qml | 30 ----- tests/auto/quick/qmltests2/data/tst_viewSoure.qml | 133 +++++++++++++++++++++ tests/auto/quick/qmltests2/qmltests2.pro | 1 + tests/auto/shared/httpserver.cpp | 10 +- tests/auto/shared/httpserver.h | 1 + tests/auto/widgets/loadsignals/tst_loadsignals.cpp | 40 +++++++ .../qwebenginehistory/tst_qwebenginehistory.cpp | 3 +- 9 files changed, 187 insertions(+), 35 deletions(-) delete mode 100644 tests/auto/quick/qmltests/BLACKLIST create mode 100644 tests/auto/quick/qmltests2/data/tst_viewSoure.qml (limited to 'tests') diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST deleted file mode 100644 index 46bc65923..000000000 --- a/tests/auto/quick/qmltests/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[WebEngineViewSource::test_viewSourceURL] -* diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml index 872c46641..47dbbc087 100644 --- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml +++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml @@ -301,8 +301,8 @@ TestWebEngineView { // In-page navigation. webEngineView.url = Qt.resolvedUrl("test4.html#content"); // In-page navigation doesn't trigger load succeeded, wait for load progress instead. + tryCompare(loadRequestArray, "length", 3); tryCompare(webEngineView, "loadProgress", 100); - compare(loadRequestArray.length, 3); compare(loadRequestArray[2].status, WebEngineView.LoadStartedStatus); // Load after in-page navigation. diff --git a/tests/auto/quick/qmltests/data/tst_viewSource.qml b/tests/auto/quick/qmltests/data/tst_viewSource.qml index 4966a052a..22c340c2b 100644 --- a/tests/auto/quick/qmltests/data/tst_viewSource.qml +++ b/tests/auto/quick/qmltests/data/tst_viewSource.qml @@ -94,36 +94,6 @@ TestWebEngineView { compare(webEngineView.url, "view-source:" + Qt.resolvedUrl("test1.html")); } - function test_viewSourceURL_data() { - var testLocalUrl = "view-source:" + Qt.resolvedUrl("test1.html"); - var testLocalUrlWithoutScheme = "view-source:" + Qt.resolvedUrl("test1.html").substring(7); - - return [ - { tag: "view-source:", userInputUrl: "view-source:", loadSucceed: true, url: "view-source:", title: "view-source:" }, - { tag: "view-source:about:blank", userInputUrl: "view-source:about:blank", loadSucceed: true, url: "view-source:about:blank", title: "view-source:about:blank" }, - { tag: testLocalUrl, userInputUrl: testLocalUrl, loadSucceed: true, url: testLocalUrl, title: "test1.html" }, - { tag: testLocalUrlWithoutScheme, userInputUrl: testLocalUrlWithoutScheme, loadSucceed: true, url: testLocalUrl, title: "test1.html" }, - { tag: "view-source:http://non.existent", userInputUrl: "view-source:http://non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" }, - { tag: "view-source:non.existent", userInputUrl: "view-source:non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" }, - ]; - } - - function test_viewSourceURL(row) { - WebEngine.settings.errorPageEnabled = true - webEngineView.url = row.userInputUrl; - - if (row.loadSucceed) { - tryCompare(webEngineView, "loadStatus", WebEngineView.LoadSucceededStatus); - } else { - tryCompare(webEngineView, "loadStatus", WebEngineView.LoadFailedStatus, 15000); - } - tryVerify(function() { return titleChangedSpy.count == 1; }); - - compare(webEngineView.url, row.url); - tryCompare(webEngineView, "title", row.title); - verify(!webEngineView.action(WebEngineView.ViewSource).enabled); - } - function test_viewSourceCredentials() { var url = "http://user:passwd@httpbin.org/basic-auth/user/passwd"; diff --git a/tests/auto/quick/qmltests2/data/tst_viewSoure.qml b/tests/auto/quick/qmltests2/data/tst_viewSoure.qml new file mode 100644 index 000000000..04b40f544 --- /dev/null +++ b/tests/auto/quick/qmltests2/data/tst_viewSoure.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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.4 +import QtWebEngine.testsupport 1.0 +import "../../qmltests/data" 1.0 + +TestWebEngineView { + id: webEngineView + width: 200 + height: 400 + + property var viewRequest: null + property var loadRequestArray: [] + + testSupport: WebEngineTestSupport { + errorPage.onLoadingChanged: { + loadRequestArray.push({ + "status": loadRequest.status, + }) + } + } + + onLoadingChanged: { + loadRequestArray.push({ + "status": loadRequest.status, + }); + } + + SignalSpy { + id: newViewRequestedSpy + target: webEngineView + signalName: "newViewRequested" + } + + SignalSpy { + id: titleChangedSpy + target: webEngineView + signalName: "titleChanged" + } + + onNewViewRequested: { + viewRequest = { + "destination": request.destination, + "userInitiated": request.userInitiated + }; + + request.openIn(webEngineView); + } + + TestCase { + id: test + name: "WebEngineViewSource" + + function init() { + webEngineView.loadStatus = null; + webEngineView.url = Qt.resolvedUrl("test1.html"); + tryCompare(webEngineView, "loadStatus", WebEngineView.LoadSucceededStatus); + webEngineView.loadStatus = null; + + newViewRequestedSpy.clear(); + titleChangedSpy.clear(); + viewRequest = null; + } + + function test_viewSourceURL_data() { + var testLocalUrl = "view-source:" + Qt.resolvedUrl("test1.html"); + var testLocalUrlWithoutScheme = "view-source:" + Qt.resolvedUrl("test1.html").substring(7); + + return [ + { tag: "view-source:", userInputUrl: "view-source:", loadSucceed: true, url: "view-source:", title: "view-source:" }, + { tag: "view-source:about:blank", userInputUrl: "view-source:about:blank", loadSucceed: true, url: "view-source:about:blank", title: "view-source:about:blank" }, + { tag: testLocalUrl, userInputUrl: testLocalUrl, loadSucceed: true, url: testLocalUrl, title: "test1.html" }, + { tag: testLocalUrlWithoutScheme, userInputUrl: testLocalUrlWithoutScheme, loadSucceed: true, url: testLocalUrl, title: "test1.html" }, + { tag: "view-source:http://non.existent", userInputUrl: "view-source:http://non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" }, + { tag: "view-source:non.existent", userInputUrl: "view-source:non.existent", loadSucceed: false, url: "http://non.existent/", title: "non.existent" }, + ]; + } + + function test_viewSourceURL(row) { + loadRequestArray = []; + WebEngine.settings.errorPageEnabled = true + webEngineView.url = row.userInputUrl; + + if (row.loadSucceed) { + tryVerify(function() { return loadRequestArray.length >= 2 }); + compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus); + } else { + tryVerify(function() { return loadRequestArray.length >= 2 }); + compare(loadRequestArray[1].status, WebEngineView.LoadFailedStatus); + tryVerify(function() { return loadRequestArray.length == 4 }); + compare(loadRequestArray[3].status, WebEngineView.LoadSucceededStatus); + } + tryVerify(function() { return titleChangedSpy.count == 1; }); + + compare(webEngineView.url, row.url); + tryCompare(webEngineView, "title", row.title); + if (row.loadSucceed) { + verify(!webEngineView.action(WebEngineView.ViewSource).enabled); + } else { + verify(webEngineView.action(WebEngineView.ViewSource).enabled); + } + } + } +} + diff --git a/tests/auto/quick/qmltests2/qmltests2.pro b/tests/auto/quick/qmltests2/qmltests2.pro index 4c7a8dc72..98e33972b 100644 --- a/tests/auto/quick/qmltests2/qmltests2.pro +++ b/tests/auto/quick/qmltests2/qmltests2.pro @@ -33,6 +33,7 @@ OTHER_FILES += \ $$PWD/data/tst_linkHovered.qml \ $$PWD/data/tst_loadFail.qml \ $$PWD/data/tst_mouseClick.qml \ + $$PWD/data/tst_viewSource.qml \ $$PWD/data/icons/favicon.png \ $$PWD/data/icons/gray128.png \ $$PWD/data/icons/gray16.png \ diff --git a/tests/auto/shared/httpserver.cpp b/tests/auto/shared/httpserver.cpp index 67f491fac..69e8cb6cc 100644 --- a/tests/auto/shared/httpserver.cpp +++ b/tests/auto/shared/httpserver.cpp @@ -54,6 +54,7 @@ bool HttpServer::start() { m_error = false; m_expectingError = false; + m_ignoreNewConnection = false; if (!m_tcpServer->listen()) { qCWarning(gHttpServerLog).noquote() << m_tcpServer->errorString(); @@ -84,6 +85,9 @@ QUrl HttpServer::url(const QString &path) const void HttpServer::handleNewConnection() { + if (m_ignoreNewConnection) + return; + auto rr = new HttpReqRep(m_tcpServer->nextPendingConnection(), this); connect(rr, &HttpReqRep::requestReceived, [this, rr]() { Q_EMIT newRequest(rr); @@ -122,5 +126,9 @@ void HttpServer::handleNewConnection() << error; m_error = true; }); - connect(rr, &HttpReqRep::closed, rr, &QObject::deleteLater); + + if (!m_tcpServer->isListening()) { + m_ignoreNewConnection = true; + connect(rr, &HttpReqRep::closed, rr, &QObject::deleteLater); + } } diff --git a/tests/auto/shared/httpserver.h b/tests/auto/shared/httpserver.h index 9764852de..952ead220 100644 --- a/tests/auto/shared/httpserver.h +++ b/tests/auto/shared/httpserver.h @@ -90,6 +90,7 @@ private: QUrl m_url; QStringList m_dirs; bool m_error = false; + bool m_ignoreNewConnection = false; bool m_expectingError = false; }; diff --git a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp index 32bf53931..b4170587d 100644 --- a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp +++ b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp @@ -52,6 +52,7 @@ private Q_SLOTS: void secondLoadForError_WhenErrorPageEnabled(); void loadAfterInPageNavigation_qtbug66869(); void fileDownloadDoesNotTriggerLoadSignals_qtbug66661(); + void numberOfStartedAndFinishedSignalsIsSame(); private: QWebEngineProfile profile; @@ -243,5 +244,44 @@ void tst_LoadSignals::fileDownloadDoesNotTriggerLoadSignals_qtbug66661() QCOMPARE(loadFinishedSpy.size(), 1); } +void tst_LoadSignals::numberOfStartedAndFinishedSignalsIsSame() { + + HttpServer server; + server.setResourceDirs({ TESTS_SOURCE_DIR "/qwebengineprofile/resources" }); + connect(&server, &HttpServer::newRequest, [] (HttpReqRep *) { + QTest::qWait(250); // just add delay to trigger some progress for every sub resource + }); + QVERIFY(server.start()); + + view.load(server.url("/hedgehog.png")); + QTRY_COMPARE(loadFinishedSpy.size(), 1); + QVERIFY(loadFinishedSpy[0][0].toBool()); + + loadStartedSpy.clear(); + loadFinishedSpy.clear(); + loadProgressSpy.clear(); + + view.page()->setHtml("" + "" + "
" + "" + ""); + + QTRY_COMPARE(loadStartedSpy.size(), 2); + QTRY_COMPARE(loadFinishedSpy.size(), 2); + + QTRY_VERIFY(!loadFinishedSpy[0][0].toBool()); + QTRY_VERIFY(loadFinishedSpy[1][0].toBool()); + + view.page()->setHtml("" + "" + "" + ""); + QTRY_COMPARE(loadStartedSpy.size(), 4); + QTRY_COMPARE(loadFinishedSpy.size(), 4); + QVERIFY(loadFinishedSpy[2][0].toBool()); + QVERIFY(loadFinishedSpy[3][0].toBool()); +} + QTEST_MAIN(tst_LoadSignals) #include "tst_loadsignals.moc" diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp index bdb486793..72a45379b 100644 --- a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp +++ b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp @@ -320,7 +320,8 @@ void tst_QWebEngineHistory::serialize_2() hist->forward(); QTRY_COMPARE(loadFinishedSpy->count(), 5); hist->forward(); - QTRY_COMPARE(loadFinishedSpy->count(), 6); + // In-page navigation, the last url was the page5.html + QTRY_COMPARE(loadFinishedSpy->count(), 5); QTRY_COMPARE(hist->currentItemIndex(), initialCurrentIndex); } -- cgit v1.2.3 From 3215168f0dc1dee1064d9063b2748e64cc2577bc Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 4 Dec 2020 17:01:26 +0100 Subject: Fix building against 5.12 on most CIs Change-Id: I4c4bbc75b9f6346a446f8094f669d142f76c164a Reviewed-by: Kirill Burtsev --- tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp | 5 +++++ tests/auto/quick/quick.pro | 2 ++ tests/auto/widgets/accessibility/tst_accessibility.cpp | 3 +++ tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 4 ++++ 4 files changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp index 5ee30f165..e879d9262 100644 --- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp +++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp @@ -993,6 +993,7 @@ void tst_QQuickWebEngineView::inputEventForwardingDisabledWhenActiveFocusOnPress void tst_QQuickWebEngineView::changeLocale() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QStringList errorLines; QUrl url("http://non.existent/"); @@ -1028,6 +1029,7 @@ void tst_QQuickWebEngineView::changeLocale() QTRY_VERIFY(!evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").isNull()); errorLines = evaluateJavaScriptSync(viewDE.data(), "document.body.innerText").toString().split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts); QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar")); +#endif } void tst_QQuickWebEngineView::userScripts() @@ -1173,6 +1175,9 @@ void tst_QQuickWebEngineView::focusChild_data() void tst_QQuickWebEngineView::focusChild() { +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 1) + QSKIP("Requires newer base Qt"); +#endif auto traverseToWebDocumentAccessibleInterface = [](QAccessibleInterface *iface) -> QAccessibleInterface * { QFETCH(QVector, ancestorRoles); for (int i = 0; i < ancestorRoles.size(); ++i) { diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 41ea5c4c1..f02652ba1 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -20,5 +20,7 @@ qtConfig(webengine-testsupport) { qtConfig(ssl): SUBDIRS += qmltests_ssl +lessThan(QT_MAJOR_VERSION, 6):lessThan(QT_MINOR_VERSION, 14): SUBDIRS -= qmltests qmltests2 qmltests_ssl + # QTBUG-66055 boot2qt: SUBDIRS -= inspectorserver qquickwebengineview qmltests qmltests2 diff --git a/tests/auto/widgets/accessibility/tst_accessibility.cpp b/tests/auto/widgets/accessibility/tst_accessibility.cpp index 84382d6f1..0c235382a 100644 --- a/tests/auto/widgets/accessibility/tst_accessibility.cpp +++ b/tests/auto/widgets/accessibility/tst_accessibility.cpp @@ -160,6 +160,9 @@ void tst_Accessibility::focusChild_data() void tst_Accessibility::focusChild() { +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 1) + QSKIP("Requires newer base Qt"); +#endif auto traverseToWebDocumentAccessibleInterface = [](QAccessibleInterface *iface) -> QAccessibleInterface * { QFETCH(QVector, ancestorRoles); for (int i = 0; i < ancestorRoles.size(); ++i) { diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 2257a6f4e..afc0750cd 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -1160,6 +1160,7 @@ void tst_QWebEngineView::doNotBreakLayout() void tst_QWebEngineView::changeLocale() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QStringList errorLines; QUrl url("http://non.existent/"); @@ -1195,6 +1196,7 @@ void tst_QWebEngineView::changeLocale() QTRY_VERIFY(!toPlainTextSync(viewDE.page()).isEmpty()); errorLines = toPlainTextSync(viewDE.page()).split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts); QCOMPARE(errorLines.first().toUtf8(), QByteArrayLiteral("Die Website ist nicht erreichbar")); +#endif } void tst_QWebEngineView::inputMethodsTextFormat_data() @@ -1480,6 +1482,7 @@ void tst_QWebEngineView::mouseClick() void tst_QWebEngineView::postData() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QMap postData; // use reserved characters to make the test harder to pass postData[QStringLiteral("Spä=m")] = QStringLiteral("ëgg:s"); @@ -1607,6 +1610,7 @@ void tst_QWebEngineView::postData() timeoutGuard.stop(); server.close(); +#endif } void tst_QWebEngineView::inputFieldOverridesShortcuts() -- cgit v1.2.3