summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-12-07 13:30:37 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-07 07:53:30 +0100
commitb989444f35c19049510fc39eba19e9cf0f4dd107 (patch)
tree7ca1c77b16c42d28cba1d90d03f46fe0035720ca /tests/auto/widgets
parent7fcc55034c382424b2c45bff440f2611eb514ae6 (diff)
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: Ia65c90cbdb165b543f5c78f9bac3cfadd77dfb3f Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp25
1 files changed, 2 insertions, 23 deletions
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index cc3fd85da6..bf547cc7d9 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -60,16 +60,6 @@ Q_DECLARE_METATYPE(IntList)
typedef QList<bool> BoolList;
Q_DECLARE_METATYPE(BoolList)
-// 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)
-
class protected_QHeaderView : public QHeaderView
{
Q_OBJECT
@@ -1447,23 +1437,12 @@ void tst_QHeaderView::focusPolicy()
QApplication::setActiveWindow(&widget);
QTest::qWaitForWindowShown(&widget);
widget.activateWindow();
- QTest::qWait(100);
-
- qApp->processEvents();
-
- WAIT_FOR_CONDITION(widget.hasFocus(), true);
-
- QVERIFY(widget.hasFocus());
+ QTRY_VERIFY(widget.hasFocus());
QVERIFY(!widget.header()->hasFocus());
widget.setFocusPolicy(Qt::NoFocus);
widget.clearFocus();
-
- qApp->processEvents();
- qApp->processEvents();
-
- WAIT_FOR_CONDITION(widget.hasFocus(), false);
- QVERIFY(!widget.hasFocus());
+ QTRY_VERIFY(!widget.hasFocus());
QVERIFY(!widget.header()->hasFocus());
QTest::keyPress(&widget, Qt::Key_Tab);