summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfocusevent
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-09-08 08:45:57 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-09-08 08:49:39 (GMT)
commitfa889cf4b80868249c70715275069eb150b597cc (patch)
treeab98dc0979d7c2874902e7f2a9812843104e1c49 /tests/auto/qfocusevent
parentdeff8fcf0ed060b949c3ec0fa0ec4bd81c253825 (diff)
downloadQt-fa889cf4b80868249c70715275069eb150b597cc.zip
Qt-fa889cf4b80868249c70715275069eb150b597cc.tar.gz
Qt-fa889cf4b80868249c70715275069eb150b597cc.tar.bz2
Try to make test more robust.
By using QTRY_{COMPARE,VERIFY} instead of waiting an arbitrary amount of time waiting for the window manager to do his job. Also use QApplication::setActiveWindow which seems to be more robust then QWidget::activateWindow
Diffstat (limited to 'tests/auto/qfocusevent')
-rw-r--r--tests/auto/qfocusevent/tst_qfocusevent.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/auto/qfocusevent/tst_qfocusevent.cpp b/tests/auto/qfocusevent/tst_qfocusevent.cpp
index 662f115..5ad78de 100644
--- a/tests/auto/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/qfocusevent/tst_qfocusevent.cpp
@@ -56,6 +56,8 @@
#include <qlineedit.h>
#include <QBoxLayout>
+#include "../../shared/util.h"
+
QT_FORWARD_DECLARE_CLASS(QWidget)
//TESTED_CLASS=
@@ -168,6 +170,7 @@ void tst_QFocusEvent::initWidget()
{
// On X11 we have to ensure the event was processed before doing any checking, on Windows
// this is processed straight away.
+ QApplication::setActiveWindow(childFocusWidgetOne);
for (int i = 0; i < 1000; ++i) {
if (childFocusWidgetOne->isActiveWindow() && childFocusWidgetOne->hasFocus())
@@ -243,9 +246,9 @@ void tst_QFocusEvent::checkReason_BackTab()
// Now test the backtab key
QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab );
- QTest::qWait(2000);
+ QTest::qWait(200);
- QVERIFY(childFocusWidgetOne->focusOutEventRecieved);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved);
QVERIFY(childFocusWidgetTwo->focusInEventRecieved);
QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
QVERIFY(childFocusWidgetTwo->focusInEventGotFocus);
@@ -265,9 +268,9 @@ void tst_QFocusEvent::checkReason_Popup()
Q3PopupMenu* popupMenu = new Q3PopupMenu( testFocusWidget );
popupMenu->insertItem( "Test" );
popupMenu->popup( QPoint(0,0) );
- QTest::qWait(500);
+ QTest::qWait(50);
- QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus);
QVERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( !childFocusWidgetOne->focusInEventRecieved );
@@ -290,11 +293,11 @@ void tst_QFocusEvent::checkReason_Popup()
QMenu* popupMenu = new QMenu( testFocusWidget );
popupMenu->addMenu( "Test" );
popupMenu->popup( QPoint(0,0) );
- QTest::qWait(500);
+ QTest::qWait(50);
- QVERIFY(childFocusWidgetOne->focusOutEventLostFocus);
+ QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus);
- QVERIFY( childFocusWidgetOne->hasFocus() );
+ QTRY_VERIFY( childFocusWidgetOne->hasFocus() );
QVERIFY( !childFocusWidgetOne->focusInEventRecieved );
QVERIFY( childFocusWidgetOne->focusOutEventRecieved );
QVERIFY( !childFocusWidgetTwo->focusInEventRecieved );
@@ -368,13 +371,13 @@ void tst_QFocusEvent::checkReason_focusWidget()
QLineEdit edit1;
QLineEdit edit2;
- QVBoxLayout outerLayout;
+ QVBoxLayout outerLayout;
outerLayout.addWidget(&frame1);
outerLayout.addWidget(&frame2);
window1.setLayout(&outerLayout);
-
- QVBoxLayout leftLayout;
- QVBoxLayout rightLayout;
+
+ QVBoxLayout leftLayout;
+ QVBoxLayout rightLayout;
leftLayout.addWidget(&edit1);
rightLayout.addWidget(&edit2);
frame1.setLayout(&leftLayout);