~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to tests/unit_x11/tst_components/tst_listitem_extras.qml

  • Committer: Zsombor Egri
  • Date: 2015-11-16 06:35:05 UTC
  • mfrom: (1664.1.1 listitemSelectModeBugs)
  • Revision ID: zsombor.egri@canonical.com-20151116063505-cwn2qfks7qzk10g9
re-sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
                leadingActions: leading
97
97
            }
98
98
        }
 
99
        ListItem {
 
100
            id: emptyActionList
 
101
            leadingActions: ListItemActions {}
 
102
            trailingActions: ListItemActions {
 
103
                actions: []
 
104
            }
 
105
        }
 
106
        ListItem {
 
107
            id: contentDragging
 
108
            swipeEnabled: ma.drag.active
 
109
            Rectangle {
 
110
                id: draggedItem
 
111
                width: units.gu(2)
 
112
                height: width
 
113
                color: "red"
 
114
                MouseArea {
 
115
                    id: ma
 
116
                    anchors.fill: parent
 
117
                    drag.target: parent
 
118
                }
 
119
            }
 
120
        }
99
121
    }
100
122
 
101
123
    ListItemTestCase13 {
246
268
            }
247
269
            clickSpy.wait(200);
248
270
        }
 
271
 
 
272
        function test_swipe_on_empty_actions_bug1500416_data() {
 
273
            return [
 
274
                {tag: "swipe leading, touch", item: emptyActionList, dx: units.gu(5), touch: true},
 
275
                {tag: "swipe trailing, touch", item: emptyActionList, dx: -units.gu(5), touch: true},
 
276
                {tag: "swipe leading, mouse", item: emptyActionList, dx: units.gu(5), touch: false},
 
277
                {tag: "swipe trailing, mouse", item: emptyActionList, dx: -units.gu(5), touch: false}
 
278
            ];
 
279
        }
 
280
        function test_swipe_on_empty_actions_bug1500416(data) {
 
281
            setupSpy(data.item, "contentMovementEnded");
 
282
            if (data.touch) {
 
283
                tugNoWait(data.item, centerOf(data.item).x, centerOf(data.item).y, data.dx, 0);
 
284
            } else {
 
285
                swipeNoWait(data.item, centerOf(data.item).x, centerOf(data.item).y, data.dx, 0);
 
286
            }
 
287
            expectFailContinue(data.tag, "No swipe should happen");
 
288
            spyWait(200);
 
289
        }
 
290
 
 
291
        function test_swipe_not_possible_when_swipe_disabled_data() {
 
292
            listView.positionViewAtBeginning();
 
293
            return [
 
294
                {tag: "leading, touch", item: findChild(listView, "listItem0"), dx: units.gu(10), touch: true},
 
295
                {tag: "trailing, touch", item: findChild(listView, "listItem0"), dx: -units.gu(10), touch: true},
 
296
                {tag: "leading, mouse", item: findChild(listView, "listItem0"), dx: units.gu(10), touch: false},
 
297
                {tag: "trailing, mouse", item: findChild(listView, "listItem0"), dx: -units.gu(10), touch: false},
 
298
            ];
 
299
        }
 
300
        function test_swipe_not_possible_when_swipe_disabled(data) {
 
301
            verify(data.item, "test item not found");
 
302
            data.item.swipeEnabled = false;
 
303
            setupSpy(data.item, "contentMovementEnded");
 
304
            if (data.touch) {
 
305
                tugNoWait(data.item, centerOf(data.item).x, centerOf(data.item).y, data.dx, 0);
 
306
            } else {
 
307
                swipeNoWait(data.item, centerOf(data.item).x, centerOf(data.item).y, data.dx, 0);
 
308
            }
 
309
            expectFailContinue(data.tag, "No swipe should happen");
 
310
            spyWait(200);
 
311
            data.item.swipeEnabled = true;
 
312
        }
 
313
 
 
314
        function test_drag_listitem_content_bug1500409_data() {
 
315
            return [
 
316
                {tag: "touch", touch: true},
 
317
                {tag: "mouse", touch: false}
 
318
            ];
 
319
        }
 
320
        function test_drag_listitem_content_bug1500409(data) {
 
321
            setupSpy(contentDragging, "contentMovementStarted");
 
322
            if (data.touch) {
 
323
                TestExtras.touchDrag(0, draggedItem, centerOf(draggedItem), Qt.point(units.gu(10), units.gu(3)));
 
324
            } else {
 
325
                mouseDrag(draggedItem, centerOf(draggedItem).x, centerOf(draggedItem).y, units.gu(10), units.gu(3));
 
326
            }
 
327
            expectFailContinue("", "drag disables swipe");
 
328
            spyWait(200);
 
329
        }
249
330
    }
250
331
}