diff --git a/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp index c7da623720..135734bab5 100644 --- a/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp @@ -639,7 +639,8 @@ void tst_QQuickDrawer::hover() QVERIFY(openedSpy.size() == 1 || openedSpy.wait()); // hover the background button outside the drawer - QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1)); + auto topSafeMargin = window->safeAreaMargins().top(); + QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - topSafeMargin - 1)); QCOMPARE(backgroundButton->isHovered(), !modal); QVERIFY(!drawerButton->isHovered()); QVERIFY(!drawerItem->isHovered()); diff --git a/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp b/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp index 69ae9415e1..d0845851f2 100644 --- a/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp +++ b/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp @@ -1679,7 +1679,10 @@ void tst_QQuickMenu::subMenuMouse() #else QQuickMenuItem *mainMenuItem1 = qobject_cast(mainMenu->itemAt(0)); QVERIFY(mainMenuItem1); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, mainMenuItem1->mapToScene({1,1}).toPoint()); + auto topSafeMargin = window->safeAreaMargins().top(); + auto mousePoint = mainMenuItem1->mapToScene(QPointF(1, 1)).toPoint(); + mousePoint.setY(mousePoint.y() - topSafeMargin); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, mousePoint); #endif // !Q_OS_ANDROID QTRY_VERIFY(!subMenu1->isVisible()); diff --git a/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp b/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp index fbb37090c0..a519def9f6 100644 --- a/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp +++ b/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp @@ -1304,14 +1304,15 @@ void tst_qquickmenubar::AA_DontUseNativeMenuBar() QQuickMenuBar *menuBar = window->property("menuBar").value(); QVERIFY(menuBar); auto menuBarPrivate = QQuickMenuBarPrivate::get(menuBar); - QQuickItem *contents = window->property("contents").value(); + QQuickItem *contents = window->contentItem(); QVERIFY(contents); QVERIFY(!menuBarPrivate->nativeHandle()); QVERIFY(menuBar->isVisible()); QVERIFY(menuBar->count() > 0); QVERIFY(menuBar->height() > 0); - QCOMPARE(contents->height(), window->height() - menuBar->height()); + auto bottomSafeMargin = window->safeAreaMargins().bottom(); + QCOMPARE(contents->height(), window->height() - menuBar->height() - bottomSafeMargin); // If the menu bar is not native, the menus should not be native either. // The main reason for this limitation is that a native menu typically @@ -1508,12 +1509,13 @@ void tst_qquickmenubar::applicationWindow() QQuickMenuBar *menuBar = window->property("menuBar").value(); QVERIFY(menuBar); auto menuBarPrivate = QQuickMenuBarPrivate::get(menuBar); - QQuickItem *contents = window->property("contents").value(); + QQuickItem *contents = window->contentItem(); QVERIFY(contents); // The window may report safe area margins when invisible, but they will not // propagate to the Quick SafeArea until shown. - auto safeAreaTopMargin = initiallyVisible ? window->safeAreaMargins().top() : 0; + auto topSafeMargin = initiallyVisible ? window->safeAreaMargins().top() : 0; + auto bottomSafeMargin = initiallyVisible ? window->safeAreaMargins().bottom() : 0; for (const bool visible : {initiallyVisible, !initiallyVisible, initiallyVisible}) { menuBar->setVisible(visible); @@ -1524,14 +1526,14 @@ void tst_qquickmenubar::applicationWindow() if (!visible) { QVERIFY(!menuBar->isVisible()); QVERIFY(!nativeMenuBarVisible); - QCOMPARE(contents->height(), window->height() - safeAreaTopMargin); + QCOMPARE(contents->height(), window->height() - topSafeMargin - bottomSafeMargin); } else if (nativeMenuBarVisible) { QVERIFY(menuBar->isVisible()); - QCOMPARE(contents->height(), window->height() - safeAreaTopMargin); + QCOMPARE(contents->height(), window->height() - topSafeMargin - bottomSafeMargin); } else { QVERIFY(menuBar->isVisible()); QVERIFY(menuBar->height() > 0); - QCOMPARE(contents->height(), window->height() - menuBar->height()); + QCOMPARE(contents->height(), window->height() - menuBar->height() - bottomSafeMargin); } } } @@ -1560,7 +1562,7 @@ void tst_qquickmenubar::menubarAsHeader() QQuickMenuBar *menuBar = window->property("header").value(); QVERIFY(menuBar); auto menuBarPrivate = QQuickMenuBarPrivate::get(menuBar); - QQuickItem *contents = window->property("contents").value(); + QQuickItem *contents = window->contentItem(); QVERIFY(contents); QVERIFY(menuBar->count() > 0); QCOMPARE(menuBarPrivate->nativeHandle() != nullptr, native); @@ -1570,7 +1572,8 @@ void tst_qquickmenubar::menubarAsHeader() QCOMPARE(contents->height(), window->height() - window->safeAreaMargins().top()); } else { // Not using native menubar - QCOMPARE(contents->height(), window->height() - menuBar->height()); + auto bottomSafeMargin = window->safeAreaMargins().bottom(); + QCOMPARE(contents->height(), window->height() - menuBar->height() - bottomSafeMargin); } } diff --git a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp index 698d1d301e..bc082a7fbb 100644 --- a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp @@ -1599,7 +1599,8 @@ void tst_QQuickPopup::cursorShape() QVERIFY(textField); // Move the mouse over the text field. - const QPoint textFieldPos(popup->x() - 1, textField->height() / 2); + auto topSafeMargin = window->safeAreaMargins().top(); + const QPoint textFieldPos(popup->x() - 1, textField->height() / 2 + topSafeMargin); QVERIFY(textField->contains(textField->mapFromScene(textFieldPos))); QTest::mouseMove(window, textFieldPos); QTRY_COMPARE(window->cursor().shape(), textField->cursor().shape());