summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2019-11-20 09:31:20 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2019-11-28 14:07:37 +0100
commit9d2521084dbec9403ab68ea5e95b8a77313af11f (patch)
tree522e74ae2f6db0065dcf2fd44afdba7d04fc7034
parent2c8113eb5b68d3678fd68bdde32fc6dca726c983 (diff)
Update find request id when a new search interrupts an ongoing search
If the new test became flaky it might happen because the first text search finished before the second findText() call. This is very unlikely, but in this case the test should be modified to not to check if the first find failed. The point is to check we get the correct amount of signals and the second search doesn't assert. If the callbacks will be removed in Qt6, it should be re-considered to remove the "unfinished find" workaround and trigger the first successful findTextFinished() signal even if it happens in the middle of another search. Fixes: QTBUG-80086 Change-Id: I9c1ce20fc43fd81e8af784385a00ac2e7f7603b7 Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io>
-rw-r--r--src/core/find_text_helper.cpp1
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp13
2 files changed, 14 insertions, 0 deletions
diff --git a/src/core/find_text_helper.cpp b/src/core/find_text_helper.cpp
index 065fed38f..da9d7f352 100644
--- a/src/core/find_text_helper.cpp
+++ b/src/core/find_text_helper.cpp
@@ -108,6 +108,7 @@ void FindTextHelper::startFinding(const QString &findText, bool caseSensitively,
// waiting for it forever.
// Assume that any unfinished find has been unsuccessful when a new one is started
// to cover that case.
+ m_lastCompletedFindRequestId = m_currentFindRequestId;
m_viewClient->findTextFinished(QWebEngineFindTextResult());
invokeResultCallback(m_currentFindRequestId, 0);
}
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 88cdcbb96..d8c1a5360 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -992,6 +992,19 @@ void tst_QWebEnginePage::findText()
QTRY_COMPARE(signalSpy.count(), 1);
QTRY_COMPARE(m_view->selectedText(), QString("foo"));
}
+
+ // Invoking startFinding operation for the same text twice. Without any wait, the second one
+ // should interrupt the first one.
+ {
+ QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
+ m_view->findText("foo", 0);
+ m_view->findText("foo", 0);
+ QTRY_COMPARE(signalSpy.count(), 2);
+ QTRY_VERIFY(m_view->selectedText().isEmpty());
+
+ QCOMPARE(signalSpy.at(0).value(0).value<QWebEngineFindTextResult>().numberOfMatches(), 0);
+ QCOMPARE(signalSpy.at(1).value(0).value<QWebEngineFindTextResult>().numberOfMatches(), 1);
+ }
}
void tst_QWebEnginePage::findTextResult()