533
536
function test_appSupportingOnlyPrimaryOrientationWillOnlyRotateInLandscape(data) {
534
537
loadShell(data.deviceName);
539
compare(topLevelSurfaceList.applicationAt(0).appId, "unity8-dash");
540
var dashSurfaceId = topLevelSurfaceList.idAt(0);
541
var dashAppWindow = findAppWindowForSurfaceId(dashSurfaceId);
536
543
// unity8-dash supports only primary orientation and should be already running
537
var dashAppWindow = findChild(shell, "appWindow_unity8-dash");
538
verify(dashAppWindow);
539
545
compare(ApplicationManager.focusedApplicationId, "unity8-dash");
540
var dashApp = dashAppWindow.application
546
var dashApp = dashAppWindow.application;
542
548
compare(dashApp.rotatesWindowContents, false);
543
549
compare(dashApp.supportedOrientations, Qt.PrimaryOrientation);
544
550
compare(dashApp.stage, ApplicationInfoInterface.MainStage);
546
tryCompareFunction(function(){return dashApp.session.lastSurface != null;}, true);
552
tryCompareFunction(function(){return dashApp.surfaceList.count > 0;}, true);
547
553
verify(checkAppSurfaceOrientation(dashAppWindow, dashApp, root.primaryOrientationAngle));
549
555
compare(shell.transformRotationAngle, root.primaryOrientationAngle);
619
626
compare(cameraApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
620
627
| Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
622
waitUntilAppSurfaceShowsUp("camera-app")
629
waitUntilAppWindowIsFullyLoaded(cameraSurfaceId);
624
var cameraSurface = cameraApp.session.lastSurface;
631
var cameraSurface = cameraApp.surfaceList.get(0);
625
632
verify(cameraSurface);
627
634
var focusChangedSpy = signalSpy;
696
704
| Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
697
705
compare(gmailApp.stage, ApplicationInfoInterface.MainStage);
699
waitUntilAppSurfaceShowsUp("gmail-webapp")
707
waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
709
var musicSurfaceId = topLevelSurfaceList.nextId;
701
710
var musicApp = ApplicationManager.startApplication("music-app");
702
711
verify(musicApp);
707
716
| Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
708
717
compare(musicApp.stage, ApplicationInfoInterface.MainStage);
710
waitUntilAppSurfaceShowsUp("music-app")
719
waitUntilAppWindowIsFullyLoaded(musicSurfaceId);
711
720
tryCompare(shell, "orientationChangesEnabled", true);
750
760
compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
751
761
| Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
753
waitUntilAppSurfaceShowsUp("twitter-webapp")
763
waitUntilAppWindowIsFullyLoaded(twitterSurfaceId);
755
765
rotateTo(data.rotationAngle);
756
766
tryCompare(shell, "transformRotationAngle", data.rotationAngle);
768
778
function test_launchLandscapeOnlyAppFromPortrait() {
769
779
loadShell("mako");
780
var weatherSurfaceId = topLevelSurfaceList.nextId;
770
781
var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
771
782
verify(weatherApp);
773
784
// ensure the mock app is as we expect
774
785
compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
776
waitUntilAppSurfaceShowsUp("ubuntu-weather-app");
787
waitUntilAppWindowIsFullyLoaded(weatherSurfaceId);
778
789
var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
779
790
waitUntilTransitionsEnd(rotationStates);
813
825
compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
814
826
| Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
816
waitUntilAppSurfaceShowsUp("twitter-webapp");
817
waitUntilAppWindowCanRotate("twitter-webapp");
828
waitUntilAppWindowIsFullyLoaded(twitterSurfaceId);
829
waitUntilAppWindowCanRotate(twitterSurfaceId);
819
831
// go back to unity8-dash
820
832
performEdgeSwipeToSwitchToPreviousApp();
830
842
var greeter = findChild(shell, "greeter");
831
843
tryCompare(greeter, "animating", false);
833
var twitterDelegate = findChild(shell, "appDelegate1");
845
var twitterDelegate = findChild(shell, "spreadDelegate_" + topLevelSurfaceList.idAt(1));
834
846
compare(twitterDelegate.application.appId, "twitter-webapp");
835
847
twitterDelegate.clicked();
1018
1030
function test_launchedAppHasActiveFocus(data) {
1019
1031
loadShell(data.deviceName);
1033
var gmailSurfaceId = topLevelSurfaceList.nextId;
1021
1034
var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1022
1035
verify(gmailApp);
1023
waitUntilAppSurfaceShowsUp("gmail-webapp")
1025
verify(gmailApp.session.lastSurface);
1027
tryCompare(gmailApp.session.lastSurface, "activeFocus", true);
1036
waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
1038
var gmailSurface = gmailApp.surfaceList.get(0);
1039
verify(gmailSurface);
1041
tryCompare(gmailSurface, "activeFocus", true);
1030
1044
function test_launchLandscapeOnlyAppOverPortraitOnlyDashThenSwitchToDash() {
1033
1047
// starts as portrait, as unity8-dash is portrait only
1034
1048
tryCompare(shell, "transformRotationAngle", 0);
1050
var weatherSurfaceId = topLevelSurfaceList.nextId;
1036
1051
var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
1037
1052
verify(weatherApp);
1039
1054
// ensure the mock app is as we expect
1040
1055
compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
1042
waitUntilAppSurfaceShowsUp("ubuntu-weather-app");
1057
waitUntilAppWindowIsFullyLoaded(weatherSurfaceId);
1044
1059
// should have rotated to landscape
1045
1060
tryCompareFunction(function () { return shell.transformRotationAngle == 270
1233
1248
function test_lockPhoneAfterClosingAppInSpreadThenUnlockAndRotate() {
1234
1249
loadShell("mako");
1251
compare(topLevelSurfaceList.applicationAt(0).appId, "unity8-dash");
1252
var dashSurfaceId = topLevelSurfaceList.idAt(0);
1254
var gmailSurfaceId = topLevelSurfaceList.nextId;
1236
1255
var gmailApp = ApplicationManager.startApplication("gmail-webapp");
1237
1256
verify(gmailApp);
1239
waitUntilAppSurfaceShowsUp("gmail-webapp");
1258
waitUntilAppWindowIsFullyLoaded(gmailSurfaceId);
1241
1260
performEdgeSwipeToShowAppSpread();
1321
1341
compare(dialerApp.rotatesWindowContents, false);
1322
1342
compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
1324
waitUntilAppSurfaceShowsUp("dialer-app");
1325
waitUntilAppWindowCanRotate("dialer-app");
1326
verify(isAppSurfaceFocused("dialer-app"));
1344
waitUntilAppWindowIsFullyLoaded(dialerSurfaceId);
1345
waitUntilAppWindowCanRotate(dialerSurfaceId);
1346
verify(isAppSurfaceFocused(dialerSurfaceId));
1329
1349
// check outcome (shell should stay in landscape)
1376
1396
tryCompare(appWindowStates, "state", "surface");
1379
function waitUntilAppSurfaceShowsUp(appId) {
1380
var appWindow = findChild(shell, "appWindow_" + appId);
1382
var appWindowStates = findInvisibleChild(appWindow, "applicationWindowStateGroup");
1383
verify(appWindowStates);
1384
tryCompare(appWindowStates, "state", "surface");
1387
function waitUntilAppWindowCanRotate(appId) {
1388
var appWindow = findChild(shell, "appWindow_" + appId);
1399
function findAppWindowForSurfaceId(surfaceId) {
1400
// for PhoneStage and TabletStage
1401
var delegate = findChild(shell, "spreadDelegate_" + surfaceId);
1404
delegate = findChild(shell, "appDelegate_" + surfaceId);
1407
var appWindow = findChild(delegate, "appWindow");
1411
// Wait until the ApplicationWindow for the given Application object is fully loaded
1412
// (ie, the real surface has replaced the splash screen)
1413
function waitUntilAppWindowIsFullyLoaded(surfaceId) {
1414
var appWindow = findAppWindowForSurfaceId(surfaceId);
1415
var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
1416
tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
1417
waitUntilTransitionsEnd(appWindowStateGroup);
1420
function waitUntilAppWindowCanRotate(surfaceId) {
1421
var appWindow = findAppWindowForSurfaceId(surfaceId);
1390
1422
tryCompare(appWindow, "orientationChangesEnabled", true);
1498
1530
tryCompare(greeter, "fullyShown", true);
1501
function killApps() {
1502
while (ApplicationManager.count > 1) {
1503
var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
1504
ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
1506
compare(ApplicationManager.count, 1)
1509
1533
function loadShell(deviceName) {
1510
1534
applicationArguments.deviceName = deviceName;
1518
1542
shell = findChild(orientedShell, "shell");
1544
topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
1545
verify(topLevelSurfaceList);
1547
var stageLoader = findChild(shell, "applicationsDisplayLoader");
1548
verify(stageLoader);
1520
1550
tryCompare(shell, "enabled", true); // enabled by greeter when ready
1522
1552
waitUntilShellIsInOrientation(root.physicalOrientation0);
1547
1577
// expectedAngle is in orientedShell's coordinate system
1548
1578
function checkAppSurfaceOrientation(item, app, expectedAngle) {
1549
var surface = app.session.lastSurface;
1579
var surface = app.surfaceList.get(0);
1550
1580
if (!surface) {
1551
1581
console.warn("no surface");
1601
1631
var spreadView = findChild(shell, "spreadView");
1602
1632
verify(spreadView);
1604
var delegateToClose = findChild(spreadView, "appDelegate0");
1634
var delegateToClose = findChild(spreadView, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
1605
1635
verify(delegateToClose);
1607
1637
var appIdToClose = ApplicationManager.get(0).appId;;
1627
1657
compare(ApplicationManager.findApplication(appIdToClose), null);
1630
function isAppSurfaceFocused(appId) {
1631
var appWindow = findChild(shell, "appWindow_" + appId);
1634
var app = ApplicationManager.findApplication(appId);
1637
var surface = app.session.lastSurface;
1660
function isAppSurfaceFocused(surfaceId) {
1661
var index = topLevelSurfaceList.indexForId(surfaceId);
1662
var surface = topLevelSurfaceList.surfaceAt(index);
1638
1663
verify(surface);
1640
var surfaceItem = findSurfaceItem(appWindow, surface);
1641
verify(surfaceItem);
1643
return surfaceItem.activeFocus;
1664
return surface.activeFocus;