diff options
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 80 |
1 files changed, 75 insertions, 5 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 66071e65d4..784988b913 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -53,6 +53,8 @@ #include "../shared/viewtestutil.h" #include "../shared/visualtestutil.h" +#include <qpa/qwindowsysteminterface.h> + using namespace QQuickViewTestUtil; using namespace QQuickVisualTestUtil; @@ -88,8 +90,10 @@ private slots: void margins(); void cancelOnMouseGrab(); void clickAndDragWhenTransformed(); + void flickTwiceUsingTouches(); private: + void flickWithTouch(QWindow *window, QTouchDevice *touchDevice); QQmlEngine engine; }; @@ -614,7 +618,7 @@ void tst_qquickflickable::movingAndFlicking() window->setSource(testFileUrl("flickable03.qml")); window->show(); window->requestActivate(); - QTest::qWaitForWindowActive(window); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -635,7 +639,7 @@ void tst_qquickflickable::movingAndFlicking() // do a flick that keeps the view within the bounds flick(window, flickFrom, flickToWithoutSnapBack, 200); - QVERIFY(flickable->isMoving()); + QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); QCOMPARE(flickable->isMovingVertically(), verticalEnabled); QVERIFY(flickable->isFlicking()); @@ -691,7 +695,7 @@ void tst_qquickflickable::movingAndFlicking() QTRY_VERIFY(!flickable->isMoving()); flick(window, flickFrom, flickToWithSnapBack, 200); - QVERIFY(flickable->isMoving()); + QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); QCOMPARE(flickable->isMovingVertically(), verticalEnabled); QVERIFY(flickable->isFlicking()); @@ -995,7 +999,7 @@ void tst_qquickflickable::pressWhileFlicking() // flicking == false, moving == true; flick(window, QPoint(20,190), QPoint(20, 50), 200); QVERIFY(flickable->verticalVelocity() > 0.0); - QVERIFY(flickable->isFlicking()); + QTRY_VERIFY(flickable->isFlicking()); QVERIFY(flickable->isFlickingVertically()); QVERIFY(!flickable->isFlickingHorizontally()); QVERIFY(flickable->isMoving()); @@ -1241,6 +1245,72 @@ void tst_qquickflickable::clickAndDragWhenTransformed() delete view; } +void tst_qquickflickable::flickTwiceUsingTouches() +{ + QTouchDevice *touchDevice = new QTouchDevice; + touchDevice->setName("Fake Touchscreen"); + touchDevice->setType(QTouchDevice::TouchScreen); + touchDevice->setCapabilities(QTouchDevice::Position); + QWindowSystemInterface::registerTouchDevice(touchDevice); + + QQuickView *window = new QQuickView; + window->setSource(testFileUrl("longList.qml")); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(window->rootObject() != 0); + + QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); + QVERIFY(flickable != 0); + + QCOMPARE(flickable->contentY(), 0.0f); + flickWithTouch(window, touchDevice); + + qreal contentYAfterFirstFlick = flickable->contentY(); + qDebug() << "contentYAfterFirstFlick " << contentYAfterFirstFlick; + QVERIFY(contentYAfterFirstFlick > 50.0f); + + flickWithTouch(window, touchDevice); + + // In the original bug, that second flick would cause Flickable to halt immediately + qreal contentYAfterSecondFlick = flickable->contentY(); + qDebug() << "contentYAfterSecondFlick " << contentYAfterSecondFlick; + QVERIFY(contentYAfterSecondFlick > (contentYAfterFirstFlick + 80.0f)); + + delete window; +} + +void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDevice) +{ + QTest::touchEvent(window, touchDevice) + .press(0, QPoint(100, 400), window); + QTest::qWait(1); + QTest::touchEvent(window, touchDevice) + .move(0, QPoint(100, 380), window); + QTest::qWait(1); + QTest::touchEvent(window, touchDevice) + .move(0, QPoint(100, 360), window); + QTest::qWait(1); + QTest::touchEvent(window, touchDevice) + .move(0, QPoint(100, 340), window); + QTest::qWait(1); + QTest::touchEvent(window, touchDevice) + .move(0, QPoint(100, 320), window); + QTest::qWait(1); + QTest::touchEvent(window, touchDevice) + .move(0, QPoint(100, 300), window); + QTest::qWait(1); + QTest::touchEvent(window, touchDevice) + .move(0, QPoint(100, 280), window); + QTest::qWait(1); + QTest::touchEvent(window, touchDevice) + .move(0, QPoint(100, 260), window); + QTest::qWait(1); + QTest::touchEvent(window, touchDevice) + .release(0, QPoint(100, 240), window); + QTest::qWait(1); +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" |