diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-05-05 16:46:14 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2017-05-08 08:57:12 +0000 |
commit | 1dc60a6b0c6fbf8da9473eb5b0435c1738865ce5 (patch) | |
tree | 42a23afae7c42103302b110bd4055155d1d963e2 /tests | |
parent | 932d5f78296e604c57c8ebcfe5c94f5ce62238f4 (diff) |
Drawer: fix dragging from the inside over interactive contents
Task-number: QTBUG-60598
Change-Id: I65e6e9440c9450fbec4a53b9ee60e11b919c090a
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/drawer/data/applicationwindow-button.qml | 70 | ||||
-rw-r--r-- | tests/auto/drawer/data/window-button.qml | 71 | ||||
-rw-r--r-- | tests/auto/drawer/tst_drawer.cpp | 30 |
3 files changed, 161 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/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..6f3e1d64 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -758,13 +758,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 +796,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); } |