aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTor Arne Vestbø <[email protected]>2025-05-28 21:36:51 +0200
committerTor Arne Vestbø <[email protected]>2025-06-02 23:11:37 +0200
commitc6351d481a939579373f031e3fe45791944aa62b (patch)
treec5bb45942ff84039a9ae5f78bc102929f8c0fde4 /tests
parentd96f616722fc7b3f49ae671ecd20f50517920a96 (diff)
Enable expanded client area by default in iOS styleHEADdev
[ChangeLog][iOS] The iOS style now enables expanded client areas by default. To override this, set the ApplicationWindow's flags explicitly to e.g. Qt.Window. Change-Id: I333e36d2959b2ff8029cc685ec2b5610d11e6069 Reviewed-by: Oliver Eftevaag <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quickcontrols/controls/data/tst_popup.qml5
-rw-r--r--tests/auto/quickcontrols/qquickcontrol/tst_qquickcontrol.cpp2
-rw-r--r--tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp6
-rw-r--r--tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp30
-rw-r--r--tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp10
-rw-r--r--tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp52
6 files changed, 67 insertions, 38 deletions
diff --git a/tests/auto/quickcontrols/controls/data/tst_popup.qml b/tests/auto/quickcontrols/controls/data/tst_popup.qml
index 3691c30b56..d88d3d4da2 100644
--- a/tests/auto/quickcontrols/controls/data/tst_popup.qml
+++ b/tests/auto/quickcontrols/controls/data/tst_popup.qml
@@ -1343,8 +1343,9 @@ TestCase {
let expectedX = (overlay.width - (control.width * control.scale)) / 2
let expectedY = (overlay.height - (control.height * control.scale)) / 2
// translate to the parent's (anotherItem's) co-ordinate system
- expectedX -= anotherItem.x
- expectedY -= anotherItem.y
+ let anotherItemScenePos = anotherItem.mapToItem(null, 0, 0);
+ expectedX -= anotherItemScenePos.x
+ expectedY -= anotherItemScenePos.y
compare(currentPos.x, expectedX)
compare(currentPos.y, expectedY)
}
diff --git a/tests/auto/quickcontrols/qquickcontrol/tst_qquickcontrol.cpp b/tests/auto/quickcontrols/qquickcontrol/tst_qquickcontrol.cpp
index 4f3a1b96c4..5434aa1efa 100644
--- a/tests/auto/quickcontrols/qquickcontrol/tst_qquickcontrol.cpp
+++ b/tests/auto/quickcontrols/qquickcontrol/tst_qquickcontrol.cpp
@@ -67,7 +67,7 @@ void tst_QQuickControl::flickable()
QSignalSpy buttonClickedSpy(button, SIGNAL(clicked()));
QVERIFY(buttonClickedSpy.isValid());
- QPoint p(button->width() / 2, button->height() / 2);
+ QPoint p = button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint();
QTest::touchEvent(window, touchDevice.data()).press(0, p);
QTRY_COMPARE(buttonPressedSpy.size(), 1);
p += QPoint(1, 1); // less than the drag threshold
diff --git a/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp
index e316663908..c7da623720 100644
--- a/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp
+++ b/tests/auto/quickcontrols/qquickdrawer/tst_qquickdrawer.cpp
@@ -575,7 +575,8 @@ void tst_QQuickDrawer::header()
// must be possible to interact with the header when the drawer is below the header
QSignalSpy clickSpy(button, SIGNAL(clicked()));
QVERIFY(clickSpy.isValid());
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + button->width() / 2, button->y() + button->height() / 2));
+ QPoint p = button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint();
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, p);
QCOMPARE(clickSpy.size(), 1);
}
@@ -742,7 +743,8 @@ void tst_QQuickDrawer::wheel()
qreal oldContentValue = contentSlider->value();
qreal oldDrawerValue = drawerSlider->value();
- QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPoint(0, 0), 15));
+ auto *overlay = QQuickOverlay::overlay(window);
+ QVERIFY(sendWheelEvent(overlay, QPoint(0, overlay->height() / 2), 15));
if (modal) {
// the content below a modal overlay must not move
diff --git a/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp b/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp
index 6de0800f96..d5fbaa5f99 100644
--- a/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp
+++ b/tests/auto/quickcontrols/qquickmenu/tst_qquickmenu.cpp
@@ -317,9 +317,9 @@ void tst_QQuickMenu::mouse()
QVERIFY(QMetaObject::invokeMethod(listView, "itemAt", Q_RETURN_ARG(QQuickItem *, hoverItem), Q_ARG(qreal, 0), Q_ARG(qreal, listView->property("contentY").toReal() + y)));
if (!hoverItem || !hoverItem->isVisible() || hoverItem == prevHoverItem)
continue;
- QTest::mouseMove(window, QPoint(
- menu->x() + menu->leftPadding() + hoverItem->x() + hoverItem->width() / 2,
- menu->y() + menu->topPadding() + hoverItem->y() + hoverItem->height() / 2));
+
+ QPoint p = hoverItem->mapToScene(QPointF(hoverItem->width() / 2, hoverItem->height() / 2)).toPoint();
+ QTest::mouseMove(hoverItem->window(), p);
QTRY_VERIFY(hoverItem->property("highlighted").toBool());
if (prevHoverItem)
QVERIFY(!prevHoverItem->property("highlighted").toBool());
@@ -356,13 +356,15 @@ void tst_QQuickMenu::pressAndHold()
QQuickMenu *menu = window->property("menu").value<QQuickMenu *>();
QVERIFY(menu);
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ QPoint windowCenter = QRect(QPoint(0, 0), window->size()).center();
+
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, windowCenter);
QTRY_VERIFY(menu->isVisible());
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, windowCenter);
QVERIFY(menu->isVisible());
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, windowCenter);
QTRY_VERIFY(!menu->isVisible());
}
@@ -1174,7 +1176,10 @@ void tst_QQuickMenu::popup()
QVERIFY(button);
QPoint oldCursorPos = QCursor::pos();
- QPoint cursorPos = window->mapToGlobal(QPoint(11, 22));
+
+ const auto safeAreaMargins = window->safeAreaMargins();
+ const auto topLeftSafePoint = QPointF(11, 22) + QPointF(safeAreaMargins.left(), safeAreaMargins.top());
+ QPoint cursorPos = window->mapToGlobal(topLeftSafePoint.toPoint());
QCursor::setPos(cursorPos);
QTRY_COMPARE(QCursor::pos(), cursorPos);
@@ -1182,13 +1187,16 @@ void tst_QQuickMenu::popup()
QCOMPARE(menu->parentItem(), window->contentItem());
QCOMPARE(menu->currentIndex(), -1);
QCOMPARE(menu->contentItem()->property("currentIndex").toInt(), -1);
- const qreal elevenOrLeftMargin = qMax(qreal(11), menu->leftMargin());
- const qreal twentyTwoOrTopMargin = qMax(qreal(22), menu->topMargin());
+
+ const auto menuPos = window->contentItem()->mapToScene(QPointF(menu->x(), menu->y()));
+
+ const qreal elevenOrLeftMargin = qMax(topLeftSafePoint.x(), menu->leftMargin());
+ const qreal twentyTwoOrTopMargin = qMax(topLeftSafePoint.y(), menu->topMargin());
// If the Menu has large margins, it may be moved to stay within them.
static QString errorStringXPos("The menu's x position was %1 and differed too much from %2");
static QString errorStringYPos("The menu's y position was %1 and differed too much from %2");
- QTRY_VERIFY2(qAbs(menu->x() - elevenOrLeftMargin) <= 0.5, qPrintable(errorStringXPos.arg(menu->x()).arg(elevenOrLeftMargin)));
- QTRY_VERIFY2(qAbs(menu->y() - twentyTwoOrTopMargin) <= 0.5, qPrintable(errorStringYPos.arg(menu->y()).arg(twentyTwoOrTopMargin)));
+ QTRY_VERIFY2(qAbs(menuPos.x() - elevenOrLeftMargin) <= 0.5, qPrintable(errorStringXPos.arg(menu->x()).arg(elevenOrLeftMargin)));
+ QTRY_VERIFY2(qAbs(menuPos.y() - twentyTwoOrTopMargin) <= 0.5, qPrintable(errorStringYPos.arg(menu->y()).arg(twentyTwoOrTopMargin)));
menu->close();
QVERIFY(QMetaObject::invokeMethod(window, "popupAtPos", Q_ARG(QVariant, QPointF(33, 44))));
diff --git a/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp b/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp
index fabb91e933..fbb37090c0 100644
--- a/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp
+++ b/tests/auto/quickcontrols/qquickmenubar/tst_qquickmenubar.cpp
@@ -1511,6 +1511,10 @@ void tst_qquickmenubar::applicationWindow()
QQuickItem *contents = window->property("contents").value<QQuickItem *>();
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;
+
for (const bool visible : {initiallyVisible, !initiallyVisible, initiallyVisible}) {
menuBar->setVisible(visible);
@@ -1520,10 +1524,10 @@ void tst_qquickmenubar::applicationWindow()
if (!visible) {
QVERIFY(!menuBar->isVisible());
QVERIFY(!nativeMenuBarVisible);
- QCOMPARE(contents->height(), window->height());
+ QCOMPARE(contents->height(), window->height() - safeAreaTopMargin);
} else if (nativeMenuBarVisible) {
QVERIFY(menuBar->isVisible());
- QCOMPARE(contents->height(), window->height());
+ QCOMPARE(contents->height(), window->height() - safeAreaTopMargin);
} else {
QVERIFY(menuBar->isVisible());
QVERIFY(menuBar->height() > 0);
@@ -1563,7 +1567,7 @@ void tst_qquickmenubar::menubarAsHeader()
if (menuBarPrivate->nativeHandle()) {
// Using native menubar
- QCOMPARE(contents->height(), window->height());
+ QCOMPARE(contents->height(), window->height() - window->safeAreaMargins().top());
} else {
// Not using native menubar
QCOMPARE(contents->height(), window->height() - menuBar->height());
diff --git a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp
index 187b9825da..9d2c7b9a84 100644
--- a/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/quickcontrols/qquickpopup/tst_qquickpopup.cpp
@@ -626,9 +626,14 @@ void tst_QQuickPopup::closePolicy()
// wait for dimmer
QTest::qWait(50);
+ const auto safeAreaMargins = window->safeAreaMargins();
+ const auto topLeftSafePoint = QPoint(1, 1) + QPoint(safeAreaMargins.left(), safeAreaMargins.top());
+
+ QPoint buttonPoint = button->mapToScene(QPointF(1, 1)).toPoint();
+
for (int i = 0; i < 2; ++i) {
// press outside popup and its parent
- QQuickTest::pointerPress(device, window, 0, {1, 1});
+ QQuickTest::pointerPress(device, window, 0, topLeftSafePoint);
if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
QTRY_VERIFY(!popup->isVisible());
else
@@ -639,7 +644,7 @@ void tst_QQuickPopup::closePolicy()
QTRY_VERIFY(popup->isOpened());
// release outside popup and its parent
- QQuickTest::pointerRelease(device, window, 0, {1, 1});
+ QQuickTest::pointerRelease(device, window, 0, topLeftSafePoint);
if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) || closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
QTRY_VERIFY(!popup->isVisible());
else
@@ -650,7 +655,7 @@ void tst_QQuickPopup::closePolicy()
QTRY_VERIFY(popup->isOpened());
// press outside popup but inside its parent
- QQuickTest::pointerPress(device, window, 0, QPoint(button->x() + 1, button->y() + 1));
+ QQuickTest::pointerPress(device, window, 0, buttonPoint);
if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
QTRY_VERIFY(!popup->isVisible());
else
@@ -661,7 +666,7 @@ void tst_QQuickPopup::closePolicy()
QTRY_VERIFY(popup->isOpened());
// release outside popup but inside its parent
- QQuickTest::pointerRelease(device, window, 0, QPoint(button->x() + 1, button->y() + 1));
+ QQuickTest::pointerRelease(device, window, 0, buttonPoint);
if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
QTRY_VERIFY(!popup->isVisible());
else
@@ -672,10 +677,9 @@ void tst_QQuickPopup::closePolicy()
QTRY_VERIFY(popup->isOpened());
// press inside and release outside
- QQuickTest::pointerPress(device, window, 0, QPoint(button->x() + popup->x() + 1,
- button->y() + popup->y() + 1));
+ QQuickTest::pointerPress(device, window, 0, buttonPoint + QPoint(popup->x(), popup->y()));
QVERIFY(popup->isOpened());
- QQuickTest::pointerRelease(device, window, 0, {1, 1});
+ QQuickTest::pointerRelease(device, window, 0, topLeftSafePoint);
QVERIFY(popup->isOpened());
}
@@ -1226,13 +1230,15 @@ void tst_QQuickPopup::hover()
QTRY_VERIFY(popup->width() > 10); // somehow this can take a short time with macOS style
// Hover the parent button outside the popup. It has 10 pixel anchor margins around the window.
+ QPoint buttonPoint = parentButton->mapToScene(QPointF()).toPoint();
PointLerper pointLerper(window);
- pointLerper.move(15, 15);
+ pointLerper.move(buttonPoint);
+
QCOMPARE(parentButton->isHovered(), !modal);
QVERIFY(!childButton->isHovered());
// Hover the popup background. Its top-left is 10 pixels in from its parent.
- pointLerper.move(25, 25);
+ pointLerper.move(buttonPoint + QPoint(10, 10));
QVERIFY(!parentButton->isHovered());
QVERIFY(!childButton->isHovered());
@@ -1353,7 +1359,8 @@ void tst_QQuickPopup::wheel()
qreal oldContentValue = contentSlider->value();
qreal oldPopupValue = popupSlider->value();
- QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPointF(0, 0), 15));
+ auto *overlay = QQuickOverlay::overlay(window);
+ QVERIFY(sendWheelEvent(overlay, QPoint(0, overlay->height() / 2), 15));
if (modal) {
// the content below a modal overlay must not move
@@ -1538,8 +1545,10 @@ void tst_QQuickPopup::grabber()
QCOMPARE(popup->isVisible(), false);
QCOMPARE(combo->isVisible(), false);
+ QPoint menuCenter = menu->contentItem()->mapToScene(QPointF(menu->width() / 2, menu->height() / 2)).toPoint();
+
// click a menu item to open the popup
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(menu->x() + menu->width() / 2, menu->y() + menu->height() / 2));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, menuCenter);
QTRY_COMPARE(menu->isVisible(), false);
QTRY_COMPARE(popup->isOpened(), true);
QCOMPARE(combo->isVisible(), false);
@@ -2170,8 +2179,9 @@ public:
{
called = true;
// let clicks at {1, 1} through the dimmer
- return point != QPoint(1, 1);
+ return point != clickThoughPoint;
}
+ QPoint clickThoughPoint;
};
/*
@@ -2182,7 +2192,6 @@ public:
*/
void tst_QQuickPopup::dimmerContainmentMask()
{
- ContainmentMask containmentMask;
int expectedClickCount = 0;
QQuickApplicationHelper helper(this, "dimmerContainmentMask.qml");
@@ -2197,13 +2206,16 @@ void tst_QQuickPopup::dimmerContainmentMask()
QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
QVERIFY(modalPopup);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ const auto safeAreaMargins = window->safeAreaMargins();
+ const auto topLeftSafePoint = QPoint(1, 1) + QPoint(safeAreaMargins.left(), safeAreaMargins.top());
+
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, topLeftSafePoint);
QCOMPARE(window->property("clickCount"), ++expectedClickCount);
modalPopup->open();
QTRY_VERIFY(modalPopup->isOpened());
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, topLeftSafePoint);
QCOMPARE(window->property("clickCount"), expectedClickCount); // blocked by modal
QTRY_VERIFY(!modalPopup->isOpened()); // auto-close
@@ -2212,21 +2224,23 @@ void tst_QQuickPopup::dimmerContainmentMask()
QPointer<QQuickItem> dimmer = overlay->property("_q_dimmerItem").value<QQuickItem *>();
QVERIFY(dimmer);
+ ContainmentMask containmentMask;
+ containmentMask.clickThoughPoint = topLeftSafePoint;
dimmer->setContainmentMask(&containmentMask);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, topLeftSafePoint);
QVERIFY(containmentMask.called);
QCOMPARE(window->property("clickCount"), ++expectedClickCount); // let through by containment mask
QVERIFY(modalPopup->isOpened()); // no auto-close
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(2, 2));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, topLeftSafePoint + QPoint(1, 1));
QCOMPARE(window->property("clickCount"), expectedClickCount); // blocked by modal
QTRY_VERIFY(!modalPopup->isOpened()); // auto-close
QTRY_VERIFY(!dimmer);
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, topLeftSafePoint);
QCOMPARE(window->property("clickCount"), ++expectedClickCount); // no mask left behind
- QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(2, 2));
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, topLeftSafePoint + QPoint(1, 1));
QCOMPARE(window->property("clickCount"), ++expectedClickCount); // no mask left behind
}