@@ -129,6 +129,12 @@ Rectangle {
129129 }
130130 }
131131
132+ SignalSpy {
133+ id: stageSaver
134+ target: WindowStateStorage
135+ signalName: "stageSaved"
136+ }
137+
132138 UnityTestCase {
133139 id: testCase
134140 name: "TabletStage"
@@ -138,6 +144,7 @@ Rectangle {
138144 property Item sideStage: tabletStage ? findChild(tabletStage, "sideStage") : null
139145
140146 function init() {
147+ stageSaver.clear();
141148 tabletStageLoader.active = true;
142149 tryCompare(tabletStageLoader, "status", Loader.Ready);
143150
@@ -510,7 +517,35 @@ Rectangle {
510517 tryCompare(stagesPriv, "sideStageAppId", data.sideStageAppId);
511518 }
512519
513− function test_loadSideStageByDragginFromMainStage() {
520+ function test_applicationSavesLastStage_data() {
521+ return [
522+ { tag: "MainStage", stage: ApplicationInfoInterface.MainStage},
523+ { tag: "SideStage", stage: ApplicationInfoInterface.SideStage},
524+ ];
525+ }
526+
527+ function test_applicationSavesLastStage(data) {
528+ WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage);
529+ stageSaver.clear();
530+
531+ var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
532+ verify(stagesPriv);
533+
534+ tryCompare(stagesPriv, "mainStageAppId", "unity8-dash");
535+ tryCompare(stagesPriv, "sideStageAppId", "");
536+
537+ var webbrowserSurfaceId = topSurfaceList.nextId;
538+ webbrowserCheckBox.checked = true;
539+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
540+
541+ webbrowserCheckBox.checked = false;
542+
543+ tryCompare(stageSaver, "count", 1);
544+ compare(stageSaver.signalArguments[0][0], "webbrowser-app")
545+ compare(stageSaver.signalArguments[0][1], data.stage)
546+ }
547+
548+ function test_loadSideStageByDraggingFromMainStage() {
514549 sideStage.showNow();
515550 var webbrowserSurfaceId = topSurfaceList.nextId;
516551 webbrowserCheckBox.checked = true;
@@ -538,7 +573,7 @@ Rectangle {
538573 tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
539574 }
540575
541− function test_unloadSideStageByDragginFromStageStage() {
576+ function test_unloadSideStageByDraggingFromStageStage() {
542577 sideStage.showNow();
543578 WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
544579 var webbrowserSurfaceId = topSurfaceList.nextId;
@@ -690,5 +725,34 @@ Rectangle {
690725 // only unity8-dash surface is left
691726 compare(topSurfaceList.count, 1);
692727 }
728+
729+ function test_draggingSurfaceKeepsSurfaceFocus() {
730+ var webbrowserSurfaceId = topSurfaceList.nextId;
731+ webbrowserCheckBox.checked = true;
732+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
733+
734+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
735+ verify(appDelegate);
736+ compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
737+
738+ tryCompare(appDelegate.surface, "activeFocus", true);
739+
740+ var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
741+ var end_pos = tabletStage.width - sideStage.width / 2;
742+
743+ multiTouchDragUntil([0,1,2],
744+ tabletStage,
745+ pos,
746+ tabletStage.height / 2,
747+ units.gu(3),
748+ 0,
749+ function() {
750+ pos += units.gu(3);
751+ return sideStage.shown && !sideStage.showAnimation.running &&
752+ pos >= end_pos;
753+ });
754+
755+ tryCompare(appDelegate.surface, "activeFocus", true);
756+ }
693757 }
694758}