From 883d58dacdcddc3f383565251f3c805a20e3d704 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Fri, 11 May 2018 16:41:12 +0300 Subject: [PATCH] Fix tst_QDoubleSpinBox::editingFinished failing after other tests Wait for the spinbox to show become active in the previous test. Also use QWidget::activateWindow() instead of QApplication::setActiveWindow(). Use of the latter seemed to result in some confusion where QWidget::isActiveWindow() returned true but QWindow::isActive() on the underlying window returned false, leading qWaitForWindowActive() to fail. Also remove superfluous setting of focus. It was just set and verified. Change-Id: I023cdc2d272e23b2537b32606b7a3bf35bf671ac Reviewed-by: Friedemann Kleint --- .../widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 22e8097949..d44cc40527 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -748,6 +748,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); @@ -770,7 +771,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()); @@ -778,7 +779,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);