diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-06-25 09:03:40 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-06-26 09:54:33 +0000 |
commit | 5f09ab8b94ab83e04493940cbd6c95e6d363d0db (patch) | |
tree | ace107ece2a134780575d03be4e37ae6646dab40 /tests | |
parent | c11ef4ffa905ac9ba5e5af89ed03b1786b5187a8 (diff) |
QQuickMonthGrid: fix touch support
QQuickMonthGrid lost its clicked() signal when multi-touch support was
added to QQuickControl, because QQuickControl now accepts touch events
and therefore QQuickMonthGrid no longer gets synthesized mouse events.
Re-implement QQuickControlPrivate::handlePress/Move/Release/Ungrab()
instead of QQuickControl::mouseXxxEvent() to gain multi-touch support.
Task-number: QTBUG-61585
Change-Id: Ic6fb2ea0b43b2b44beb0d8fdd3335a20f7c028f6
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/calendar/data/tst_monthgrid.qml | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/calendar/data/tst_monthgrid.qml b/tests/auto/calendar/data/tst_monthgrid.qml index 413e6d55..f07121dc 100644 --- a/tests/auto/calendar/data/tst_monthgrid.qml +++ b/tests/auto/calendar/data/tst_monthgrid.qml @@ -79,6 +79,11 @@ TestCase { } } + Component { + id: signalSpy + SignalSpy { } + } + function test_locale() { var control = delegateGrid.createObject(testCase, {month: 0, year: 2013}) @@ -227,4 +232,52 @@ TestCase { control.destroy() } + + function test_clicked_data() { + return [ + { tag: "mouse", touch: false }, + { tag: "touch", touch: true } + ] + } + + function test_clicked(data) { + var control = createTemporaryObject(defaultGrid, testCase) + verify(control) + + compare(control.contentItem.children.length, 6 * 7 + 1) + + var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressed"}) + verify(pressedSpy.valid) + + var releasedSpy = signalSpy.createObject(control, {target: control, signalName: "released"}) + verify(releasedSpy.valid) + + var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"}) + verify(clickedSpy.valid) + + var touch = touchEvent(control) + + for (var i = 0; i < 42; ++i) { + var cell = control.contentItem.children[i] + verify(cell) + + if (data.touch) + touch.press(0, cell).commit() + else + mousePress(cell) + + compare(pressedSpy.count, i + 1) + compare(releasedSpy.count, i) + compare(clickedSpy.count, i) + + if (data.touch) + touch.release(0, cell).commit() + else + mouseRelease(cell) + + compare(pressedSpy.count, i + 1) + compare(releasedSpy.count, i + 1) + compare(clickedSpy.count, i + 1) + } + } } |