diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2019-07-11 13:15:39 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2019-08-22 13:00:16 +0200 |
commit | 55a4c28542c6dc9e4a4edc0aab7043feef2ab0d2 (patch) | |
tree | 551751f87ed36388ebd545edd5f31a48859a2719 /tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | |
parent | f0c471d9e2f3e9808cbf8c57bee533e8254ad1c5 (diff) |
Refactor findText handling
Move most of the findText logic to the QtWebEngineCore::FindTextHelper
class. This change also separates findText callbacks in the new class
for getting rid of the request ID conversion and make it easier to
remove them in Qt6.
Task-number: QTBUG-50420
Change-Id: I348cedd0f90a49f9b360165c46319aeed2c236c0
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp')
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 713feca6d..7e9815298 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -127,6 +127,7 @@ private Q_SLOTS: void findText(); void findTextResult(); void findTextSuccessiveShouldCallAllCallbacks(); + void findTextCalledOnMatch(); void deleteQWebEngineViewTwice(); void loadSignalsOrder_data(); void loadSignalsOrder(); @@ -1024,6 +1025,28 @@ void tst_QWebEnginePage::findTextSuccessiveShouldCallAllCallbacks() QVERIFY(spy5.wasCalled()); } +void tst_QWebEnginePage::findTextCalledOnMatch() +{ + QSignalSpy loadSpy(m_view->page(), &QWebEnginePage::loadFinished); + + // findText will abort in blink if the view has an empty size. + m_view->resize(800, 600); + m_view->show(); + m_view->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>")); + QTRY_COMPARE(loadSpy.count(), 1); + + bool callbackCalled = false; + m_view->page()->findText("foo", 0, [this, &callbackCalled](bool found) { + QVERIFY(found); + + m_view->page()->findText("bar", 0, [&callbackCalled](bool found) { + QVERIFY(found); + callbackCalled = true; + }); + }); + QTRY_VERIFY(callbackCalled); +} + static QWindow *findNewTopLevelWindow(const QWindowList &oldTopLevelWindows) { const auto tlws = QGuiApplication::topLevelWindows(); |