summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2019-07-11 16:23:49 +0200
committerKirill Burtsev <kirill.burtsev@qt.io>2019-07-12 16:05:41 +0000
commitb7054e3dc8cbe3dc4583dd75463aac11142d5643 (patch)
tree484ab276996c2a07969db4dff829c8580cfb4bf2
parenta2e47fa8c90be25407268434f60114892c9e500a (diff)
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 <michal.klocek@qt.io>
-rw-r--r--tests/auto/widgets/spellchecking/tst_spellchecking.cpp43
1 files changed, 35 insertions, 8 deletions
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"));