diff options
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 128 |
1 files changed, 93 insertions, 35 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index da3d8c41e2..d0f015324c 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 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:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -38,6 +33,7 @@ #include <QtQuick/qquickview.h> #include <private/qquickflickable_p.h> #include <private/qquickflickable_p_p.h> +#include <private/qquickmousearea_p.h> #include <private/qquicktransition_p.h> #include <private/qqmlvaluetype_p.h> #include <math.h> @@ -492,8 +488,20 @@ void tst_qquickflickable::nestedPressDelay() // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec. QTRY_VERIFY(outer->property("pressed").toBool()); + QTest::mouseMove(window.data(), QPoint(130, 150)); + QTest::mouseMove(window.data(), QPoint(110, 150)); + QTest::mouseMove(window.data(), QPoint(90, 150)); + + QVERIFY(!outer->property("moving").toBool()); + QVERIFY(!outer->property("dragging").toBool()); + QVERIFY(inner->property("moving").toBool()); + QVERIFY(inner->property("dragging").toBool()); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150)); + QVERIFY(!inner->property("dragging").toBool()); + QTRY_VERIFY(!inner->property("moving").toBool()); + // Dragging inner Flickable should work moveAndPress(window.data(), QPoint(80, 150)); // the MouseArea is not pressed immediately @@ -505,10 +513,15 @@ void tst_qquickflickable::nestedPressDelay() QTest::mouseMove(window.data(), QPoint(20, 150)); QVERIFY(inner->property("moving").toBool()); + QVERIFY(inner->property("dragging").toBool()); QVERIFY(!outer->property("moving").toBool()); + QVERIFY(!outer->property("dragging").toBool()); QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(20, 150)); + QVERIFY(!inner->property("dragging").toBool()); + QTRY_VERIFY(!inner->property("moving").toBool()); + // Dragging the MouseArea in the inner Flickable should move the inner Flickable moveAndPress(window.data(), QPoint(150, 150)); // the MouseArea is not pressed immediately @@ -518,11 +531,15 @@ void tst_qquickflickable::nestedPressDelay() QTest::mouseMove(window.data(), QPoint(110, 150)); QTest::mouseMove(window.data(), QPoint(90, 150)); - QVERIFY(!outer->property("moving").toBool()); + QVERIFY(!outer->property("dragging").toBool()); QVERIFY(inner->property("moving").toBool()); + QVERIFY(inner->property("dragging").toBool()); QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(90, 150)); + + QVERIFY(!inner->property("dragging").toBool()); + QTRY_VERIFY(!inner->property("moving").toBool()); } void tst_qquickflickable::filterReplayedPress() @@ -1529,7 +1546,6 @@ void tst_qquickflickable::flickWithTouch(QQuickWindow *window, QTouchDevice *tou for (int i = 1; i <= 8; ++i) { QTest::touchEvent(window, touchDevice).move(0, from + i*diff/8, window); QQuickTouchUtils::flush(window); - QTest::qWait(1); // because Flickable pays attention to velocity, we need some time between movements } QTest::touchEvent(window, touchDevice).release(0, to, window); QQuickTouchUtils::flush(window); @@ -1541,20 +1557,26 @@ void tst_qquickflickable::nestedStopAtBounds_data() QTest::addColumn<bool>("invert"); QTest::addColumn<int>("boundsBehavior"); QTest::addColumn<qreal>("margin"); - - QTest::newRow("left,stop") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0); - QTest::newRow("right,stop") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(0); - QTest::newRow("top,stop") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(0); - QTest::newRow("bottom,stop") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(0); - QTest::newRow("left,over") << false << false << int(QQuickFlickable::DragOverBounds) << qreal(0); - QTest::newRow("right,over") << false << true << int(QQuickFlickable::DragOverBounds) << qreal(0); - QTest::newRow("top,over") << true << false << int(QQuickFlickable::DragOverBounds) << qreal(0); - QTest::newRow("bottom,over") << true << true << int(QQuickFlickable::DragOverBounds) << qreal(0); - - QTest::newRow("left,stop,margin") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(20); - QTest::newRow("right,stop,margin") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(20); - QTest::newRow("top,stop,margin") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(20); - QTest::newRow("bottom,stop,margin") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(20); + QTest::addColumn<bool>("innerFiltering"); + QTest::addColumn<int>("pressDelay"); + QTest::addColumn<bool>("waitForPressDelay"); + + QTest::newRow("left,stop") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0) << false << 0 << false; + QTest::newRow("right,stop") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(0) << false << 0 << false; + QTest::newRow("top,stop") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(0) << false << 0 << false; + QTest::newRow("bottom,stop") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(0) << false << 0 << false; + QTest::newRow("left,over") << false << false << int(QQuickFlickable::DragOverBounds) << qreal(0) << false << 0 << false; + QTest::newRow("right,over") << false << true << int(QQuickFlickable::DragOverBounds) << qreal(0) << false << 0 << false; + QTest::newRow("top,over") << true << false << int(QQuickFlickable::DragOverBounds) << qreal(0) << false << 0 << false; + QTest::newRow("bottom,over") << true << true << int(QQuickFlickable::DragOverBounds) << qreal(0) << false << 0 << false; + + QTest::newRow("left,stop,margin") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(20) << false << 0 << false; + QTest::newRow("right,stop,margin") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(20) << false << 0 << false; + QTest::newRow("top,stop,margin") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(20) << false << 0 << false; + QTest::newRow("bottom,stop,margin") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(20) << false << 0 << false; + + QTest::newRow("left,stop,after press delay") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0) << true << 50 << true; + QTest::newRow("left,stop,before press delay") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0) << true << 50 << false; } void tst_qquickflickable::nestedStopAtBounds() @@ -1563,6 +1585,9 @@ void tst_qquickflickable::nestedStopAtBounds() QFETCH(bool, invert); QFETCH(int, boundsBehavior); QFETCH(qreal, margin); + QFETCH(bool, innerFiltering); + QFETCH(int, pressDelay); + QFETCH(bool, waitForPressDelay); QQuickView view; view.setSource(testFileUrl("nestedStopAtBounds.qml")); @@ -1595,6 +1620,12 @@ void tst_qquickflickable::nestedStopAtBounds() QCOMPARE(inner->isAtYBeginning(), invert); QCOMPARE(inner->isAtYEnd(), !invert); + inner->setPressDelay(pressDelay); + + QQuickMouseArea *mouseArea = inner->findChild<QQuickMouseArea *>("mouseArea"); + QVERIFY(mouseArea); + mouseArea->setEnabled(innerFiltering); + const int threshold = qApp->styleHints()->startDragDistance(); QPoint position(200, 200); @@ -1602,17 +1633,25 @@ void tst_qquickflickable::nestedStopAtBounds() // drag toward the aligned boundary. Outer flickable dragged. moveAndPress(&view, position); - QTest::qWait(10); + if (waitForPressDelay) { + QVERIFY(innerFiltering); // isPressed will never be true if the mouse area isn't enabled. + QTRY_VERIFY(mouseArea->pressed()); + } + axis += invert ? threshold * 2 : -threshold * 2; QTest::mouseMove(&view, position); axis += invert ? threshold : -threshold; QTest::mouseMove(&view, position); QCOMPARE(outer->isDragging(), true); + QCOMPARE(outer->isMoving(), true); QCOMPARE(inner->isDragging(), false); + QCOMPARE(inner->isMoving(), false); QTest::mouseRelease(&view, Qt::LeftButton, 0, position); QVERIFY(!outer->isDragging()); QTRY_VERIFY(!outer->isMoving()); + QVERIFY(!inner->isDragging()); + QVERIFY(!inner->isMoving()); axis = 200; outer->setContentX(50); @@ -1626,10 +1665,15 @@ void tst_qquickflickable::nestedStopAtBounds() axis += invert ? -threshold : threshold; QTest::mouseMove(&view, position); QCOMPARE(outer->isDragging(), false); + QCOMPARE(outer->isMoving(), false); QCOMPARE(inner->isDragging(), true); + QCOMPARE(inner->isMoving(), true); QTest::mouseRelease(&view, Qt::LeftButton, 0, position); - QTRY_VERIFY(!outer->isMoving()); + QVERIFY(!inner->isDragging()); + QTRY_VERIFY(!inner->isMoving()); + QVERIFY(!outer->isDragging()); + QVERIFY(!outer->isMoving()); axis = 200; inner->setContentX(-margin); @@ -1645,9 +1689,16 @@ void tst_qquickflickable::nestedStopAtBounds() axis += invert ? -threshold : threshold; QTest::mouseMove(&view, position); QCOMPARE(outer->isDragging(), true); + QCOMPARE(outer->isMoving(), true); QCOMPARE(inner->isDragging(), false); + QCOMPARE(inner->isMoving(), false); QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + QVERIFY(!outer->isDragging()); + QTRY_VERIFY(!outer->isMoving()); + QVERIFY(!inner->isDragging()); + QVERIFY(!inner->isMoving()); + axis = 200; inner->setContentX(-margin); inner->setContentY(-margin); @@ -1662,8 +1713,15 @@ void tst_qquickflickable::nestedStopAtBounds() axis += invert ? -threshold : threshold; QTest::mouseMove(&view, position); QCOMPARE(outer->isDragging(), true); + QCOMPARE(outer->isMoving(), true); QCOMPARE(inner->isDragging(), false); + QCOMPARE(inner->isMoving(), false); QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + QVERIFY(!outer->isDragging()); + QTRY_VERIFY(!outer->isMoving()); + QVERIFY(!inner->isDragging()); + QVERIFY(!inner->isMoving()); } void tst_qquickflickable::stopAtBounds_data() |