on xenial help sign in
Make tryTutorial more useful; add bottom edge tests
9efe8c5Michael Terry
tests/mocks/Unity/Application/ApplicationInfo.h+1−1
@@ -59,7 +59,7 @@ public:
59
59
60 QUrl icon() const override { return m_icon; }
60 QUrl icon() const override { return m_icon; }
61
61
62− void setStage(Stage value);
62+ Q_INVOKABLE void setStage(Stage value); // invokable only for mock
63 Stage stage() const override { return m_stage; }
63 Stage stage() const override { return m_stage; }
64
64
65 Q_INVOKABLE void setState(State value);
65 Q_INVOKABLE void setState(State value);
tests/qmltests/Tutorial/tst_Tutorial.qml+211−124
@@ -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"
28
29
29−Item {
30+Rectangle {
30 id: root
31 id: root
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)
33
35
34 QtObject {
36 QtObject {
35 id: applicationArguments
37 id: applicationArguments
@@ -59,24 +61,62 @@ Item {
59 shellLoader.active = true;
61 shellLoader.active = true;
60 }
62 }
61
63
62− Row {
64+ Item {
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
65
70
66 Loader {
71 Loader {
67 id: shellLoader
72 id: shellLoader
68
73
69 active: false
74 active: false
75+ anchors.horizontalCenter: parent.horizontalCenter
76+ anchors.top: parent.top
77+ anchors.bottom: parent.bottom
78+
79+ property int shellOrientation: Qt.PortraitOrientation
80+ property int nativeOrientation: Qt.PortraitOrientation
81+ property int primaryOrientation: Qt.PortraitOrientation
82+
83+ state: modeSelector.model[modeSelector.selectedIndex]
84+ states: [
85+ State {
86+ name: "phone"
87+ PropertyChanges {
88+ target: shellLoader
70− width: units.gu(40)
89+ width: units.gu(40)
90+ }
91+ },
92+ State {
93+ name: "tablet"
94+ PropertyChanges {
95+ target: shellLoader
96+ width: units.gu(100)
97+ shellOrientation: Qt.LandscapeOrientation
98+ nativeOrientation: Qt.LandscapeOrientation
99+ primaryOrientation: Qt.LandscapeOrientation
100+ }
101+ },
102+ State {
103+ name: "desktop"
104+ PropertyChanges {
105+ target: shellLoader
71− height: units.gu(71)
106+ width: units.gu(100)
107+ }
108+ }
109+ ]
72
110
73 property bool itemDestroyed: false
111 property bool itemDestroyed: false
74 sourceComponent: Component {
112 sourceComponent: Component {
75 Shell {
113 Shell {
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
80 }
120 }
81
121
82 Component.onDestruction: {
122 Component.onDestruction: {
@@ -85,102 +125,92 @@ Item {
85 }
125 }
86 }
126 }
87 }
127 }
128+ }
88
129
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
137+
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)
98− Row {
141+ Row {
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)
104− return;
147+ return;
105−
148+
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();
109− }
110 }
152 }
111 }
153 }
112 }
154 }
155+ }
113
156
114− Row {
157+ Row {
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)
120− return;
163+ return;
121−
164+
122− AccountsService.demoEdges = false;
165+ AccountsService.demoEdges = false;
123− AccountsService.demoEdgesCompleted = [];
166+ AccountsService.demoEdgesCompleted = [];
124− AccountsService.demoEdges = true;
167+ AccountsService.demoEdges = true;
125− }
126 }
168 }
127 }
169 }
170+ }
128
171
129− Row {
172+ Row {
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;
137− }
138 }
180 }
139 }
181 }
140− Label {
141− text: "Active Call"
142− anchors.verticalCenter: parent.verticalCenter
143− }
144 }
182 }
145−
146− Row {
147− anchors { left: parent.left; right: parent.right }
148− CheckBox {
149− activeFocusOnPress: false
150− onCheckedChanged: {
151− var surface = SurfaceManager.inputMethodSurface();
152− if (checked) {
153− surface.setState(Mir.RestoredState);
154− } else {
155− surface.setState(Mir.MinimizedState);
156− }
157− }
158− }
159− Label {
183+ Label {
160− text: "Input Method"
184+ text: "Active Call"
161− anchors.verticalCenter: parent.verticalCenter
185+ anchors.verticalCenter: parent.verticalCenter
162− }
163 }
186 }
187+ }
164
188
165− Row {
189+ Row {
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();
170− return;
171−
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);
176− }
177 }
199 }
178 }
200 }
179− Label {
180− text: "Desktop Mode"
181− anchors.verticalCenter: parent.verticalCenter
182− }
183 }
201 }
202+ Label {
203+ text: "Input Method"
204+ anchors.verticalCenter: parent.verticalCenter
205+ }
206+ }
207+
208+ ItemSelector {
209+ id: modeSelector
210+ anchors { left: parent.left; right: parent.right }
211+ activeFocusOnPress: false
212+ text: "Mode"
213+ model: ["phone", "tablet", "desktop"]
184 }
214 }
185 }
215 }
186 }
216 }
@@ -195,24 +225,21 @@ Item {
195 property real halfHeight: shell ? shell.height / 2 : 0
225 property real halfHeight: shell ? shell.height / 2 : 0
196
226
197 function init() {
227 function init() {
198− tryCompare(shell, "enabled", true); // enabled by greeter when ready
228+ prepareShell();
199−
200− shell.usageScenario = "phone";
201− callManager.foregroundCall = null;
202− AccountsService.demoEdges = false;
203− AccountsService.demoEdgesCompleted = [];
204− AccountsService.demoEdges = true;
205−
206− LightDM.Greeter.hideGreeter();
207
229
208 var tutorialLeft = findChild(shell, "tutorialLeft");
230 var tutorialLeft = findChild(shell, "tutorialLeft");
209 tryCompare(tutorialLeft, "opacity", 1);
231 tryCompare(tutorialLeft, "opacity", 1);
210 }
232 }
211
233
212 function cleanup() {
234 function cleanup() {
235+ resetLoader("phone");
236+ }
237+
238+ function resetLoader(state) {
213 shellLoader.itemDestroyed = false;
239 shellLoader.itemDestroyed = false;
214
240
215 shellLoader.active = false;
241 shellLoader.active = false;
242+ shellLoader.state = state;
216
243
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);
226
253
254+ // Reset any futzing our tests may have done with persistent objects
255+ var app = ApplicationManager.findApplication("dialer-app");
256+ if (app) {
257+ app.setStage(ApplicationInfoInterface.SideStage);
258+ }
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
230
262
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);
236 }
268 }
237
269
270+ function prepareShell() {
271+ tryCompare(shell, "enabled", true); // enabled by greeter when ready
272+
273+ callManager.foregroundCall = null;
274+ AccountsService.demoEdges = false;
275+ AccountsService.demoEdgesCompleted = [];
276+ AccountsService.demoEdges = true;
277+
278+ LightDM.Greeter.hideGreeter();
279+ }
280+
281+ function loadShell(state) {
282+ resetLoader(state);
283+ prepareShell();
284+ }
285+
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");
274
322
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");
279
326
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
360
407
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");
363
410
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"]);
521 }
568 }
522
569
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);
540− }*/
587+ }
541
588
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");
545
592
@@ -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);
552− }*/
599+ }
553
600
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");
559
608
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");
564
612
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);
617+ }
618+
619+ function test_tutorialBottomOnlyCoversSideStageOnTablet() {
620+ loadShell("tablet");
621+
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);
626+
627+ openTutorialBottom();
628+
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);
632+
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);
636+ }
637+
638+ function test_tutorialBottomOnlyCoversMainStageOnTablet() {
639+ loadShell("tablet");
640+
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);
645+
646+ openTutorialBottom();
647+ var app = ApplicationManager.findApplication("dialer-app");
648+ app.setStage(ApplicationInfoInterface.MainStage);
649+
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);
653+
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);
569− }*/
657+ }
570
658
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 {
622 }
710 }
623
711
624 function test_desktopOnlyShowsTutorialRight() {
712 function test_desktopOnlyShowsTutorialRight() {
625− shell.usageScenario = "desktop";
713+ loadShell("desktop");
626
714
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, []);
636
724
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);
642 }
729 }