Merge lp:~zsombi/ubuntu-ui-toolkit/alarm-date-fix into lp:ubuntu-ui-toolkit
- alarm-date-fix
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/alarm-date-fix |
Merge into: | lp:ubuntu-ui-toolkit |
Prerequisite: | lp:~zsombi/ubuntu-ui-toolkit/alarm-fetch-fix |
Diff against target: |
137 lines (+50/-6) 3 files modified
modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp (+9/-5) modules/Ubuntu/Components/plugin/alarmmanager_p.h (+8/-0) tests/unit/tst_alarms/tst_alarms.cpp (+33/-1) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/alarm-date-fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cris Dywan | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+210181@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-04-10.
Commit message
Fix for alarm dates to occur in the same time in all timezones.
Description of the change
Fix for alarm dates to occur in the same time in all timezones.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:976
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nekhelesh Ramananthan (nik90) wrote : | # |
So on testing this MP using the ubuntu-clock-app, I have the following observations.
1. Alarms created in the local tz are saved and properly triggered at the correct time. The correct time is also displayed in the indicator-datetime. Hence one can say that the bug #1283236 is fixed.
2. If I switch from UTC+1 (netherlands) to UTC (london) using the system settings app and then create an alarm for say 11:00 AM, it gets saved as 10:00 AM in the clock app. The indicator also shows the alarm as 10:00 AM. The alarm does *not* trigger at 10:00 AM however.
3. If I perform observation #2 but restart the phone after changing the locale, then things work as expected meaning an alarm saved at 11:00 AM gets triggered at 11:00 AM, shown in the indicator as 11:00 AM as well.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:977
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nekhelesh Ramananthan (nik90) wrote : | # |
I tested this MP since it also includes the MP at https:/
1. Bug #1283236 is fixed. Alarms saved in local tz are triggered in local tz.
2. Bug #1283859 is not fixed. Editing and saving alarms (both single and recurring) doesn't update the alarm time shown in the indicator. The alarm also rings at the original time and not at the updated time.
3. Bug #1285958 Recurring alarms can now be saved on sundays :)
Zsombor Egri (zsombi) wrote : | # |
> I tested this MP since it also includes the MP at
> https:/
> fix/+merge/208749. On testing it, here are my observations.
>
> 1. Bug #1283236 is fixed. Alarms saved in local tz are triggered in local tz.
>
> 2. Bug #1283859 is not fixed. Editing and saving alarms (both single and
> recurring) doesn't update the alarm time shown in the indicator. The alarm
> also rings at the original time and not at the updated time.
Removed attach to the bug as it doesn't seem to be related to Alarm API.
>
> 3. Bug #1285958 Recurring alarms can now be saved on sundays :)
Cris Dywan (kalikiana) wrote : | # |
Should be a good idea to have a small test case for transcodeDate, even if it's internal, to be sure it works as expected.
Zsombor Egri (zsombi) wrote : | # |
> Should be a good idea to have a small test case for transcodeDate, even if
> it's internal, to be sure it works as expected.
Test case added.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:979
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 980. By Zsombor Egri
-
prereq merge
- 981. By Zsombor Egri
-
prereq merge
- 982. By Zsombor Egri
-
prereq merge
- 983. By Zsombor Egri
-
staging merge
Unmerged revisions
Preview Diff
1 | === modified file 'modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp' | |||
2 | --- modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp 2014-04-10 09:53:40 +0000 | |||
3 | +++ modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp 2014-04-10 09:53:40 +0000 | |||
4 | @@ -119,7 +119,7 @@ | |||
5 | 119 | 119 | ||
6 | 120 | int type, days; | 120 | int type, days; |
7 | 121 | in >> alarm.message >> alarm.date >> alarm.sound >> type >> days >> alarm.enabled; | 121 | in >> alarm.message >> alarm.date >> alarm.sound >> type >> days >> alarm.enabled; |
9 | 122 | alarm.originalDate = alarm.date; | 122 | alarm.originalDate = alarm.date = AlarmData::transcodeDate(alarm.date, Qt::LocalTime); |
10 | 123 | alarm.type = static_cast<UCAlarm::AlarmType>(type); | 123 | alarm.type = static_cast<UCAlarm::AlarmType>(type); |
11 | 124 | alarm.days = static_cast<UCAlarm::DaysOfWeek>(days); | 124 | alarm.days = static_cast<UCAlarm::DaysOfWeek>(days); |
12 | 125 | 125 | ||
13 | @@ -148,7 +148,7 @@ | |||
14 | 148 | 148 | ||
15 | 149 | Q_FOREACH(const AlarmData &alarm, alarmList) { | 149 | Q_FOREACH(const AlarmData &alarm, alarmList) { |
16 | 150 | out << alarm.message | 150 | out << alarm.message |
18 | 151 | << alarm.originalDate | 151 | << AlarmData::transcodeDate(alarm.originalDate, Qt::UTC) |
19 | 152 | << alarm.sound | 152 | << alarm.sound |
20 | 153 | << alarm.type | 153 | << alarm.type |
21 | 154 | << alarm.days | 154 | << alarm.days |
22 | @@ -162,7 +162,7 @@ | |||
23 | 162 | { | 162 | { |
24 | 163 | event.setCollectionId(collection.id()); | 163 | event.setCollectionId(collection.id()); |
25 | 164 | event.setAllDay(false); | 164 | event.setAllDay(false); |
27 | 165 | event.setStartDateTime(alarm.date); | 165 | event.setStartDateTime(AlarmData::transcodeDate(alarm.date, Qt::UTC)); |
28 | 166 | event.setDisplayLabel(alarm.message); | 166 | event.setDisplayLabel(alarm.message); |
29 | 167 | 167 | ||
30 | 168 | if (alarm.enabled) { | 168 | if (alarm.enabled) { |
31 | @@ -229,7 +229,7 @@ | |||
32 | 229 | 229 | ||
33 | 230 | alarm.cookie = QVariant::fromValue<QOrganizerItemId>(event.id()); | 230 | alarm.cookie = QVariant::fromValue<QOrganizerItemId>(event.id()); |
34 | 231 | alarm.message = event.displayLabel(); | 231 | alarm.message = event.displayLabel(); |
36 | 232 | alarm.date = AlarmData::normalizeDate(event.startDateTime()); | 232 | alarm.date = AlarmData::transcodeDate(event.startDateTime().toUTC(), Qt::LocalTime); |
37 | 233 | alarm.sound = QUrl(event.description()); | 233 | alarm.sound = QUrl(event.description()); |
38 | 234 | alarm.originalDate = alarm.date; | 234 | alarm.originalDate = alarm.date; |
39 | 235 | 235 | ||
40 | @@ -355,6 +355,10 @@ | |||
41 | 355 | endDate = startDate.addDays(8); | 355 | endDate = startDate.addDays(8); |
42 | 356 | } | 356 | } |
43 | 357 | 357 | ||
44 | 358 | // transcode both dates | ||
45 | 359 | startDate = AlarmData::transcodeDate(startDate, Qt::UTC); | ||
46 | 360 | endDate = AlarmData::transcodeDate(endDate, Qt::UTC); | ||
47 | 361 | |||
48 | 358 | QList<QOrganizerItem> occurrences = manager->itemOccurrences(event, startDate, endDate, 10); | 362 | QList<QOrganizerItem> occurrences = manager->itemOccurrences(event, startDate, endDate, 10); |
49 | 359 | // get the first occurrence and use the date from it | 363 | // get the first occurrence and use the date from it |
50 | 360 | if ((occurrences.length() > 0) && (occurrences[0].type() == QOrganizerItemType::TypeTodoOccurrence)) { | 364 | if ((occurrences.length() > 0) && (occurrences[0].type() == QOrganizerItemType::TypeTodoOccurrence)) { |
51 | @@ -364,7 +368,7 @@ | |||
52 | 364 | // check if the date is after the current datetime | 368 | // check if the date is after the current datetime |
53 | 365 | // the first occurrence is the one closest to the currentDate, therefore we can safely | 369 | // the first occurrence is the one closest to the currentDate, therefore we can safely |
54 | 366 | // set that startDate to the alarm | 370 | // set that startDate to the alarm |
56 | 367 | alarm.date = occurrence.startDateTime(); | 371 | alarm.date = AlarmData::transcodeDate(occurrence.startDateTime().toUTC(), Qt::LocalTime); |
57 | 368 | if (alarm.date > currentDate) { | 372 | if (alarm.date > currentDate) { |
58 | 369 | // we have the proper date set, leave | 373 | // we have the proper date set, leave |
59 | 370 | break; | 374 | break; |
60 | 371 | 375 | ||
61 | === modified file 'modules/Ubuntu/Components/plugin/alarmmanager_p.h' | |||
62 | --- modules/Ubuntu/Components/plugin/alarmmanager_p.h 2014-04-10 09:53:40 +0000 | |||
63 | +++ modules/Ubuntu/Components/plugin/alarmmanager_p.h 2014-04-10 09:53:40 +0000 | |||
64 | @@ -101,6 +101,14 @@ | |||
65 | 101 | return QDateTime(dt.date(), time, dt.timeSpec()); | 101 | return QDateTime(dt.date(), time, dt.timeSpec()); |
66 | 102 | } | 102 | } |
67 | 103 | 103 | ||
68 | 104 | // the function normalizes and transcodes the date into UTC/LocalTime equivalent | ||
69 | 105 | static QDateTime transcodeDate(const QDateTime &dt, Qt::TimeSpec targetSpec) { | ||
70 | 106 | if (dt.timeSpec() == targetSpec) { | ||
71 | 107 | return normalizeDate(dt); | ||
72 | 108 | } | ||
73 | 109 | return QDateTime(dt.date(), normalizeDate(dt).time(), targetSpec); | ||
74 | 110 | } | ||
75 | 111 | |||
76 | 104 | unsigned int changes; | 112 | unsigned int changes; |
77 | 105 | QVariant cookie; | 113 | QVariant cookie; |
78 | 106 | 114 | ||
79 | 107 | 115 | ||
80 | === modified file 'tests/unit/tst_alarms/tst_alarms.cpp' | |||
81 | --- tests/unit/tst_alarms/tst_alarms.cpp 2014-04-10 09:53:40 +0000 | |||
82 | +++ tests/unit/tst_alarms/tst_alarms.cpp 2014-04-10 09:53:40 +0000 | |||
83 | @@ -31,6 +31,7 @@ | |||
84 | 31 | #include <QtCore/QDebug> | 31 | #include <QtCore/QDebug> |
85 | 32 | #include <QtTest/QTest> | 32 | #include <QtTest/QTest> |
86 | 33 | #include <QtTest/QSignalSpy> | 33 | #include <QtTest/QSignalSpy> |
87 | 34 | #include <QtCore/QTimeZone> | ||
88 | 34 | 35 | ||
89 | 35 | class tst_UCAlarms : public QObject | 36 | class tst_UCAlarms : public QObject |
90 | 36 | { | 37 | { |
91 | @@ -126,7 +127,7 @@ | |||
92 | 126 | } | 127 | } |
93 | 127 | 128 | ||
94 | 128 | void test_singleShotAlarmPass() { | 129 | void test_singleShotAlarmPass() { |
96 | 129 | UCAlarm alarm(QDateTime::currentDateTime().addSecs(10), "test_singleShotAlarmPass"); | 130 | UCAlarm alarm(QDateTime::currentDateTime().addSecs(4), "test_singleShotAlarmPass"); |
97 | 130 | alarm.save(); | 131 | alarm.save(); |
98 | 131 | waitForRequest(&alarm); | 132 | waitForRequest(&alarm); |
99 | 132 | QCOMPARE(alarm.error(), (int)UCAlarm::NoError); | 133 | QCOMPARE(alarm.error(), (int)UCAlarm::NoError); |
100 | @@ -424,6 +425,37 @@ | |||
101 | 424 | QVERIFY(containsAlarm(&nextAlarm)); | 425 | QVERIFY(containsAlarm(&nextAlarm)); |
102 | 425 | } | 426 | } |
103 | 426 | 427 | ||
104 | 428 | void test_transcodeDate_data() | ||
105 | 429 | { | ||
106 | 430 | QTest::addColumn<QDateTime>("date"); | ||
107 | 431 | QTest::addColumn<int>("srcSpec"); | ||
108 | 432 | QTest::addColumn<int>("dstSpec"); | ||
109 | 433 | QTest::addColumn<bool>("xfail"); | ||
110 | 434 | |||
111 | 435 | QDateTime now = QDateTime::currentDateTime(); | ||
112 | 436 | QTest::newRow("Local to Local") << now << (int)Qt::LocalTime << (int)Qt::LocalTime << true; | ||
113 | 437 | QTest::newRow("Local to UTC") << now << (int)Qt::LocalTime << (int)Qt::UTC << false; | ||
114 | 438 | QTest::newRow("UTC to UTC") << now << (int)Qt::UTC << (int)Qt::UTC << true; | ||
115 | 439 | QTest::newRow("UTC to Local") << now << (int)Qt::UTC << (int)Qt::LocalTime << false; | ||
116 | 440 | } | ||
117 | 441 | |||
118 | 442 | void test_transcodeDate() | ||
119 | 443 | { | ||
120 | 444 | QFETCH(QDateTime, date); | ||
121 | 445 | QFETCH(int, srcSpec); | ||
122 | 446 | QFETCH(int, dstSpec); | ||
123 | 447 | QFETCH(bool, xfail); | ||
124 | 448 | |||
125 | 449 | QDateTime srcDate = AlarmData::normalizeDate(QDateTime(date.date(), date.time(), (Qt::TimeSpec)srcSpec)); | ||
126 | 450 | QDateTime dstDate(AlarmData::transcodeDate(srcDate, (Qt::TimeSpec)dstSpec)); | ||
127 | 451 | QCOMPARE(srcDate.date(), dstDate.date()); | ||
128 | 452 | QCOMPARE(srcDate.time(), dstDate.time()); | ||
129 | 453 | if (xfail) { | ||
130 | 454 | QEXPECT_FAIL("", "Similar timespec set, expect fail", Continue); | ||
131 | 455 | } | ||
132 | 456 | QVERIFY(srcDate.timeZone() != dstDate.timeZone()); | ||
133 | 457 | } | ||
134 | 458 | |||
135 | 427 | }; | 459 | }; |
136 | 428 | 460 | ||
137 | 429 | QTEST_MAIN(tst_UCAlarms) | 461 | QTEST_MAIN(tst_UCAlarms) |
PASSED: Continuous integration, rev:975 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- ci/1872/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 3809 jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty- touch/3394 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- amd64-ci/ 820 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- armhf-ci/ 820 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- trusty- armhf-ci/ 820/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-trusty/ 3346 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/3827 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/3827/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/3396 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/3396/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/5762 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 4654
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- ui-toolkit- ci/1872/ rebuild
http://