From 26d528f6b5c61ab5003e97989693851bb6964be4 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Jul 2017 14:54:47 +0200 Subject: PageIndicator: fix touch support Change-Id: I00d4f6ed466e33be3f31b2cd0bcbae6707d84cb9 Reviewed-by: Mitch Curtis --- tests/auto/controls/data/tst_pageindicator.qml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'tests/auto/controls') diff --git a/tests/auto/controls/data/tst_pageindicator.qml b/tests/auto/controls/data/tst_pageindicator.qml index 86c0bd8b..0ceefa35 100644 --- a/tests/auto/controls/data/tst_pageindicator.qml +++ b/tests/auto/controls/data/tst_pageindicator.qml @@ -83,20 +83,35 @@ TestCase { compare(control.currentIndex, 5) } - function test_interactive() { + function test_interactive_data() { + return [ + { tag: "mouse", touch: false }, + { tag: "touch", touch: true } + ] + } + + function test_interactive(data) { var control = createTemporaryObject(pageIndicator, testCase, {count: 5, spacing: 10, padding: 10}) verify(control) verify(!control.interactive) compare(control.currentIndex, 0) - mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton) + var touch = touchEvent(control) + + if (data.touch) + touch.press(0, control).commit().release(0, control).commit() + else + mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.currentIndex, 0) control.interactive = true verify(control.interactive) - mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton) + if (data.touch) + touch.press(0, control).commit().release(0, control).commit() + else + mouseClick(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.currentIndex, 2) // test also clicking outside delegates => the nearest should be selected @@ -108,7 +123,10 @@ TestCase { compare(control.currentIndex, -1) var pos = control.mapFromItem(child, x, y) - mouseClick(control, pos.x, pos.y, Qt.LeftButton) + if (data.touch) + touch.press(0, control, pos.x, pos.y).commit().release(0, control, pos.x, pos.y).commit() + else + mouseClick(control, pos.x, pos.y, Qt.LeftButton) compare(control.currentIndex, i) } } -- cgit v1.2.3