summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-07-19 12:08:56 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-07-23 14:06:37 +0200
commitb73e4ce6f7cfe35a85b9a41e1a5ab36783e5edb0 (patch)
tree24d8c74f02562bc4d7815f3cb5c95d17e96f1550 /tests
parentb4a661eaa3506bd2a698e61e8228de029bd810ca (diff)
parentc18c51acf8d0eb9426ce998d6e09f20a4a481c40 (diff)
Merge "Merge remote-tracking branch 'origin/5.12' into 5.13"
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/dialogs/WebView.qml9
-rw-r--r--tests/auto/quick/qmltests/data/tst_findText.qml22
-rw-r--r--tests/auto/widgets/spellchecking/tst_spellchecking.cpp43
3 files changed, 57 insertions, 17 deletions
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 + "'")
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml
index 1ec574fae..14053a675 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,17 @@ 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("<html><body>New page with same hello text</body></html>")
+ 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())
+
+ webEngineView.clear();
+ webEngineView.findText('New page', findFlags, webEngineView.findTextCallback)
+ tryCompare(webEngineView, 'matchCount', 1)
}
}
}
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"));