on xenial help sign in
Convert the MouseArea to MultiPointTouchArea to track multiple touch points. Fixes: #1445472

Approved by: Michael Zanetti

commitab7130b1003bebce2388707a3aed889b30169827 authorhandsome_feng <445865575@qq.com> dateWed 12 Aug 2015, 08:40 (11 years ago) parentb3a42eff9a9c4b
3 files changed+38−6
qml/Launcher/Launcher.qml+2−1 tests/qmltests/Launcher/tst_Launcher.qml+27−5 tests/utils/modules/Unity/Test/UnityTestCase.qml+9
qml/Launcher/Launcher.qml+2−1
@@ -177,7 +177,8 @@ Item {
177177 }
178178
179179 }
180− MouseArea {
180+
181+ MultiPointTouchArea {
181182 id: closeMouseArea
182183 anchors {
183184 left: launcherDragArea.right
tests/qmltests/Launcher/tst_Launcher.qml+27−5
@@ -520,7 +520,14 @@ Item {
520520 waitUntilLauncherDisappears();
521521 }
522522
523− function test_dragndrop_cancel() {
523+ function test_dragndrop_cancel_data() {
524+ return [
525+ {tag: "by mouse", mouse: true},
526+ {tag: "by touch", mouse: false}
527+ ]
528+ }
529+
530+ function test_dragndrop_cancel(data) {
524531 dragLauncherIntoView();
525532 var draggedItem = findChild(launcher, "launcherDelegate4")
526533 var item0 = findChild(launcher, "launcherDelegate0")
@@ -529,22 +536,37 @@ Item {
529536 // Doing longpress
530537 var currentMouseX = draggedItem.width / 2
531538 var currentMouseY = draggedItem.height / 2
532− mousePress(draggedItem, currentMouseX, currentMouseY)
539+
540+ if(data.mouse) {
541+ mousePress(draggedItem, currentMouseX, currentMouseY)
542+ } else {
543+ touchPress(draggedItem, currentMouseX, currentMouseY)
544+ }
545+
533546 // DraggedItem needs to hide and fakeDragItem become visible
534547 tryCompare(draggedItem, "itemOpacity", 0)
535548 tryCompare(fakeDragItem, "visible", true)
536549
537550 // Dragging
538551 currentMouseX -= units.gu(20)
539− mouseMove(draggedItem, currentMouseX, currentMouseY)
552+
553+ if(data.mouse) {
554+ mouseMove(draggedItem, currentMouseX, currentMouseY)
555+ } else {
556+ touchMove(draggedItem, currentMouseX, currentMouseY)
557+ }
540558
541559 // Make sure we're in the dragging state
542560 var dndArea = findChild(launcher, "dndArea");
543561 tryCompare(draggedItem, "dragging", true)
544562 tryCompare(dndArea, "draggedIndex", 4)
545563
546− // Tap somewhere in the middle of the screen to close/hide the launcher
547− tap(root)
564+ // Click/Tap somewhere in the middle of the screen to close/hide the launcher
565+ if(data.mouse) {
566+ mouseClick(root)
567+ } else {
568+ tap(root)
569+ }
548570
549571 // Make sure the dnd operation has been stopped
550572 tryCompare(draggedItem, "dragging", false)
tests/utils/modules/Unity/Test/UnityTestCase.qml+9
@@ -351,6 +351,15 @@ TestCase {
351351 event.commit()
352352 }
353353
354+ function touchMove(item, tox, toy) {
355+ var root = fetchRootItem(item)
356+ var rootPoint = item.mapToItem(root, tox, toy)
357+
358+ var event = touchEvent(item);
359+ event.move(0 /* touchId */, rootPoint.x, rootPoint.y);
360+ event.commit();
361+ }
362+
354363 function touchPinch(item, x1Start, y1Start, x1End, y1End, x2Start, y2Start, x2End, y2End) {
355364 // Make sure the item is rendered
356365 waitForRendering(item);