diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-10-17 18:51:44 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-19 07:23:44 +0200 |
commit | ae1810658b75dd0eb0247b0e951ce315c8ce4c86 (patch) | |
tree | cbc133fa2b3ba0e476aa375974e71f58d494a2a1 /src/testlib/qtestcase.h | |
parent | 757b0529c42690988f565ca03194900c4d1289f8 (diff) |
Move QTRY_VERIFY/QTRY_COMPARE into testlib.
These functions have lived in tests/shared/util.h for a long time, but
they really belong in qtestlib.
Change-Id: I60d569d002dea220b51563931d8b7aa77a20b98b
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib/qtestcase.h')
-rw-r--r-- | src/testlib/qtestcase.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index b3ac5f0c4f..642be0bc96 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -82,6 +82,34 @@ do {\ return;\ } while (0) +// Will try to wait for the expression to become true while allowing event processing +#define QTRY_VERIFY(__expr) \ +do { \ + const int __step = 50; \ + const int __timeout = 5000; \ + if (!(__expr)) { \ + QTest::qWait(0); \ + } \ + for (int __i = 0; __i < __timeout && !(__expr); __i+=__step) { \ + QTest::qWait(__step); \ + } \ + QVERIFY(__expr); \ +} while (0) + +// Will try to wait for the comparison to become successful while allowing event processing +#define QTRY_COMPARE(__expr, __expected) \ +do { \ + const int __step = 50; \ + const int __timeout = 5000; \ + if ((__expr) != (__expected)) { \ + QTest::qWait(0); \ + } \ + for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \ + QTest::qWait(__step); \ + } \ + QCOMPARE(__expr, __expected); \ +} while (0) + #define QSKIP(statement, mode) \ do {\ QTest::qSkip(statement, QTest::mode, __FILE__, __LINE__);\ |