on xenial help sign in
Delay tutorials if a notification or dialog is present
commit4a2274e589bfe85dffa823cdbbe06b5bf7fb63e8 authorMichael Terry <michael.terry@canonical.com> dateThu 28 Apr 2016, 14:38 (11 years ago) parentabeab16
5 files changed+90−23
qml/Components/Dialogs.qml+2 qml/Shell.qml+2−1 qml/Tutorial/Tutorial.qml+4−4 qml/Tutorial/TutorialContent.qml+5−5 tests/qmltests/Tutorial/tst_Tutorial.qml+77−13
qml/Components/Dialogs.qml+2
@@ -27,6 +27,8 @@ import "../Greeter"
2727Item {
2828 id: root
2929
30+ readonly property alias hasActiveDialog: dialogLoader.active
31+
3032 // to be set from outside, useful mostly for testing purposes
3133 property var unitySessionService: DBusUnitySessionService
3234 property var closeAllApps: function() {
qml/Shell.qml+2−1
@@ -617,7 +617,8 @@ Item {
617617 anchors.fill: parent
618618
619619 paused: callManager.hasCalls || greeter.shown
620− keyboardVisible: inputMethod.state === "shown"
620+ delayed: dialogs.hasActiveDialog || notifications.count > 0 ||
621+ inputMethod.state === "shown"
621622 usageScenario: shell.usageScenario
622623 lastInputTimestamp: inputFilter.lastInputTimestamp
623624 launcher: launcher
qml/Tutorial/Tutorial.qml+4−4
@@ -32,8 +32,8 @@ Item {
3232 property Item panel
3333 property Item stage
3434 property string usageScenario
35− property bool paused
36− property bool keyboardVisible
35+ property bool paused // hide any existing tutorial and don't show new ones
36+ property bool delayed // don't show new tutorials
3737 property int lastInputTimestamp
3838
3939 readonly property bool launcherEnabled: loader.item ? loader.item.launcherEnabled : true
@@ -86,8 +86,8 @@ Item {
8686
8787 Binding {
8888 target: loader.item
89− property: "keyboardVisible"
90− value: root.keyboardVisible
89+ property: "delayed"
90+ value: root.delayed
9191 }
9292
9393 Binding {
qml/Tutorial/TutorialContent.qml+5−5
@@ -27,7 +27,7 @@ Item {
2727 property Item stage
2828 property string usageScenario
2929 property bool paused
30− property bool keyboardVisible
30+ property bool delayed
3131 property var lastInputTimestamp
3232
3333 readonly property bool launcherEnabled: !running
@@ -85,7 +85,7 @@ Item {
8585 hides: [launcher, panel.indicators]
8686 paused: root.paused
8787
88− isReady: !tutorialLeftLoader.skipped && !paused && !keyboardVisible
88+ isReady: !tutorialLeftLoader.skipped && !paused && !delayed
8989
9090 InactivityTimer {
9191 id: tutorialLeftTimer
@@ -119,7 +119,7 @@ Item {
119119 paused: root.paused
120120
121121 skipped: tutorialTopLoader.skipped
122− isReady: tutorialLeftLoader.skipped && !skipped && !paused && !keyboardVisible
122+ isReady: tutorialLeftLoader.skipped && !skipped && !paused && !delayed
123123
124124 InactivityTimer {
125125 id: tutorialTopTimer
@@ -153,7 +153,7 @@ Item {
153153 paused: root.paused
154154
155155 skipped: tutorialLeftLongLoader.skipped
156− isReady: tutorialTopLoader.skipped && !skipped && !paused && !keyboardVisible &&
156+ isReady: tutorialTopLoader.skipped && !skipped && !paused && !delayed &&
157157 ApplicationManager.focusedApplicationId != "unity8-dash"
158158
159159 InactivityTimer {
@@ -189,7 +189,7 @@ Item {
189189 paused: root.paused
190190
191191 skipped: tutorialRightLoader.skipped
192− isReady: tutorialTopLoader.skipped && !skipped && !paused && !keyboardVisible &&
192+ isReady: tutorialTopLoader.skipped && !skipped && !paused && !delayed &&
193193 ApplicationManager.count >= 4
194194
195195 InactivityTimer {
tests/qmltests/Tutorial/tst_Tutorial.qml+77−13
@@ -22,6 +22,7 @@ import Ubuntu.Components 1.3
2222import Ubuntu.Components.ListItems 1.3
2323import Ubuntu.Telephony 0.1 as Telephony
2424import Unity.Application 0.1
25+import Unity.Notifications 1.0
2526import Unity.Test 0.1 as UT
2627import Utils 0.1
2728
@@ -55,6 +56,33 @@ Rectangle {
5556 phoneNumber: "+447812221111"
5657 }
5758
59+ Component {
60+ id: mockNotification
61+ QtObject {}
62+ }
63+
64+ ListModel {
65+ id: mockNotificationsModel
66+
67+ function getRaw(id) {
68+ return mockNotification.createObject(mockNotificationsModel)
69+ }
70+ }
71+
72+ function addNotification() {
73+ var n = {
74+ type: Notification.Confirmation,
75+ hints: {},
76+ summary: "",
77+ body: "",
78+ icon: "",
79+ secondaryIcon: "",
80+ actions: []
81+ };
82+
83+ mockNotificationsModel.append(n);
84+ }
85+
5886 Component.onCompleted: {
5987 // must set the mock mode before loading the Shell
6088 LightDM.Greeter.mockMode = "single-pin";
@@ -262,6 +290,7 @@ Rectangle {
262290 // reload our test subject to get it in a fresh state once again
263291 shellLoader.active = true;
264292
293+ mockNotificationsModel.clear();
265294 tryCompare(shellLoader, "status", Loader.Ready);
266295 removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
267296 }
@@ -690,24 +719,59 @@ Rectangle {
690719 verify(tutorialLeft.shown);
691720 }
692721
693− function test_oskPreventsTutorial() {
694− var surface = SurfaceManager.inputMethodSurface;
695− var inputMethod = findInvisibleChild(shell, "inputMethod");
722+ function test_oskDelaysTutorial() {
723+ var tutorial = findChild(shell, "tutorial");
724+ verify(!tutorial.delayed);
696725
697− AccountsService.demoEdges = false;
698− surface.setState(Mir.RestoredState);
699− tryCompare(inputMethod, "state", "shown");
726+ SurfaceManager.inputMethodSurface.setState(Mir.RestoredState);
700727
728+ tryCompare(tutorial, "delayed", true);
729+ }
730+
731+ function test_notificationDelaysTutorial() {
701732 var tutorial = findChild(shell, "tutorial");
702− tryCompare(tutorial, "keyboardVisible", true);
733+ verify(!tutorial.delayed);
703734
704− AccountsService.demoEdges = true;
705− var tutorialLeft = findChild(shell, "tutorialLeft");
706− verify(!tutorialLeft.shown);
735+ var notifications = findChild(shell, "notificationList");
736+ notifications.model = mockNotificationsModel;
737+ addNotification();
707738
708− surface.setState(Mir.MinimizedState);
709− tryCompare(inputMethod, "state", "hidden");
710− tryCompare(tutorialLeft, "shown", false);
739+ tryCompare(tutorial, "delayed", true);
740+ }
741+
742+ function test_dialogDelaysTutorial() {
743+ var tutorial = findChild(shell, "tutorial");
744+ verify(!tutorial.delayed);
745+
746+ var dialogs = findChild(shell, "dialogs");
747+ dialogs.showPowerDialog();
748+
749+ verify(tutorial.delayed);
750+ }
751+
752+ function test_delayedTutorial() {
753+ var tutorial = findChild(shell, "tutorial");
754+ var tutorialTop = findChild(tutorial, "tutorialTop");
755+ var tutorialTopTimer = findChild(tutorialTop, "tutorialTopTimer");
756+
757+ // Get top tutorial ready
758+ AccountsService.demoEdgesCompleted = ["left"];
759+ verify(tutorialTop.isReady);
760+ verify(tutorialTopTimer.running);
761+
762+ // Confirm that we become unready when delayed, but timer still goes
763+ tutorial.delayed = true;
764+ verify(!tutorialTop.isReady);
765+ verify(tutorialTopTimer.running);
766+
767+ // Confirm that we don't open the tutorial when delayed
768+ tutorialTopTimer.interval = 1;
769+ wait(5);
770+ verify(!tutorialTop.shown);
771+
772+ // Confirm we go back to normal when undelayed
773+ tutorial.delayed = false;
774+ tryCompare(tutorialTop, "shown", true);
711775 }
712776
713777 function test_accountsServiceSettings() {