From: Samuel Rødal Date: Wed, 14 Mar 2012 11:16:45 +0000 (+0100) Subject: Improved qWaitForWindowShown(). X-Git-Tag: qt-v5.0.0-alpha1~269 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b70d8c6afb525d80cf4f1fc788e1a5947f0b152;p=profile%2Fivi%2Fqtbase.git Improved qWaitForWindowShown(). Made faster by actually waiting for the window to be exposed, using similar waiting logic as qWait(). Should speed up autotests that use it quite a bit. Change-Id: I628c6110a554fdbbf5bed7e91f57c2fe341113ed Reviewed-by: Lars Knoll --- diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index 1f10967..ade5f4c 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -53,9 +53,6 @@ QT_BEGIN_NAMESPACE class QWidget; -#ifdef Q_WS_X11 -extern void qt_x11_wait_for_window_manager(QWidget *w); -#endif namespace QTest { @@ -74,22 +71,25 @@ namespace QTest inline static bool qWaitForWindowShown(QWidget *window) { -#if defined(Q_WS_X11) - qt_x11_wait_for_window_manager(window); - QCoreApplication::processEvents(); -#else Q_UNUSED(window); qWait(200); -#endif return true; } + inline static bool qWaitForWindowShown(QWindow *window) { - Q_UNUSED(window); - qWait(200); + QElapsedTimer timer; + timer.start(); + while (!window->isExposed()) { + int remaining = int(timer.elapsed()) - 1000; + if (remaining <= 0) + break; + QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QTest::qSleep(10); + } return true; } - } QT_END_NAMESPACE