@@ -234,6 +234,12 @@ Item {
234234 }
235235 }
236236
237+ Binding {
238+ target: LightDM.Infographic
239+ property: "username"
240+ value: "single"
241+ }
242+
237243 SignalSpy {
238244 id: selectedSpy
239245 target: loader.item
@@ -258,6 +264,12 @@ Item {
258264 signalName: "emergencyCall"
259265 }
260266
267+ SignalSpy {
268+ id: infographicDataChangedSpy
269+ target: LightDM.Infographic
270+ signalName: "dataChanged"
271+ }
272+
261273 UT.UnityTestCase {
262274 name: "WideView"
263275 when: windowShown
@@ -266,10 +278,12 @@ Item {
266278
267279 function init() {
268280 view.currentIndex = 0; // break binding with text field
281+
269282 selectedSpy.clear();
270283 respondedSpy.clear();
271284 teaseSpy.clear();
272285 emergencySpy.clear();
286+ infographicDataChangedSpy.clear();
273287 }
274288
275289 function cleanup() {
@@ -283,10 +297,18 @@ Item {
283297 removeTimeConstraintsFromDirectionalDragAreas(loader.item);
284298 }
285299
286− function swipeAwayCover() {
300+ function swipeAwayCover(toTheRight) {
301+ if (toTheRight === undefined) {
302+ toTheRight = false;
303+ }
304+
287305 tryCompare(view, "fullyShown", true);
288306 var touchY = view.height / 2;
289− touchFlick(view, view.width, touchY, 0, touchY);
307+ if (toTheRight) {
308+ touchFlick(view, 0, touchY, view.width, touchY);
309+ } else {
310+ touchFlick(view, view.width, touchY, 0, touchY);
311+ }
290312 var coverPage = findChild(view, "coverPage");
291313 tryCompare(coverPage, "showProgress", 0);
292314 waitForRendering(view);
@@ -300,9 +322,18 @@ Item {
300322 }
301323 }
302324
303− function test_tease() {
304− tap(view, 1, 1);
305− compare(teaseSpy.count, 1);
325+ function test_tease_data() {
326+ return [
327+ {tag: "left", x: 0, offset: 0, count: 1},
328+ {tag: "leftWithOffsetPass", x: 10, offset: 10, count: 1},
329+ {tag: "leftWithOffsetFail", x: 9, offset: 10, count: 0},
330+ {tag: "right", x: view.width, offset: 0, count: 1}
331+ ]
332+ }
333+ function test_tease(data) {
334+ view.dragHandleLeftMargin = data.offset;
335+ tap(view, data.x, 0);
336+ compare(teaseSpy.count, data.count);
306337 }
307338
308339 function test_respondedWithPin() {
@@ -323,8 +354,16 @@ Item {
323354 compare(respondedSpy.signalArguments[0][0], "test");
324355 }
325356
326− function test_respondedWithSwipe() {
327− swipeAwayCover();
357+ function test_respondedWithSwipe_data() {
358+ return [
359+ {tag: "left", toTheRight: false, hiddenX: -view.width},
360+ {tag: "right", toTheRight: true, hiddenX: view.width},
361+ ];
362+ }
363+ function test_respondedWithSwipe(data) {
364+ swipeAwayCover(data.toTheRight);
365+ var coverPage = findChild(view, "coverPage");
366+ compare(coverPage.x, data.hiddenX);
328367 compare(respondedSpy.count, 1);
329368 compare(respondedSpy.signalArguments[0][0], "");
330369 }
@@ -356,5 +395,61 @@ Item {
356395 view.locked = false;
357396 tryCompare(view, "required", false);
358397 }
398+
399+ /*
400+ Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1388359
401+ "User metrics can no longer be changed by double tap"
402+ */
403+ function test_doubleTapSwitchesToNextInfographic() {
404+ var infographicPrivate = findInvisibleChild(view, "infographicPrivate");
405+ verify(infographicPrivate);
406+
407+ // wait for the UI to settle down before double tapping it
408+ tryCompare(infographicPrivate, "animating", false);
409+
410+ var dataCircle = findChild(view, "dataCircle");
411+ verify(dataCircle);
412+
413+ tap(dataCircle);
414+ wait(1);
415+ tap(dataCircle);
416+
417+ tryCompare(infographicDataChangedSpy, "count", 1);
418+ }
419+
420+ function test_movesBackIntoPlaceWhenNotDraggedFarEnough() {
421+ var coverPage = findChild(view, "coverPage");
422+
423+ var dragEvaluator = findInvisibleChild(coverPage, "edgeDragEvaluator");
424+ verify(dragEvaluator);
425+
426+ // Make it easier to get a rejection/rollback. Otherwise would have to inject
427+ // a fake timer into dragEvaluator.
428+ // Afterall, we are testing if the CoverPage indeed moves back on a
429+ // rollback decision, not the drag evaluation itself.
430+ dragEvaluator.minDragDistance = dragEvaluator.maxDragDistance / 2;
431+
432+ // it starts as fully shown
433+ compare(coverPage.x, 0);
434+
435+ // then we drag it a bit
436+ var startX = coverPage.width - 1;
437+ var touchY = coverPage.height / 2;
438+ var dragXDelta = -(dragEvaluator.minDragDistance * 0.3);
439+ touchFlick(coverPage,
440+ startX , touchY, // start pos
441+ startX + dragXDelta, touchY, // end pos
442+ true /* beginTouch */, false /* endTouch */);
443+
444+ // which should make it move a bit
445+ tryCompareFunction(function() {return coverPage.x < 0;}, true);
446+
447+ // then we release it
448+ touchRelease(coverPage, startX + dragXDelta, touchY);
449+
450+ // which should make it move back into its original position as it didn't move
451+ // far enough to have it hidden
452+ tryCompare(coverPage, "x", 0);
453+ }
359454 }
360455}