on xenial help sign in
Ensure tutorial doesn't let user drag the launcher past screen edge.

This was because the bouncing animation on the left added a bit of extra offset to the launcher. So I just made sure that offset doesn't go past the screen edge as the user drags the launcher out. And added a test.

commit430e06519ebc0df9617244546e1928eb3906bcb6 authorDaniel d'Andrada <dandrader@panzer> dateThu 2 Jul 2015, 13:13 (11 years ago) parentef843beff623b9
2 files changed+47−7
qml/Tutorial/TutorialLeft.qml+16−6 tests/qmltests/Tutorial/tst_Tutorial.qml+31−1
qml/Tutorial/TutorialLeft.qml+16−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014,2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -46,24 +46,34 @@ TutorialPage {
4646
4747 SequentialAnimation {
4848 id: teaseAnimation
49+ objectName: "teaseAnimation"
4950 paused: running && root.paused
5051 running: !slider.active && root.launcher.visibleWidth === 0 && root.shown
5152 loops: Animation.Infinite
53+ property real bounce: 0
54+ readonly property real maxBounce: units.gu(2)
5255
5356 UbuntuNumberAnimation {
54− target: root.launcher
55− property: "x"
56− to: units.gu(2)
57+ target: teaseAnimation
58+ property: "bounce"
59+ to: teaseAnimation.maxBounce
5760 duration: UbuntuAnimation.SleepyDuration
5861 }
5962 UbuntuNumberAnimation {
60− target: root.launcher
61− property: "x"
63+ target: teaseAnimation
64+ property: "bounce"
6265 to: 0
6366 duration: UbuntuAnimation.SleepyDuration
6467 }
6568 }
6669
70+ Binding {
71+ target: root.launcher
72+ when: root.shown
73+ property: "x"
74+ value: Math.min(root.launcher.panelWidth - root.launcher.visibleWidth, teaseAnimation.bounce)
75+ }
76+
6777 Timer {
6878 id: finishTimer
6979 interval: 1
tests/qmltests/Tutorial/tst_Tutorial.qml+31−1
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013,2014 Canonical, Ltd.
2+ * Copyright (C) 2013,2014,2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -319,6 +319,36 @@ Item {
319319 tryCompare(left, "shown", true); // and we should still be on left
320320 }
321321
322+ function test_launcherNoDragGap() {
323+ // See bug 1454882, where if you dragged the launcher while it was
324+ // visible, you could pull it further than the edge of the screen.
325+
326+ var left = goToPage("tutorialLeft");
327+ var launcher = findChild(shell, "launcher");
328+ var teaseAnimation = findInvisibleChild(left, "teaseAnimation");
329+
330+ // Wait for launcher to be really out there
331+ tryCompareFunction(function() {return launcher.x > teaseAnimation.maxBounce/2}, true);
332+ verify(teaseAnimation.running);
333+
334+ // Start a drag, make sure animation stops
335+ touchFlick(shell, 0, halfHeight, units.gu(3), halfHeight, true, false);
336+ verify(!teaseAnimation.running);
337+ verify(launcher.visibleWidth > 0);
338+ verify(launcher.x > 0);
339+ compare(launcher.x, teaseAnimation.bounce);
340+
341+ // Continue drag, make sure we don't create a gap on the left hand side
342+ touchFlick(shell, units.gu(3), halfHeight, shell.width, halfHeight, false, false);
343+ verify(!teaseAnimation.running);
344+ compare(launcher.visibleWidth, launcher.panelWidth);
345+ compare(launcher.x, 0);
346+
347+ // Finish and make sure we continue animation
348+ touchFlick(shell, shell.width, halfHeight, shell.width, halfHeight, false, true);
349+ tryCompare(teaseAnimation, "running", true);
350+ }
351+
322352 function test_spread() {
323353 // Unfortunately, most of what we want to test of the spread is
324354 // "did it render correctly?" but that's hard to test. So instead,