From 58c67b08f7ad668f95a6edaccd96dd0fe72f675d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 9 Jul 2021 16:48:00 +0200 Subject: Update parameters to findText callback Change-Id: I622ff55c1c9b6f9d4818228c75543c3deffa37be Reviewed-by: Qt CI Bot Reviewed-by: Peter Varga (cherry picked from commit 56b1f53d9b2927f5ba2a73f85cee59e385bf489d) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/util/util.h | 5 ++-- .../widgets/qwebenginepage/tst_qwebenginepage.cpp | 30 +++++++++++----------- 2 files changed, 18 insertions(+), 17 deletions(-) (limited to 'tests') 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 #include #include +#include #include // Disconnect signal on destruction. @@ -141,9 +142,9 @@ static inline QString toHtmlSync(QWebEnginePage *page) static inline bool findTextSync(QWebEnginePage *page, const QString &subString) { - CallbackSpy spy; + CallbackSpy 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 callbackSpy; + CallbackSpy 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 callbackSpy; + CallbackSpy 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(); 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 callbackSpy; + CallbackSpy 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 callbackSpy; + CallbackSpy 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 spy1; - CallbackSpy spy2; - CallbackSpy spy3; - CallbackSpy spy4; - CallbackSpy spy5; + CallbackSpy spy1; + CallbackSpy spy2; + CallbackSpy spy3; + CallbackSpy spy4; + CallbackSpy spy5; QSignalSpy loadSpy(m_view, SIGNAL(loadFinished(bool))); m_view->setHtml(QString("
abcdefg abcdefg abcdefg abcdefg abcdefg
")); 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; }); }); -- cgit v1.2.3