@@ -19,6 +19,7 @@ import QtTest 1.0
19import AccountsService 0.1
19import AccountsService 0.1
20import IntegratedLightDM 0.1 as LightDM
20import IntegratedLightDM 0.1 as LightDM
21import Ubuntu.Components 1.3
21import Ubuntu.Components 1.3
22+import Ubuntu.Components.ListItems 1.3
22import Ubuntu.Telephony 0.1 as Telephony
23import Ubuntu.Telephony 0.1 as Telephony
23import Unity.Application 0.1
24import Unity.Application 0.1
24import Unity.Test 0.1 as UT
25import Unity.Test 0.1 as UT
@@ -26,10 +27,11 @@ import Unity.Test 0.1 as UT
26import "../../../qml"
27import "../../../qml"
27import "../../../qml/Components"
28import "../../../qml/Components"
32+ color: UbuntuColors.lightGrey
31− width: shellLoader.width + buttons.width
33+ width: units.gu(100) + buttons.width
32− height: shellLoader.height
34+ height: units.gu(71)
34 QtObject {
36 QtObject {
35 id: applicationArguments
37 id: applicationArguments
@@ -59,24 +61,62 @@ Item {
59 shellLoader.active = true;
61 shellLoader.active = true;
63− spacing: 0
65+ id: shellContainer
64− anchors.fill: parent
66+ anchors.left: root.left
67+ anchors.right: buttons.left
68+ anchors.top: root.top
69+ anchors.bottom: root.bottom
67 id: shellLoader
72 id: shellLoader
69 active: false
74 active: false
75+ anchors.horizontalCenter: parent.horizontalCenter
76+ anchors.top: parent.top
77+ anchors.bottom: parent.bottom
79+ property int shellOrientation: Qt.PortraitOrientation
80+ property int nativeOrientation: Qt.PortraitOrientation
81+ property int primaryOrientation: Qt.PortraitOrientation
83+ state: modeSelector.model[modeSelector.selectedIndex]
70− width: units.gu(40)
89+ width: units.gu(40)
97+ shellOrientation: Qt.LandscapeOrientation
98+ nativeOrientation: Qt.LandscapeOrientation
99+ primaryOrientation: Qt.LandscapeOrientation
71− height: units.gu(71)
106+ width: units.gu(100)
73 property bool itemDestroyed: false
111 property bool itemDestroyed: false
74 sourceComponent: Component {
112 sourceComponent: Component {
114+ usageScenario: shellLoader.state
76 property string indicatorProfile: "phone"
115 property string indicatorProfile: "phone"
116+ orientation: shellLoader.shellOrientation
77 orientations: Orientations {
117 orientations: Orientations {
78− native_: Qt.PortraitOrientation
118+ native_: shellLoader.nativeOrientation
79− primary: Qt.PortraitOrientation
119+ primary: shellLoader.primaryOrientation
82 Component.onDestruction: {
122 Component.onDestruction: {
@@ -85,102 +125,92 @@ Item {
89− Rectangle {
130+ Rectangle {
90− id: buttons
131+ id: buttons
91− color: "black"
132+ color: UbuntuColors.darkGrey
92− width: units.gu(30)
133+ width: units.gu(30)
93− height: shellLoader.height
134+ anchors.top: root.top
94−
135+ anchors.bottom: root.bottom
136+ anchors.right: root.right
95− Column {
138+ Column {
96− anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
139+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
97− spacing: units.gu(1)
140+ spacing: units.gu(1)
99− anchors { left: parent.left; right: parent.right }
142+ anchors { left: parent.left; right: parent.right }
100− Button {
143+ Button {
101− text: "Hide Greeter"
144+ text: "Hide Greeter"
102− onClicked: {
145+ onClicked: {
103− if (shellLoader.status !== Loader.Ready)
146+ if (shellLoader.status !== Loader.Ready)
106− var greeter = testCase.findChild(shellLoader.item, "greeter");
149+ var greeter = testCase.findChild(shellLoader.item, "greeter");
107− if (greeter.shown) {
150+ if (greeter.shown) {
108− greeter.hide();
151+ greeter.hide();
115− anchors { left: parent.left; right: parent.right }
158+ anchors { left: parent.left; right: parent.right }
116− Button {
159+ Button {
117− text: "Restart Tutorial"
160+ text: "Restart Tutorial"
118− onClicked: {
161+ onClicked: {
119− if (shellLoader.status !== Loader.Ready)
162+ if (shellLoader.status !== Loader.Ready)
122− AccountsService.demoEdges = false;
165+ AccountsService.demoEdges = false;
123− AccountsService.demoEdgesCompleted = [];
166+ AccountsService.demoEdgesCompleted = [];
124− AccountsService.demoEdges = true;
167+ AccountsService.demoEdges = true;
130− anchors { left: parent.left; right: parent.right }
173+ anchors { left: parent.left; right: parent.right }
131− CheckBox {
174+ CheckBox {
132− onCheckedChanged: {
175+ onCheckedChanged: {
133− if (checked) {
176+ if (checked) {
134− callManager.foregroundCall = phoneCall;
177+ callManager.foregroundCall = phoneCall;
135− } else {
178+ } else {
136− callManager.foregroundCall = null;
179+ callManager.foregroundCall = null;
142− anchors.verticalCenter: parent.verticalCenter
147− anchors { left: parent.left; right: parent.right }
149− activeFocusOnPress: false
151− var surface = SurfaceManager.inputMethodSurface();
153− surface.setState(Mir.RestoredState);
155− surface.setState(Mir.MinimizedState);
160− text: "Input Method"
184+ text: "Active Call"
161− anchors.verticalCenter: parent.verticalCenter
185+ anchors.verticalCenter: parent.verticalCenter
166− anchors { left: parent.left; right: parent.right }
190+ anchors { left: parent.left; right: parent.right }
167− CheckBox {
191+ CheckBox {
192+ activeFocusOnPress: false
168− onCheckedChanged: {
193+ onCheckedChanged: {
169− if (shellLoader.status !== Loader.Ready)
194+ var surface = SurfaceManager.inputMethodSurface();
172− if (checked) {
195+ if (checked) {
173− shellLoader.item.usageScenario = "desktop";
196+ surface.setState(Mir.RestoredState);
174− } else {
197+ } else {
175− shellLoader.item.usageScenario = "phone";
198+ surface.setState(Mir.MinimizedState);
180− text: "Desktop Mode"
181− anchors.verticalCenter: parent.verticalCenter
203+ text: "Input Method"
204+ anchors.verticalCenter: parent.verticalCenter
210+ anchors { left: parent.left; right: parent.right }
211+ activeFocusOnPress: false
213+ model: ["phone", "tablet", "desktop"]
@@ -195,24 +225,21 @@ Item {
195 property real halfHeight: shell ? shell.height / 2 : 0
225 property real halfHeight: shell ? shell.height / 2 : 0
197 function init() {
227 function init() {
198− tryCompare(shell, "enabled", true); // enabled by greeter when ready
228+ prepareShell();
200− shell.usageScenario = "phone";
201− callManager.foregroundCall = null;
202− AccountsService.demoEdges = false;
203− AccountsService.demoEdgesCompleted = [];
204− AccountsService.demoEdges = true;
206− LightDM.Greeter.hideGreeter();
208 var tutorialLeft = findChild(shell, "tutorialLeft");
230 var tutorialLeft = findChild(shell, "tutorialLeft");
209 tryCompare(tutorialLeft, "opacity", 1);
231 tryCompare(tutorialLeft, "opacity", 1);
212 function cleanup() {
234 function cleanup() {
235+ resetLoader("phone");
238+ function resetLoader(state) {
213 shellLoader.itemDestroyed = false;
239 shellLoader.itemDestroyed = false;
215 shellLoader.active = false;
241 shellLoader.active = false;
242+ shellLoader.state = state;
217 tryCompare(shellLoader, "status", Loader.Null);
244 tryCompare(shellLoader, "status", Loader.Null);
218 tryCompare(shellLoader, "item", null);
245 tryCompare(shellLoader, "item", null);
@@ -224,9 +251,14 @@ Item {
224 // Shell instance gets destroyed.
251 // Shell instance gets destroyed.
225 tryCompare(shellLoader, "itemDestroyed", true);
252 tryCompare(shellLoader, "itemDestroyed", true);
254+ // Reset any futzing our tests may have done with persistent objects
255+ var app = ApplicationManager.findApplication("dialer-app");
257+ app.setStage(ApplicationInfoInterface.SideStage);
259+ SurfaceManager.inputMethodSurface().destroy(); // so that InputMethod will notice new one
227 // kill all (fake) running apps
260 // kill all (fake) running apps
228 killApps();
261 killApps();
229− SurfaceManager.inputMethodSurface().destroy(); // so that InputMethod will notice new one
231 // reload our test subject to get it in a fresh state once again
263 // reload our test subject to get it in a fresh state once again
232 shellLoader.active = true;
264 shellLoader.active = true;
@@ -235,6 +267,22 @@ Item {
235 removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
267 removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
270+ function prepareShell() {
271+ tryCompare(shell, "enabled", true); // enabled by greeter when ready
273+ callManager.foregroundCall = null;
274+ AccountsService.demoEdges = false;
275+ AccountsService.demoEdgesCompleted = [];
276+ AccountsService.demoEdges = true;
278+ LightDM.Greeter.hideGreeter();
281+ function loadShell(state) {
238 function killApps() {
286 function killApps() {
239 while (ApplicationManager.count > 1) {
287 while (ApplicationManager.count > 1) {
240 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
288 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
@@ -273,9 +321,8 @@ Item {
273 var tutorialRight = findChild(shell, "tutorialRight");
321 var tutorialRight = findChild(shell, "tutorialRight");
275 AccountsService.demoEdgesCompleted = ["left", "top"];
323 AccountsService.demoEdgesCompleted = ["left", "top"];
276− ApplicationManager.startApplication("dialer-app");
324+ ApplicationManager.startApplication("gallery-app");
277− ApplicationManager.startApplication("camera-app");
278− ApplicationManager.startApplication("messaging-app");
325+ ApplicationManager.startApplication("facebook-webapp");
280 tryCompare(tutorialLeft, "visible", false);
327 tryCompare(tutorialLeft, "visible", false);
281 tryCompare(tutorialRight, "shown", true);
328 tryCompare(tutorialRight, "shown", true);
@@ -359,7 +406,7 @@ Item {
359 // Just confirm that a long drag ("dash" drag) doesn't confuse us
406 // Just confirm that a long drag ("dash" drag) doesn't confuse us
361 // So that we actually switch to dash and launcher hides
408 // So that we actually switch to dash and launcher hides
362− ApplicationManager.startApplication("dialer-app");
409+ ApplicationManager.startApplication("gallery-app");
364 var launcher = findChild(shell, "launcher");
411 var launcher = findChild(shell, "launcher");
365 var tutorialLeft = findChild(shell, "tutorialLeft");
412 var tutorialLeft = findChild(shell, "tutorialLeft");
@@ -520,7 +567,7 @@ Item {
520 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "right"]);
567 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "right"]);
523− /*function test_tutorialBottomEdges() {
570+ function test_tutorialBottomEdges() {
524 var tutorial = findChild(shell, "tutorial");
571 var tutorial = findChild(shell, "tutorial");
525 var tutorialBottom = findChild(tutorial, "tutorialBottom");
572 var tutorialBottom = findChild(tutorial, "tutorialBottom");
526 var launcher = findChild(shell, "launcher");
573 var launcher = findChild(shell, "launcher");
@@ -537,9 +584,9 @@ Item {
537 verify(!launcher.available);
584 verify(!launcher.available);
538 verify(!stage.spreadEnabled);
585 verify(!stage.spreadEnabled);
539 verify(!panel.indicators.available);
586 verify(!panel.indicators.available);
542− /*function test_tutorialBottomFinish() {
589+ function test_tutorialBottomFinish() {
543 var tutorial = findChild(shell, "tutorial");
590 var tutorial = findChild(shell, "tutorial");
544 var tutorialBottom = findChild(tutorial, "tutorialBottom");
591 var tutorialBottom = findChild(tutorial, "tutorialBottom");
@@ -549,24 +596,65 @@ Item {
549 tryCompare(tutorialBottom, "shown", false);
596 tryCompare(tutorialBottom, "shown", false);
550 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top", "right", "bottom"]);
597 tryCompare(AccountsService, "demoEdgesCompleted", ["left", "top", "right", "bottom"]);
551 tryCompare(AccountsService, "demoEdges", false);
598 tryCompare(AccountsService, "demoEdges", false);
554− /*function test_tutorialBottomDelay() {
601+ function test_tutorialBottomAppearsBeforeRight() {
555− // Test that if we exit the right tutorial, we don't immediately
602+ // Confirm that if bottom edge and right edge would appear on the
556− // jump into bottom tutorial.
603+ // the same app open, bottom edge appears first. (this is a lightly
604+ // edited version of openTutorialRight)
605+ var tutorialLeft = findChild(shell, "tutorialLeft");
606+ var tutorialRight = findChild(shell, "tutorialRight");
557 var tutorialBottom = findChild(shell, "tutorialBottom");
607 var tutorialBottom = findChild(shell, "tutorialBottom");
558− var tutorialBottomTimer = findInvisibleChild(tutorialBottom, "tutorialBottomTimer");
560− tutorialBottomTimer.interval = 1;
609+ AccountsService.demoEdgesCompleted = ["left", "top"];
561− openTutorialRight();
562− ApplicationManager.requestFocusApplication("dialer-app");
610+ ApplicationManager.startApplication("gallery-app");
563− tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
611+ ApplicationManager.startApplication("dialer-app");
565− AccountsService.demoEdgesCompleted = ["left", "top", "right"];
613+ tryCompare(tutorialLeft, "visible", false);
566− verify(tutorialBottomTimer.running);
614+ tryCompare(tutorialRight, "visible", false);
567− verify(!tutorialBottom.shown);
568 tryCompare(tutorialBottom, "shown", true);
615 tryCompare(tutorialBottom, "shown", true);
616+ tryCompare(tutorialBottom, "opacity", 1);
619+ function test_tutorialBottomOnlyCoversSideStageOnTablet() {
620+ loadShell("tablet");
622+ var tutorialBottom = findChild(shell, "tutorialBottom");
623+ var targetHeight = shell.height - units.gu(4);
624+ var mainStageX = units.gu(20);
625+ var sideStageX = shell.width - units.gu(20);
627+ openTutorialBottom();
629+ touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, true, false);
630+ compare(tutorialBottom.opacity, 1);
631+ touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, false, true);
633+ touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, true, false);
634+ verify(tutorialBottom.opacity < 1);
635+ touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, false, true);
638+ function test_tutorialBottomOnlyCoversMainStageOnTablet() {
639+ loadShell("tablet");
641+ var tutorialBottom = findChild(shell, "tutorialBottom");
642+ var targetHeight = shell.height - units.gu(4);
643+ var mainStageX = units.gu(20);
644+ var sideStageX = shell.width - units.gu(20);
646+ openTutorialBottom();
647+ var app = ApplicationManager.findApplication("dialer-app");
648+ app.setStage(ApplicationInfoInterface.MainStage);
650+ touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, true, false);
651+ compare(tutorialBottom.opacity, 1);
652+ touchFlick(shell, sideStageX, shell.height, sideStageX, targetHeight, false, true);
654+ touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, true, false);
655+ verify(tutorialBottom.opacity < 1);
656+ touchFlick(shell, mainStageX, shell.height, mainStageX, targetHeight, false, true);
571 function test_activeCallInterruptsTutorial() {
659 function test_activeCallInterruptsTutorial() {
572 var tutorialLeft = findChild(shell, "tutorialLeft");
660 var tutorialLeft = findChild(shell, "tutorialLeft");
@@ -622,21 +710,20 @@ Item {
624 function test_desktopOnlyShowsTutorialRight() {
712 function test_desktopOnlyShowsTutorialRight() {
625− shell.usageScenario = "desktop";
713+ loadShell("desktop");
627 var tutorialLeft = findChild(shell, "tutorialLeft");
715 var tutorialLeft = findChild(shell, "tutorialLeft");
628 var tutorialTop = findChild(shell, "tutorialTop");
716 var tutorialTop = findChild(shell, "tutorialTop");
629 var tutorialRight = findChild(shell, "tutorialRight");
717 var tutorialRight = findChild(shell, "tutorialRight");
630− //var tutorialBottom = findChild(shell, "tutorialBottom");
718+ var tutorialBottom = findChild(shell, "tutorialBottom");
631 verify(tutorialLeft.skipped);
719 verify(tutorialLeft.skipped);
632 verify(tutorialTop.skipped);
720 verify(tutorialTop.skipped);
633 verify(!tutorialRight.skipped);
721 verify(!tutorialRight.skipped);
634− //verify(tutorialBottom.skipped);
722+ verify(tutorialBottom.skipped);
635 compare(AccountsService.demoEdgesCompleted, []);
723 compare(AccountsService.demoEdgesCompleted, []);
637 ApplicationManager.startApplication("dialer-app");
725 ApplicationManager.startApplication("dialer-app");
638 ApplicationManager.startApplication("camera-app");
726 ApplicationManager.startApplication("camera-app");
639− ApplicationManager.startApplication("messaging-app");
640 tryCompare(tutorialRight, "isReady", true);
727 tryCompare(tutorialRight, "isReady", true);
641 tryCompare(tutorialRight, "shown", true);
728 tryCompare(tutorialRight, "shown", true);