From b76dffec3c8ed486ffaf90ad6e4b878825a63c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 14 Sep 2022 11:14:09 +0200 Subject: [PATCH] Don't rely on synthetic mouse events in updateFocusChainWhenChildDie test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Synthetic mouse events are not reliable, as the platform might restrict synthetic mouse moves. In addition, the WM might automatically activate the window when the other window is hidden, which makes the EXPECT_FAIL flakey. Since the test was not written to test window activation, let's just explicitly activate the window. Fixes: QTBUG-23699 Change-Id: I0ac1d3bc0658dfbd600a1f5d960839860be6dd2c Reviewed-by: Timur Pocheptsov (cherry picked from commit 2e58e242b436d0d462748546d4451f6365de4743) Reviewed-by: Tor Arne Vestbø --- .../qgraphicswidget/tst_qgraphicswidget.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index cd91137fbde..ba0c8217e67 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -1719,7 +1719,7 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() view.resize(200, 150); view.move(availableGeometry.topLeft() + QPoint(50, 50)); view.show(); - QApplication::setActiveWindow(&view); + view.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&view)); // delete item in focus chain with no focus and verify chain @@ -1748,13 +1748,8 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie() w->setParentItem(parent); //We don't crash perfect QVERIFY(w); - const QPoint center(view.viewport()->width() / 2, view.viewport()->height() / 2); - QTest::mouseMove(view.viewport(), center); - QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, center); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23699", Continue); -#endif - QTRY_COMPARE(qApp->activeWindow(), static_cast(&view)); + view.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_COMPARE(scene.focusItem(), static_cast(w)); }