@@ -49,6 +49,11 @@ Item {
4949 property int maxPanelX: 0
5050 }
5151
52+ SignalSpy {
53+ id: signalSpy
54+ target: LauncherModel
55+ }
56+
5257 Connections {
5358 target: testCase.findChild(launcher, "launcherPanel")
5459
@@ -306,5 +311,79 @@ Item {
306311 tryCompare(draggedItem, "itemOpacity", 1)
307312 tryCompare(fakeDragItem, "visible", false)
308313 }
314+
315+ function test_quicklist_dismiss() {
316+ revealer.dragLauncherIntoView();
317+ var draggedItem = findChild(launcher, "launcherDelegate5")
318+ var item0 = findChild(launcher, "launcherDelegate0")
319+ var fakeDragItem = findChild(launcher, "fakeDragItem")
320+ var dndArea = findChild(launcher, "dndArea")
321+
322+ // Initial state
323+ compare(dndArea.quickListPopover, null)
324+
325+ // Doing longpress
326+ mousePress(draggedItem, draggedItem.width / 2, draggedItem.height / 2)
327+ tryCompare(fakeDragItem, "visible", true) // Wait longpress happening
328+ verify(dndArea.quickListPopover != null)
329+
330+ // Dragging a bit (> 1.5 gu)
331+ mouseMove(draggedItem, -units.gu(2), draggedItem.height / 2)
332+
333+ // QuickList needs to be closed when a drag operation starts
334+ tryCompare(dndArea, "quickListPopover", null)
335+
336+ mouseRelease(draggedItem);
337+ }
338+
339+ function test_quicklist_click_data() {
340+ return [
341+ {tag: "non-clickable", index: 1, clickable: false },
342+ {tag: "clickable", index: 2, clickable: true },
343+ ];
344+ }
345+
346+ function test_quicklist_click(data) {
347+ revealer.dragLauncherIntoView();
348+ var clickedItem = findChild(launcher, "launcherDelegate5")
349+ var dndArea = findChild(launcher, "dndArea")
350+
351+ // Initial state
352+ compare(dndArea.quickListPopover, null)
353+
354+ // Doing longpress
355+ mousePress(clickedItem, clickedItem.width / 2, clickedItem.height / 2)
356+ tryCompare(clickedItem, "itemOpacity", 0) // Wait for longpress to happen
357+ verify(dndArea.quickListPopover != null)
358+
359+ mouseRelease(clickedItem);
360+
361+ var quickListEntry = findChild(dndArea.quickListPopover, "quickListEntry" + data.index)
362+
363+ signalSpy.clear();
364+ signalSpy.signalName = "quickListTriggered"
365+
366+ mouseClick(quickListEntry, quickListEntry.width / 2, quickListEntry.height / 2)
367+
368+ if (data.clickable) {
369+ // QuickList needs to be closed when some clickable item is clicked
370+ tryCompare(dndArea, "quickListPopover", null)
371+
372+ compare(signalSpy.count, 1, "Quicklist signal wasn't triggered")
373+ compare(signalSpy.signalArguments[0][0], LauncherModel.get(5).appId)
374+ compare(signalSpy.signalArguments[0][1], 2)
375+
376+ } else {
377+
378+ // QuickList must not be closed when a non-clickable item is clicked
379+ verify(dndArea.quickListPopover != null)
380+
381+ compare(signalSpy.count, 0, "Quicklist signal must NOT be triggered when clicking a non-clickable item")
382+
383+ // Click somewhere in the empty space to dismiss the quicklist
384+ mouseClick(launcher, launcher.width - units.gu(1), units.gu(1));
385+ tryCompare(dndArea, "quickListPopover", null)
386+ }
387+ }
309388 }
310389}