diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-07-21 09:34:06 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-07-21 09:34:26 +0200 |
commit | ef63be14186607c2b806f45d257d8aba6e9a6472 (patch) | |
tree | f86e663d32e2ad8cfd6ac307dd11526e561c66ba /tests/auto | |
parent | 7eace7ac5a74b68338b948857c4f2bc2e58abc48 (diff) | |
parent | d6c8721476607f22896785baa547a7551015f164 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: Idb1895dae2870dbed860ba3106fe52b01d733504
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/drawer/data/multiTouch.qml | 82 | ||||
-rw-r--r-- | tests/auto/drawer/tst_drawer.cpp | 115 |
2 files changed, 197 insertions, 0 deletions
diff --git a/tests/auto/drawer/data/multiTouch.qml b/tests/auto/drawer/data/multiTouch.qml new file mode 100644 index 00000000..0faf3c61 --- /dev/null +++ b/tests/auto/drawer/data/multiTouch.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** 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 { + id: window + width: 400 + height: 400 + + property alias drawer: drawer + property alias popup: popup + property alias button: button + + Drawer { + id: drawer + width: window.width / 2 + height: parent.height + dragMargin: parent.width + } + + Popup { + id: popup + x: 10; y: 10 + width: window.width - 10 + height: window.height - 10 + + Button { + id: button + text: "Button" + anchors.fill: parent + } + } +} diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 9c30f8cf..d316e08f 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -86,6 +86,8 @@ private slots: void touch_data(); void touch(); + void multiTouch(); + void grabber(); void interactive_data(); @@ -813,6 +815,119 @@ void tst_Drawer::touch() QCOMPARE(drawer->position(), 0.0); } +void tst_Drawer::multiTouch() +{ + QQuickApplicationHelper helper(this, QStringLiteral("multiTouch.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickOverlay *overlay = QQuickOverlay::overlay(window); + QVERIFY(overlay); + + QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer *>(); + QVERIFY(drawer); + + QQuickPopup *popup = window->property("popup").value<QQuickPopup *>(); + QVERIFY(popup); + + QQuickButton *button = window->property("button").value<QQuickButton *>(); + QVERIFY(button); + + QSignalSpy overlayPressedSpy(overlay, SIGNAL(pressed())); + QSignalSpy overlayReleasedSpy(overlay, SIGNAL(released())); + QVERIFY(overlayPressedSpy.isValid()); + QVERIFY(overlayReleasedSpy.isValid()); + + QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); + QVERIFY(drawerOpenedSpy.isValid()); + + QSignalSpy buttonPressedSpy(button, SIGNAL(pressed())); + QSignalSpy buttonReleasedSpy(button, SIGNAL(released())); + QVERIFY(buttonPressedSpy.isValid()); + QVERIFY(buttonReleasedSpy.isValid()); + + popup->open(); + QVERIFY(popup->isVisible()); + + drawer->open(); + QVERIFY(drawer->isVisible()); + QVERIFY(drawerOpenedSpy.wait()); + + // 1st press + QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 1); + + // 2nd press (blocked & ignored) + QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 2); + + // 2nd release (blocked & ignored) + QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 200)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(buttonReleasedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 2); + QCOMPARE(overlayReleasedSpy.count(), 1); + + // 1st release + QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100)); + QVERIFY(popup->isVisible()); + QTRY_VERIFY(!drawer->isVisible()); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(buttonReleasedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 2); + QCOMPARE(overlayReleasedSpy.count(), 2); + + drawer->open(); + QVERIFY(drawer->isVisible()); + QVERIFY(drawerOpenedSpy.wait()); + + // 1st drag + QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100)); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 3); + for (int x = 300; x >= 100; x -= 10) { + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, 100)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + } + QCOMPARE(drawer->position(), 0.5); + + // 2nd drag (blocked & ignored) + QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200)); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 4); + for (int x = 300; x >= 0; x -= 10) { + QTest::touchEvent(window, touchDevice.data()).stationary(0).move(1, QPoint(x, 200)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + } + QCOMPARE(drawer->position(), 0.5); + + // 2nd release (blocked & ignored) + QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 0)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + QCOMPARE(drawer->position(), 0.5); + QCOMPARE(buttonReleasedSpy.count(), 0); + QCOMPARE(overlayReleasedSpy.count(), 3); + + // 1st release + QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100)); + QVERIFY(popup->isVisible()); + QTRY_VERIFY(!drawer->isVisible()); + QCOMPARE(buttonReleasedSpy.count(), 0); + QCOMPARE(overlayReleasedSpy.count(), 4); +} + void tst_Drawer::grabber() { QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml")); |