Merge lp:~nik90/ubuntu-clock-app/3-fix-alarm-refresh-ui into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Superseded
Proposed branch: lp:~nik90/ubuntu-clock-app/3-fix-alarm-refresh-ui
Merge into: lp:ubuntu-clock-app
Diff against target: 188 lines (+84/-5)
7 files modified
app/alarm/AlarmDelegate.qml (+12/-0)
app/clock/ClockPage.qml (+3/-0)
app/clock/MainClock.qml (+5/-0)
app/ubuntu-clock-app.qml (+8/-0)
debian/changelog (+4/-0)
tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu (+48/-0)
tests/unit/tst_alarmRepeat.qml (+4/-5)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/3-fix-alarm-refresh-ui
Reviewer Review Type Date Requested Status
Ubuntu Clock Developers Pending
Review via email: mp+247086@code.launchpad.net

This proposal has been superseded by a proposal from 2015-01-21.

Commit message

Refresh the alarm page ui whenever clock app gains focus to ensure that the alarm switch status is updated properly after the user dismisses an alarm notification.

Description of the change

Refresh the alarm page ui whenever clock app gains focus to ensure that the alarm switch status is updated properly after the user dismisses an alarm notification.

I also added 2 manual test cases to ensure this bug doesn't appear again in the future.

Regression Potential: Minimal since the code change affects only the alarm page UI code and would be visible immediately.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/AlarmDelegate.qml'
2--- app/alarm/AlarmDelegate.qml 2014-11-19 14:56:42 +0000
3+++ app/alarm/AlarmDelegate.qml 2015-01-21 02:37:04 +0000
4@@ -94,6 +94,18 @@
5 if (checked !== model.enabled) {
6 var alarmData = model
7 alarmData.enabled = checked
8+
9+ /*
10+ Calculate the new alarm time if it is a one-time alarm and has
11+ gone-off and the user is re-enabling the alarm. Repeating
12+ alarms do this automatically.
13+ */
14+ if(checked && type === Alarm.OneTime && alarmData.date < new Date()) {
15+ var tomorrow = new Date()
16+ tomorrow.setDate(tomorrow.getDate() + 1)
17+ alarmData.daysOfWeek = alarmUtils.get_alarm_day(tomorrow.getDay())
18+ }
19+
20 alarmData.save()
21 }
22 }
23
24=== modified file 'app/clock/ClockPage.qml'
25--- app/clock/ClockPage.qml 2014-11-04 15:58:05 +0000
26+++ app/clock/ClockPage.qml 2015-01-21 02:37:04 +0000
27@@ -36,6 +36,9 @@
28 // Property to keep track of the clock time
29 property var clockTime: new Date()
30
31+ // Property to keep track of app cold start status
32+ property alias isColdStart: clock.isColdStart
33+
34 property var alarmModel
35
36 flickable: null
37
38=== modified file 'app/clock/MainClock.qml'
39--- app/clock/MainClock.qml 2014-10-10 19:58:49 +0000
40+++ app/clock/MainClock.qml 2015-01-21 02:37:04 +0000
41@@ -23,6 +23,9 @@
42 Clock {
43 id: mainClock
44
45+ // Property to keep track of the cold start status of the app
46+ property bool isColdStart: true
47+
48 fontSize: units.dp(62)
49 periodFontSize: units.dp(12)
50 innerCircleWidth: units.gu(23)
51@@ -98,6 +101,7 @@
52 target: digitalModeLoader.item
53 onAnimationComplete: {
54 alarmModelLoader.source = Qt.resolvedUrl("../alarm/AlarmModelComponent.qml")
55+ isColdStart = false
56 }
57 }
58
59@@ -105,6 +109,7 @@
60 target: analogModeLoader.item
61 onAnimationComplete: {
62 alarmModelLoader.source = Qt.resolvedUrl("../alarm/AlarmModelComponent.qml")
63+ isColdStart = false
64 }
65 }
66 }
67
68=== modified file 'app/ubuntu-clock-app.qml'
69--- app/ubuntu-clock-app.qml 2014-10-28 10:54:45 +0000
70+++ app/ubuntu-clock-app.qml 2015-01-21 02:37:04 +0000
71@@ -86,6 +86,14 @@
72
73 onApplicationStateChanged: {
74 localTimeSource.update()
75+ /*
76+ Reload the alarm model when the clock app gains focus to refresh
77+ the alarm page UI in the case of alarm notifications.
78+ */
79+ if(applicationState && !clockPage.isColdStart) {
80+ alarmModelLoader.source = ""
81+ alarmModelLoader.source = Qt.resolvedUrl("alarm/AlarmModelComponent.qml")
82+ }
83 }
84
85 PageStack {
86
87=== modified file 'debian/changelog'
88--- debian/changelog 2014-11-19 14:51:35 +0000
89+++ debian/changelog 2015-01-21 02:37:04 +0000
90@@ -29,6 +29,10 @@
91 * Added manual test to check disabling of alarms.
92 * Fixed alarm string not being translatable (LP: #1380248)
93 * Fixed the incorrect overriding of alarm delegate model value.
94+ * Fixed qml tests broken in vivid due to listitem behaviour change.
95+ * Fixed one-time alarms not being able to be re-enabled using the alarm switch
96+ after they have gone off once (LP: #1413027)
97+ * OneTime alarms are not automatically dismissed after they are triggered (LP: #1362341)
98
99 [Akiva Shammai Avraham]
100 * Improved the analog clock performance by updating the clock hands every second
101
102=== modified file 'tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu'
103--- tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu 2014-10-25 13:31:26 +0000
104+++ tests/manual/2014.com.ubuntu.clock:clock-tests/jobs/alarms.pxu 2015-01-21 02:37:04 +0000
105@@ -156,3 +156,51 @@
106 The alarm switch should be colorless to indicate it is disabled.
107 5. Wait for the time to pass the alarm time.
108 The alarm should not ring since it was disabled.
109+
110+id: alarm/refresh-one-alarm
111+plugin: manual
112+depends: alarm/trigger-alarm
113+estimated_duration: 120
114+_summary: Test the alarm page refresh issue
115+_description:
116+ This test checks if the alarm listview refreshes appropriately when clock app gains focus.
117+ 1. Launch the clock app.
118+ Clock app opens showing the current local time.
119+ 2. Swipe the bottom edge to open the alarms page.
120+ Alarms page should appear showing a list of alarm. If empty then you should see a
121+ message being displayed that "No saved alarms".
122+ 3. Press the plus icon to create a new one-time alarm. Change the alarm time to ring in the next
123+ minute. Do not change any other options. Save Alarm.
124+ The saved alarm should be displayed in the alarms page.
125+ 4. Wait for the time to pass the alarm time.
126+ The alarm should ring at the time set in the previous step.
127+ 5. Press "Ok" to dismiss the alarm
128+ The alarm should be dismissed.
129+ 6. Check the status of the one-time alarm you just dismissed.
130+ The one-time alarm must be disabled since it was triggered and dismissed by the user.
131+
132+id: alarm/refresh-recurring-alarm
133+plugin: manual
134+depends: alarm/trigger-alarm
135+estimated_duration: 120
136+_summary: Test the alarm switch disable issue
137+_description:
138+ This test checks if the recurring alarm switches stays enabled after dismissing the alarm.
139+ 1. Launch the clock app.
140+ Clock app opens showing the current local time.
141+ 2. Swipe the bottom edge to open the alarms page.
142+ Alarms page should appear showing a list of alarm. If empty then you should see a
143+ message being displayed that "No saved alarms".
144+ 3. Press the plus icon to create a new recurring alarm. Change the alarm time to ring in the next
145+ minute and set it to repeat on 2-3 days (including today). Save Alarm.
146+ The saved alarm should be displayed in the alarms page.
147+ 4. Wait for the time to pass the alarm time.
148+ The alarm should ring at the time set in the previous step.
149+ 5. Press "Ok" to dismiss the alarm
150+ The alarm should be dismissed.
151+ 6. Check the status of the recurring alarm you just dismissed.
152+ The recurring alarm must not be disabled after it was triggered and dismissed by the user since
153+ it is a recurring alarm.
154+ 7. Check the recurring alarm in the datetime indicator.
155+ Indicator datetime should update and show the next occurance day of the recurring alarm you dismissed.
156+
157
158=== modified file 'tests/unit/tst_alarmRepeat.qml'
159--- tests/unit/tst_alarmRepeat.qml 2014-10-05 21:23:09 +0000
160+++ tests/unit/tst_alarmRepeat.qml 2015-01-21 02:37:04 +0000
161@@ -112,12 +112,12 @@
162
163 tryCompare(_alarm, "type", Alarm.OneTime, 3000, "Alarm type is not OneTime by default")
164
165- var dayListItem = findChild(alarmRepeatPageLoader.item, "alarmDay"+3)
166+ var randomDaySwitch = findChild(alarmRepeatPageLoader.item, "daySwitch"+3)
167
168- mouseClick(dayListItem, centerOf(dayListItem).x, centerOf(dayListItem).y)
169+ mouseClick(randomDaySwitch, centerOf(randomDaySwitch).x, centerOf(randomDaySwitch).y)
170 tryCompare(_alarm, "type", Alarm.Repeating, 3000, "Alarm type did not change to Repeating despite enabling a switch")
171
172- mouseClick(dayListItem, centerOf(dayListItem).x, centerOf(dayListItem).y)
173+ mouseClick(randomDaySwitch, centerOf(randomDaySwitch).x, centerOf(randomDaySwitch).y)
174 tryCompare(_alarm, "type", Alarm.OneTime, 3000, "Alarm type is not OneTime despite all switches disabled")
175 }
176
177@@ -129,11 +129,10 @@
178 waitForRendering(alarmRepeatPageLoader.item);
179
180 for(var i=0; i<repeater.count; i++) {
181- var dayListItem = findChild(alarmRepeatPageLoader.item, "alarmDayHolder"+i)
182 var currentDaySwitch = findChild(alarmRepeatPageLoader.item, "daySwitch"+i)
183
184 if(!currentDaySwitch.checked) {
185- mouseClick(dayListItem, centerOf(dayListItem).x, centerOf(dayListItem).y)
186+ mouseClick(currentDaySwitch, centerOf(currentDaySwitch).x, centerOf(currentDaySwitch).y)
187 }
188 }
189

Subscribers

People subscribed via source and target branches