on xenial help sign in
fix testOrientedShell

one test still failing

commit928545f332dda9ebcc838d403c1120eb46d64bb2 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 21 Sep 2016, 13:36 (10 years ago) parent32b483d
3 files changed+35−179
qml/Stage/DecoratedWindow.qml+1 qml/Stage/Stage.qml+8−1 tests/qmltests/tst_OrientedShell.qml+26−178
qml/Stage/DecoratedWindow.qml+1
@@ -34,6 +34,7 @@ FocusScope {
3434 readonly property alias title: applicationWindow.title
3535 property alias maximizeButtonShown: decoration.maximizeButtonShown
3636 property alias interactive: applicationWindow.interactive
37+ readonly property alias orientationChangesEnabled: applicationWindow.orientationChangesEnabled
3738
3839 // Changing this will actually add/remove a decoration, meaning, requestedHeight will take the decoration into account.
3940 property bool hasDecoration: true
qml/Stage/Stage.qml+8−1
@@ -65,7 +65,7 @@ FocusScope {
6565 // application windows never rotate independently
6666 property int mainAppWindowOrientationAngle: shellOrientationAngle
6767
68− property bool orientationChangesEnabled: true
68+ property bool orientationChangesEnabled: priv.focusedAppDelegate.orientationChangesEnabled
6969
7070 property int supportedOrientations: {
7171 if (mainApp) {
@@ -111,6 +111,12 @@ FocusScope {
111111 }
112112 }
113113
114+ onSpreadEnabledChanged: {
115+ if (!spreadEnabled && root.state == "spread") {
116+ priv.goneToSpread = false;
117+ }
118+ }
119+
114120 GSettings {
115121 id: lifecycleExceptions
116122 schema.id: "com.canonical.qtmir"
@@ -700,6 +706,7 @@ FocusScope {
700706 (maximumHeight == 0 || maximumHeight >= appContainer.height/2)
701707 readonly property bool canBeMaximizedHorizontally: maximumWidth == 0 || maximumWidth >= appContainer.width
702708 readonly property bool canBeMaximizedVertically: maximumHeight == 0 || maximumHeight >= appContainer.height
709+ readonly property alias orientationChangesEnabled: decoratedWindow.orientationChangesEnabled
703710
704711 property int windowState: WindowStateStorage.WindowStateNormal
705712 property bool animationsEnabled: true
tests/qmltests/tst_OrientedShell.qml+26−178
@@ -511,7 +511,7 @@ Rectangle {
511511
512512 var primaryAppWindow = findAppWindowForSurfaceId(primarySurfaceId);
513513 verify(primaryAppWindow)
514− var primaryDelegate = findChild(shell, "spreadDelegate_" + primarySurfaceId);
514+ var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
515515
516516 compare(primaryDelegate.focus, true);
517517 compare(primaryApp.rotatesWindowContents, false);
@@ -559,7 +559,7 @@ Rectangle {
559559 compare(ApplicationManager.focusedApplicationId, "primary-oriented-app");
560560 compare(primaryApp.rotatesWindowContents, false);
561561 compare(primaryApp.supportedOrientations, Qt.PrimaryOrientation);
562− var primaryDelegate = findChild(shell, "spreadDelegate_" + primarySurfaceId);
562+ var primaryDelegate = findChild(shell, "appDelegate_" + primarySurfaceId);
563563 compare(primaryDelegate.stage, ApplicationInfoInterface.MainStage);
564564
565565 tryCompareFunction(function(){return primaryApp.surfaceList.count > 0;}, true);
@@ -736,7 +736,7 @@ Rectangle {
736736 compare(musicApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
737737 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
738738 if (data.deviceName === "manta" || data.deviceName === "flo") {
739− var musicDelegate = findChild(shell, "spreadDelegate_" + musicSurfaceId);
739+ var musicDelegate = findChild(shell, "appDelegate_" + musicSurfaceId);
740740 compare(musicDelegate.stage, ApplicationInfoInterface.MainStage);
741741 }
742742
@@ -873,9 +873,9 @@ Rectangle {
873873 var greeter = findChild(shell, "greeter");
874874 tryCompare(greeter, "animating", false);
875875
876− var twitterDelegate = findChild(shell, "spreadDelegate_" + topLevelSurfaceList.idAt(1));
876+ var twitterDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(1));
877877 compare(twitterDelegate.application.appId, "twitter-webapp");
878− twitterDelegate.clicked();
878+ tap(twitterDelegate, 1, 1);
879879
880880 // now it should finally follow the physical orientation
881881 tryCompare(shell, "transformRotationAngle", 90);
@@ -894,24 +894,10 @@ Rectangle {
894894 WindowStateStorage.saveStage("twitter-webapp", ApplicationInfoInterface.SideStage)
895895 loadShell(data.deviceName);
896896
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−
911897 var twitterSurfaceId = topLevelSurfaceList.nextId;
912898 var twitterApp = ApplicationManager.startApplication("twitter-webapp");
913899 verify(twitterApp);
914− var twitterDelegate = findChild(shell, "spreadDelegate_" + twitterSurfaceId);
900+ var twitterDelegate = findChild(shell, "appDelegate_" + twitterSurfaceId);
915901 compare(twitterDelegate.stage, ApplicationInfoInterface.SideStage);
916902
917903 // ensure the mock twitter-webapp is as we expect
@@ -919,15 +905,11 @@ Rectangle {
919905 compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
920906 | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
921907
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−
926908 tryCompare(twitterDelegate, "orientationChangesEnabled", true);
927909
928− var appWindowWithShadow = findChild(twitterDelegate, "appWindowWithShadow");
929− verify(appWindowWithShadow);
930− tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
910+ var decoratedWindow = findChild(twitterDelegate, "decoratedWindow");
911+ verify(decoratedWindow);
912+ tryCompare(decoratedWindow, "counterRotate", false);
931913
932914 // no reason for any rotation animation to have taken place
933915 compare(signalSpy.count, 0);
@@ -960,16 +942,12 @@ Rectangle {
960942 tryCompareFunction(function(){ return dialerDelegate != null; }, true);
961943 tryCompare(dialerDelegate, "orientationChangesEnabled", true);
962944
963− var appWindowWithShadow = findChild(dialerDelegate, "appWindowWithShadow");
964− verify(appWindowWithShadow);
965− tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
945+ var decoratedWindow = findChild(dialerDelegate, "decoratedWindow");
946+ verify(decoratedWindow);
947+ tryCompare(decoratedWindow, "counterRotate", false);
966948
967949 // app must have portrait aspect ratio
968− verify(appWindowWithShadow.width < appWindowWithShadow.height);
969−
970− compare(appWindowWithShadow.rotation, 0);
971−
972− verifyAppWindowWithinSpreadDelegateBoundaries(dialerDelegate);
950+ verify(decoratedWindow.width < decoratedWindow.height);
973951
974952 // shell should remain in its primery orientation as the app in the main stage
975953 // is the one that dictates its orientation. In this case it's unity8-dash
@@ -977,83 +955,6 @@ Rectangle {
977955 compare(shell.orientation, orientedShell.orientations.primary);
978956 }
979957
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−
1057958 function test_launchedAppHasActiveFocus_data() {
1058959 return [
1059960 {tag: "mako", deviceName: "mako"},
@@ -1449,11 +1350,10 @@ Rectangle {
14491350 function waitUntilAppDelegateIsFullyInit(spreadDelegate) {
14501351 tryCompare(spreadDelegate, "orientationChangesEnabled", true);
14511352
1452− var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
1453− verify(appWindowWithShadow);
1454− tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
1353+ var decoratedWindow = findChild(spreadDelegate, "decoratedWindow");
1354+ tryCompare(decoratedWindow, "counterRotate", false);
14551355
1456− var appWindowStates = findInvisibleChild(appWindowWithShadow, "applicationWindowStateGroup");
1356+ var appWindowStates = findInvisibleChild(decoratedWindow, "applicationWindowStateGroup");
14571357 verify(appWindowStates);
14581358 tryCompare(appWindowStates, "state", "surface");
14591359 }
@@ -1491,8 +1391,7 @@ Rectangle {
14911391 }
14921392
14931393 function performLeftEdgeSwipeToSwitchToDash() {
1494− var spreadView = findChild(shell, "spreadView");
1495− var swipeLength = spreadView.width * 0.7;
1394+ var swipeLength = shell.width * 0.7;
14961395
14971396 var touchStartX = 1;
14981397 var touchStartY = shell.height / 2;
@@ -1507,35 +1406,13 @@ Rectangle {
15071406 // swipe just enough to ensure an app switch action.
15081407 // If we swipe too much we will trigger the spread mode
15091408 // and we don't want that.
1510− var spreadView = findChild(shell, "spreadView");
1511− verify(spreadView);
1512−
15131409 verify(topLevelSurfaceList.count >= 2);
15141410 var previousSurfaceId = topLevelSurfaceList.idAt(1);
15151411
15161412 var touchStartX = shell.width - 1;
15171413 var touchStartY = shell.height / 2;
15181414
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,
1534− -units.gu(1), 0,
1535− condition);
1536−
1537− // ensure the app switch animation has ended
1538− tryCompare(spreadView, "shiftedContentX", 0);
1415+ touchFlick(shell, touchStartX, touchStartY, touchStartX - units.gu(8), touchStartY, units.gu(4), 10);
15391416
15401417 tryCompareFunction(function(){ return topLevelSurfaceList.idAt(0); }, previousSurfaceId);
15411418 }
@@ -1546,11 +1423,9 @@ Rectangle {
15461423 shell.width - 1, touchStartY,
15471424 0, touchStartY);
15481425
1549− var spreadView = findChild(shell, "spreadView");
1550− verify(spreadView);
1551− tryCompare(spreadView, "phase", 2);
1552− tryCompare(spreadView, "flicking", false);
1553− tryCompare(spreadView, "moving", false);
1426+ var stage = findChild(shell, "stage");
1427+ tryCompare(stage, "state", "spread");
1428+ waitForRendering(stage);
15541429 }
15551430
15561431 function showPowerDialog() {
@@ -1559,19 +1434,6 @@ Rectangle {
15591434 dialogsPrivate.showPowerDialog();
15601435 }
15611436
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−
15751437 function swipeAwayGreeter() {
15761438 var greeter = findChild(shell, "greeter");
15771439 tryCompare(greeter, "fullyShown", true);
@@ -1643,11 +1505,9 @@ Rectangle {
16431505
16441506 var topMargin = 0.;
16451507 if (!app.fullscreen) {
1646− var appsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
1647− verify(appsDisplayLoader);
1648− verify(appsDisplayLoader.item);
1649− verify(appsDisplayLoader.item.maximizedAppTopMargin !== undefined);
1650− topMargin = appsDisplayLoader.item.maximizedAppTopMargin;
1508+ var stage = findChild(shell, "stage");
1509+ verify(stage.maximizedAppTopMargin !== undefined);
1510+ topMargin = stage.maximizedAppTopMargin;
16511511 }
16521512
16531513 var surfaceItem = findSurfaceItem(item, surface);
@@ -1687,24 +1547,12 @@ Rectangle {
16871547 }
16881548
16891549 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));
16941551 verify(delegateToClose);
16951552
1696− var appIdToClose = ApplicationManager.get(0).appId;;
1553+ var appIdToClose = ApplicationManager.get(0).appId;
16971554 var appCountBefore = ApplicationManager.count;
16981555
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−
17081556 // Swipe up close to its left edge, as it is the only area of it guaranteed to be exposed
17091557 // in the spread. Eg: its center could be covered by some other delegate.
17101558 touchFlick(delegateToClose,