diff options
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r-- | tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp | 15 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp | 4 |
2 files changed, 11 insertions, 8 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 diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 36fd0eb54a..ee9446f00b 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -814,6 +814,7 @@ void tst_QDoubleSpinBox::setReadOnly() QDoubleSpinBox spin(0); spin.setValue(0.2); spin.show(); + QVERIFY(QTest::qWaitForWindowActive(&spin)); QCOMPARE(spin.value(), 0.2); QTest::keyClick(&spin, Qt::Key_Up); QCOMPARE(spin.value(), 1.2); @@ -836,7 +837,7 @@ void tst_QDoubleSpinBox::editingFinished() layout->addWidget(box2); testFocusWidget->show(); - QApplication::setActiveWindow(testFocusWidget); + testFocusWidget->activateWindow(); QVERIFY(QTest::qWaitForWindowActive(testFocusWidget)); box->setFocus(); QTRY_VERIFY(box->hasFocus()); @@ -844,7 +845,6 @@ void tst_QDoubleSpinBox::editingFinished() QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished())); - box->setFocus(); QTest::keyClick(box, Qt::Key_Up); QTest::keyClick(box, Qt::Key_Up); |