@@ -242,6 +242,48 @@ Rectangle {
242 appWindow.width * 0.1, -appWindow.height / 2);
242 appWindow.width * 0.1, -appWindow.height / 2);
245+ function dragToSideStage(surfaceId) {
246+ sideStage.showNow();
247+ var targetAppDelegate = findChild(tabletStage, "spreadDelegate_" + surfaceId);
249+ var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
250+ var end_pos = tabletStage.width - sideStage.width / 2;
252+ multiTouchDragUntil([0,1,2],
255+ tabletStage.height / 2,
260+ return sideStage.shown && !sideStage.showAnimation.running &&
263+ tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.SideStage);
266+ function dragToMainStage(surfaceId) {
267+ sideStage.showNow();
268+ var targetAppDelegate = findChild(tabletStage, "spreadDelegate_" + surfaceId);
269+ verify(targetAppDelegate);
271+ var pos = tabletStage.width - sideStage.width / 2;
272+ var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
274+ multiTouchDragUntil([0,1,2],
277+ tabletStage.height / 2,
282+ return pos <= end_pos;
284+ tryCompare(targetAppDelegate, "stage", ApplicationInfoInterface.MainStage);
245 function test_tappingSwitchesFocusBetweenStages() {
287 function test_tappingSwitchesFocusBetweenStages() {
246 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
288 WindowStateStorage.saveStage(dialerCheckBox.appId, ApplicationInfoInterface.SideStage)
@@ -519,13 +561,13 @@ Rectangle {
520 function test_applicationSavesLastStage_data() {
562 function test_applicationSavesLastStage_data() {
522− { tag: "MainStage", stage: ApplicationInfoInterface.MainStage},
564+ { tag: "MainStage", fromStage: ApplicationInfoInterface.MainStage, toStage: ApplicationInfoInterface.SideStage },
523− { tag: "SideStage", stage: ApplicationInfoInterface.SideStage},
565+ { tag: "SideStage", fromStage: ApplicationInfoInterface.SideStage, toStage: ApplicationInfoInterface.MainStage },
527 function test_applicationSavesLastStage(data) {
569 function test_applicationSavesLastStage(data) {
528− WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.stage);
570+ WindowStateStorage.saveStage(webbrowserCheckBox.appId, data.fromStage);
529 stageSaver.clear();
571 stageSaver.clear();
531 var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
573 var stagesPriv = findInvisibleChild(tabletStage, "stagesPriv");
@@ -538,11 +580,15 @@ Rectangle {
538 webbrowserCheckBox.checked = true;
580 webbrowserCheckBox.checked = true;
539 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
581 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
541− webbrowserCheckBox.checked = false;
583+ if (data.toStage === ApplicationInfoInterface.SideStage) {
584+ dragToSideStage(webbrowserSurfaceId);
586+ dragToMainStage(webbrowserSurfaceId);
543 tryCompare(stageSaver, "count", 1);
589 tryCompare(stageSaver, "count", 1);
544 compare(stageSaver.signalArguments[0][0], "webbrowser-app")
590 compare(stageSaver.signalArguments[0][0], "webbrowser-app")
545− compare(stageSaver.signalArguments[0][1], data.stage)
591+ compare(stageSaver.signalArguments[0][1], data.toStage)
548 function test_loadSideStageByDraggingFromMainStage() {
594 function test_loadSideStageByDraggingFromMainStage() {
@@ -555,20 +601,7 @@ Rectangle {
555 verify(appDelegate);
601 verify(appDelegate);
556 compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
602 compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
558− var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
604+ dragToSideStage(webbrowserSurfaceId);
559− var end_pos = tabletStage.width - sideStage.width / 2;
561− multiTouchDragUntil([0,1,2],
564− tabletStage.height / 2,
569− return sideStage.shown && !sideStage.showAnimation.running &&
573 var spreadView = findChild(tabletStageLoader, "spreadView")
606 var spreadView = findChild(tabletStageLoader, "spreadView")
574 tryCompare(spreadView, "surfaceDragging", false);
607 tryCompare(spreadView, "surfaceDragging", false);
@@ -586,19 +619,7 @@ Rectangle {
586 verify(appDelegate);
619 verify(appDelegate);
587 compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
620 compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
589− var pos = tabletStage.width - sideStage.width / 2;
622+ dragToMainStage(webbrowserSurfaceId);
590− var end_pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
592− multiTouchDragUntil([0,1,2],
595− tabletStage.height / 2,
600− return pos <= end_pos;
603 var spreadView = findChild(tabletStageLoader, "spreadView")
624 var spreadView = findChild(tabletStageLoader, "spreadView")
604 tryCompare(spreadView, "surfaceDragging", false);
625 tryCompare(spreadView, "surfaceDragging", false);
@@ -741,20 +762,7 @@ Rectangle {
742 tryCompare(appDelegate.surface, "activeFocus", true);
763 tryCompare(appDelegate.surface, "activeFocus", true);
744− var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
765+ dragToSideStage(webbrowserSurfaceId);
745− var end_pos = tabletStage.width - sideStage.width / 2;
747− multiTouchDragUntil([0,1,2],
750− tabletStage.height / 2,
755− return sideStage.shown && !sideStage.showAnimation.running &&
759 var spreadView = findChild(tabletStageLoader, "spreadView")
767 var spreadView = findChild(tabletStageLoader, "spreadView")
760 tryCompare(spreadView, "surfaceDragging", false);
768 tryCompare(spreadView, "surfaceDragging", false);
@@ -789,5 +797,67 @@ Rectangle {
789 tryCompare(spreadView, "surfaceDragging", false);
797 tryCompare(spreadView, "surfaceDragging", false);
790 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
798 tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
801+ function test_switchStageOnRotation() {
802+ WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
803+ var webbrowserSurfaceId = topSurfaceList.nextId;
804+ webbrowserCheckBox.checked = true;
805+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
807+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
808+ verify(appDelegate);
809+ compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
811+ tabletStage.shellOrientation = Qt.PortraitOrientation;
812+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
815+ function test_restoreOriginalStageOnRotation() {
816+ var webbrowserSurfaceId = topSurfaceList.nextId;
817+ webbrowserCheckBox.checked = true;
818+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
820+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
821+ verify(appDelegate);
823+ dragToSideStage(webbrowserSurfaceId);
825+ // will be in sidestage now
826+ tabletStage.shellOrientation = Qt.PortraitOrientation;
827+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
829+ tabletStage.shellOrientation = Qt.LandscapeOrientation;
830+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
833+ function test_restoreSavedStageOnCloseReopen() {
834+ var webbrowserSurfaceId = topSurfaceList.nextId;
835+ webbrowserCheckBox.checked = true;
836+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
838+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
839+ verify(appDelegate);
841+ dragToSideStage(webbrowserSurfaceId);
842+ // will be in sidestage now
843+ tabletStage.shellOrientation = Qt.PortraitOrientation;
844+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
846+ webbrowserCheckBox.checked = false;
847+ tryCompare(ApplicationManager, "count", 1);
849+ // back to landscape
850+ tabletStage.shellOrientation = Qt.LandscapeOrientation;
852+ webbrowserSurfaceId = topSurfaceList.nextId;
853+ webbrowserCheckBox.checked = true;
854+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
856+ appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
857+ verify(appDelegate);
858+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);