Android: fix Quick tests handling for for safe area margins
Account for top and bottom safe margins in Quick tests. Pick-to: 6.10 6.9 Change-Id: Id1cb4486780f3fc42a96e2efb854d3700de619a0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
6b14ba5c2f
commit
f84f10259a
|
@ -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());
|
||||
|
|
|
@ -1679,7 +1679,10 @@ void tst_QQuickMenu::subMenuMouse()
|
|||
#else
|
||||
QQuickMenuItem *mainMenuItem1 = qobject_cast<QQuickMenuItem *>(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());
|
||||
|
|
|
@ -1304,14 +1304,15 @@ void tst_qquickmenubar::AA_DontUseNativeMenuBar()
|
|||
QQuickMenuBar *menuBar = window->property("menuBar").value<QQuickMenuBar *>();
|
||||
QVERIFY(menuBar);
|
||||
auto menuBarPrivate = QQuickMenuBarPrivate::get(menuBar);
|
||||
QQuickItem *contents = window->property("contents").value<QQuickItem *>();
|
||||
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<QQuickMenuBar *>();
|
||||
QVERIFY(menuBar);
|
||||
auto menuBarPrivate = QQuickMenuBarPrivate::get(menuBar);
|
||||
QQuickItem *contents = window->property("contents").value<QQuickItem *>();
|
||||
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<QQuickMenuBar *>();
|
||||
QVERIFY(menuBar);
|
||||
auto menuBarPrivate = QQuickMenuBarPrivate::get(menuBar);
|
||||
QQuickItem *contents = window->property("contents").value<QQuickItem *>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue