From 87618403976aa82450895da6196a944195980de7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 18 Jul 2012 13:12:59 +0200 Subject: Implement waitForWindowExposed and friends for widget windows. - Implement waitForWindowExposed() for toplevel windows. - Implement waitForWindowShown(QWidget *) and mark as deprecated in line with waitForWindowShown(QWindow*). - Use in tests. - Simplify tests (collapse waitForExposed, setActive into setActiveWindow, waitForActive), remove most hard-coded timeouts. - Stabilize graphicsview tests by using waitForWindowActive. Change-Id: Ic7c061e2745b36f71a715ee4e47c0346b11a91e8 Reviewed-by: Jason McDonald --- src/testlib/qtestsystem.h | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/testlib/qtestsystem.h') diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index eb0fcb8178..66849f465d 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -46,14 +46,14 @@ #include #include #include +#ifdef QT_WIDGETS_LIB +# include +#endif QT_BEGIN_HEADER QT_BEGIN_NAMESPACE - -class QWidget; - namespace QTest { inline static void qWait(int ms) @@ -69,13 +69,6 @@ namespace QTest } while (timer.elapsed() < ms); } - inline static bool qWaitForWindowShown(QWidget *window) - { - Q_UNUSED(window); - qWait(200); - return true; - } - inline static bool qWaitForWindowActive(QWindow *window, int timeout = 1000) { QElapsedTimer timer; @@ -120,11 +113,34 @@ namespace QTest return window->isExposed(); } +#ifdef QT_WIDGETS_LIB + inline static bool qWaitForWindowActive(QWidget *widget, int timeout = 1000) + { + if (QWindow *window = widget->windowHandle()) + return qWaitForWindowActive(window, timeout); + return false; + } + + inline static bool qWaitForWindowExposed(QWidget *widget, int timeout = 1000) + { + if (QWindow *window = widget->windowHandle()) + return qWaitForWindowExposed(window, timeout); + return false; + } +#endif + #if QT_DEPRECATED_SINCE(6, 0) QT_DEPRECATED inline static bool qWaitForWindowShown(QWindow *window, int timeout = 1000) { return qWaitForWindowExposed(window, timeout); } + +# ifdef QT_WIDGETS_LIB + QT_DEPRECATED inline static bool qWaitForWindowShown(QWidget *widget, int timeout = 1000) + { + return qWaitForWindowExposed(widget, timeout); + } +# endif // QT_WIDGETS_LIB #endif // QT_DEPRECATED_SINCE(6, 0) } -- cgit v1.2.3