summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpushbutton/tst_qpushbutton.cpp
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/qpushbutton/tst_qpushbutton.cpp
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/qpushbutton/tst_qpushbutton.cpp')
-rw-r--r--tests/auto/qpushbutton/tst_qpushbutton.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp
index 5059578..2013258 100644
--- a/tests/auto/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp
@@ -54,6 +54,8 @@
#include <QStyleFactory>
#include <QTabWidget>
+#include "../../shared/util.h"
+
Q_DECLARE_METATYPE(QPushButton*)
//TESTED_CLASS=
@@ -413,6 +415,7 @@ void tst_QPushButton::setAccel()
// The shortcut will not be activated unless the button is in a active
// window and has focus
+ QApplication::setActiveWindow(testWidget);
testWidget->setFocus();
for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) {
testWidget->activateWindow();
@@ -421,8 +424,8 @@ void tst_QPushButton::setAccel()
}
QVERIFY(testWidget->isActiveWindow());
QTest::keyClick( testWidget, 'A', Qt::AltModifier );
- QTest::qWait( 500 );
- QVERIFY( click_count == 1 );
+ QTest::qWait( 50 );
+ QTRY_VERIFY( click_count == 1 );
QVERIFY( press_count == 1 );
QVERIFY( release_count == 1 );
QVERIFY( toggle_count == 0 );
@@ -430,6 +433,7 @@ void tst_QPushButton::setAccel()
// wait 200 ms because setAccel uses animateClick.
// if we don't wait this may screw up a next test.
QTest::qWait(200);
+ QTRY_VERIFY( !testWidget->isDown() );
}
void tst_QPushButton::animateClick()