diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-12-07 10:58:31 +1000 |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-12-07 10:58:31 +1000 |
commit | ea4adaa0f859929d9fc1a5e6a169c7f493f64dee (patch) | |
tree | 9d6bdb2c8de8ba415e2873c614da42da05b01606 | |
parent | d44013f256d6e234c82a1386e27dbe9acd853557 (diff) |
Add equivalents of qWait() and qSleep()
-rw-r--r-- | doc/testcases.txt | 6 | ||||
-rw-r--r-- | src/imports/testlib/TestCase.qml | 8 | ||||
-rw-r--r-- | src/quicktestlib/qdeclarativetestresult.cpp | 11 | ||||
-rw-r--r-- | src/quicktestlib/qdeclarativetestresult_p.h | 3 |
4 files changed, 28 insertions, 0 deletions
diff --git a/doc/testcases.txt b/doc/testcases.txt index c2a459c..4a5e53f 100644 --- a/doc/testcases.txt +++ b/doc/testcases.txt @@ -96,6 +96,12 @@ A number of helper functions are available to assist with writing tests: - Ignore warning message - Similar to QTest::ignoreMessage(QtWarningMsg, msg) + wait(ms) + - Wait for "ms" milliseconds, processing Qt events. + + sleep(ms) + - Sleep for "ms" milliseconds, but do not process events. + The "msg" parameters can be omitted if there is no particular message that should be displayed other than "FAIL" or "SKIP". diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 78a42af..deb7605 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -161,6 +161,14 @@ Item { results.ignoreWarning(msg) } + function wait(ms) { + results.wait(ms) + } + + function sleep(ms) { + results.sleep(ms) + } + // Functions that can be overridden in subclasses for init/cleanup duties. function initTestCase() {} function cleanupTestCase() {} diff --git a/src/quicktestlib/qdeclarativetestresult.cpp b/src/quicktestlib/qdeclarativetestresult.cpp index 1ecf43c..3de9588 100644 --- a/src/quicktestlib/qdeclarativetestresult.cpp +++ b/src/quicktestlib/qdeclarativetestresult.cpp @@ -41,6 +41,7 @@ #include "qdeclarativetestresult_p.h" #include "qtestcase.h" +#include "qtestsystem.h" #include "qtestresult_p.h" #include "qtesttable_p.h" #include "qtestlog_p.h" @@ -430,6 +431,16 @@ void QDeclarativeTestResult::ignoreWarning(const QString &message) QTestResult::ignoreMessage(QtWarningMsg, message.toLatin1().constData()); } +void QDeclarativeTestResult::wait(int ms) +{ + QTest::qWait(ms); +} + +void QDeclarativeTestResult::sleep(int ms) +{ + QTest::qSleep(ms); +} + namespace QTest { void qtest_qParseArgs(int argc, char *argv[]); }; diff --git a/src/quicktestlib/qdeclarativetestresult_p.h b/src/quicktestlib/qdeclarativetestresult_p.h index 1905b4c..679196c 100644 --- a/src/quicktestlib/qdeclarativetestresult_p.h +++ b/src/quicktestlib/qdeclarativetestresult_p.h @@ -124,6 +124,9 @@ public Q_SLOTS: void ignoreWarning(const QString &message); + void wait(int ms); + void sleep(int ms); + public: // Helper functions for the C++ main() shell. static void parseArgs(int argc, char *argv[]); |