~unity-team/unity8/trunk

« back to all changes in this revision

Viewing changes to tests/qmltests/Launcher/tst_Launcher.qml

  • Committer: Tarmac
  • Author(s): Michael Zanetti
  • Date: 2013-08-19 13:32:37 UTC
  • mfrom: (95.2.48 unity8-dnd)
  • Revision ID: tarmac-20130819133237-35p2rl9pz0c0vnoc
Add Drag'n'drop support to Launcher

As dragging an item pins it to the launcher this also contains initial quicklist and pinning support in the plugin part.

Approved by Michał Sawicz, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import Unity.Test 0.1 as UT
20
20
import ".."
21
21
import "../../../Launcher"
 
22
import Unity.Launcher 0.1
22
23
 
23
24
/* Nothing is shown at first. If you drag from left edge you will bring up the
24
25
   launcher. */
247
248
        }
248
249
        */
249
250
    }
 
251
 
 
252
    UT.UnityTestCase {
 
253
        id: dndTestCase
 
254
        name: "Drag and Drop"
 
255
        when: windowShown && initTestCase.completed
 
256
 
 
257
        function test_dragndrop_data() {
 
258
            return [
 
259
                {tag: "startDrag", fullDrag: false},
 
260
                {tag: "fullDrag", fullDrag: true},
 
261
            ];
 
262
        }
 
263
 
 
264
        function test_dragndrop(data) {
 
265
            revealer.dragLauncherIntoView();
 
266
            var draggedItem = findChild(launcher, "launcherDelegate5")
 
267
            var item0 = findChild(launcher, "launcherDelegate0")
 
268
            var fakeDragItem = findChild(launcher, "fakeDragItem")
 
269
            var initialItemHeight = draggedItem.height
 
270
            var item5Name = LauncherModel.get(5).iconName
 
271
            var item4Name = LauncherModel.get(4).iconName
 
272
 
 
273
            // Initial state
 
274
            compare(draggedItem.itemOpacity, 1, "Item's opacity is not 1 at beginning")
 
275
            compare(fakeDragItem.visible, false, "FakeDragItem isn't invisible at the beginning")
 
276
            tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 0)
 
277
 
 
278
            // Doing longpress
 
279
            mousePress(draggedItem, draggedItem.width / 2, draggedItem.height / 2)
 
280
            // DraggedItem needs to hide and fakeDragItem become visible
 
281
            tryCompare(draggedItem, "itemOpacity", 0)
 
282
            tryCompare(fakeDragItem, "visible", true)
 
283
 
 
284
            // Dragging a bit (> 1.5 gu)
 
285
            mouseMove(draggedItem, -units.gu(2), draggedItem.height / 2)
 
286
            // Other items need to expand and become 0.6 opaque
 
287
            tryCompare(item0, "angle", 0)
 
288
            tryCompare(item0, "itemOpacity", 0.6)
 
289
 
 
290
            if (data.fullDrag) {
 
291
                // Dragging a bit more
 
292
                mouseMove(draggedItem, -units.gu(15), draggedItem.height / 2, 100)
 
293
                tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 1)
 
294
                tryCompare(draggedItem, "height", units.gu(1))
 
295
 
 
296
                // Dragging downwards. Item needs to move in the model
 
297
                mouseMove(draggedItem, -units.gu(15), -initialItemHeight)
 
298
                waitForRendering(draggedItem)
 
299
                compare(LauncherModel.get(5).iconName, item4Name)
 
300
                compare(LauncherModel.get(5).iconName, item5Name)
 
301
            }
 
302
 
 
303
            // Releasing and checking if initial values are restored
 
304
            mouseRelease(draggedItem)
 
305
            tryCompare(findChild(draggedItem, "dropIndicator"), "opacity", 0)
 
306
            tryCompare(draggedItem, "itemOpacity", 1)
 
307
            tryCompare(fakeDragItem, "visible", false)
 
308
        }
 
309
    }
250
310
}