summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-07-18 13:12:59 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-20 09:27:28 +0200
commit87618403976aa82450895da6196a944195980de7 (patch)
tree906d035678d8a31e57a94c01e8756b0085b3e1e4 /src/testlib
parentc081107206cb1d31415539c4429f7896b997cf71 (diff)
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 <jason.mcdonald@nokia.com>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtest_gui.h4
-rw-r--r--src/testlib/qtestcase.cpp67
-rw-r--r--src/testlib/qtestsystem.h36
3 files changed, 74 insertions, 33 deletions
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h
index 5415b64158..a4b1ba810f 100644
--- a/src/testlib/qtest_gui.h
+++ b/src/testlib/qtest_gui.h
@@ -150,10 +150,6 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
}
-#ifdef Q_WS_X11
-extern void qt_x11_wait_for_window_manager(QWidget *w);
-#endif
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index e0c330d74a..bf402181c1 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -859,46 +859,75 @@ QT_BEGIN_NAMESPACE
\sa QTest::qSleep()
*/
-/*! \fn bool QTest::qWaitForWindowShown(QWidget *window)
- \since 4.6
+/*! \fn bool QTest::qWaitForWindowExposed(QWindow *window, int timeout)
+ \since 5.0
- Waits until the \a window is shown on the screen. This is mainly useful for
- asynchronous systems like X11, where a window will be mapped to screen some
- time after being asked to show itself on the screen. Returns true.
+ Waits for \a timeout milliseconds or until the \a window is exposed.
+ Returns true if \c window is exposed within \a timeout milliseconds, otherwise returns false.
- Example:
- \snippet code/src_qtestlib_qtestcase.cpp 24
+ This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
+ time after being asked to show itself on the screen.
+
+ \sa QTest::qWaitForWindowActive(), QWindow::isExposed()
+*/
+
+/*! \fn bool QTest::qWaitForWindowActive(QWindow *window, int timeout)
+ \since 5.0
+
+ Waits for \a timeout milliseconds or until the \a window is active.
+
+ Returns true if \c window is active within \a timeout milliseconds, otherwise returns false.
+
+ \sa QTest::qWaitForWindowExposed(), QWindow::isActive()
*/
/*! \fn bool QTest::qWaitForWindowShown(QWindow *window, int timeout)
\since 5.0
+ \deprecated
- Waits for \a timeout milliseconds or until the \a window is shown on the screen.
- This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
- time after being asked to show itself on the screen.
+ Waits for \a timeout milliseconds or until the \a window is exposed.
+ Returns true if \c window is exposed within \a timeout milliseconds, otherwise returns false.
- Returns true if \c window is show in \a timout milliseconds, otherwise returns false.
+ This function does the same as qWaitForWindowExposed().
\sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowExposed()
*/
-/*! \fn bool QTest::qWaitForWindowActive(QWindow *window, int timeout)
+/*! \fn bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout)
\since 5.0
- Waits for \a timeout milliseconds or until the \a window is active.
+ Waits for \a timeout milliseconds or until the \a widget's window is exposed.
+ Returns true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns false.
- Returns true if \c window is active in \a timout milliseconds, otherwise returns false.
+ This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
+ time after being asked to show itself on the screen.
- \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowShown(), QWindow::isActive()
+ \sa QTest::qWaitForWindowActive()
*/
-/*! \fn bool QTest::qWaitForWindowExposed(QWindow *window, int timeout)
+/*! \fn bool QTest::qWaitForWindowActive(QWidget *widget, int timeout)
\since 5.0
- Waits for \a timeout milliseconds or until the \a window is exposed.
- Returns true if \c window is exposed in \a timout milliseconds, otherwise returns false.
+ Waits for \a timeout milliseconds or until the \a widget's window is active.
+
+ Returns true if \c widget's window is active within \a timeout milliseconds, otherwise returns false.
+
+ \sa QTest::qWaitForWindowExposed(), QWidget::isActiveWindow()
+*/
+
+/*! \fn bool QTest::qWaitForWindowShown(QWidget *widget, int timeout)
+ \since 5.0
+ \deprecated
+
+ Waits for \a timeout milliseconds or until the \a widget's window is exposed.
+ Returns true if \c widget's window is exposed within \a timeout milliseconds, otherwise returns false.
+
+ This function does the same as qWaitForWindowExposed().
- \sa QTest::qWaitForWindowShown(), QTest::qWaitForWindowExposed(), QWindow::isExposed()
+ Example:
+ \snippet code/src_qtestlib_qtestcase.cpp 24
+
+ \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowExposed()
*/
/*!
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 <QtCore/qcoreapplication.h>
#include <QtCore/qelapsedtimer.h>
#include <QtGui/QWindow>
+#ifdef QT_WIDGETS_LIB
+# include <QtWidgets/QWidget>
+#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)
}