From 22e8dd8653281ebf79fc7fc0061b225c8daf2977 Mon Sep 17 00:00:00 2001
From: Rohan McGovern <rohan.mcgovern@nokia.com>
Date: Tue, 8 Sep 2009 15:15:12 +1000
Subject: Fixed some focus-related tst_qlineedit failures.

There are many places where the test assumes that a widget gets focus
after some fixed timeout.  Change it to block until the widget really
gets focus.
---
 tests/auto/qlineedit/tst_qlineedit.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 6bbdf5d..47f0730 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -343,6 +343,7 @@ void tst_QLineEdit::initTestCase()
     // to be safe and avoid failing setFocus with window managers
     qt_x11_wait_for_window_manager(testWidget);
 #endif
+    QTRY_VERIFY(testWidget->hasFocus());
 
     changed_count = 0;
     edited_count = 0;
@@ -1601,8 +1602,7 @@ void tst_QLineEdit::passwordEchoOnEdit()
     testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
     testWidget->setFocus();
     testWidget->raise();
-    QTest::qWait(250);
-    QVERIFY(testWidget->hasFocus());
+    QTRY_VERIFY(testWidget->hasFocus());
 
     QTest::keyPress(testWidget, '0');
     QTest::keyPress(testWidget, '1');
@@ -1614,6 +1614,7 @@ void tst_QLineEdit::passwordEchoOnEdit()
     QVERIFY(!testWidget->hasFocus());
     QCOMPARE(testWidget->displayText(), QString(5, fillChar));
     testWidget->setFocus();
+    QTRY_VERIFY(testWidget->hasFocus());
 
     QCOMPARE(testWidget->displayText(), QString(5, fillChar));
     QTest::keyPress(testWidget, '0');
@@ -3397,7 +3398,7 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion()
     qt_x11_wait_for_window_manager(&lineEdit);
 #endif
     lineEdit.setFocus();
-    QTest::qWait(200);
+    QTRY_VERIFY(lineEdit.hasFocus());
     QTest::keyPress(&lineEdit, 'a');
     QTest::keyPress(&lineEdit, Qt::Key_Return);
     QCOMPARE(lineEdit.text(), completion);
@@ -3491,7 +3492,7 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
 
     testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
     testWidget->setFocus();
-    QTest::qWait(250);
+    QTRY_VERIFY(testWidget->hasFocus());
 
     QTest::keyPress(testWidget, '0');
     QCOMPARE(testWidget->displayText(), QString("0"));
-- 
cgit v0.12