on xenial help sign in
update the test_dragndrop_cancel function
f9a9c4bhandsome_feng
qml/Launcher/Launcher.qml−7
@@ -178,14 +178,7 @@ Item {
178
178
179 }
179 }
180
180
181− //We need to eat touch events here because of bug lp:1445472
182 MultiPointTouchArea {
181 MultiPointTouchArea {
183− objectName: "eatTouchArea"
184− anchors.fill: parent
185− enabled: root.shadeBackground && root.state == "visible"
186− }
187−
188− MouseArea {
189 id: closeMouseArea
182 id: closeMouseArea
190 anchors {
183 anchors {
191 left: launcherDragArea.right
184 left: launcherDragArea.right
tests/qmltests/Launcher/tst_Launcher.qml+27−5
@@ -459,7 +459,14 @@ Item {
459 waitUntilLauncherDisappears();
459 waitUntilLauncherDisappears();
460 }
460 }
461
461
462+ function test_dragndrop_cancel_data() {
463+ return [
464+ {tag: "by mouse", mouse: true},
465+ {tag: "by touch", mouse: false}
466+ ]
467+ }
468+
462− function test_dragndrop_cancel() {
469+ function test_dragndrop_cancel(data) {
463 dragLauncherIntoView();
470 dragLauncherIntoView();
464 var draggedItem = findChild(launcher, "launcherDelegate4")
471 var draggedItem = findChild(launcher, "launcherDelegate4")
465 var item0 = findChild(launcher, "launcherDelegate0")
472 var item0 = findChild(launcher, "launcherDelegate0")
@@ -468,22 +475,37 @@ Item {
468 // Doing longpress
475 // Doing longpress
469 var currentMouseX = draggedItem.width / 2
476 var currentMouseX = draggedItem.width / 2
470 var currentMouseY = draggedItem.height / 2
477 var currentMouseY = draggedItem.height / 2
478+
479+ if(data.mouse) {
471− mousePress(draggedItem, currentMouseX, currentMouseY)
480+ mousePress(draggedItem, currentMouseX, currentMouseY)
481+ } else {
482+ touchPress(draggedItem, currentMouseX, currentMouseY)
483+ }
484+
472 // DraggedItem needs to hide and fakeDragItem become visible
485 // DraggedItem needs to hide and fakeDragItem become visible
473 tryCompare(draggedItem, "itemOpacity", 0)
486 tryCompare(draggedItem, "itemOpacity", 0)
474 tryCompare(fakeDragItem, "visible", true)
487 tryCompare(fakeDragItem, "visible", true)
475
488
476 // Dragging
489 // Dragging
477 currentMouseX -= units.gu(20)
490 currentMouseX -= units.gu(20)
491+
492+ if(data.mouse) {
478− mouseMove(draggedItem, currentMouseX, currentMouseY)
493+ mouseMove(draggedItem, currentMouseX, currentMouseY)
494+ } else {
495+ touchMove(draggedItem, currentMouseX, currentMouseY)
496+ }
479
497
480 // Make sure we're in the dragging state
498 // Make sure we're in the dragging state
481 var dndArea = findChild(launcher, "dndArea");
499 var dndArea = findChild(launcher, "dndArea");
482 tryCompare(draggedItem, "dragging", true)
500 tryCompare(draggedItem, "dragging", true)
483 tryCompare(dndArea, "draggedIndex", 4)
501 tryCompare(dndArea, "draggedIndex", 4)
484
502
485− // Tap somewhere in the middle of the screen to close/hide the launcher
503+ // Click/Tap somewhere in the middle of the screen to close/hide the launcher
504+ if(data.mouse) {
505+ mouseClick(root)
506+ } else {
486− tap(root)
507+ tap(root)
508+ }
487
509
488 // Make sure the dnd operation has been stopped
510 // Make sure the dnd operation has been stopped
489 tryCompare(draggedItem, "dragging", false)
511 tryCompare(draggedItem, "dragging", false)
tests/utils/modules/Unity/Test/UnityTestCase.qml+9
@@ -351,6 +351,15 @@ TestCase {
351 event.commit()
351 event.commit()
352 }
352 }
353
353
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+
354 function touchPinch(item, x1Start, y1Start, x1End, y1End, x2Start, y2Start, x2End, y2End) {
363 function touchPinch(item, x1Start, y1Start, x1End, y1End, x2Start, y2Start, x2End, y2End) {
355 // Make sure the item is rendered
364 // Make sure the item is rendered
356 waitForRendering(item);
365 waitForRendering(item);