diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-03-31 23:29:38 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-03-31 23:49:46 (GMT) |
commit | ea304fb207b681ee084c4ce9bc61d1dd847bd7b0 (patch) | |
tree | d19e81af86abec773ae6bed0413e61a59e58fc12 /tests | |
parent | 8d9e7bbc1a4efb5b883f66f41c31f9165ef48117 (diff) | |
download | Qt-ea304fb207b681ee084c4ce9bc61d1dd847bd7b0.zip Qt-ea304fb207b681ee084c4ce9bc61d1dd847bd7b0.tar.gz Qt-ea304fb207b681ee084c4ce9bc61d1dd847bd7b0.tar.bz2 |
PinchArea and Flickable don't work well enough together
Allow PinchArea to be more aggressive in grabbing the gesture and
keep the gesture until all touches are released.
Change-Id: Ic80b7c4c478e1ee3b1c3da0772553756d9d5473f
Task-number: QTBUG-17829
Reviewed-by: Bea Lam
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp b/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp index f175033..90506ba 100644 --- a/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp +++ b/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp @@ -43,6 +43,7 @@ #include <QtTest/QSignalSpy> #include <private/qdeclarativepincharea_p.h> #include <private/qdeclarativerectangle_p.h> +#include <private/qdeclarativeflickable_p.h> #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativecontext.h> @@ -58,6 +59,7 @@ private slots: void pinchProperties(); void scale(); void pan(); + void flickable(); private: QDeclarativeView *createView(); @@ -301,6 +303,77 @@ void tst_QDeclarativePinchArea::pan() delete canvas; } +void tst_QDeclarativePinchArea::flickable() +{ + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickresize.qml")); + canvas->show(); + canvas->setFocus(); + QTest::qWaitForWindowShown(canvas); + QVERIFY(canvas->rootObject() != 0); + qApp->processEvents(); + + QDeclarativePinchArea *pinchArea = canvas->rootObject()->findChild<QDeclarativePinchArea*>("pincharea"); + QDeclarativePinch *pinch = pinchArea->pinch(); + QVERIFY(pinchArea != 0); + QVERIFY(pinch != 0); + + QDeclarativeFlickable *root = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject()); + QVERIFY(root != 0); + + QWidget *vp = canvas->viewport(); + + QPoint p1(110, 80); + QPoint p2(100, 100); + + // begin by moving one touch point (mouse) + QTest::mousePress(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1)); + QTest::touchEvent(vp).press(0, p1); + { + p1 -= QPoint(10,10); + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + QTest::touchEvent(vp).move(0, p1); + } + { + p1 -= QPoint(10,10); + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(vp, &mv); + QTest::touchEvent(vp).move(0, p1); + } + { + p1 -= QPoint(10,10); + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(vp, &mv); + QTest::touchEvent(vp).move(0, p1); + } + + // Flickable has reacted to the gesture + QVERIFY(root->isMoving()); + QVERIFY(root->property("scale").toReal() == 1.0); + + // add another touch point and continue moving + QTest::touchEvent(vp).stationary(0).press(1, p2); + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(vp).move(0, p1).move(1, p2); + + QCOMPARE(root->property("scale").toReal(), 1.0); + + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(vp).move(0, p1).move(1, p2); + + // PinchArea has stolen the gesture. + QVERIFY(!root->isMoving()); + QVERIFY(root->property("scale").toReal() > 1.0); + + QTest::mouseRelease(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1)); + QTest::touchEvent(vp).release(0, p1).release(1, p2); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePinchArea::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); |