@@ -19,6 +19,7 @@ import QtTest 1.0
1919import AccountsService 0.1
2020import IntegratedLightDM 0.1 as LightDM
2121import Ubuntu.Components 1.1
22+import Ubuntu.Telephony 0.1 as Telephony
2223import Unity.Application 0.1
2324import Unity.Test 0.1 as UT
2425
@@ -45,6 +46,11 @@ Item {
4546 }
4647 }
4748
49+ Telephony.CallEntry {
50+ id: phoneCall
51+ phoneNumber: "+447812221111"
52+ }
53+
4854 Component.onCompleted: {
4955 // must set the mock mode before loading the Shell
5056 LightDM.Greeter.mockMode = "single-pin";
@@ -77,13 +83,29 @@ Item {
7783
7884 Rectangle {
7985 id: buttons
80− color: "white"
86+ color: "black"
8187 width: units.gu(30)
8288 height: shellLoader.height
8389
8490 Column {
8591 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
8692 spacing: units.gu(1)
93+ Row {
94+ anchors { left: parent.left; right: parent.right }
95+ Button {
96+ text: "Hide Greeter"
97+ onClicked: {
98+ if (shellLoader.status !== Loader.Ready)
99+ return;
100+
101+ var greeter = testCase.findChild(shellLoader.item, "greeter");
102+ if (greeter.shown) {
103+ greeter.hide();
104+ }
105+ }
106+ }
107+ }
108+
87109 Row {
88110 anchors { left: parent.left; right: parent.right }
89111 Button {
@@ -98,6 +120,62 @@ Item {
98120 }
99121 }
100122 }
123+
124+ Row {
125+ anchors { left: parent.left; right: parent.right }
126+ CheckBox {
127+ onCheckedChanged: {
128+ if (checked) {
129+ callManager.foregroundCall = phoneCall;
130+ } else {
131+ callManager.foregroundCall = null;
132+ }
133+ }
134+ }
135+ Label {
136+ text: "Active Call"
137+ anchors.verticalCenter: parent.verticalCenter
138+ }
139+ }
140+
141+ Row {
142+ anchors { left: parent.left; right: parent.right }
143+ CheckBox {
144+ activeFocusOnPress: false
145+ onCheckedChanged: {
146+ var surface = SurfaceManager.inputMethodSurface();
147+ if (checked) {
148+ surface.setState(Mir.RestoredState);
149+ } else {
150+ surface.setState(Mir.MinimizedState);
151+ }
152+ }
153+ }
154+ Label {
155+ text: "Input Method"
156+ anchors.verticalCenter: parent.verticalCenter
157+ }
158+ }
159+
160+ Row {
161+ anchors { left: parent.left; right: parent.right }
162+ CheckBox {
163+ onCheckedChanged: {
164+ if (shellLoader.status !== Loader.Ready)
165+ return;
166+
167+ if (checked) {
168+ shellLoader.item.usageScenario = "desktop";
169+ } else {
170+ shellLoader.item.usageScenario = "phone";
171+ }
172+ }
173+ }
174+ Label {
175+ text: "Desktop Mode"
176+ anchors.verticalCenter: parent.verticalCenter
177+ }
178+ }
101179 }
102180 }
103181 }
@@ -114,14 +192,16 @@ Item {
114192 function init() {
115193 tryCompare(shell, "enabled", true); // enabled by greeter when ready
116194
117− var greeter = findChild(shell, "greeter");
118− tryCompare(greeter, "shown", true);
119−
195+ shell.usageScenario = "phone";
196+ callManager.foregroundCall = null;
120197 AccountsService.demoEdges = false;
121198 AccountsService.demoEdgesCompleted = [];
122199 AccountsService.demoEdges = true;
123200
124− tryCompare(greeter, "shown", false);
201+ LightDM.Greeter.hideGreeter();
202+
203+ var tutorialLeft = findChild(shell, "tutorialLeft");
204+ tryCompare(tutorialLeft, "opacity", 1);
125205 }
126206
127207 function cleanup() {
@@ -485,20 +565,121 @@ Item {
485565 tryCompare(tutorialBottom, "shown", true);
486566 }
487567
488− function disabled_test_skipOnDesktop() {
489− var tutorial = findChild(shell, "tutorial");
490− tryCompare(tutorial, "active", true);
491− tryCompare(tutorial, "running", true);
568+ function test_activeCallInterruptsTutorial() {
569+ var tutorialLeft = findChild(shell, "tutorialLeft");
570+ verify(tutorialLeft.shown);
571+ verify(!tutorialLeft.paused);
492572
493− shell.usageScenario = "desktop";
494− tryCompare(tutorial, "active", false);
495− tryCompare(tutorial, "running", false);
573+ callManager.foregroundCall = phoneCall;
574+ verify(!tutorialLeft.shown);
575+ verify(tutorialLeft.paused);
576+ tryCompare(tutorialLeft, "visible", false);
577+
578+ callManager.foregroundCall = null;
579+ verify(tutorialLeft.shown);
580+ verify(!tutorialLeft.paused);
581+ }
582+
583+ function test_greeterInterruptsTutorial() {
584+ var tutorialLeft = findChild(shell, "tutorialLeft");
585+ verify(tutorialLeft.shown);
586+ verify(!tutorialLeft.paused);
587+
588+ LightDM.Greeter.showGreeter();
589+ verify(!tutorialLeft.shown);
590+ verify(tutorialLeft.paused);
591+ tryCompare(tutorialLeft, "visible", false);
592+
593+ LightDM.Greeter.hideGreeter();
594+ tryCompare(tutorialLeft, "shown", true);
595+ verify(!tutorialLeft.paused);
596+ }
597+
598+ function test_interruptionChecksReadyStateWhenDone() {
599+ // If we're done with an interruption (like active call), make sure
600+ // that we don't blindly resume the tutorial -- our trigger
601+ // conditions still need to be met. For example, there need to be
602+ // enough apps open for the right edge tutorial.
603+
604+ openTutorialRight();
605+
606+ var tutorialRight = findChild(shell, "tutorialRight");
607+ verify(tutorialRight.isReady);
608+ verify(tutorialRight.shown);
609+ verify(!tutorialRight.paused);
610+
611+ callManager.foregroundCall = phoneCall;
612+ killApps();
613+ callManager.foregroundCall = null;
614+
615+ verify(!tutorialRight.isReady);
616+ verify(!tutorialRight.shown);
617+ verify(!tutorialRight.paused);
618+ compare(AccountsService.demoEdgesCompleted, ["left", "top"]);
496619 }
497620
498− function disabled_test_interrupted() {
499− goToPage("tutorialLeft");
621+ function test_desktopOnlyShowsTutorialRight() {
622+ shell.usageScenario = "desktop";
623+
624+ var tutorialLeft = findChild(shell, "tutorialLeft");
625+ var tutorialTop = findChild(shell, "tutorialTop");
626+ var tutorialRight = findChild(shell, "tutorialRight");
627+ var tutorialBottom = findChild(shell, "tutorialBottom");
628+ verify(tutorialLeft.skipped);
629+ verify(tutorialTop.skipped);
630+ verify(!tutorialRight.skipped);
631+ verify(tutorialBottom.skipped);
632+ compare(AccountsService.demoEdgesCompleted, []);
633+
500634 ApplicationManager.startApplication("dialer-app");
501− checkFinished();
635+ ApplicationManager.startApplication("camera-app");
636+ ApplicationManager.startApplication("messaging-app");
637+ tryCompare(tutorialRight, "isReady", true);
638+ tryCompare(tutorialRight, "shown", true);
639+ }
640+
641+ function test_oskDoesNotHideTutorial() {
642+ var tutorialLeft = findChild(shell, "tutorialLeft");
643+ verify(tutorialLeft.shown);
644+
645+ var surface = SurfaceManager.inputMethodSurface();
646+ surface.setState(Mir.RestoredState);
647+
648+ var inputMethod = findInvisibleChild(shell, "inputMethod");
649+ tryCompare(inputMethod, "state", "shown");
650+
651+ verify(tutorialLeft.shown);
652+ }
653+
654+ function test_oskPreventsTutorial() {
655+ var surface = SurfaceManager.inputMethodSurface();
656+ var inputMethod = findInvisibleChild(shell, "inputMethod");
657+
658+ AccountsService.demoEdges = false;
659+ surface.setState(Mir.RestoredState);
660+ tryCompare(inputMethod, "state", "shown");
661+
662+ AccountsService.demoEdges = true;
663+ var tutorialLeft = findChild(shell, "tutorialLeft");
664+ verify(!tutorialLeft.shown);
665+
666+ surface.setState(Mir.MinimizedState);
667+ tryCompare(inputMethod, "state", "hidden");
668+ verify(tutorialLeft.shown);
669+ }
670+
671+ function test_accountsServiceSettings() {
672+ var tutorialLeft = findChild(shell, "tutorialLeft");
673+ verify(tutorialLeft != null);
674+ verify(tutorialLeft.shown);
675+
676+ AccountsService.demoEdges = false;
677+ verify(findChild(shell, "tutorialLeft") == null);
678+
679+ AccountsService.demoEdges = true;
680+ tutorialLeft = findChild(shell, "tutorialLeft");
681+ verify(tutorialLeft != null);
682+ verify(tutorialLeft.shown);
502683 }
503684 }
504685}