on xenial help sign in
fix testOrientedShell
928545fMichael Zanetti
qml/Stage/DecoratedWindow.qml+1
@@ -34,6 +34,7 @@ FocusScope {
34 readonly property alias title: applicationWindow.title
34 readonly property alias title: applicationWindow.title
35 property alias maximizeButtonShown: decoration.maximizeButtonShown
35 property alias maximizeButtonShown: decoration.maximizeButtonShown
36 property alias interactive: applicationWindow.interactive
36 property alias interactive: applicationWindow.interactive
37+ readonly property alias orientationChangesEnabled: applicationWindow.orientationChangesEnabled
37
38
38 // Changing this will actually add/remove a decoration, meaning, requestedHeight will take the decoration into account.
39 // Changing this will actually add/remove a decoration, meaning, requestedHeight will take the decoration into account.
39 property bool hasDecoration: true
40 property bool hasDecoration: true
qml/Stage/Stage.qml+8−1
@@ -65,7 +65,7 @@ FocusScope {
65 // application windows never rotate independently
65 // application windows never rotate independently
66 property int mainAppWindowOrientationAngle: shellOrientationAngle
66 property int mainAppWindowOrientationAngle: shellOrientationAngle
67
67
68− property bool orientationChangesEnabled: true
68+ property bool orientationChangesEnabled: priv.focusedAppDelegate.orientationChangesEnabled
69
69
70 property int supportedOrientations: {
70 property int supportedOrientations: {
71 if (mainApp) {
71 if (mainApp) {
@@ -111,6 +111,12 @@ FocusScope {
111 }
111 }
112 }
112 }
113
113
114+ onSpreadEnabledChanged: {
115+ if (!spreadEnabled && root.state == "spread") {
116+ priv.goneToSpread = false;
117+ }
118+ }
119+
114 GSettings {
120 GSettings {
115 id: lifecycleExceptions
121 id: lifecycleExceptions
116 schema.id: "com.canonical.qtmir"
122 schema.id: "com.canonical.qtmir"
@@ -700,6 +706,7 @@ FocusScope {
700 (maximumHeight == 0 || maximumHeight >= appContainer.height/2)
706 (maximumHeight == 0 || maximumHeight >= appContainer.height/2)
701 readonly property bool canBeMaximizedHorizontally: maximumWidth == 0 || maximumWidth >= appContainer.width
707 readonly property bool canBeMaximizedHorizontally: maximumWidth == 0 || maximumWidth >= appContainer.width
702 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
708 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
709+ readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
703
710
704 property int windowState: WindowStateStorage.WindowStateNormal
711 property int windowState: WindowStateStorage.WindowStateNormal
705 property bool animationsEnabled: true
712 property bool animationsEnabled: true
tests/qmltests/tst_OrientedShell.qml+26−178
@@ -511,7 +511,7 @@ Rectangle {
511
511
512 var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
512 var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
513 verify(primaryAppWindow)
513 verify(primaryAppWindow)
514− var primaryDelegate = findChild(shell, "spreadDelegate_" + primarySurfaceId);
514+ var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
515
515
516 compare(primaryDelegate.focus, true);
516 compare(primaryDelegate.focus, true);
517 compare(primaryApp.rotatesWindowContents, false);
517 compare(primaryApp.rotatesWindowContents, false);
@@ -559,7 +559,7 @@ Rectangle {
559 compare(ApplicationManager.focusedApplicationId, "primary-oriented-app");
559 compare(ApplicationManager.focusedApplicationId, "primary-oriented-app");
560 compare(primaryApp.rotatesWindowContents, false);
560 compare(primaryApp.rotatesWindowContents, false);
561 compare(primaryApp.supportedOrientations, Qt.PrimaryOrientation);
561 compare(primaryApp.supportedOrientations, Qt.PrimaryOrientation);
562− var primaryDelegate = findChild(shell, "spreadDelegate_" + primarySurfaceId);
562+ var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
563 compare(primaryDelegate.stage, ApplicationInfoInterface.MainStage);
563 compare(primaryDelegate.stage, ApplicationInfoInterface.MainStage);
564
564
565 tryCompareFunction(function(){return primaryApp.surfaceList.count > 0;}, true);
565 tryCompareFunction(function(){return primaryApp.surfaceList.count > 0;}, true);
@@ -736,7 +736,7 @@ Rectangle {
736 compare(musicApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
736 compare(musicApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
737 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
737 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
738 if (data.deviceName === "manta" || data.deviceName === "flo") {
738 if (data.deviceName === "manta" || data.deviceName === "flo") {
739− var musicDelegate = findChild(shell, "spreadDelegate_" + musicSurfaceId);
739+ var musicDelegate = findChild(shell, "appDelegate_" + musicSurfaceId);
740 compare(musicDelegate.stage, ApplicationInfoInterface.MainStage);
740 compare(musicDelegate.stage, ApplicationInfoInterface.MainStage);
741 }
741 }
742
742
@@ -873,9 +873,9 @@ Rectangle {
873 var greeter = findChild(shell, "greeter");
873 var greeter = findChild(shell, "greeter");
874 tryCompare(greeter, "animating", false);
874 tryCompare(greeter, "animating", false);
875
875
876− var twitterDelegate = findChild(shell, "spreadDelegate_" + topLevelSurfaceList.idAt(1));
876+ var twitterDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(1));
877 compare(twitterDelegate.application.appId, "twitter-webapp");
877 compare(twitterDelegate.application.appId, "twitter-webapp");
878− twitterDelegate.clicked();
878+ tap(twitterDelegate, 1, 1);
879
879
880 // now it should finally follow the physical orientation
880 // now it should finally follow the physical orientation
881 tryCompare(shell, "transformRotationAngle", 90);
881 tryCompare(shell, "transformRotationAngle", 90);
@@ -894,24 +894,10 @@ Rectangle {
894 WindowStateStorage.saveStage("twitter-webapp", ApplicationInfoInterface.SideStage)
894 WindowStateStorage.saveStage("twitter-webapp", ApplicationInfoInterface.SideStage)
895 loadShell(data.deviceName);
895 loadShell(data.deviceName);
896
896
897− var twitterDelegate = null;
898−
899− verify(appRepeaterConnections.target);
900− appRepeaterConnections.itemAddedCallback = function(item) {
901− verify(item.application.appId, "twitter-webapp");
902− twitterDelegate = item;
903− signalSpy.target = findInvisibleChild(item, "orientationChangeAnimation");
904− verify(signalSpy.valid);
905− }
906−
907− signalSpy.clear();
908− signalSpy.target = null;
909− signalSpy.signalName = "runningChanged";
910−
911 var twitterSurfaceId = topLevelSurfaceList.nextId;
897 var twitterSurfaceId = topLevelSurfaceList.nextId;
912 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
898 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
913 verify(twitterApp);
899 verify(twitterApp);
914− var twitterDelegate = findChild(shell, "spreadDelegate_" + twitterSurfaceId);
900+ var twitterDelegate = findChild(shell, "appDelegate_" + twitterSurfaceId);
915 compare(twitterDelegate.stage, ApplicationInfoInterface.SideStage);
901 compare(twitterDelegate.stage, ApplicationInfoInterface.SideStage);
916
902
917 // ensure the mock twitter-webapp is as we expect
903 // ensure the mock twitter-webapp is as we expect
@@ -919,15 +905,11 @@ Rectangle {
919 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
905 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
920 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
906 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
921
907
922− // Wait until appRepeaterConnections hs caught the new SpreadDelegate and
923− // set up the signalSpy target accordingly.
924− tryCompareFunction(function(){ return signalSpy.target != null && signalSpy.valid; }, true);
925−
926 tryCompare(twitterDelegate, "orientationChangesEnabled", true);
908 tryCompare(twitterDelegate, "orientationChangesEnabled", true);
927
909
928− var appWindowWithShadow = findChild(twitterDelegate, "appWindowWithShadow");
910+ var decoratedWindow = findChild(twitterDelegate, "decoratedWindow");
929− verify(appWindowWithShadow);
911+ verify(decoratedWindow);
930− tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
912+ tryCompare(decoratedWindow, "counterRotate", false);
931
913
932 // no reason for any rotation animation to have taken place
914 // no reason for any rotation animation to have taken place
933 compare(signalSpy.count, 0);
915 compare(signalSpy.count, 0);
@@ -960,16 +942,12 @@ Rectangle {
960 tryCompareFunction(function(){ return dialerDelegate != null; }, true);
942 tryCompareFunction(function(){ return dialerDelegate != null; }, true);
961 tryCompare(dialerDelegate, "orientationChangesEnabled", true);
943 tryCompare(dialerDelegate, "orientationChangesEnabled", true);
962
944
963− var appWindowWithShadow = findChild(dialerDelegate, "appWindowWithShadow");
945+ var decoratedWindow = findChild(dialerDelegate, "decoratedWindow");
964− verify(appWindowWithShadow);
946+ verify(decoratedWindow);
965− tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
947+ tryCompare(decoratedWindow, "counterRotate", false);
966
948
967 // app must have portrait aspect ratio
949 // app must have portrait aspect ratio
968− verify(appWindowWithShadow.width < appWindowWithShadow.height);
950+ verify(decoratedWindow.width < decoratedWindow.height);
969−
970− compare(appWindowWithShadow.rotation, 0);
971−
972− verifyAppWindowWithinSpreadDelegateBoundaries(dialerDelegate);
973
951
974 // shell should remain in its primery orientation as the app in the main stage
952 // shell should remain in its primery orientation as the app in the main stage
975 // is the one that dictates its orientation. In this case it's unity8-dash
953 // is the one that dictates its orientation. In this case it's unity8-dash
@@ -977,83 +955,6 @@ Rectangle {
977 compare(shell.orientation, orientedShell.orientations.primary);
955 compare(shell.orientation, orientedShell.orientations.primary);
978 }
956 }
979
957
980− function test_sideStageAppsRemainPortraitInSpread_data() {
981− return [
982− {tag: "manta", deviceName: "manta"},
983− {tag: "flo", deviceName: "flo"}
984− ];
985− }
986− function test_sideStageAppsRemainPortraitInSpread(data) {
987− loadShell(data.deviceName);
988−
989−
990− ////
991− // Launch dialer
992− var dialerDelegate = null;
993− verify(appRepeaterConnections.target);
994− appRepeaterConnections.itemAddedCallback = function(item) {
995− dialerDelegate = item;
996− verify(item.application.appId, "dialer-app");
997− }
998−
999− WindowStateStorage.saveStage("dialer-app", ApplicationInfoInterface.SideStage)
1000− var dialerApp = ApplicationManager.startApplication("dialer-app");
1001− verify(dialerApp);
1002−
1003− // ensure the mock dialer-app is as we expect
1004− compare(dialerApp.rotatesWindowContents, false);
1005− compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1006−
1007− tryCompareFunction(function(){ return dialerDelegate != null; }, true);
1008− waitUntilAppDelegateIsFullyInit(dialerDelegate);
1009−
1010−
1011− ////
1012− // Launch twitter
1013− var twitterDelegate = null;
1014− appRepeaterConnections.itemAddedCallback = function(item) {
1015− twitterDelegate = item;
1016− verify(item.application.appId, "twitter-webapp");
1017− }
1018−
1019− var twitterApp = ApplicationManager.startApplication("twitter-webapp");
1020− verify(twitterApp);
1021− twitterApp.stage = ApplicationInfoInterface.SideStage;
1022−
1023− // ensure the mock twitter-webapp is as we expect
1024− compare(twitterApp.rotatesWindowContents, false);
1025− compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
1026− | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
1027−
1028− tryCompareFunction(function(){ return twitterDelegate != null; }, true);
1029− waitUntilAppDelegateIsFullyInit(twitterDelegate);
1030−
1031− ////
1032− // Edge swipe to show spread and check orientations
1033−
1034− performEdgeSwipeToShowAppSpread();
1035−
1036− {
1037− var appWindowWithShadow = findChild(dialerDelegate, "appWindowWithShadow");
1038− verify(appWindowWithShadow);
1039− tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
1040− compare(appWindowWithShadow.width, dialerDelegate.width);
1041− compare(appWindowWithShadow.height, dialerDelegate.height);
1042− compare(appWindowWithShadow.rotation, 0);
1043− }
1044− {
1045− var appWindowWithShadow = findChild(twitterDelegate, "appWindowWithShadow");
1046− verify(appWindowWithShadow);
1047− tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
1048− compare(appWindowWithShadow.width, twitterDelegate.width);
1049− compare(appWindowWithShadow.height, twitterDelegate.height);
1050− compare(appWindowWithShadow.rotation, 0);
1051− }
1052−
1053− verifyAppWindowWithinSpreadDelegateBoundaries(dialerDelegate);
1054− verifyAppWindowWithinSpreadDelegateBoundaries(twitterDelegate);
1055− }
1056−
1057 function test_launchedAppHasActiveFocus_data() {
958 function test_launchedAppHasActiveFocus_data() {
1058 return [
959 return [
1059 {tag: "mako", deviceName: "mako"},
960 {tag: "mako", deviceName: "mako"},
@@ -1449,11 +1350,10 @@ Rectangle {
1449 function waitUntilAppDelegateIsFullyInit(spreadDelegate) {
1350 function waitUntilAppDelegateIsFullyInit(spreadDelegate) {
1450 tryCompare(spreadDelegate, "orientationChangesEnabled", true);
1351 tryCompare(spreadDelegate, "orientationChangesEnabled", true);
1451
1352
1452− var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
1353+ var decoratedWindow = findChild(spreadDelegate, "decoratedWindow");
1453− verify(appWindowWithShadow);
1354+ tryCompare(decoratedWindow, "counterRotate", false);
1454− tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
1455
1355
1456− var appWindowStates = findInvisibleChild(appWindowWithShadow, "applicationWindowStateGroup");
1356+ var appWindowStates = findInvisibleChild(decoratedWindow, "applicationWindowStateGroup");
1457 verify(appWindowStates);
1357 verify(appWindowStates);
1458 tryCompare(appWindowStates, "state", "surface");
1358 tryCompare(appWindowStates, "state", "surface");
1459 }
1359 }
@@ -1491,8 +1391,7 @@ Rectangle {
1491 }
1391 }
1492
1392
1493 function performLeftEdgeSwipeToSwitchToDash() {
1393 function performLeftEdgeSwipeToSwitchToDash() {
1494− var spreadView = findChild(shell, "spreadView");
1495− var swipeLength = spreadView.width * 0.7;
1394+ var swipeLength = shell.width * 0.7;
1496
1395
1497 var touchStartX = 1;
1396 var touchStartX = 1;
1498 var touchStartY = shell.height / 2;
1397 var touchStartY = shell.height / 2;
@@ -1507,35 +1406,13 @@ Rectangle {
1507 // swipe just enough to ensure an app switch action.
1406 // swipe just enough to ensure an app switch action.
1508 // If we swipe too much we will trigger the spread mode
1407 // If we swipe too much we will trigger the spread mode
1509 // and we don't want that.
1408 // and we don't want that.
1510− var spreadView = findChild(shell, "spreadView");
1511− verify(spreadView);
1512−
1513 verify(topLevelSurfaceList.count >= 2);
1409 verify(topLevelSurfaceList.count >= 2);
1514 var previousSurfaceId = topLevelSurfaceList.idAt(1);
1410 var previousSurfaceId = topLevelSurfaceList.idAt(1);
1515
1411
1516 var touchStartX = shell.width - 1;
1412 var touchStartX = shell.width - 1;
1517 var touchStartY = shell.height / 2;
1413 var touchStartY = shell.height / 2;
1518
1414
1519− var condition;
1520− if (applicationArguments.deviceName === "phone") {
1521− condition = function() {
1522− return spreadView.shiftedContentX > units.gu(2) &&
1523− spreadView.shiftedContentX < spreadView.positionMarker1 * spreadView.width;
1524− };
1525− } else {
1526− condition = function() {
1527− return spreadView.shiftedContentX > spreadView.width * spreadView.positionMarker1
1528− && spreadView.shiftedContentX < spreadView.width * spreadView.positionMarker2;
1529− };
1530− }
1531−
1532− touchDragUntil(shell,
1533− touchStartX, touchStartY,
1415+ touchFlick(shell, touchStartX, touchStartY, touchStartX - units.gu(8), touchStartY, units.gu(4), 10);
1534− -units.gu(1), 0,
1535− condition);
1536−
1537− // ensure the app switch animation has ended
1538− tryCompare(spreadView, "shiftedContentX", 0);
1539
1416
1540 tryCompareFunction(function(){ return topLevelSurfaceList.idAt(0); }, previousSurfaceId);
1417 tryCompareFunction(function(){ return topLevelSurfaceList.idAt(0); }, previousSurfaceId);
1541 }
1418 }
@@ -1546,11 +1423,9 @@ Rectangle {
1546 shell.width - 1, touchStartY,
1423 shell.width - 1, touchStartY,
1547 0, touchStartY);
1424 0, touchStartY);
1548
1425
1549− var spreadView = findChild(shell, "spreadView");
1426+ var stage = findChild(shell, "stage");
1550− verify(spreadView);
1427+ tryCompare(stage, "state", "spread");
1551− tryCompare(spreadView, "phase", 2);
1428+ waitForRendering(stage);
1552− tryCompare(spreadView, "flicking", false);
1553− tryCompare(spreadView, "moving", false);
1554 }
1429 }
1555
1430
1556 function showPowerDialog() {
1431 function showPowerDialog() {
@@ -1559,19 +1434,6 @@ Rectangle {
1559 dialogsPrivate.showPowerDialog();
1434 dialogsPrivate.showPowerDialog();
1560 }
1435 }
1561
1436
1562− function verifyAppWindowWithinSpreadDelegateBoundaries(spreadDelegate) {
1563− var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
1564− verify(appWindowWithShadow);
1565−
1566− var windowInDelegateCoords = appWindowWithShadow.mapToItem(spreadDelegate, 0, 0,
1567− appWindowWithShadow.width, appWindowWithShadow.height);
1568−
1569− compare(windowInDelegateCoords.x, 0);
1570− compare(windowInDelegateCoords.y, 0);
1571− compare(windowInDelegateCoords.width, spreadDelegate.width);
1572− compare(windowInDelegateCoords.height, spreadDelegate.height);
1573− }
1574−
1575 function swipeAwayGreeter() {
1437 function swipeAwayGreeter() {
1576 var greeter = findChild(shell, "greeter");
1438 var greeter = findChild(shell, "greeter");
1577 tryCompare(greeter, "fullyShown", true);
1439 tryCompare(greeter, "fullyShown", true);
@@ -1643,11 +1505,9 @@ Rectangle {
1643
1505
1644 var topMargin = 0.;
1506 var topMargin = 0.;
1645 if (!app.fullscreen) {
1507 if (!app.fullscreen) {
1646− var appsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
1508+ var stage = findChild(shell, "stage");
1647− verify(appsDisplayLoader);
1648− verify(appsDisplayLoader.item);
1649− verify(appsDisplayLoader.item.maximizedAppTopMargin !== undefined);
1509+ verify(stage.maximizedAppTopMargin !== undefined);
1650− topMargin = appsDisplayLoader.item.maximizedAppTopMargin;
1510+ topMargin = stage.maximizedAppTopMargin;
1651 }
1511 }
1652
1512
1653 var surfaceItem = findSurfaceItem(item, surface);
1513 var surfaceItem = findSurfaceItem(item, surface);
@@ -1687,24 +1547,12 @@ Rectangle {
1687 }
1547 }
1688
1548
1689 function swipeToCloseCurrentAppInSpread() {
1549 function swipeToCloseCurrentAppInSpread() {
1690− var spreadView = findChild(shell, "spreadView");
1691− verify(spreadView);
1692−
1693− var delegateToClose = findChild(spreadView, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
1550+ var delegateToClose = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1694 verify(delegateToClose);
1551 verify(delegateToClose);
1695
1552
1696− var appIdToClose = ApplicationManager.get(0).appId;;
1553+ var appIdToClose = ApplicationManager.get(0).appId;
1697 var appCountBefore = ApplicationManager.count;
1554 var appCountBefore = ApplicationManager.count;
1698
1555
1699− // ensure the current app is widely visible by swiping to the right,
1700− // which will move the app windows accordingly
1701− touchFlick(shell,
1702− shell.width * 0.25, shell.width / 2,
1703− shell.width, shell.width / 2);
1704−
1705− tryCompare(spreadView, "flicking", false);
1706− tryCompare(spreadView, "moving", false);
1707−
1708 // Swipe up close to its left edge, as it is the only area of it guaranteed to be exposed
1556 // Swipe up close to its left edge, as it is the only area of it guaranteed to be exposed
1709 // in the spread. Eg: its center could be covered by some other delegate.
1557 // in the spread. Eg: its center could be covered by some other delegate.
1710 touchFlick(delegateToClose,
1558 touchFlick(delegateToClose,