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 0cb940b1d3, 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>
This commit is contained in:
Kari Oikarinen 2018-05-09 16:45:32 +03:00
parent 09cb23f342
commit ae8743bf86

View File

@ -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