From bebc5a1c6ff9968bf8b06ca74a76b0618a57700b Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 3 Apr 2020 08:24:02 +0200 Subject: 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 --- tests/auto/widgets/util.h | 9 ++++++--- 1 file 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; } -- cgit v1.2.1