aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickcontrols2/qquickpopup
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quickcontrols2/qquickpopup')
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml9
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/mirroredCombobox.qml26
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/nested-wheel.qml44
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/rotatedCombobox.qml26
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml9
-rw-r--r--tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp512
6 files changed, 487 insertions, 139 deletions
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml b/tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml
index 073300a36c..1668b042e0 100644
--- a/tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml
+++ b/tests/auto/quickcontrols2/qquickpopup/data/applicationwindow-wheel.qml
@@ -11,6 +11,7 @@ ApplicationWindow {
height: 400
property alias popup: popup
+ property alias nestedPopup: nestedPopup
property alias popupSlider: popupSlider
property alias contentSlider: contentSlider
@@ -30,5 +31,13 @@ ApplicationWindow {
id: popupSlider
wheelEnabled: true
}
+
+ Popup {
+ id: nestedPopup
+ x: 0; y: 0
+ clip: true
+ implicitWidth: 50
+ implicitHeight: 50
+ }
}
}
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/mirroredCombobox.qml b/tests/auto/quickcontrols2/qquickpopup/data/mirroredCombobox.qml
new file mode 100644
index 0000000000..ed48179bce
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickpopup/data/mirroredCombobox.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Window {
+ width: 400
+ height: 400
+
+ contentItem.rotation: 180
+
+ ComboBox {
+ objectName: "first"
+ x: 100
+ y: 300 // is missing space, needs to unroll in the "mirrored" direction
+ model: ["First", "Second", "Third", "Fourth", "Fifth"]
+ }
+
+ ComboBox {
+ objectName: "second"
+ x: 200
+ y: 100 // has enough space to unroll
+ model: ["A", "B", "C"]
+ }
+}
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/nested-wheel.qml b/tests/auto/quickcontrols2/qquickpopup/data/nested-wheel.qml
new file mode 100644
index 0000000000..a0b319fd24
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickpopup/data/nested-wheel.qml
@@ -0,0 +1,44 @@
+import QtQuick
+import QtQuick.Controls
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ property alias modalPopup: popup
+ property alias comboBox: combobox
+
+ Popup {
+ id: popup
+ objectName: "Modal Dialog"
+ width: 300
+ height: 300
+ anchors.centerIn: parent
+ visible: true
+ modal: true
+
+ ComboBox {
+ id: combobox
+ anchors.centerIn: parent
+ width: 120
+ model: 30
+
+ popup: Popup {
+ objectName: "Combobox Popup"
+ y: combobox.height
+ width: combobox.width
+ height: contentItem.implicitHeight
+ contentItem: ListView {
+ objectName: "Combobox ListView"
+ clip: true
+ implicitHeight: 150
+ model: combobox.delegateModel
+ currentIndex: combobox.highlightedIndex
+ ScrollBar.vertical: ScrollBar {
+ objectName: "vbar"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/rotatedCombobox.qml b/tests/auto/quickcontrols2/qquickpopup/data/rotatedCombobox.qml
new file mode 100644
index 0000000000..df217be4b7
--- /dev/null
+++ b/tests/auto/quickcontrols2/qquickpopup/data/rotatedCombobox.qml
@@ -0,0 +1,26 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Controls
+
+Window {
+ width: 400
+ height: 400
+
+ contentItem.rotation: 90
+
+ ComboBox {
+ objectName: "first"
+ x: 100
+ y: 320 // is missing space, needs to unroll in the "mirrored" direction
+ model: ["First", "Second", "Third", "Fourth", "Fifth"]
+ }
+
+ ComboBox {
+ objectName: "second"
+ x: 200
+ y: 100 // has enough space to unroll
+ model: ["A", "B", "C"]
+ }
+}
diff --git a/tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml b/tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml
index 315c3f2a78..ae9c2ecdfd 100644
--- a/tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml
+++ b/tests/auto/quickcontrols2/qquickpopup/data/window-wheel.qml
@@ -11,6 +11,7 @@ Window {
height: 400
property alias popup: popup
+ property alias nestedPopup: nestedPopup
property alias popupSlider: popupSlider
property alias contentSlider: contentSlider
@@ -30,5 +31,13 @@ Window {
id: popupSlider
wheelEnabled: true
}
+
+ Popup {
+ id: nestedPopup
+ x: 0; y: 0
+ clip: true
+ implicitWidth: 50
+ implicitHeight: 50
+ }
}
}
diff --git a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
index 5b14c6b867..c6e491618d 100644
--- a/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/quickcontrols2/qquickpopup/tst_qquickpopup.cpp
@@ -11,6 +11,7 @@
#include <QtQuick/qquickview.h>
#include <QtQuick/private/qquickpalette_p.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>
+#include <QtQuickTestUtils/private/viewtestutils_p.h>
#include <QtQuickTestUtils/private/visualtestutils_p.h>
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
#include <QtQuickTemplates2/private/qquickcombobox_p.h>
@@ -64,6 +65,7 @@ private slots:
void wheel();
void parentDestroyed();
void nested();
+ void nestedWheel();
void modelessOnModalOnModeless();
void grabber();
void cursorShape();
@@ -87,11 +89,16 @@ private slots:
void dimmerContainmentMask();
void shrinkPopupThatWasLargerThanWindow_data();
void shrinkPopupThatWasLargerThanWindow();
+ void mirroredCombobox();
+ void rotatedCombobox();
private:
static bool hasWindowActivation();
+ QScopedPointer<QPointingDevice> touchScreen = QScopedPointer<QPointingDevice>(QTest::createTouchDevice());
};
+using namespace Qt::StringLiterals;
+
tst_QQuickPopup::tst_QQuickPopup()
: QQmlDataTest(QT_QMLTEST_DATADIR)
{
@@ -176,18 +183,18 @@ void tst_QQuickPopup::state()
QVERIFY(closedSpy.isValid());
popup->open();
- QCOMPARE(visibleChangedSpy.count(), 1);
- QCOMPARE(aboutToShowSpy.count(), 1);
- QCOMPARE(aboutToHideSpy.count(), 0);
- QTRY_COMPARE(openedSpy.count(), 1);
- QCOMPARE(closedSpy.count(), 0);
+ QCOMPARE(visibleChangedSpy.size(), 1);
+ QCOMPARE(aboutToShowSpy.size(), 1);
+ QCOMPARE(aboutToHideSpy.size(), 0);
+ QTRY_COMPARE(openedSpy.size(), 1);
+ QCOMPARE(closedSpy.size(), 0);
popup->close();
- QTRY_COMPARE(visibleChangedSpy.count(), 2);
- QCOMPARE(aboutToShowSpy.count(), 1);
- QCOMPARE(aboutToHideSpy.count(), 1);
- QCOMPARE(openedSpy.count(), 1);
- QTRY_COMPARE(closedSpy.count(), 1);
+ QTRY_COMPARE(visibleChangedSpy.size(), 2);
+ QCOMPARE(aboutToShowSpy.size(), 1);
+ QCOMPARE(aboutToHideSpy.size(), 1);
+ QCOMPARE(openedSpy.size(), 1);
+ QTRY_COMPARE(closedSpy.size(), 1);
}
void tst_QQuickPopup::overlay_data()
@@ -213,7 +220,6 @@ void tst_QQuickPopup::overlay()
QFETCH(bool, modal);
QFETCH(bool, dim);
- QScopedPointer<QPointingDevice> device(QTest::createTouchDevice());
QQuickControlsApplicationHelper helper(this, source);
QVERIFY2(helper.ready, helper.failureMessage());
@@ -232,8 +238,8 @@ void tst_QQuickPopup::overlay()
QVERIFY(!overlay->isVisible()); // no popups open
QTest::mouseClick(window, Qt::LeftButton);
- QCOMPARE(overlayPressedSignal.count(), 0);
- QCOMPARE(overlayReleasedSignal.count(), 0);
+ QCOMPARE(overlayPressedSignal.size(), 0);
+ QCOMPARE(overlayReleasedSignal.size(), 0);
QQuickPopup *popup = window->property("popup").value<QQuickPopup*>();
QVERIFY(popup);
@@ -259,19 +265,19 @@ void tst_QQuickPopup::overlay()
QTRY_VERIFY(popup->isOpened());
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
QTRY_VERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); // no modal-popups open
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount); // no modal-popups open
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
popup->setDim(dim);
popup->setModal(modal);
@@ -284,16 +290,16 @@ void tst_QQuickPopup::overlay()
QTRY_VERIFY(popup->isOpened());
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), ++overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
QTRY_VERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
@@ -304,17 +310,17 @@ void tst_QQuickPopup::overlay()
QVERIFY(overlay->isVisible());
QTRY_VERIFY(popup->isOpened());
- QTest::touchEvent(window, device.data()).press(0, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QTest::touchEvent(window, touchScreen.data()).press(0, QPoint(1, 1));
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
- QTest::touchEvent(window, device.data()).release(0, QPoint(1, 1));
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount);
- QCOMPARE(overlayAttachedPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayAttachedReleasedSignal.count(), overlayReleaseCount);
+ QTest::touchEvent(window, touchScreen.data()).release(0, QPoint(1, 1));
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), ++overlayReleaseCount);
+ QCOMPARE(overlayAttachedPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayAttachedReleasedSignal.size(), overlayReleaseCount);
QTRY_VERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
@@ -326,33 +332,33 @@ void tst_QQuickPopup::overlay()
QVERIFY(!button->isPressed());
QTRY_VERIFY(popup->isOpened());
- QTest::touchEvent(window, device.data()).press(0, button->mapToScene(QPointF(1, 1)).toPoint());
+ QTest::touchEvent(window, touchScreen.data()).press(0, button->mapToScene(QPointF(1, 1)).toPoint());
QVERIFY(popup->isVisible());
QVERIFY(overlay->isVisible());
QCOMPARE(button->isPressed(), !modal);
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
- QTest::touchEvent(window, device.data()).stationary(0).press(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QTest::touchEvent(window, touchScreen.data()).stationary(0).press(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
QVERIFY(popup->isVisible());
QVERIFY(overlay->isVisible());
QCOMPARE(button->isPressed(), !modal);
- QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), ++overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
- QTest::touchEvent(window, device.data()).release(0, button->mapToScene(QPointF(1, 1)).toPoint()).stationary(1);
+ QTest::touchEvent(window, touchScreen.data()).release(0, button->mapToScene(QPointF(1, 1)).toPoint()).stationary(1);
QTRY_VERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
QVERIFY(!button->isPressed());
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), ++overlayReleaseCount);
- QTest::touchEvent(window, device.data()).release(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
+ QTest::touchEvent(window, touchScreen.data()).release(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint());
QVERIFY(!popup->isVisible());
QVERIFY(!overlay->isVisible());
QVERIFY(!button->isPressed());
- QCOMPARE(overlayPressedSignal.count(), overlayPressCount);
- QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount);
+ QCOMPARE(overlayPressedSignal.size(), overlayPressCount);
+ QCOMPARE(overlayReleasedSignal.size(), overlayReleaseCount);
}
void tst_QQuickPopup::zOrder_data()
@@ -405,40 +411,40 @@ void tst_QQuickPopup::windowChange()
QQuickItem item;
popup.setParentItem(&item);
QVERIFY(!popup.window());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QQuickWindow window;
item.setParentItem(window.contentItem());
QCOMPARE(popup.window(), &window);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
item.setParentItem(nullptr);
QVERIFY(!popup.window());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
popup.setParentItem(window.contentItem());
QCOMPARE(popup.window(), &window);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
popup.resetParentItem();
QVERIFY(!popup.window());
- QCOMPARE(spy.count(), 4);
+ QCOMPARE(spy.size(), 4);
popup.setParent(&window);
popup.resetParentItem();
QCOMPARE(popup.window(), &window);
- QCOMPARE(spy.count(), 5);
+ QCOMPARE(spy.size(), 5);
popup.setParent(this);
popup.resetParentItem();
QVERIFY(!popup.window());
- QCOMPARE(spy.count(), 6);
+ QCOMPARE(spy.size(), 6);
item.setParentItem(window.contentItem());
popup.setParent(&item);
popup.resetParentItem();
QCOMPARE(popup.window(), &window);
- QCOMPARE(spy.count(), 7);
+ QCOMPARE(spy.size(), 7);
popup.setParent(nullptr);
}
@@ -448,25 +454,44 @@ Q_DECLARE_METATYPE(QQuickPopup::ClosePolicy)
void tst_QQuickPopup::closePolicy_data()
{
qRegisterMetaType<QQuickPopup::ClosePolicy>();
+ const auto *mouse = QPointingDevice::primaryPointingDevice();
+ const auto *touch = touchScreen.data();
QTest::addColumn<QString>("source");
+ QTest::addColumn<const QPointingDevice *>("device");
QTest::addColumn<QQuickPopup::ClosePolicy>("closePolicy");
- QTest::newRow("Window:NoAutoClose") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
- QTest::newRow("Window:CloseOnPressOutside") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
- QTest::newRow("Window:CloseOnPressOutsideParent") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
- QTest::newRow("Window:CloseOnPressOutside|Parent") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
- QTest::newRow("Window:CloseOnReleaseOutside") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
- QTest::newRow("Window:CloseOnReleaseOutside|Parent") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
- QTest::newRow("Window:CloseOnEscape") << "window.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
-
- QTest::newRow("ApplicationWindow:NoAutoClose") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
- QTest::newRow("ApplicationWindow:CloseOnPressOutside") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
- QTest::newRow("ApplicationWindow:CloseOnPressOutsideParent") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
- QTest::newRow("ApplicationWindow:CloseOnPressOutside|Parent") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
- QTest::newRow("ApplicationWindow:CloseOnReleaseOutside") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
- QTest::newRow("ApplicationWindow:CloseOnReleaseOutside|Parent") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
- QTest::newRow("ApplicationWindow:CloseOnEscape") << "applicationwindow.qml"<< static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
+ QTest::newRow("Window:NoAutoClose mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
+ QTest::newRow("Window:CloseOnPressOutside mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
+ QTest::newRow("Window:CloseOnPressOutsideParent mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("Window:CloseOnPressOutside|Parent mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("Window:CloseOnReleaseOutside mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
+ QTest::newRow("Window:CloseOnReleaseOutside|Parent mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
+ QTest::newRow("Window:CloseOnEscape mouse") << "window.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
+
+ QTest::newRow("ApplicationWindow:NoAutoClose mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutside mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutsideParent mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutside|Parent mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnReleaseOutside mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
+ QTest::newRow("ApplicationWindow:CloseOnReleaseOutside|Parent mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnEscape mouse") << "applicationwindow.qml" << mouse << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
+
+ QTest::newRow("Window:NoAutoClose touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
+ QTest::newRow("Window:CloseOnPressOutside touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
+ QTest::newRow("Window:CloseOnPressOutsideParent touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("Window:CloseOnPressOutside|Parent touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("Window:CloseOnReleaseOutside touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
+ QTest::newRow("Window:CloseOnReleaseOutside|Parent touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
+ QTest::newRow("Window:CloseOnEscape touch") << "window.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
+
+ QTest::newRow("ApplicationWindow:NoAutoClose touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::NoAutoClose);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutside touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutsideParent touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnPressOutside|Parent touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnReleaseOutside touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside);
+ QTest::newRow("ApplicationWindow:CloseOnReleaseOutside|Parent touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent);
+ QTest::newRow("ApplicationWindow:CloseOnEscape touch") << "applicationwindow.qml" << touch << static_cast<QQuickPopup::ClosePolicy>(QQuickPopup::CloseOnEscape);
}
void tst_QQuickPopup::closePolicy()
@@ -475,6 +500,7 @@ void tst_QQuickPopup::closePolicy()
QSKIP("Window activation is not supported");
QFETCH(QString, source);
+ QFETCH(const QPointingDevice *, device);
QFETCH(QQuickPopup::ClosePolicy, closePolicy);
QQuickControlsApplicationHelper helper(this, source);
@@ -502,56 +528,58 @@ void tst_QQuickPopup::closePolicy()
// wait for dimmer
QTest::qWait(50);
- // press outside popup and its parent
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
- QTRY_VERIFY(!popup->isVisible());
- else
- QVERIFY(popup->isOpened());
+ for (int i = 0; i < 2; ++i) {
+ // press outside popup and its parent
+ QQuickTest::pointerPress(device, window, 0, {1, 1});
+ if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
+ QTRY_VERIFY(!popup->isVisible());
+ else
+ QVERIFY(popup->isOpened());
- popup->open();
- QVERIFY(popup->isVisible());
- QTRY_VERIFY(popup->isOpened());
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(popup->isOpened());
- // release outside popup and its parent
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) || closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
- QTRY_VERIFY(!popup->isVisible());
- else
- QVERIFY(popup->isOpened());
+ // release outside popup and its parent
+ QQuickTest::pointerRelease(device, window, 0, {1, 1});
+ if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) || closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
+ QTRY_VERIFY(!popup->isVisible());
+ else
+ QVERIFY(popup->isOpened());
- popup->open();
- QVERIFY(popup->isVisible());
- QTRY_VERIFY(popup->isOpened());
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(popup->isOpened());
- // press outside popup but inside its parent
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + 1, button->y() + 1));
- if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
- QTRY_VERIFY(!popup->isVisible());
- else
- QVERIFY(popup->isOpened());
+ // press outside popup but inside its parent
+ QQuickTest::pointerPress(device, window, 0, QPoint(button->x() + 1, button->y() + 1));
+ if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent))
+ QTRY_VERIFY(!popup->isVisible());
+ else
+ QVERIFY(popup->isOpened());
- popup->open();
- QVERIFY(popup->isVisible());
- QTRY_VERIFY(popup->isOpened());
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(popup->isOpened());
- // release outside popup but inside its parent
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + 1, button->y() + 1));
- if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
- QTRY_VERIFY(!popup->isVisible());
- else
- QVERIFY(popup->isOpened());
+ // release outside popup but inside its parent
+ QQuickTest::pointerRelease(device, window, 0, QPoint(button->x() + 1, button->y() + 1));
+ if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent))
+ QTRY_VERIFY(!popup->isVisible());
+ else
+ QVERIFY(popup->isOpened());
- popup->open();
- QVERIFY(popup->isVisible());
- QTRY_VERIFY(popup->isOpened());
+ popup->open();
+ QVERIFY(popup->isVisible());
+ QTRY_VERIFY(popup->isOpened());
- // press inside and release outside
- QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + popup->x() + 1,
- button->y() + popup->y() + 1));
- QVERIFY(popup->isOpened());
- QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
- QVERIFY(popup->isOpened());
+ // press inside and release outside
+ QQuickTest::pointerPress(device, window, 0, QPoint(button->x() + popup->x() + 1,
+ button->y() + popup->y() + 1));
+ QVERIFY(popup->isOpened());
+ QQuickTest::pointerRelease(device, window, 0, {1, 1});
+ QVERIFY(popup->isOpened());
+ }
// escape
QTest::keyClick(window, Qt::Key_Escape);
@@ -945,7 +973,7 @@ void tst_QQuickPopup::hover()
QSignalSpy openedSpy(popup, SIGNAL(opened()));
QVERIFY(openedSpy.isValid());
popup->open();
- QVERIFY(openedSpy.count() == 1 || openedSpy.wait());
+ QVERIFY(openedSpy.size() == 1 || openedSpy.wait());
QTRY_VERIFY(popup->width() > 10); // somehow this can take a short time with macOS style
// hover the parent button outside the popup
@@ -966,7 +994,7 @@ void tst_QQuickPopup::hover()
QSignalSpy closedSpy(popup, SIGNAL(closed()));
QVERIFY(closedSpy.isValid());
popup->close();
- QVERIFY(closedSpy.count() == 1 || closedSpy.wait());
+ QVERIFY(closedSpy.size() == 1 || closedSpy.wait());
// hover the parent button after closing the popup
QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2));
@@ -984,16 +1012,23 @@ void tst_QQuickPopup::wheel_data()
QTest::newRow("ApplicationWindow:modeless") << "applicationwindow-wheel.qml" << false;
}
-static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees)
+static bool sendWheelEvent(QQuickItem *item, const QPointF &localPos, int degrees)
{
QQuickWindow *window = item->window();
- QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0),
+ const QPoint scenePos = item->mapToScene(localPos).toPoint();
+ QWheelEvent wheelEvent(scenePos, window->mapToGlobal(scenePos), QPoint(0, 0),
QPoint(0, 8 * degrees), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase,
false);
QSpontaneKeyEvent::setSpontaneous(&wheelEvent);
return qGuiApp->notify(window, &wheelEvent);
}
+static bool sendWheelEvent(QQuickItem *item, int degrees)
+{
+ const QPointF localPos = QPointF(item->width() / 2, item->height() / 2);
+ return sendWheelEvent(item, localPos, degrees);
+}
+
void tst_QQuickPopup::wheel()
{
QFETCH(QString, source);
@@ -1012,6 +1047,10 @@ void tst_QQuickPopup::wheel()
QVERIFY(popup && popup->contentItem());
popup->setModal(modal);
+ QQuickPopup *nestedPopup = window->property("nestedPopup").value<QQuickPopup*>();
+ QVERIFY(nestedPopup && nestedPopup->contentItem());
+ nestedPopup->setModal(modal);
+
QQuickSlider *popupSlider = window->property("popupSlider").value<QQuickSlider*>();
QVERIFY(popupSlider);
@@ -1020,7 +1059,7 @@ void tst_QQuickPopup::wheel()
qreal oldContentValue = contentSlider->value();
qreal oldPopupValue = popupSlider->value();
- QVERIFY(sendWheelEvent(contentSlider, QPoint(contentSlider->width() / 2, contentSlider->height() / 2), 15));
+ QVERIFY(sendWheelEvent(contentSlider, 15));
QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); // must have moved
QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved
@@ -1029,25 +1068,41 @@ void tst_QQuickPopup::wheel()
QSignalSpy openedSpy(popup, SIGNAL(opened()));
QVERIFY(openedSpy.isValid());
popup->open();
- QVERIFY(openedSpy.count() == 1 || openedSpy.wait());
+ QVERIFY(openedSpy.size() == 1 || openedSpy.wait());
{
// wheel over the popup content
qreal oldContentValue = contentSlider->value();
qreal oldPopupValue = popupSlider->value();
- QVERIFY(sendWheelEvent(popupSlider, QPoint(popupSlider->width() / 2, popupSlider->height() / 2), 15));
+ QVERIFY(sendWheelEvent(popupSlider, 15));
QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved
QVERIFY(!qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must have moved
}
+ QSignalSpy nestedOpenedSpy(nestedPopup, SIGNAL(opened()));
+ QVERIFY(nestedOpenedSpy.isValid());
+ nestedPopup->open();
+ QVERIFY(nestedOpenedSpy.size() == 1 || nestedOpenedSpy.wait());
+
+ {
+ // wheel over the popup content
+ qreal oldContentValue = contentSlider->value();
+ qreal oldPopupValue = popupSlider->value();
+
+ QVERIFY(sendWheelEvent(popupSlider, 15));
+
+ QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved
+ QCOMPARE(qFuzzyCompare(popupSlider->value(), oldPopupValue), modal); // must not have moved unless modeless
+ }
+
{
// wheel over the overlay
qreal oldContentValue = contentSlider->value();
qreal oldPopupValue = popupSlider->value();
- QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPoint(0, 0), 15));
+ QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPointF(0, 0), 15));
if (modal) {
// the content below a modal overlay must not move
@@ -1097,6 +1152,36 @@ void tst_QQuickPopup::nested()
QCOMPARE(modalPopup->isVisible(), true);
}
+void tst_QQuickPopup::nestedWheel()
+{
+ QQuickControlsApplicationHelper helper(this, QStringLiteral("nested-wheel.qml"));
+ QVERIFY2(helper.ready, helper.failureMessage());
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
+ QVERIFY(modalPopup);
+
+ QQuickComboBox *comboBox = window->property("comboBox").value<QQuickComboBox *>();
+ QVERIFY(comboBox);
+
+ const QPoint comboBoxCenter = comboBox->mapToScene(
+ QPointF(comboBox->width() / 2, comboBox->height() / 2)).toPoint();
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, comboBoxCenter);
+ QTRY_VERIFY(comboBox->popup()->isOpened());
+
+ QQuickItem *listView = comboBox->popup()->contentItem();
+ QVERIFY(listView);
+ QQuickItem *vbar = listView->findChild<QQuickItem *>("vbar");
+ QVERIFY(vbar);
+
+ const double startPosition = vbar->property("position").toDouble();
+ // wheel over the list view, verify that it scrolls
+ sendWheelEvent(listView, -30);
+ QTRY_COMPARE_GT(vbar->property("position").toDouble(), startPosition);
+}
+
void tst_QQuickPopup::modelessOnModalOnModeless()
{
QQuickControlsApplicationHelper helper(this, QStringLiteral("modelessOnModalOnModeless.qml"));
@@ -1353,12 +1438,12 @@ void tst_QQuickPopup::enabled()
popup.setEnabled(false);
QVERIFY(!popup.isEnabled());
QVERIFY(!popup.popupItem()->isEnabled());
- QCOMPARE(enabledSpy.count(), 1);
+ QCOMPARE(enabledSpy.size(), 1);
popup.popupItem()->setEnabled(true);
QVERIFY(popup.isEnabled());
QVERIFY(popup.popupItem()->isEnabled());
- QCOMPARE(enabledSpy.count(), 2);
+ QCOMPARE(enabledSpy.size(), 2);
}
void tst_QQuickPopup::orientation_data()
@@ -1477,15 +1562,15 @@ void tst_QQuickPopup::disabledPalette()
auto palette = QQuickPopupPrivate::get(popup)->palette();
palette->setBase(Qt::green);
palette->disabled()->setBase(Qt::red);
- QCOMPARE(popupPaletteSpy.count(), 2);
- QCOMPARE(popupItemPaletteSpy.count(), 2);
+ QCOMPARE(popupPaletteSpy.size(), 2);
+ QCOMPARE(popupItemPaletteSpy.size(), 2);
QCOMPARE(popup->background()->property("color").value<QColor>(), Qt::green);
popup->setEnabled(false);
- QCOMPARE(popupEnabledSpy.count(), 1);
- QCOMPARE(popupItemEnabledSpy.count(), 1);
- QCOMPARE(popupPaletteSpy.count(), 3);
- QCOMPARE(popupItemPaletteSpy.count(), 3);
+ QCOMPARE(popupEnabledSpy.size(), 1);
+ QCOMPARE(popupItemEnabledSpy.size(), 1);
+ QCOMPARE(popupPaletteSpy.size(), 3);
+ QCOMPARE(popupItemPaletteSpy.size(), 3);
QCOMPARE(popup->background()->property("color").value<QColor>(), Qt::red);
}
@@ -1517,8 +1602,8 @@ void tst_QQuickPopup::disabledParentPalette()
auto palette = QQuickPopupPrivate::get(popup)->palette();
palette->setBase(Qt::green);
palette->disabled()->setBase(Qt::red);
- QCOMPARE(popupPaletteSpy.count(), 2);
- QCOMPARE(popupItemPaletteSpy.count(), 2);
+ QCOMPARE(popupPaletteSpy.size(), 2);
+ QCOMPARE(popupItemPaletteSpy.size(), 2);
QCOMPARE(popup->background()->property("color").value<QColor>(), Qt::green);
// Disable the overlay (which is QQuickPopupItem's parent) to ensure that
@@ -1529,10 +1614,10 @@ void tst_QQuickPopup::disabledParentPalette()
QVERIFY(!popup->isEnabled());
QVERIFY(!popup->popupItem()->isEnabled());
QCOMPARE(popup->background()->property("color").value<QColor>(), Qt::red);
- QCOMPARE(popupEnabledSpy.count(), 1);
- QCOMPARE(popupItemEnabledSpy.count(), 1);
- QCOMPARE(popupPaletteSpy.count(), 3);
- QCOMPARE(popupItemPaletteSpy.count(), 3);
+ QCOMPARE(popupEnabledSpy.size(), 1);
+ QCOMPARE(popupItemEnabledSpy.size(), 1);
+ QCOMPARE(popupPaletteSpy.size(), 3);
+ QCOMPARE(popupItemPaletteSpy.size(), 3);
popup->close();
QTRY_VERIFY(!popup->isVisible());
@@ -1690,7 +1775,7 @@ void tst_QQuickPopup::invisibleToolTipOpen()
QVERIFY(componentLoadedSpy.isValid());
loader->setProperty("active", true);
- QTRY_COMPARE(componentLoadedSpy.count(), 1);
+ QTRY_COMPARE(componentLoadedSpy.size(), 1);
QTRY_VERIFY(toolTip->isVisible());
}
@@ -1884,6 +1969,155 @@ void tst_QQuickPopup::shrinkPopupThatWasLargerThanWindow()
.arg(popup->height()).arg(window->height())));
}
+void tst_QQuickPopup::mirroredCombobox()
+{
+#ifdef Q_OS_ANDROID
+ // Android screens might be pretty small, such that additional
+ // repositioning (apart from the mirroring) will happen to the
+ // popups and mess up the expected positions below.
+ QSKIP("Skipping test for Android.");
+#endif
+ QStringList nativeStyles;
+ nativeStyles.append(u"macOS"_s);
+ nativeStyles.append(u"iOS"_s);
+ nativeStyles.append(u"Windows"_s);
+ if (nativeStyles.contains(QQuickStyle::name()))
+ QSKIP("Skipping test for native styles: they might rearrange their combobox the way they "
+ "want.");
+
+ QQuickControlsApplicationHelper helper(this, "mirroredCombobox.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
+
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ {
+ QQuickComboBox *comboBox = window->findChild<QQuickComboBox *>("first");
+ QVERIFY(comboBox);
+ QQuickPopup *popup = comboBox->popup();
+ QVERIFY(popup);
+ popup->open();
+ QTRY_COMPARE(popup->isVisible(), true);
+ const QPointF popupPos(popup->contentItem()->mapToItem(comboBox->parentItem(),
+ popup->contentItem()->position()));
+ const QSizeF popupSize(popup->contentItem()->size());
+
+ // ignore popup.{top,bottom}Padding() as not included in popup->contentItem()->size()
+ // some styles prefer to draw the popup "over" (in z-axis direction) the combobox to hide
+ // the combobox
+ const bool styleDrawsPopupOverCombobox =
+ comboBox->position().y() - popupSize.height() + comboBox->size().height()
+ == popupPos.y();
+ // some styles prefer to draw the popup below (in y-axis direction) the combobox
+ const bool styleDrawsPopupBelowCombobox =
+ comboBox->position().y() - popupSize.height() + comboBox->topPadding()
+ == popupPos.y();
+
+ QVERIFY(styleDrawsPopupOverCombobox || styleDrawsPopupBelowCombobox);
+
+ popup->close();
+ }
+
+ {
+ QQuickComboBox *comboBox = window->findChild<QQuickComboBox *>("second");
+ QVERIFY(comboBox);
+ QQuickPopup *popup = comboBox->popup();
+ QVERIFY(popup);
+ popup->open();
+ QTRY_COMPARE(popup->isVisible(), true);
+ const QPointF popupPos(popup->contentItem()->mapToItem(comboBox->parentItem(),
+ popup->contentItem()->position()));
+
+ // some styles prefer to draw the popup "over" (in z-axis direction) the combobox to hide
+ // the combobox
+ const bool styleDrawsPopupOverCombobox = comboBox->position().y() + comboBox->topPadding()
+ + popup->topPadding() + popup->bottomPadding()
+ == popupPos.y();
+ // some styles prefer to draw the popup above (in y-axis direction) the combobox
+ const bool styleDrawsPopupAboveCombobox =
+ comboBox->position().y() + comboBox->height() - comboBox->topPadding()
+ == popupPos.y();
+
+ QVERIFY(styleDrawsPopupOverCombobox || styleDrawsPopupAboveCombobox);
+
+ popup->close();
+ }
+}
+
+void tst_QQuickPopup::rotatedCombobox()
+{
+#ifdef Q_OS_ANDROID
+ // Android screens might be pretty small, such that additional
+ // repositioning (apart from the rotating) will happen to the
+ // popups and mess up the expected positions below.
+ QSKIP("Skipping test for Android.");
+#endif
+ QStringList nativeStyles;
+ nativeStyles.append(u"macOS"_s);
+ nativeStyles.append(u"iOS"_s);
+ nativeStyles.append(u"Windows"_s);
+ if (nativeStyles.contains(QQuickStyle::name()))
+ QSKIP("Skipping test for native styles: they might rearrange their combobox the way they "
+ "want.");
+
+ QQuickControlsApplicationHelper helper(this, "rotatedCombobox.qml");
+ QVERIFY2(helper.ready, helper.failureMessage());
+
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ {
+ QQuickComboBox *comboBox = window->findChild<QQuickComboBox *>("first");
+ QVERIFY(comboBox);
+ QQuickPopup *popup = comboBox->popup();
+ QVERIFY(popup);
+ popup->open();
+ QTRY_COMPARE(popup->isVisible(), true);
+ const QPointF popupPos(popup->contentItem()->mapToItem(comboBox->parentItem(),
+ popup->contentItem()->position()));
+ const QSizeF popupSize(popup->contentItem()->size());
+
+ // ignore popup.{left,right}Padding() as not included in popup->contentItem()->size()
+ // some styles prefer to draw the popup "over" (in z-axis direction) the combobox to hide
+ // the combobox
+ const bool styleDrawsPopupOverCombobox =
+ comboBox->position().x() - popupSize.width() + comboBox->width() == popupPos.x();
+ // some styles prefer to draw the popup right (in x-axis direction) of the combobox
+ const bool styleDrawsPopupBelowCombobox =
+ comboBox->position().x() - popupSize.width() - comboBox->leftPadding()
+ == popupPos.x();
+
+ QVERIFY(styleDrawsPopupOverCombobox || styleDrawsPopupBelowCombobox);
+ }
+
+ {
+ QQuickComboBox *comboBox = window->findChild<QQuickComboBox *>("second");
+ QVERIFY(comboBox);
+ QQuickPopup *popup = comboBox->popup();
+ QVERIFY(popup);
+ popup->open();
+ QTRY_COMPARE(popup->isVisible(), true);
+ const QPointF popupPos(popup->contentItem()->mapToItem(comboBox->parentItem(),
+ popup->contentItem()->position()));
+
+ // some styles prefer to draw the popup "over" (in z-axis direction) the combobox to hide
+ // the combobox
+ const bool styleDrawsPopupOverCombobox = comboBox->position().x() + comboBox->leftPadding()
+ + popup->leftPadding() + popup->rightPadding()
+ == popupPos.x();
+ // some styles prefer to draw the popup left (in y-axis direction) of the combobox
+ const bool styleDrawsPopupAboveCombobox =
+ comboBox->position().x() + comboBox->width() - comboBox->leftPadding()
+ == popupPos.x();
+
+ QVERIFY(styleDrawsPopupOverCombobox || styleDrawsPopupAboveCombobox);
+
+ popup->close();
+ }
+}
+
QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
#include "tst_qquickpopup.moc"