summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-03-19 10:03:48 +0100
committerKent Hansen <kent.hansen@nokia.com>2012-03-19 10:03:48 +0100
commit95d6f8a4cf3fba2fd675f0e6b5de0ce1d702da26 (patch)
treea0bb36e478c97761afa36baf8026726b3d2fdbc8 /src/testlib
parent3f64a7b67bfbcaab65ebb03f84962cce5834790b (diff)
parent25e004bfe493e18be255b057ae5c132a5ec5458b (diff)
Merge master into api_changes
Conflicts: src/corelib/tools/qvector.h tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp Change-Id: I877256e95f3788e617437f4e9661a88047f38cd6
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestaccessible.h8
-rw-r--r--src/testlib/qtestcase.cpp33
-rw-r--r--src/testlib/qtestsystem.h26
3 files changed, 59 insertions, 8 deletions
diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h
index 807cc2f846..6d8d6125c1 100644
--- a/src/testlib/qtestaccessible.h
+++ b/src/testlib/qtestaccessible.h
@@ -98,18 +98,18 @@ public:
}
static void clearEvents() { eventList().clear(); }
static EventList events() { return eventList(); }
- static bool verifyEvent(const QAccessibleEvent& ev)
+ static bool verifyEvent(QAccessibleEvent *ev)
{
if (eventList().isEmpty())
return false;
QAccessibleEvent *first = eventList().takeFirst();
- bool res = *first == ev;
+ bool res = *first == *ev;
delete first;
return res;
}
- static bool containsEvent(const QAccessibleEvent &event) {
+ static bool containsEvent(QAccessibleEvent *event) {
Q_FOREACH (QAccessibleEvent *ev, eventList()) {
- if (*ev == event)
+ if (*ev == *event)
return true;
}
return false;
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index fb9a8e630c..3075726cae 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -862,7 +862,7 @@ QT_BEGIN_NAMESPACE
/*! \fn bool QTest::qWaitForWindowShown(QWidget *window)
\since 4.6
- Waits until the \a window is shown in the screen. This is mainly useful for
+ 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.
@@ -870,6 +870,37 @@ QT_BEGIN_NAMESPACE
\snippet doc/src/snippets/code/src_qtestlib_qtestcase.cpp 24
*/
+/*! \fn bool QTest::qWaitForWindowShown(QWindow *window, int timeout)
+ \since 5.0
+
+ 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.
+
+ Returns true if \c window is show in \a timout milliseconds, otherwise returns false.
+
+ \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowExposed()
+*/
+
+/*! \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 in \a timout milliseconds, otherwise returns false.
+
+ \sa QTest::qWaitForWindowActive(), QTest::qWaitForWindowShown(), QWindow::isActive()
+*/
+
+/*! \fn bool QTest::qWaitForWindowExposed(QWindow *window, 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.
+
+ \sa QTest::qWaitForWindowShown(), QTest::qWaitForWindowExposed(), QWindow::isExposed()
+*/
+
/*!
\class QTest::QTouchEventSequence
\inmodule QtTest
diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h
index ade5f4c8ac..095f791cac 100644
--- a/src/testlib/qtestsystem.h
+++ b/src/testlib/qtestsystem.h
@@ -76,19 +76,39 @@ namespace QTest
return true;
}
- inline static bool qWaitForWindowShown(QWindow *window)
+ inline static bool qWaitForWindowActive(QWindow *window, int timeout = 1000)
+ {
+ QElapsedTimer timer;
+ timer.start();
+ while (!window->isActive()) {
+ int remaining = timeout - int(timer.elapsed());
+ if (remaining <= 0)
+ break;
+ QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QTest::qSleep(10);
+ }
+ return window->isActive();
+ }
+
+ inline static bool qWaitForWindowExposed(QWindow *window, int timeout = 1000)
{
QElapsedTimer timer;
timer.start();
while (!window->isExposed()) {
- int remaining = int(timer.elapsed()) - 1000;
+ int remaining = timeout - int(timer.elapsed());
if (remaining <= 0)
break;
QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QTest::qSleep(10);
}
- return true;
+ return window->isExposed();
+ }
+
+ inline static bool qWaitForWindowShown(QWindow *window, int timeout = 1000)
+ {
+ return qWaitForWindowActive(window, timeout);
}
}