summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2020-04-03 08:24:02 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2020-04-09 22:18:23 +0200
commitbebc5a1c6ff9968bf8b06ca74a76b0618a57700b (patch)
treed7c37535fff3c4baffeddb0ca486550af7c44779
parent5d2026cb04ef8fd408e5722a84e2affb5b9a3119 (diff)
Stabilize widget auto tests which use evaluateJavaScriptSync()
Interrupt the waiting on the event loop in CallbackSpy::waitForResult() to not block calls on the UI thread. It is necessary because RenderProcessHost creates channel for mojo communication on the UI thread. QWebEnginePage::runJavaScript() needs this channel because the JavaScript is executed in the render process. If evaluateJavaScriptSync() is called before the mentioned channel is created, the JavaScriptExecuteRequest mojo message might not be sent because the wait would block the thread. Change-Id: Ic5bb5a6fde02717cec49dcf9e458f2eaac09eacf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--tests/auto/widgets/util.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h
index 20241be8b..ca03c5833 100644
--- a/tests/auto/widgets/util.h
+++ b/tests/auto/widgets/util.h
@@ -83,10 +83,13 @@ public:
QObject::connect(&timeoutTimer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
}
- T waitForResult() {
- if (!called) {
- timeoutTimer.start(20000);
+ T waitForResult(int timeout = 20000) {
+ const int step = 1000;
+ int elapsed = 0;
+ while (elapsed < timeout && !called) {
+ timeoutTimer.start(step);
eventLoop.exec();
+ elapsed += step;
}
return result;
}