summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2018-05-09 16:45:32 +0300
committerKari Oikarinen <kari.oikarinen@qt.io>2018-05-16 06:10:08 +0000
commitae8743bf861a94aa078675d8ebcc0b1cf567aa4d (patch)
tree7b76fa53183cdc5eebbbd4cb28f538ce77b0323c
parent09cb23f342fd2eae7ca85a99fa0a10b7ab103443 (diff)
tst_QCommandLinkButton: Add back wait to the beginning of setAutoRepeat()
setAutoRepeat() is failing on macOS and Windows when run together with defaultAndAutoDefault(). It succeeds when run on its own. Adding the wait allows it to succeed when run with the other tests as well. Amends 0cb940b1d3b9a1ba50f2d1973fca411706da266d, which removed the wait. The comment is the same as before. I couldn't see a better way to replace the wait (QApplication::topLevelWidgets() already returns only the testWidget and testWidget->isActiveWindow() returns true). Another theory I had was something waiting for the KeyRelease so I changed QApplication::sendEvent() uses to QTest::keyClick(). It did not help but that still seems preferable. Change-Id: If87d1e6e018751f3068ea4c913ae6731aba41ff0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
index c0f33b9c79..2e5d24cd26 100644
--- a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
@@ -167,6 +167,12 @@ 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() );
@@ -421,8 +427,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
QVERIFY(dialog.isVisible());
QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
- QApplication::sendEvent(&dialog, &event);
+ QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
}
@@ -462,8 +467,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
QVERIFY(dialog.isVisible());
QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
- QApplication::sendEvent(&dialog, &event);
+ QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
}
@@ -478,8 +482,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
// No default button is set, and button2 is the first autoDefault button
// that is next in the tab order
QObject::connect(&button2, SIGNAL(clicked()), &dialog, SLOT(hide()));
- QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
- QApplication::sendEvent(&dialog, &event);
+ QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
// Reparenting