diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-11-01 02:32:17 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-11-01 02:58:20 (GMT) |
commit | b438b15b8291ce9591fbe0a64fe452383662bbda (patch) | |
tree | 82b61cf42f06443ef716d1458c94ea2954951a90 /tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp | |
parent | 95e00f7d712ee51389948a018b27c0d1dde4fa99 (diff) | |
download | Qt-b438b15b8291ce9591fbe0a64fe452383662bbda.zip Qt-b438b15b8291ce9591fbe0a64fe452383662bbda.tar.gz Qt-b438b15b8291ce9591fbe0a64fe452383662bbda.tar.bz2 |
Quickly clicking an item that doesn't use double clicking should result in two separate clicks
Task-number: QTBUG-14832
Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index 5a50e0d..57a58e9 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -63,6 +63,7 @@ private slots: void noOnClickedWithPressAndHold(); void onMousePressRejected(); void doubleClick(); + void clickTwice(); private: QDeclarativeView *createView(); @@ -426,6 +427,47 @@ void tst_QDeclarativeMouseArea::doubleClick() QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1); QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); + +} + +// QTBUG-14832 +void tst_QDeclarativeMouseArea::clickTwice() +{ + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clicktwice.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QGraphicsScene *scene = canvas->scene(); + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setScenePos(QPointF(100, 100)); + pressEvent.setButton(Qt::LeftButton); + pressEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &pressEvent); + + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + releaseEvent.setScenePos(QPointF(100, 100)); + releaseEvent.setButton(Qt::LeftButton); + releaseEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &releaseEvent); + + QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); + + QGraphicsSceneMouseEvent dblClickEvent(QEvent::GraphicsSceneMouseDoubleClick); + dblClickEvent.setScenePos(QPointF(100, 100)); + dblClickEvent.setButton(Qt::LeftButton); + dblClickEvent.setButtons(Qt::LeftButton); + QApplication::sendEvent(scene, &dblClickEvent); + + QApplication::sendEvent(scene, &pressEvent); + QApplication::sendEvent(scene, &releaseEvent); + + QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2); + QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); + QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2); } QTEST_MAIN(tst_QDeclarativeMouseArea) |