@@ -42,7 +42,7 @@ Item {
42 anchors { fill: parent; rightMargin: units.gu(30) }
42 anchors { fill: parent; rightMargin: units.gu(30) }
43 focus: true
43 focus: true
44 dragAreaWidth: units.gu(2)
44 dragAreaWidth: units.gu(2)
45− interactive: true
45+ allowInteractivity: true
46 shellOrientation: Qt.PortraitOrientation
46 shellOrientation: Qt.PortraitOrientation
47 orientations: Orientations {}
47 orientations: Orientations {}
48 applicationManager: ApplicationManager
48 applicationManager: ApplicationManager
@@ -210,7 +210,7 @@ Item {
211 {tag: "<breakPoint (trigger)", progress: .2, cancel: false, endState: "staged", newFocusedIndex: 1 },
211 {tag: "<breakPoint (trigger)", progress: .2, cancel: false, endState: "staged", newFocusedIndex: 1 },
212 {tag: "<breakPoint (cancel)", progress: .2, cancel: true, endState: "staged", newFocusedIndex: 0 },
212 {tag: "<breakPoint (cancel)", progress: .2, cancel: true, endState: "staged", newFocusedIndex: 0 },
213− {tag: ">breakPoint (trigger)", progress: .5, cancel: false, endState: "spread", newFocusedIndex: 0 },
213+ {tag: ">breakPoint (trigger)", progress: .5, cancel: false, endState: "spread", newFocusedIndex: null },
214 {tag: ">breakPoint (cancel)", progress: .8, cancel: true, endState: "staged", newFocusedIndex: 0 },
214 {tag: ">breakPoint (cancel)", progress: .8, cancel: true, endState: "staged", newFocusedIndex: 0 },
@@ -225,7 +225,6 @@ Item {
225 var endY = startY;
225 var endY = startY;
226 var endX = stage.width - (stage.width * data.progress) - stage.dragAreaWidth;
226 var endX = stage.width - (stage.width * data.progress) - stage.dragAreaWidth;
228− var oldFocusedApp = ApplicationManager.get(0);
229 var newFocusedApp = ApplicationManager.get(data.newFocusedIndex);
228 var newFocusedApp = ApplicationManager.get(data.newFocusedIndex);
231 touchFlick(stage, startX, startY, endX, endY,
230 touchFlick(stage, startX, startY, endX, endY,
@@ -238,7 +237,7 @@ Item {
238 touchRelease(stage, endX, endY); }
237 touchRelease(stage, endX, endY); }
240 tryCompare(stage, "state", data.endState);
239 tryCompare(stage, "state", data.endState);
241− tryCompare(ApplicationManager, "focusedApplicationId", data.endState == "spread" ? oldFocusedApp.appId : newFocusedApp.appId);
240+ tryCompare(ApplicationManager, "focusedApplicationId", data.endState == "spread" ? "" : newFocusedApp.appId);
244 function test_selectAppFromSpread_data() {
243 function test_selectAppFromSpread_data() {
@@ -583,5 +582,32 @@ Item {
583 compare(topLevelSurfaceList.idAt(0), webbrowserSurfaceId);
582 compare(topLevelSurfaceList.idAt(0), webbrowserSurfaceId);
584 compare(webbrowserApp.focused, true);
583 compare(webbrowserApp.focused, true);
587+ Ensure that closing a surface while rootFocus is off focuses the
588+ next available surface when rootFocus is given back.
590+ Regression test for https://github.com/ubports/unity8/issues/234
592+ This cannot be tested in tst_TopLevelWindowModel.cpp, the mocks for
593+ it are not advanced enough.
595+ function test_closeFocusedAppWithSpreadOpen()
597+ var dashApp = ApplicationManager.findApplication("unity8-dash");
598+ var webbrowserSurfaceId = topLevelSurfaceList.nextId;
599+ var webbrowserApp = ApplicationManager.startApplication("morph-browser");
600+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
602+ topLevelSurfaceList.rootFocus = false;
604+ performEdgeSwipeToShowAppSpread();
606+ swipeSurfaceUpwards(webbrowserSurfaceId);
607+ tryCompareFunction(function() { return topLevelSurfaceList.indexForId(webbrowserSurfaceId); }, -1);
609+ topLevelSurfaceList.rootFocus = true;
610+ compare(dashApp.focused, true);