From 293a2e9641b44743e8f355286bed47371418bbf3 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 10 Dec 2011 16:22:00 +0200 Subject: [PATCH] Update QDeclarativePinchArea autotest. Similarly to the QtQuick2 tests this one also needs some minor changes to make it compile with the recent touch changes in qtbase. Change-Id: Ie7114dc181579b45c850cb0cf18eb1168a37d8d4 Reviewed-by: Martin Jones --- .../tst_qdeclarativepincharea.cpp | 50 ++++++++++++-------- 1 files changed, 30 insertions(+), 20 deletions(-) diff --git a/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp b/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp index a1e27ea..1af73f9 100644 --- a/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp +++ b/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp @@ -50,7 +50,16 @@ class tst_QDeclarative1PinchArea: public QObject { Q_OBJECT +public: + tst_QDeclarative1PinchArea() : device(0) { } private slots: + void initTestCase() { + if (!device) { + device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + } + } void pinchProperties(); void scale(); void pan(); @@ -58,6 +67,7 @@ private slots: private: QDeclarativeView *createView(); + QTouchDevice *device; }; void tst_QDeclarative1PinchArea::pinchProperties() @@ -213,17 +223,17 @@ void tst_QDeclarative1PinchArea::scale() QPoint p1(80, 80); QPoint p2(100, 100); - QTest::touchEvent(vp).press(0, p1, canvas); - QTest::touchEvent(vp).stationary(0).press(1, p2, canvas); + QTest::touchEvent(vp, device).press(0, p1, canvas); + QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas); p1 -= QPoint(10,10); p2 += QPoint(10,10); - QTest::touchEvent(vp).move(0, p1, canvas).move(1, p2, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); QCOMPARE(root->property("scale").toReal(), 1.0); p1 -= QPoint(10,10); p2 += QPoint(10,10); - QTest::touchEvent(vp).move(0, p1, canvas).move(1, p2, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); QCOMPARE(root->property("scale").toReal(), 1.5); QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50 @@ -232,11 +242,11 @@ void tst_QDeclarative1PinchArea::scale() // scale beyond bound p1 -= QPoint(50,50); p2 += QPoint(50,50); - QTest::touchEvent(vp).move(0, p1, canvas).move(1, p2, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); QCOMPARE(blackRect->scale(), 2.0); - QTest::touchEvent(vp).release(0, p1, canvas).release(1, p2, canvas); + QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas); delete canvas; } @@ -268,17 +278,17 @@ void tst_QDeclarative1PinchArea::pan() QPoint p1(80, 80); QPoint p2(100, 100); - QTest::touchEvent(vp).press(0, p1, canvas); - QTest::touchEvent(vp).stationary(0).press(1, p2, canvas); + QTest::touchEvent(vp, device).press(0, p1, canvas); + QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas); p1 += QPoint(10,10); p2 += QPoint(10,10); - QTest::touchEvent(vp).move(0, p1, canvas).move(1, p2, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); QCOMPARE(root->property("scale").toReal(), 1.0); p1 += QPoint(10,10); p2 += QPoint(10,10); - QTest::touchEvent(vp).move(0, p1, canvas).move(1, p2, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50 @@ -288,12 +298,12 @@ void tst_QDeclarative1PinchArea::pan() // pan x beyond bound p1 += QPoint(100,100); p2 += QPoint(100,100); - QTest::touchEvent(vp).move(0, p1, canvas).move(1, p2, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); QCOMPARE(blackRect->x(), 140.0); QCOMPARE(blackRect->y(), 160.0); - QTest::touchEvent(vp).release(0, p1, canvas).release(1, p2, canvas); + QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas); delete canvas; } @@ -323,24 +333,24 @@ void tst_QDeclarative1PinchArea::flickable() // begin by moving one touch point (mouse) QTest::mousePress(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1)); - QTest::touchEvent(vp).press(0, p1, canvas); + QTest::touchEvent(vp, device).press(0, p1, canvas); { 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, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas); } { 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, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas); } { 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, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas); } // Flickable has reacted to the gesture @@ -348,23 +358,23 @@ void tst_QDeclarative1PinchArea::flickable() QVERIFY(root->property("scale").toReal() == 1.0); // add another touch point and continue moving - QTest::touchEvent(vp).stationary(0).press(1, p2, canvas); + QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas); p1 -= QPoint(10,10); p2 += QPoint(10,10); - QTest::touchEvent(vp).move(0, p1, canvas).move(1, p2, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); QCOMPARE(root->property("scale").toReal(), 1.0); p1 -= QPoint(10,10); p2 += QPoint(10,10); - QTest::touchEvent(vp).move(0, p1, canvas).move(1, p2, canvas); + QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); // 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, canvas).release(1, p2, canvas); + QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas); delete canvas; } -- 1.7.2.5