on xenial help sign in
Merge lp:~mterry/unity8/tutorial-launcher-gap
ed94002Daniel d'Andrada
qml/Tutorial/TutorialLeft.qml+15−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014,2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -46,24 +46,33 @@ TutorialPage {
46
46
47 SequentialAnimation {
47 SequentialAnimation {
48 id: teaseAnimation
48 id: teaseAnimation
49+ objectName: "teaseAnimation"
49 paused: running && root.paused
50 paused: running && root.paused
50 running: !slider.active && root.launcher.visibleWidth === 0 && root.shown
51 running: !slider.active && root.launcher.visibleWidth === 0 && root.shown
51 loops: Animation.Infinite
52 loops: Animation.Infinite
53+ property real bounce: 0
54+ readonly property real maxBounce: units.gu(2)
52
55
53 UbuntuNumberAnimation {
56 UbuntuNumberAnimation {
54− target: root.launcher
57+ target: teaseAnimation
55− property: "x"
58+ property: "bounce"
56− to: units.gu(2)
59+ to: teaseAnimation.maxBounce
57 duration: UbuntuAnimation.SleepyDuration
60 duration: UbuntuAnimation.SleepyDuration
58 }
61 }
59 UbuntuNumberAnimation {
62 UbuntuNumberAnimation {
60− target: root.launcher
63+ target: teaseAnimation
61− property: "x"
64+ property: "bounce"
62 to: 0
65 to: 0
63 duration: UbuntuAnimation.SleepyDuration
66 duration: UbuntuAnimation.SleepyDuration
64 }
67 }
65 }
68 }
66
69
70+ Binding {
71+ target: root.launcher
72+ property: "x"
73+ value: Math.min(root.launcher.panelWidth - root.launcher.visibleWidth, teaseAnimation.bounce)
74+ }
75+
67 Timer {
76 Timer {
68 id: finishTimer
77 id: finishTimer
69 interval: 1
78 interval: 1
tests/qmltests/Tutorial/tst_Tutorial.qml+31−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013,2014 Canonical, Ltd.
2+ * Copyright (C) 2013,2014,2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -325,6 +325,36 @@ Item {
325 tryCompare(left, "shown", true); // and we should still be on left
325 tryCompare(left, "shown", true); // and we should still be on left
326 }
326 }
327
327
328+ function test_launcherNoDragGap() {
329+ // See bug 1454882, where if you dragged the launcher while it was
330+ // visible, you could pull it further than the edge of the screen.
331+
332+ var left = goToPage("tutorialLeft");
333+ var launcher = findChild(shell, "launcher");
334+ var teaseAnimation = findInvisibleChild(left, "teaseAnimation");
335+
336+ // Wait for launcher to be really out there
337+ tryCompareFunction(function() {return launcher.x > teaseAnimation.maxBounce/2}, true);
338+ verify(teaseAnimation.running);
339+
340+ // Start a drag, make sure animation stops
341+ touchFlick(shell, 0, halfHeight, units.gu(3), halfHeight, true, false);
342+ verify(!teaseAnimation.running);
343+ verify(launcher.visibleWidth > 0);
344+ verify(launcher.x > 0);
345+ compare(launcher.x, teaseAnimation.bounce);
346+
347+ // Continue drag, make sure we don't create a gap on the left hand side
348+ touchFlick(shell, units.gu(3), halfHeight, shell.width, halfHeight, false, false);
349+ verify(!teaseAnimation.running);
350+ compare(launcher.visibleWidth, launcher.panelWidth);
351+ compare(launcher.x, 0);
352+
353+ // Finish and make sure we continue animation
354+ touchFlick(shell, shell.width, halfHeight, shell.width, halfHeight, false, true);
355+ tryCompare(teaseAnimation, "running", true);
356+ }
357+
328 function test_spread() {
358 function test_spread() {
329 // Unfortunately, most of what we want to test of the spread is
359 // Unfortunately, most of what we want to test of the spread is
330 // "did it render correctly?" but that's hard to test. So instead,
360 // "did it render correctly?" but that's hard to test. So instead,