From: Toby Tomkins Date: Wed, 14 Sep 2011 03:02:16 +0000 (+1000) Subject: Restructure test to use QTRY_ macro for instability. X-Git-Tag: qt-v5.0.0-alpha1~1602 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02ae57b886ccf819db6e6da19acb43d2f0dcb939;p=profile%2Fivi%2Fqtdeclarative.git Restructure test to use QTRY_ macro for instability. Restructure test to use QTRY_ for asynchronous gui functions. Remove reference to specific X11 and generalise event queue processing for all platforms. Change-Id: I9aa27729d35cbf3c2e2a7986210f6128d22696ef Reviewed-on: http://codereview.qt-project.org/4728 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index 50cca1d..9a80525 100644 --- a/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -47,6 +47,7 @@ #include #include #include +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -112,14 +113,10 @@ void tst_qdeclarativefocusscope::basic() view->show(); qApp->setActiveWindow(view); - qApp->processEvents(); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(view); -#endif + QTest::qWaitForWindowShown(view); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); QVERIFY(item0->hasActiveFocus() == true); QVERIFY(item1->hasActiveFocus() == true); @@ -159,14 +156,10 @@ void tst_qdeclarativefocusscope::nested() view->show(); qApp->setActiveWindow(view); - qApp->processEvents(); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(view); -#endif + QTest::qWaitForWindowShown(view); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); QVERIFY(item1->hasActiveFocus() == true); @@ -193,14 +186,10 @@ void tst_qdeclarativefocusscope::noFocus() view->show(); qApp->setActiveWindow(view); - qApp->processEvents(); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(view); -#endif + QTest::qWaitForWindowShown(view); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); QVERIFY(item0->hasActiveFocus() == false); QVERIFY(item1->hasActiveFocus() == false); @@ -238,14 +227,10 @@ void tst_qdeclarativefocusscope::textEdit() view->show(); qApp->setActiveWindow(view); - qApp->processEvents(); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(view); -#endif + QTest::qWaitForWindowShown(view); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); QVERIFY(item0->hasActiveFocus() == true); QVERIFY(item1->hasActiveFocus() == true); @@ -297,14 +282,10 @@ void tst_qdeclarativefocusscope::forceFocus() view->show(); qApp->setActiveWindow(view); - qApp->processEvents(); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(view); -#endif + QTest::qWaitForWindowShown(view); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); QVERIFY(item0->hasActiveFocus() == true); QVERIFY(item1->hasActiveFocus() == true); @@ -363,17 +344,13 @@ void tst_qdeclarativefocusscope::signalEmission() view->show(); qApp->setActiveWindow(view); - qApp->processEvents(); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(view); -#endif + QTest::qWaitForWindowShown(view); QVariant blue(QColor("blue")); QVariant red(QColor("red")); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); item1->setFocus(true); QCOMPARE(item1->property("color"), red); @@ -416,14 +393,10 @@ void tst_qdeclarativefocusscope::qtBug13380() view->show(); QVERIFY(view->rootObject()); qApp->setActiveWindow(view); - qApp->processEvents(); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(view); -#endif + QTest::qWaitForWindowShown(view); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QVERIFY(view->scene()->hasFocus()); QVERIFY(view->rootObject()->property("noFocus").toBool());