diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-01 12:47:12 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-01 12:47:12 (GMT) |
commit | d194ebdc199fdd85245bfecb766d836dfa79c3f3 (patch) | |
tree | 20208d97fb9d6a785053647ef36513d2fc773d0e /tests | |
parent | ee3625dafeb89e8e556a03d02582931f9866b47a (diff) | |
parent | b438b15b8291ce9591fbe0a64fe452383662bbda (diff) | |
download | Qt-d194ebdc199fdd85245bfecb766d836dfa79c3f3.zip Qt-d194ebdc199fdd85245bfecb766d836dfa79c3f3.tar.gz Qt-d194ebdc199fdd85245bfecb766d836dfa79c3f3.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Quickly clicking an item that doesn't use double clicking should result in two separate clicks
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativemousearea/data/clicktwice.qml | 16 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp | 42 |
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativemousearea/data/clicktwice.qml b/tests/auto/declarative/qdeclarativemousearea/data/clicktwice.qml new file mode 100644 index 0000000..c6b1f89 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemousearea/data/clicktwice.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 + +Item { + id: root + property int clicked: 0 + property int pressed: 0 + property int released: 0 + + MouseArea { + width: 200; height: 200 + onPressed: { root.pressed++ } + onClicked: { root.clicked++ } + onReleased: { root.released++ } + } +} + 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) |