on xenial help sign in
update the test_dragndrop_cancel function
commitf9a9c4b56120d204939ae7e3958e004942722797 authorhandsome_feng <445865575@qq.com> dateThu 23 Jul 2015, 15:30 (11 years ago) parentc4ad0cb
3 files changed+36−12
qml/Launcher/Launcher.qml−7 tests/qmltests/Launcher/tst_Launcher.qml+27−5 tests/utils/modules/Unity/Test/UnityTestCase.qml+9
qml/Launcher/Launcher.qml−7
@@ -178,14 +178,7 @@ Item {
178178
179179 }
180180
181− //We need to eat touch events here because of bug lp:1445472
182181 MultiPointTouchArea {
183− objectName: "eatTouchArea"
184− anchors.fill: parent
185− enabled: root.shadeBackground && root.state == "visible"
186− }
187−
188− MouseArea {
189182 id: closeMouseArea
190183 anchors {
191184 left: launcherDragArea.right
tests/qmltests/Launcher/tst_Launcher.qml+27−5
@@ -459,7 +459,14 @@ Item {
459459 waitUntilLauncherDisappears();
460460 }
461461
462− function test_dragndrop_cancel() {
462+ function test_dragndrop_cancel_data() {
463+ return [
464+ {tag: "by mouse", mouse: true},
465+ {tag: "by touch", mouse: false}
466+ ]
467+ }
468+
469+ function test_dragndrop_cancel(data) {
463470 dragLauncherIntoView();
464471 var draggedItem = findChild(launcher, "launcherDelegate4")
465472 var item0 = findChild(launcher, "launcherDelegate0")
@@ -468,22 +475,37 @@ Item {
468475 // Doing longpress
469476 var currentMouseX = draggedItem.width / 2
470477 var currentMouseY = draggedItem.height / 2
471− mousePress(draggedItem, currentMouseX, currentMouseY)
478+
479+ if(data.mouse) {
480+ mousePress(draggedItem, currentMouseX, currentMouseY)
481+ } else {
482+ touchPress(draggedItem, currentMouseX, currentMouseY)
483+ }
484+
472485 // DraggedItem needs to hide and fakeDragItem become visible
473486 tryCompare(draggedItem, "itemOpacity", 0)
474487 tryCompare(fakeDragItem, "visible", true)
475488
476489 // Dragging
477490 currentMouseX -= units.gu(20)
478− mouseMove(draggedItem, currentMouseX, currentMouseY)
491+
492+ if(data.mouse) {
493+ mouseMove(draggedItem, currentMouseX, currentMouseY)
494+ } else {
495+ touchMove(draggedItem, currentMouseX, currentMouseY)
496+ }
479497
480498 // Make sure we're in the dragging state
481499 var dndArea = findChild(launcher, "dndArea");
482500 tryCompare(draggedItem, "dragging", true)
483501 tryCompare(dndArea, "draggedIndex", 4)
484502
485− // Tap somewhere in the middle of the screen to close/hide the launcher
486− tap(root)
503+ // Click/Tap somewhere in the middle of the screen to close/hide the launcher
504+ if(data.mouse) {
505+ mouseClick(root)
506+ } else {
507+ tap(root)
508+ }
487509
488510 // Make sure the dnd operation has been stopped
489511 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);