diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-01-17 22:08:56 +0100 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-01-17 22:08:56 +0100 |
commit | 9c54d0ef8f6442e32d5762edccef46db80b68681 (patch) | |
tree | 0fdbc2be98a2e7fd7728a3860d56c94db3e173bb /tests/auto/quick/qquickflickable | |
parent | 1512835ee1425a3e874d2f2dd2b01f1a1ea7b763 (diff) | |
parent | 36a42ed6b11dce102d0e0f93fbd441011b003157 (diff) |
Merge branch 'stable' into dev
Conflicts:
src/qml/doc/qtqml.qdocconf
src/quick/doc/qtquick.qdocconf
Change-Id: I087fa14720995a5e53c43567dc4a3c29eb9992a9
Diffstat (limited to 'tests/auto/quick/qquickflickable')
-rw-r--r-- | tests/auto/quick/qquickflickable/data/longList.qml | 22 | ||||
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 72 |
2 files changed, 93 insertions, 1 deletions
diff --git a/tests/auto/quick/qquickflickable/data/longList.qml b/tests/auto/quick/qquickflickable/data/longList.qml new file mode 100644 index 0000000000..424f2890ea --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/longList.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Flickable { + id: flick + + width: 200 + height: 480 + + contentHeight: 100 * 100 + + Grid { + columns: 1 + Repeater { + model: 100 + Rectangle { + width: flick.width + height: 100 + color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1) + } + } + } +} diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 66071e65d4..662e86018c 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; }; @@ -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(); + 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" |