diff options
Diffstat (limited to 'tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp index d7eda5e19c..9e3261f7b2 100644 --- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp @@ -68,6 +68,7 @@ private slots: void touchLongPress(); void mouseLongPress(); void buttonsMultiTouch(); + void componentUserBehavioralOverride(); private: void createView(QScopedPointer<QQuickView> &window, const char *fileName); @@ -585,6 +586,41 @@ void tst_TapHandler::buttonsMultiTouch() QVERIFY(buttonReleaseWithinBounds->property("pressed").toBool()); } +void tst_TapHandler::componentUserBehavioralOverride() +{ + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "buttonOverrideHandler.qml"); + QQuickView * window = windowPtr.data(); + + QQuickItem *button = window->rootObject()->findChild<QQuickItem*>("Overridden"); + QVERIFY(button); + QQuickTapHandler *innerTapHandler = button->findChild<QQuickTapHandler*>("Overridden"); + QVERIFY(innerTapHandler); + QQuickTapHandler *userTapHandler = button->findChild<QQuickTapHandler*>("override"); + QVERIFY(userTapHandler); + QSignalSpy tappedSpy(button, SIGNAL(tapped())); + QSignalSpy innerGrabChangedSpy(innerTapHandler, SIGNAL(grabChanged(QQuickEventPoint *))); + QSignalSpy userGrabChangedSpy(userTapHandler, SIGNAL(grabChanged(QQuickEventPoint *))); + QSignalSpy innerPressedChangedSpy(innerTapHandler, SIGNAL(pressedChanged())); + QSignalSpy userPressedChangedSpy(userTapHandler, SIGNAL(pressedChanged())); + + // Press + QPoint p1 = button->mapToScene(button->clipRect().center()).toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(userPressedChangedSpy.count(), 1); + QCOMPARE(innerPressedChangedSpy.count(), 0); + QCOMPARE(innerGrabChangedSpy.count(), 0); + QCOMPARE(userGrabChangedSpy.count(), 1); + + // Release + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_COMPARE(userPressedChangedSpy.count(), 2); + QCOMPARE(innerPressedChangedSpy.count(), 0); + QCOMPARE(tappedSpy.count(), 1); // only because the override handler makes that happen + QCOMPARE(innerGrabChangedSpy.count(), 0); + QCOMPARE(userGrabChangedSpy.count(), 2); +} + QTEST_MAIN(tst_TapHandler) #include "tst_qquicktaphandler.moc" |