diff options
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp | 3 | ||||
-rw-r--r-- | tests/auto/quick/shared/util.h | 32 |
2 files changed, 8 insertions, 27 deletions
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp index 2d68fd744..2a43c9c1c 100644 --- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp +++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp @@ -151,7 +151,8 @@ void tst_QQuickWebEngineView::stopEnabledAfterLoadStarted() LoadStartedCatcher catcher(webEngineView()); webEngineView()->setUrl(urlFromTestPath("html/basic_page.html")); - waitForSignal(&catcher, SIGNAL(finished())); + QSignalSpy spy(&catcher, &LoadStartedCatcher::finished); + QVERIFY(spy.wait()); QCOMPARE(webEngineView()->isLoading(), true); diff --git a/tests/auto/quick/shared/util.h b/tests/auto/quick/shared/util.h index 063caa766..674c2da34 100644 --- a/tests/auto/quick/shared/util.h +++ b/tests/auto/quick/shared/util.h @@ -91,45 +91,25 @@ private: QQuickWebEngineView *m_webEngineView; }; -/** - * Starts an event loop that runs until the given signal is received. - * Optionally the event loop - * can return earlier on a timeout. - * - * \return \p true if the requested signal was received - * \p false on timeout - */ -inline bool waitForSignal(QObject *obj, const char *signal, int timeout = 10000) -{ - QEventLoop loop; - QObject::connect(obj, signal, &loop, SLOT(quit())); - QTimer timer; - QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); - if (timeout > 0) { - QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.setSingleShot(true); - timer.start(timeout); - } - loop.exec(); - return timeoutSpy.isEmpty(); -} - inline bool waitForLoadSucceeded(QQuickWebEngineView *webEngineView, int timeout = 10000) { LoadSpy loadSpy(webEngineView); - return waitForSignal(&loadSpy, SIGNAL(loadSucceeded()), timeout); + QSignalSpy spy(&loadSpy, &LoadSpy::loadSucceeded); + return spy.wait(timeout); } inline bool waitForLoadFailed(QQuickWebEngineView *webEngineView, int timeout = 10000) { LoadSpy loadSpy(webEngineView); - return waitForSignal(&loadSpy, SIGNAL(loadFailed()), timeout); + QSignalSpy spy(&loadSpy, &LoadSpy::loadFailed); + return spy.wait(timeout); } inline bool waitForViewportReady(QQuickWebEngineView *webEngineView, int timeout = 10000) { #ifdef ENABLE_QML_TESTSUPPORT_API - return waitForSignal(reinterpret_cast<QObject *>(webEngineView->testSupport()), SIGNAL(loadVisuallyCommitted()), timeout); + QSignalSpy spy(reinterpret_cast<QObject *>(webEngineView->testSupport()), SIGNAL(loadVisuallyCommitted())); + return spy.wait(timeout); #else Q_UNUSED(webEngineView) Q_UNUSED(timeout) |