Skip to content

Commit 73daf5b

Browse files
author
Kirill Burtsev
committed
Remove qt.io load from findTextInterruptedByLoad and ensure checks
Load of real website is not really needed, simple html is enough to verify that on load no findText callback is executed from previous query. Ensure callback is not called with timeout and additional check inside it to verify that it's not called twise. Task-number: QTBUG-75541 Change-Id: Iebf207e40d8f4d4f680b46bb0f32480edd72f36d Reviewed-by: Jüri Valdmann <[email protected]> Reviewed-by: Peter Varga <[email protected]>
1 parent fef43d7 commit 73daf5b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tests/auto/quick/qmltests/data/tst_findText.qml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,21 @@ TestWebEngineView {
4343
matchCount = -1
4444
}
4545

46+
function findCallbackCalled() { return matchCount != -1 }
47+
4648
function findTextCallback(matchCount) {
49+
// If this starts to fail then either clear was not called before findText
50+
// or unexpected callback was triggered from some search.
51+
// On c++ side callback id can be checked to verify
52+
testcase.verify(!findCallbackCalled(), 'Unexpected callback call or uncleared state before findText call!')
53+
4754
webEngineView.matchCount = matchCount
4855
findFailed = matchCount == 0
4956
}
5057

5158

5259
TestCase {
60+
id: testcase
5361
name: "WebViewFindText"
5462

5563
function getBodyInnerHTML() {
@@ -207,13 +215,13 @@ TestWebEngineView {
207215
webEngineView.findText("hello", findFlags, webEngineView.findTextCallback);
208216

209217
// This should not crash.
210-
webEngineView.url = "https://www.qt.io";
211-
if (!webEngineView.waitForLoadSucceeded(12000))
212-
skip("Couldn't load page from network, skipping test.");
218+
webEngineView.loadHtml("<html><body>New page with same hello text</body></html>")
219+
verify(webEngineView.waitForLoadSucceeded())
213220

214221
// The callback is not supposed to be called, see QTBUG-61506.
215-
// Check whether the callback was called (-1 = no, other values = yes).
216-
tryVerify(function() { return webEngineView.matchCount == -1; }, 20000);
222+
expectFailContinue('', 'No unexpected findText callback calls occurred.')
223+
tryVerify(function() { return webEngineView.findCallbackCalled() })
224+
verify(!webEngineView.findCallbackCalled())
217225
}
218226
}
219227
}

0 commit comments

Comments
 (0)