Merge lp:~dandrader/unity8/shouldNotRotate-lp1476757 into lp:unity8

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Michael Zanetti
Approved revision: 1971
Merged at revision: 1984
Proposed branch: lp:~dandrader/unity8/shouldNotRotate-lp1476757
Merge into: lp:unity8
Diff against target: 201 lines (+122/-9)
3 files modified
qml/Stages/PhoneStage.qml (+15/-7)
qml/Stages/SpreadDelegate.qml (+1/-1)
tests/qmltests/tst_OrientedShell.qml (+106/-1)
To merge this branch: bzr merge lp:~dandrader/unity8/shouldNotRotate-lp1476757
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michael Zanetti (community) Approve
Review via email: mp+271814@code.launchpad.net

Commit message

PhoneStage: ensure you're left in a consistent state after being reset

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
No

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

* Did you make sure that your branch does not contain spurious tags?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable

* If you changed the UI, has there been a design review?
Not applicable

To post a comment you must log in.
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Change makes sense, fixes the bug.

 * Did you perform an exploratory manual test run of the code change and any related functionality?

yes

 * Did CI run pass? If not, please explain why.

waiting

 * Did you make sure that the branch does not contain spurious tags?

yes

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1971
http://jenkins.qa.ubuntu.com/job/unity8-ci/6328/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4290
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/699
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1040
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/358
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/935
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/936
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/567
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/568
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3496
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4287
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4287/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23538
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/414
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/699
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/699/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23539

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6328/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Stages/PhoneStage.qml'
2--- qml/Stages/PhoneStage.qml 2015-08-03 13:47:44 +0000
3+++ qml/Stages/PhoneStage.qml 2015-09-21 13:52:42 +0000
4@@ -48,17 +48,12 @@
5 onBeingResizedChanged: {
6 if (beingResized) {
7 // Brace yourselves for impact!
8- spreadView.selectedIndex = -1;
9- spreadView.phase = 0;
10- spreadView.contentX = -spreadView.shift;
11+ priv.reset();
12 }
13 }
14 onSpreadEnabledChanged: {
15 if (!spreadEnabled) {
16- // reset. go back to display the focused app
17- spreadView.selectedIndex = -1;
18- spreadView.phase = 0;
19- spreadView.contentX = -spreadView.shift;
20+ priv.reset();
21 }
22 }
23 function updateFocusedAppOrientation() {
24@@ -94,6 +89,7 @@
25 readonly property var mainApp: applicationManager.focusedApplicationId
26 ? applicationManager.findApplication(applicationManager.focusedApplicationId)
27 : null
28+
29 property int mainAppWindowOrientationAngle: 0
30 readonly property bool orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
31 && !priv.focusedAppDelegateIsDislocated
32@@ -216,6 +212,18 @@
33 // Is more stable than "spreadView.shiftedContentX === 0" as it filters out noise caused by
34 // Flickable.contentX changing due to resizes.
35 property bool fullyShowingFocusedApp: true
36+
37+ function reset() {
38+ // The app that's about to go to foreground has to be focused, otherwise
39+ // it would leave us in an inconsistent state.
40+ if (!root.applicationManager.focusedApplicationId && root.applicationManager.count > 0) {
41+ root.applicationManager.focusApplication(root.applicationManager.get(0).appId);
42+ }
43+
44+ spreadView.selectedIndex = -1;
45+ spreadView.phase = 0;
46+ spreadView.contentX = -spreadView.shift;
47+ }
48 }
49 Timer {
50 id: fullyShowingFocusedAppUpdateTimer
51
52=== modified file 'qml/Stages/SpreadDelegate.qml'
53--- qml/Stages/SpreadDelegate.qml 2015-07-10 15:55:50 +0000
54+++ qml/Stages/SpreadDelegate.qml 2015-09-21 13:52:42 +0000
55@@ -268,7 +268,7 @@
56 focus: true
57 anchors {
58 fill: parent
59- topMargin: appWindow.fullscreen || application.rotatesWindowContents
60+ topMargin: appWindow.fullscreen || (application && application.rotatesWindowContents)
61 ? 0 : maximizedAppTopMargin
62 }
63
64
65=== modified file 'tests/qmltests/tst_OrientedShell.qml'
66--- tests/qmltests/tst_OrientedShell.qml 2015-09-02 13:42:24 +0000
67+++ tests/qmltests/tst_OrientedShell.qml 2015-09-21 13:52:42 +0000
68@@ -996,6 +996,60 @@
69 tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
70 }
71
72+ /*
73+ Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1476757
74+
75+ Steps:
76+ 1- have a portrait-only app in foreground (eg unity8-dash)
77+ 2- launch or switch to some other application
78+ 3- right-edge swipe to show the apps spread
79+ 4- swipe up to close the current app (the one from step 2)
80+ 5- lock the phone (press the power button)
81+ 6- unlock the phone (press power button again and swipe greeter away)
82+ * app from step 1 should be on foreground and focused
83+ 7- rotate phone
84+
85+ Expected outcome:
86+ - The portrait-only application stays put
87+
88+ Actual outcome:
89+ - The portrait-only application rotates freely
90+ */
91+ function test_lockPhoneAfterClosingAppInSpreadThenUnlockAndRotate() {
92+ loadShell("mako");
93+
94+ var gmailApp = ApplicationManager.startApplication("gmail-webapp");
95+ verify(gmailApp);
96+
97+ waitUntilAppSurfaceShowsUp("gmail-webapp");
98+
99+ performEdgeSwipeToShowAppSpread();
100+
101+ swipeToCloseCurrentAppInSpread();
102+
103+ // press the power key once
104+ Powerd.setStatus(Powerd.Off, Powerd.Unknown);
105+ var greeter = findChild(shell, "greeter");
106+ tryCompare(greeter, "fullyShown", true);
107+
108+ // and a second time to turn the display back on
109+ Powerd.setStatus(Powerd.On, Powerd.Unknown);
110+
111+ swipeAwayGreeter();
112+
113+ verify(isAppSurfaceFocused("unity8-dash"))
114+
115+ signalSpy.clear();
116+ signalSpy.target = shell;
117+ signalSpy.signalName = "widthChanged";
118+ verify(signalSpy.valid);
119+
120+ rotateTo(90);
121+
122+ // shell shouldn't have change its orientation at any moment
123+ compare(signalSpy.count, 0);
124+ }
125+
126 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
127 function rotateTo(angle) {
128 switch (angle) {
129@@ -1016,6 +1070,12 @@
130 }
131
132 var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
133+ verify(rotationStates.d);
134+ verify(rotationStates.d.stateUpdateTimer);
135+
136+ // wait for the delayed state update to take place, if any
137+ tryCompare(rotationStates.d.stateUpdateTimer, "running", false);
138+
139 waitUntilTransitionsEnd(rotationStates);
140 }
141
142@@ -1239,7 +1299,6 @@
143 var childs = new Array(0);
144 childs.push(obj)
145 while (childs.length > 0) {
146- console.log("Checking " + childs[0].objectName);
147 if (childs[0].objectName === "surfaceItem"
148 && childs[0].surface !== undefined
149 && childs[0].surface === surface) {
150@@ -1252,5 +1311,51 @@
151 }
152 return null;
153 }
154+
155+ function swipeToCloseCurrentAppInSpread() {
156+ var spreadView = findChild(shell, "spreadView");
157+ verify(spreadView);
158+
159+ var delegateToClose = findChild(spreadView, "appDelegate0");
160+ verify(delegateToClose);
161+
162+ var appIdToClose = ApplicationManager.get(0).appId;;
163+ var appCountBefore = ApplicationManager.count;
164+
165+ // ensure the current app is widely visible by swiping to the right,
166+ // which will move the app windows accordingly
167+ touchFlick(shell,
168+ shell.width * 0.25, shell.width / 2,
169+ shell.width, shell.width / 2);
170+
171+ tryCompare(spreadView, "flicking", false);
172+ tryCompare(spreadView, "moving", false);
173+
174+ // Swipe up close to its left edge, as it is the only area of it guaranteed to be exposed
175+ // in the spread. Eg: its center could be covered by some other delegate.
176+ touchFlick(delegateToClose,
177+ 1, delegateToClose.height / 2,
178+ 1, - delegateToClose.height / 4);
179+
180+ // ensure it got closed
181+ tryCompare(ApplicationManager, "count", appCountBefore - 1);
182+ compare(ApplicationManager.findApplication(appIdToClose), null);
183+ }
184+
185+ function isAppSurfaceFocused(appId) {
186+ var appWindow = findChild(shell, "appWindow_" + appId);
187+ verify(appWindow);
188+
189+ var app = ApplicationManager.findApplication(appId);
190+ verify(app);
191+
192+ var surface = app.session.surface;
193+ verify(surface);
194+
195+ var surfaceItem = findSurfaceItem(appWindow, surface);
196+ verify(surfaceItem);
197+
198+ return surfaceItem.activeFocus;
199+ }
200 }
201 }

Subscribers

People subscribed via source and target branches