aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/popup
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-07-22 18:23:00 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-22 18:24:30 +0200
commit6d36375fe3559f420a15b8240ed32679358a19e7 (patch)
tree16d20788d187dcd1c5de343955b867a10a22f378 /tests/auto/popup
parent8b60bfd13f80588adab2c4778bc8de08832ecb7b (diff)
parent92032bee2923024d126bc20929f79abd459cae49 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Diffstat (limited to 'tests/auto/popup')
-rw-r--r--tests/auto/popup/data/applicationwindow.qml11
-rw-r--r--tests/auto/popup/data/hover.qml69
-rw-r--r--tests/auto/popup/tst_popup.cpp99
3 files changed, 178 insertions, 1 deletions
diff --git a/tests/auto/popup/data/applicationwindow.qml b/tests/auto/popup/data/applicationwindow.qml
index 7af71495..9b85eb85 100644
--- a/tests/auto/popup/data/applicationwindow.qml
+++ b/tests/auto/popup/data/applicationwindow.qml
@@ -46,6 +46,7 @@ ApplicationWindow {
height: 400
property alias popup: popup
+ property alias popup2: popup2
property alias button: button
Button {
@@ -69,4 +70,14 @@ ApplicationWindow {
}
}
}
+
+ Popup {
+ id: popup2
+ y: popup.y
+ z: 1
+ contentItem: Text {
+ text: "Popup2"
+ font.pixelSize: 36
+ }
+ }
}
diff --git a/tests/auto/popup/data/hover.qml b/tests/auto/popup/data/hover.qml
new file mode 100644
index 00000000..044d983c
--- /dev/null
+++ b/tests/auto/popup/data/hover.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Controls 2.0
+
+ApplicationWindow {
+ width: 400
+ height: 400
+
+ property alias popup: popup
+ property alias parentButton: parentButton
+ property alias childButton: childButton
+
+ Button {
+ id: parentButton
+ text: "Parent"
+ anchors.fill: parent
+
+ Popup {
+ id: popup
+ x: 1
+ y: 1
+ padding: 1
+
+ Button {
+ id: childButton
+ text: "Child"
+ }
+ }
+ }
+}
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp
index 3da32407..7a8a6557 100644
--- a/tests/auto/popup/tst_popup.cpp
+++ b/tests/auto/popup/tst_popup.cpp
@@ -53,11 +53,14 @@ class tst_popup : public QQmlDataTest
private slots:
void visible();
void overlay();
+ void zOrder();
void windowChange();
void closePolicy_data();
void closePolicy();
void activeFocusOnClose1();
void activeFocusOnClose2();
+ void hover_data();
+ void hover();
};
void tst_popup::visible()
@@ -134,6 +137,7 @@ void tst_popup::overlay()
QVERIFY(!overlay->isVisible());
popup->setModal(true);
+ popup->setClosePolicy(QQuickPopup::CloseOnReleaseOutside);
popup->open();
QVERIFY(popup->isVisible());
@@ -148,7 +152,40 @@ void tst_popup::overlay()
QCOMPARE(overlayReleasedSignal.count(), 1);
QVERIFY(!popup->isVisible());
- QVERIFY(overlay->isVisible());
+ QVERIFY(!overlay->isVisible());
+}
+
+void tst_popup::zOrder()
+{
+ QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
+
+ QQuickApplicationWindow *window = helper.window;
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>();
+ QVERIFY(popup);
+ popup->setModal(true);
+
+ QQuickPopup *popup2 = helper.window->property("popup2").value<QQuickPopup*>();
+ QVERIFY(popup2);
+ popup2->setModal(true);
+
+ // show popups in reverse order. popup2 has higher z-order so it appears
+ // on top and must be closed first, even if the other popup was opened last
+ popup2->open();
+ popup->open();
+ QVERIFY(popup2->isVisible());
+ QVERIFY(popup->isVisible());
+
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ QVERIFY(!popup2->isVisible());
+ QVERIFY(popup->isVisible());
+
+ QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
+ QVERIFY(!popup2->isVisible());
+ QVERIFY(!popup->isVisible());
}
void tst_popup::windowChange()
@@ -329,6 +366,66 @@ void tst_popup::activeFocusOnClose2()
QVERIFY(popup1->hasActiveFocus());
}
+void tst_popup::hover_data()
+{
+ QTest::addColumn<bool>("modal");
+
+ QTest::newRow("modal") << true;
+ QTest::newRow("modeless") << false;
+}
+
+void tst_popup::hover()
+{
+ QFETCH(bool, modal);
+
+ QQuickApplicationHelper helper(this, QStringLiteral("hover.qml"));
+ QQuickApplicationWindow *window = helper.window;
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>();
+ QVERIFY(popup);
+ popup->setModal(modal);
+
+ QQuickButton *parentButton = helper.window->property("parentButton").value<QQuickButton*>();
+ QVERIFY(parentButton);
+ parentButton->setHoverEnabled(true);
+
+ QQuickButton *childButton = helper.window->property("childButton").value<QQuickButton*>();
+ QVERIFY(childButton);
+ childButton->setHoverEnabled(true);
+
+ QSignalSpy openedSpy(popup, SIGNAL(opened()));
+ QVERIFY(openedSpy.isValid());
+ popup->open();
+ QVERIFY(openedSpy.count() == 1 || openedSpy.wait());
+
+ // hover the parent button outside the popup
+ QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1));
+ QCOMPARE(parentButton->isHovered(), !modal);
+ QVERIFY(!childButton->isHovered());
+
+ // hover the popup background
+ QTest::mouseMove(window, QPoint(1, 1));
+ QVERIFY(!parentButton->isHovered());
+ QVERIFY(!childButton->isHovered());
+
+ // hover the child button in a popup
+ QTest::mouseMove(window, QPoint(2, 2));
+ QVERIFY(!parentButton->isHovered());
+ QVERIFY(childButton->isHovered());
+
+ QSignalSpy closedSpy(popup, SIGNAL(closed()));
+ QVERIFY(closedSpy.isValid());
+ popup->close();
+ QVERIFY(closedSpy.count() == 1 || closedSpy.wait());
+
+ // hover the parent button after closing the popup
+ QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2));
+ QVERIFY(parentButton->isHovered());
+}
+
QTEST_MAIN(tst_popup)
#include "tst_popup.moc"