From: Jason McDonald Date: Wed, 7 Dec 2011 03:26:00 +0000 (+1000) Subject: Use QTRY_VERIFY to test asynchronous behaviour. X-Git-Tag: qt-v5.0.0-alpha1~2381 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fcc55034c382424b2c45bff440f2611eb514ae6;p=profile%2Fivi%2Fqtbase.git Use QTRY_VERIFY to test asynchronous behaviour. QTRY_VERIFY waits for a condition to become true while regularly processing events. There is no need for a custom solution to this problem. Change-Id: Ia23e2fb61cdc5c3a3a8a729cd4356ba930fe7cb7 Reviewed-by: Rohan McGovern --- diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 84aa8c7..383fcf8 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -46,16 +46,6 @@ #include #include "private/qapplication_p.h" -// Will try to wait for the condition while allowing event processing -// for a maximum of 2 seconds. -#define WAIT_FOR_CONDITION(expr, expected) \ - do { \ - const int step = 100; \ - for (int i = 0; i < 2000 && expr != expected; i+=step) { \ - QTest::qWait(step); \ - } \ - } while(0) - #ifdef QT_BUILD_INTERNAL #define VERIFY_SPANS_CONSISTENCY(TEST_VIEW_) \ QVERIFY(static_cast(QObjectPrivate::get(TEST_VIEW_))->spans.checkConsistency()) @@ -3358,16 +3348,9 @@ void tst_QTableView::tabFocus() window.setFocus(); QTest::qWait(100); window.activateWindow(); - QTest::qWait(100); - - qApp->processEvents(); - - WAIT_FOR_CONDITION(window.hasFocus(), true); - - qApp->processEvents(); // window - QVERIFY(window.hasFocus()); + QTRY_VERIFY(window.hasFocus()); QVERIFY(!view->hasFocus()); QVERIFY(!edit->hasFocus());