summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-07-09 16:48:00 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-07-13 13:33:45 +0200
commit56b1f53d9b2927f5ba2a73f85cee59e385bf489d (patch)
tree3113af56066dfb6c4ae8b08cc364b09bfec6b56b /tests
parente4bb4b8bc443fa78c0cd4509cc8ec1251e8296ae (diff)
Update parameters to findText callback
Pick-to: 6.2 Change-Id: I622ff55c1c9b6f9d4818228c75543c3deffa37be Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/util/util.h5
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp30
2 files changed, 18 insertions, 17 deletions
diff --git a/tests/auto/util/util.h b/tests/auto/util/util.h
index cc5f5e8b4..a624a978f 100644
--- a/tests/auto/util/util.h
+++ b/tests/auto/util/util.h
@@ -35,6 +35,7 @@
#include <QEventLoop>
#include <QSignalSpy>
#include <QTimer>
+#include <qwebenginefindtextresult.h>
#include <qwebenginepage.h>
// Disconnect signal on destruction.
@@ -141,9 +142,9 @@ static inline QString toHtmlSync(QWebEnginePage *page)
static inline bool findTextSync(QWebEnginePage *page, const QString &subString)
{
- CallbackSpy<bool> spy;
+ CallbackSpy<QWebEngineFindTextResult> spy;
page->findText(subString, {}, spy.ref());
- return spy.waitForResult();
+ return spy.waitForResult().numberOfMatches() > 0;
}
static inline QVariant evaluateJavaScriptSync(QWebEnginePage *page, const QString &script)
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 0376168a2..db467562a 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -1050,7 +1050,7 @@ void tst_QWebEnginePage::findText()
// Invoking a stopFinding operation will not change or clear the currently selected text,
// if nothing was found beforehand.
{
- CallbackSpy<bool> callbackSpy;
+ CallbackSpy<QWebEngineFindTextResult> callbackSpy;
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
m_view->findText("", {}, callbackSpy.ref());
QVERIFY(callbackSpy.wasCalled());
@@ -1061,10 +1061,10 @@ void tst_QWebEnginePage::findText()
// Invoking a startFinding operation with text that won't be found, will clear the current
// selection.
{
- CallbackSpy<bool> callbackSpy;
+ CallbackSpy<QWebEngineFindTextResult> callbackSpy;
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
m_view->findText("Will not be found", {}, callbackSpy.ref());
- QCOMPARE(callbackSpy.waitForResult(), false);
+ QCOMPARE(callbackSpy.waitForResult().numberOfMatches(), 0);
QTRY_COMPARE(signalSpy.count(), 1);
auto result = signalSpy.takeFirst().value(0).value<QWebEngineFindTextResult>();
QCOMPARE(result.numberOfMatches(), 0);
@@ -1078,10 +1078,10 @@ void tst_QWebEnginePage::findText()
// Invoking a startFinding operation with text that will be found, will clear the current
// selection as well.
{
- CallbackSpy<bool> callbackSpy;
+ CallbackSpy<QWebEngineFindTextResult> callbackSpy;
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
m_view->findText("foo", {}, callbackSpy.ref());
- QVERIFY(callbackSpy.waitForResult());
+ QVERIFY(callbackSpy.waitForResult().numberOfMatches() > 0);
QTRY_COMPARE(signalSpy.count(), 1);
QTRY_VERIFY(m_view->selectedText().isEmpty());
}
@@ -1089,7 +1089,7 @@ void tst_QWebEnginePage::findText()
// Invoking a stopFinding operation after text was found, will set the selected text to the
// found text.
{
- CallbackSpy<bool> callbackSpy;
+ CallbackSpy<QWebEngineFindTextResult> callbackSpy;
QSignalSpy signalSpy(m_view->page(), &QWebEnginePage::findTextFinished);
m_view->findText("", {}, callbackSpy.ref());
QTRY_VERIFY(callbackSpy.wasCalled());
@@ -1149,11 +1149,11 @@ void tst_QWebEnginePage::findTextResult()
void tst_QWebEnginePage::findTextSuccessiveShouldCallAllCallbacks()
{
- CallbackSpy<bool> spy1;
- CallbackSpy<bool> spy2;
- CallbackSpy<bool> spy3;
- CallbackSpy<bool> spy4;
- CallbackSpy<bool> spy5;
+ CallbackSpy<QWebEngineFindTextResult> spy1;
+ CallbackSpy<QWebEngineFindTextResult> spy2;
+ CallbackSpy<QWebEngineFindTextResult> spy3;
+ CallbackSpy<QWebEngineFindTextResult> spy4;
+ CallbackSpy<QWebEngineFindTextResult> spy5;
QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool)));
m_view->setHtml(QString("<html><head></head><body><div>abcdefg abcdefg abcdefg abcdefg abcdefg</div></body></html>"));
QTRY_COMPARE_WITH_TIMEOUT(loadSpy.count(), 1, 20000);
@@ -1182,11 +1182,11 @@ void tst_QWebEnginePage::findTextCalledOnMatch()
// CALLBACK
bool callbackCalled = false;
- m_view->page()->findText("foo", {}, [this, &callbackCalled](bool found) {
- QVERIFY(found);
+ m_view->page()->findText("foo", {}, [this, &callbackCalled](QWebEngineFindTextResult result) {
+ QVERIFY(result.numberOfMatches());
- m_view->page()->findText("bar", {}, [&callbackCalled](bool found) {
- QVERIFY(found);
+ m_view->page()->findText("bar", {}, [&callbackCalled](QWebEngineFindTextResult result) {
+ QVERIFY(result.numberOfMatches());
callbackCalled = true;
});
});