diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-04-11 14:36:55 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-04-11 14:36:55 +0200 |
commit | 98d3e40fb7c88b670a93e73dace2d0f05a5f903c (patch) | |
tree | b1292124a86c219fb434db4ec28e8f805ff52287 /src/testlib | |
parent | a74e4b85be83e2da47f4a1d8fcf0e78079335b80 (diff) | |
parent | bab494e4d046f5617d19f5fec35eeff94377c51f (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
mkspecs/qnx-armv7le-qcc/qplatformdefs.h
src/printsupport/kernel/qcups.cpp
src/widgets/styles/qstyle.h
tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
Change-Id: Ia41e13051169a6d4a8a1267548e7d47b859bb267
Diffstat (limited to 'src/testlib')
-rw-r--r-- | src/testlib/qtestcase.cpp | 7 | ||||
-rw-r--r-- | src/testlib/qtestcase.h | 14 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 3ab3fcc44c..cbf479f1d2 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2878,7 +2878,12 @@ void QTest::qSleep(int ms) // requested time. qint64 requested = 1000000 * (qint64)ms; qint64 diff = timer.nsecsElapsed() - requested; - if (diff * 2 > requested || diff * 10 < -requested) { +#ifndef Q_OS_WIN + const qint64 factor = 2; // more than 50% longer +#else + const qint64 factor = 1; // Windows: 50% is quite common, warn about 100% +#endif + if (diff * factor > requested || diff * 10 < -requested) { QTestLog::warn(qPrintable( QString::fromLatin1("QTest::qSleep() should have taken %1ns, but actually took %2ns!") .arg(requested).arg(diff + requested)), __FILE__, __LINE__); diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index b715d83383..d9c8a43a2a 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -140,7 +140,7 @@ do {\ #define QTRY_TIMEOUT_DEBUG_IMPL(__expr, __timeoutValue, __step)\ if (!(__expr)) { \ - QTRY_LOOP_IMPL(__expr, (2 * __timeoutValue), __step);\ + QTRY_LOOP_IMPL((__expr), (2 * __timeoutValue), __step);\ if (__expr) { \ QString msg = QString::fromUtf8("QTestLib: This test case check (\"%1\") failed because the requested timeout (%2 ms) was too short, %3 ms would have been sufficient this time."); \ msg = msg.arg(QString::fromUtf8(#__expr)).arg(__timeoutValue).arg(__timeoutValue + __i); \ @@ -151,26 +151,26 @@ do {\ #define QTRY_IMPL(__expr, __timeout)\ const int __step = 50; \ const int __timeoutValue = __timeout; \ - QTRY_LOOP_IMPL(__expr, __timeoutValue, __step); \ - QTRY_TIMEOUT_DEBUG_IMPL(__expr, __timeoutValue, __step)\ + QTRY_LOOP_IMPL((__expr), __timeoutValue, __step); \ + QTRY_TIMEOUT_DEBUG_IMPL((__expr), __timeoutValue, __step)\ // Will try to wait for the expression to become true while allowing event processing #define QTRY_VERIFY_WITH_TIMEOUT(__expr, __timeout) \ do { \ - QTRY_IMPL(__expr, __timeout);\ + QTRY_IMPL((__expr), __timeout);\ QVERIFY(__expr); \ } while (0) -#define QTRY_VERIFY(__expr) QTRY_VERIFY_WITH_TIMEOUT(__expr, 5000) +#define QTRY_VERIFY(__expr) QTRY_VERIFY_WITH_TIMEOUT((__expr), 5000) // Will try to wait for the comparison to become successful while allowing event processing #define QTRY_COMPARE_WITH_TIMEOUT(__expr, __expected, __timeout) \ do { \ QTRY_IMPL(((__expr) == (__expected)), __timeout);\ - QCOMPARE(__expr, __expected); \ + QCOMPARE((__expr), __expected); \ } while (0) -#define QTRY_COMPARE(__expr, __expected) QTRY_COMPARE_WITH_TIMEOUT(__expr, __expected, 5000) +#define QTRY_COMPARE(__expr, __expected) QTRY_COMPARE_WITH_TIMEOUT((__expr), __expected, 5000) #define QSKIP_INTERNAL(statement) \ do {\ |