diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2018-04-06 16:25:21 +0300 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2018-04-25 11:55:34 +0000 |
commit | 0cb940b1d3b9a1ba50f2d1973fca411706da266d (patch) | |
tree | 326e6a32edef67c9e4000862a47fa49db2dd8263 /tests/auto/widgets/widgets/qcommandlinkbutton | |
parent | 7917305aa5acdad117632bc2723d9bec85daa0e0 (diff) |
tests/auto/widgets/widgets: Avoid unconditional qWait()s
Task-number: QTBUG-63992
Change-Id: I7b0c259800082284ddae4e25d139ad3adc858467
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qcommandlinkbutton')
-rw-r--r-- | tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp index 667e348945..c0f33b9c79 100644 --- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp +++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp @@ -110,6 +110,7 @@ void tst_QCommandLinkButton::initTestCase() testWidget->setObjectName("testWidget"); testWidget->resize( 200, 200 ); testWidget->show(); + QVERIFY(QTest::qWaitForWindowActive(testWidget)); connect( testWidget, SIGNAL(clicked()), this, SLOT(onClicked()) ); connect( testWidget, SIGNAL(pressed()), this, SLOT(onPressed()) ); @@ -166,12 +167,6 @@ void tst_QCommandLinkButton::onReleased() void tst_QCommandLinkButton::setAutoRepeat() { - // Give the last tests time to finish - i.e., wait for the window close - // and deactivate to avoid a race condition here. We can't add this to the - // end of the defaultAndAutoDefault test, since any failure in that test - // will return out of that function. - QTest::qWait( 1000 ); - // If this changes, this test must be completely revised. QVERIFY( !testWidget->isCheckable() ); @@ -194,8 +189,6 @@ void tst_QCommandLinkButton::setAutoRepeat() testWidget->setAutoRepeat( false ); QTest::keyPress( testWidget, Qt::Key_Space ); - QTest::qWait( 300 ); - QVERIFY( testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QVERIFY( press_count == 1 ); @@ -206,18 +199,16 @@ void tst_QCommandLinkButton::setAutoRepeat() resetCounters(); // check that the button is down if we press space while in autorepeat - // we can't actually confirm how many times it is fired, more than 1 is enough. testWidget->setDown( false ); testWidget->setAutoRepeat( true ); QTest::keyPress( testWidget, Qt::Key_Space ); - QTest::qWait(900); + QTRY_VERIFY(press_count > 10); QVERIFY( testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QTest::keyRelease( testWidget, Qt::Key_Space ); QCOMPARE(press_count, release_count); QCOMPARE(release_count, click_count); - QVERIFY(press_count > 1); // #### shouldn't I check here to see if multiple signals have been fired??? @@ -227,8 +218,6 @@ void tst_QCommandLinkButton::setAutoRepeat() testWidget->setAutoRepeat( false ); QTest::keyPress( testWidget, Qt::Key_Enter ); - QTest::qWait( 300 ); - QVERIFY( !testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QVERIFY( press_count == 0 ); @@ -241,7 +230,6 @@ void tst_QCommandLinkButton::setAutoRepeat() testWidget->setDown( false ); testWidget->setAutoRepeat( true ); QTest::keyClick( testWidget, Qt::Key_Enter ); - QTest::qWait( 300 ); QVERIFY( !testWidget->isDown() ); QVERIFY( toggle_count == 0 ); QVERIFY( press_count == 0 ); @@ -252,23 +240,19 @@ void tst_QCommandLinkButton::setAutoRepeat() void tst_QCommandLinkButton::pressed() { QTest::keyPress( testWidget, ' ' ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)0 ); QTest::keyRelease( testWidget, ' ' ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)1 ); QTest::keyPress( testWidget,Qt::Key_Enter ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)1 ); QCOMPARE( release_count, (uint)1 ); testWidget->setAutoDefault(true); QTest::keyPress( testWidget,Qt::Key_Enter ); -// QTest::qWait( 300 ); QCOMPARE( press_count, (uint)2 ); QCOMPARE( release_count, (uint)2 ); testWidget->setAutoDefault(false); @@ -349,19 +333,7 @@ void tst_QCommandLinkButton::setAccel() // The shortcut will not be activated unless the button is in a active // window and has focus testWidget->setFocus(); - - // QWidget::isActiveWindow() can report window active before application - // has handled the asynchronous activation event on platforms that have - // implemented QPlatformWindow::isActive(), so process events to sync up. - QApplication::instance()->processEvents(); - - for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) { - testWidget->activateWindow(); - QApplication::instance()->processEvents(); - QTest::qWait(100); - } - - QVERIFY(testWidget->isActiveWindow()); + QVERIFY(QTest::qWaitForWindowActive(testWidget)); QTest::keyClick( testWidget, 'A', Qt::AltModifier ); QTest::qWait( 500 ); |