summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestsystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib/qtestsystem.h')
-rw-r--r--src/testlib/qtestsystem.h26
1 files changed, 23 insertions, 3 deletions
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);
}
}