From b7054e3dc8cbe3dc4583dd75463aac11142d5643 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 11 Jul 2019 16:23:49 +0200 Subject: Fix spellcheck test flaky failure with misspelled word missing Work is done asynchronously by chromium SpellChecker object. Therefore there is no guarantee that on ShowContextMenu event for WebContents there will be a result with misspelled word. Change-Id: I2978ed99e4c14f0a7d9086853c5218f82ea1ab60 Reviewed-by: Michal Klocek --- .../widgets/spellchecking/tst_spellchecking.cpp | 43 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/spellchecking/tst_spellchecking.cpp b/tests/auto/widgets/spellchecking/tst_spellchecking.cpp index b6582083d..d02fc78b9 100644 --- a/tests/auto/widgets/spellchecking/tst_spellchecking.cpp +++ b/tests/auto/widgets/spellchecking/tst_spellchecking.cpp @@ -174,14 +174,41 @@ void tst_Spellchecking::spellcheck() QString result = evaluateJavaScriptSync(m_view->page(), "text();").toString(); QVERIFY(result == text); - // open menu on misspelled word - m_view->activateMenu(m_view->focusWidget(), rect.center()); - QSignalSpy spyMenuReady(m_view, &WebView::menuReady); - QVERIFY(spyMenuReady.wait()); - - // check if menu is valid - QVERIFY(m_view->data().isValid()); - QVERIFY(m_view->data().isContentEditable()); + bool gotMisspelledWord = false; // clumsy QTRY_VERIFY still execs expr after first success + QString detail; + + // check that spellchecker has done text processing and filled misspelled word + QTRY_VERIFY2([&] () { + detail.clear(); + if (gotMisspelledWord) + return true; + + // open menu on misspelled word + m_view->activateMenu(m_view->focusWidget(), rect.center()); + QSignalSpy spyMenuReady(m_view, &WebView::menuReady); + if (!spyMenuReady.wait()) { + detail = "menu was not shown"; + return false; + } + + if (!m_view->data().isValid()) { + detail = "invalid data"; + return false; + } + + if (!m_view->data().isContentEditable()) { + detail = "content is not editable"; + return false; + } + + if (m_view->data().misspelledWord().isEmpty()) { + detail = "no misspelled word"; + return false; + }; + + gotMisspelledWord = true; + return true; + } (), qPrintable(QString("Context menu: %1").arg(detail))); // check misspelled word QCOMPARE(m_view->data().misspelledWord(), QStringLiteral("lowe")); -- cgit v1.2.3 From fef43d7b6fad44f9ee3de12ea49cc418245b1844 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 12 Jul 2019 11:14:07 +0200 Subject: Fix quick dialog test wrong message on view's LoadStatus changed Change-Id: Ic8eb671409794799bcdad4760dc58e84de3b109f Reviewed-by: Michal Klocek --- tests/auto/quick/dialogs/WebView.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/dialogs/WebView.qml b/tests/auto/quick/dialogs/WebView.qml index 4f8b7a0ce..01f4ac297 100644 --- a/tests/auto/quick/dialogs/WebView.qml +++ b/tests/auto/quick/dialogs/WebView.qml @@ -56,11 +56,12 @@ Window { WebEngineView { id: view anchors.fill: parent - onLoadingChanged: function(reqeust) { - if (reqeust.status === WebEngineView.LoadSucceededStatus) { + onLoadingChanged: function(request) { + if (request.status === WebEngineView.LoadSucceededStatus) { handler.ready = true - } else { - console.log("Wooohooo loading page from qrc failed !") + } else if (request.status === WebEngineView.LoadFailedStatus) { + console.log("Page was not successfully loaded from qrc! Status: " + request.status + + ", error [code: " + request.errorCode + "]: '" + request.errorString + "'") } } -- cgit v1.2.3 From 73daf5b669c943d3c7a765533c5b5d61c380a576 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Fri, 12 Jul 2019 11:23:17 +0200 Subject: Remove qt.io load from findTextInterruptedByLoad and ensure checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Load of real website is not really needed, simple html is enough to verify that on load no findText callback is executed from previous query. Ensure callback is not called with timeout and additional check inside it to verify that it's not called twise. Task-number: QTBUG-75541 Change-Id: Iebf207e40d8f4d4f680b46bb0f32480edd72f36d Reviewed-by: Jüri Valdmann Reviewed-by: Peter Varga --- tests/auto/quick/qmltests/data/tst_findText.qml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml index dfcfd586f..9687d9183 100644 --- a/tests/auto/quick/qmltests/data/tst_findText.qml +++ b/tests/auto/quick/qmltests/data/tst_findText.qml @@ -43,13 +43,21 @@ TestWebEngineView { matchCount = -1 } + function findCallbackCalled() { return matchCount != -1 } + function findTextCallback(matchCount) { + // If this starts to fail then either clear was not called before findText + // or unexpected callback was triggered from some search. + // On c++ side callback id can be checked to verify + testcase.verify(!findCallbackCalled(), 'Unexpected callback call or uncleared state before findText call!') + webEngineView.matchCount = matchCount findFailed = matchCount == 0 } TestCase { + id: testcase name: "WebViewFindText" function getBodyInnerHTML() { @@ -207,13 +215,13 @@ TestWebEngineView { webEngineView.findText("hello", findFlags, webEngineView.findTextCallback); // This should not crash. - webEngineView.url = "https://www.qt.io"; - if (!webEngineView.waitForLoadSucceeded(12000)) - skip("Couldn't load page from network, skipping test."); + webEngineView.loadHtml("New page with same hello text") + verify(webEngineView.waitForLoadSucceeded()) // The callback is not supposed to be called, see QTBUG-61506. - // Check whether the callback was called (-1 = no, other values = yes). - tryVerify(function() { return webEngineView.matchCount == -1; }, 20000); + expectFailContinue('', 'No unexpected findText callback calls occurred.') + tryVerify(function() { return webEngineView.findCallbackCalled() }) + verify(!webEngineView.findCallbackCalled()) } } } -- cgit v1.2.3 From b4589db4c7cb10cb55b38bab00d80eb1290312b1 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Mon, 15 Jul 2019 13:03:14 +0200 Subject: Reset findText reply id on StopFinding to prevent callback later Not updating lastReceivedFindReply caused next findText call after StopFinding to trigger redundant callback call on checking stale query. Fixes: QTBUG-77029 Change-Id: Iad4b71364ecb3ec3db3096b739e77620d12731f9 Reviewed-by: Peter Varga --- tests/auto/quick/qmltests/data/tst_findText.qml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml index 9687d9183..93aa48365 100644 --- a/tests/auto/quick/qmltests/data/tst_findText.qml +++ b/tests/auto/quick/qmltests/data/tst_findText.qml @@ -222,6 +222,10 @@ TestWebEngineView { expectFailContinue('', 'No unexpected findText callback calls occurred.') tryVerify(function() { return webEngineView.findCallbackCalled() }) verify(!webEngineView.findCallbackCalled()) + + webEngineView.clear(); + webEngineView.findText('New page', findFlags, webEngineView.findTextCallback) + tryCompare(webEngineView, 'matchCount', 1) } } } -- cgit v1.2.3