diff options
author | Liang Qi <liang.qi@qt.io> | 2017-05-31 08:13:14 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-05-31 08:13:14 +0200 |
commit | 1e472c6c1aafd893eebf29929b36b77c42c0e199 (patch) | |
tree | 5d63cff70bc21e0ead4135347cc87e65e864f824 /tests | |
parent | 44dd55be23138f0a6495b08818acaaa0ff68b086 (diff) | |
parent | ef6b8d3081f0bf93d6d59e67c8e3f82c63c511c3 (diff) |
Merge remote-tracking branch 'origin/5.9.0' into 5.9
Change-Id: Iba044084bf82f6b2b8ceba4aa2a80bdcf8fc38e0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/drawer/data/applicationwindow-button.qml | 70 | ||||
-rw-r--r-- | tests/auto/drawer/data/dragOverModalShadow.qml | 87 | ||||
-rw-r--r-- | tests/auto/drawer/data/window-button.qml | 71 | ||||
-rw-r--r-- | tests/auto/drawer/tst_drawer.cpp | 89 |
4 files changed, 307 insertions, 10 deletions
diff --git a/tests/auto/drawer/data/applicationwindow-button.qml b/tests/auto/drawer/data/applicationwindow-button.qml new file mode 100644 index 00000000..9641351e --- /dev/null +++ b/tests/auto/drawer/data/applicationwindow-button.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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.1 + +ApplicationWindow { + width: 400 + height: 400 + + property alias drawer: drawer + + Drawer { + id: drawer + width: 200 + height: 200 + + Button { + text: "Button" + anchors.fill: parent + } + } +} diff --git a/tests/auto/drawer/data/dragOverModalShadow.qml b/tests/auto/drawer/data/dragOverModalShadow.qml new file mode 100644 index 00000000..66eb2f4b --- /dev/null +++ b/tests/auto/drawer/data/dragOverModalShadow.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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 drawer: drawer + property alias popup: popup + + Drawer { + id: drawer + width: 200 + height: parent.height + dragMargin: parent.width + } + + Popup { + id: popup + modal: true + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: parent.width / 2 + height: parent.height / 2 + + Rectangle { + objectName: "shadow" + parent: popup.background + anchors.fill: parent + anchors.margins: -20 + + z: -1 + opacity: 0.5 + color: "silver" + } + } +} diff --git a/tests/auto/drawer/data/window-button.qml b/tests/auto/drawer/data/window-button.qml new file mode 100644 index 00000000..1b8ac7d5 --- /dev/null +++ b/tests/auto/drawer/data/window-button.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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.Window 2.2 +import QtQuick.Controls 2.0 + +Window { + width: 400 + height: 400 + + property alias drawer: drawer + + Drawer { + id: drawer + width: 200 + height: 200 + + Button { + text: "Button" + anchors.fill: parent + } + } +} diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index a7ebaa9e..9c30f8cf 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -94,6 +94,9 @@ private slots: void flickable_data(); void flickable(); + void dragOverModalShadow_data(); + void dragOverModalShadow(); + private: struct TouchDeviceDeleter { @@ -758,13 +761,26 @@ void tst_Drawer::multiple() void tst_Drawer::touch_data() { QTest::addColumn<QString>("source"); - QTest::newRow("Window") << "window.qml"; - QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; + QTest::addColumn<QPoint>("from"); + QTest::addColumn<QPoint>("to"); + + QTest::newRow("Window:inside") << "window.qml" << QPoint(150, 100) << QPoint(50, 100); + QTest::newRow("Window:outside") << "window.qml" << QPoint(300, 100) << QPoint(100, 100); + QTest::newRow("ApplicationWindow:inside") << "applicationwindow.qml" << QPoint(150, 100) << QPoint(50, 100); + QTest::newRow("ApplicationWindow:outside") << "applicationwindow.qml" << QPoint(300, 100) << QPoint(100, 100); + + QTest::newRow("Window+Button:inside") << "window-button.qml" << QPoint(150, 100) << QPoint(50, 100); + QTest::newRow("Window+Button:outside") << "window-button.qml" << QPoint(300, 100) << QPoint(100, 100); + QTest::newRow("ApplicationWindow+Button:inside") << "applicationwindow-button.qml" << QPoint(150, 100) << QPoint(50, 100); + QTest::newRow("ApplicationWindow+Button:outside") << "applicationwindow-button.qml" << QPoint(300, 100) << QPoint(100, 100); } void tst_Drawer::touch() { QFETCH(QString, source); + QFETCH(QPoint, from); + QFETCH(QPoint, to); + QQuickApplicationHelper helper(this, source); QQuickWindow *window = helper.window; @@ -783,19 +799,16 @@ void tst_Drawer::touch() QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(0, 100)); QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(50, 100)); QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(150, 100)); - QTRY_COMPARE(drawer->position(), 0.5); QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(150, 100)); QVERIFY(drawerOpenedSpy.wait()); QCOMPARE(drawer->position(), 1.0); // drag to close - QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100)); - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(300 - drawer->dragMargin(), 100)); - for (int x = 300; x > 100; x -= 10) - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, 100)); - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(100, 100)); - QTRY_COMPARE(drawer->position(), 0.5); - QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(100, 100)); + QTest::touchEvent(window, touchDevice.data()).press(0, from); + for (int x = from.x(); x > to.x(); x -= 10) + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, to.y())); + QTest::touchEvent(window, touchDevice.data()).move(0, to); + QTest::touchEvent(window, touchDevice.data()).release(0, to); QVERIFY(drawerClosedSpy.wait()); QCOMPARE(drawer->position(), 0.0); } @@ -952,6 +965,62 @@ void tst_Drawer::flickable() QVERIFY(!flickable->isDragging()); } +void tst_Drawer::dragOverModalShadow_data() +{ + QTest::addColumn<bool>("mouse"); + QTest::newRow("mouse") << true; + QTest::newRow("touch") << false; +} + +// QTBUG-60602 +void tst_Drawer::dragOverModalShadow() +{ + QFETCH(bool, mouse); + + QQuickApplicationHelper helper(this, QStringLiteral("dragOverModalShadow.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer *>(); + QVERIFY(drawer); + + QQuickPopup *popup = window->property("popup").value<QQuickPopup *>(); + QVERIFY(popup); + + popup->open(); + QVERIFY(popup->isVisible()); + QVERIFY(!drawer->isVisible()); + + const QPoint from(popup->x(), popup->y() + popup->height() + 5); + const QPoint to(popup->x() + popup->width(), popup->y() + popup->height() + 5); + + if (mouse) + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); + else + QTest::touchEvent(window, touchDevice.data()).press(0, from); + QVERIFY(!drawer->isVisible()); + + static const int steps = 10; + for (int i = 0; i < steps; ++i) { + int x = from.x() + i * qAbs(from.x() - to.x()) / steps; + int y = from.y() + i * qAbs(from.y() - to.y()) / steps; + + if (mouse) + QTest::mouseMove(window, QPoint(x, y)); + else + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); + QTest::qWait(1); // avoid infinite velocity + QVERIFY(!drawer->isVisible()); + } + + if (mouse) + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); + else + QTest::touchEvent(window, touchDevice.data()).release(0, to); + QVERIFY(!drawer->isVisible()); +} + QTEST_MAIN(tst_Drawer) #include "tst_drawer.moc" |