Merge lp:~zsombi/ubuntu-ui-toolkit/expose-alarm-id into lp:ubuntu-ui-toolkit/staging
- expose-alarm-id
- Merge into staging
Status: | Work in progress |
---|---|
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/expose-alarm-id |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Diff against target: |
639 lines (+268/-31) 14 files modified
components.api (+5/-3) src/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp (+149/-18) src/Ubuntu/Components/plugin/adapters/alarmsadapter_p.h (+19/-0) src/Ubuntu/Components/plugin/alarmmanager_p.cpp (+5/-0) src/Ubuntu/Components/plugin/alarmmanager_p.h (+2/-0) src/Ubuntu/Components/plugin/alarmmanager_p_p.h (+1/-0) src/Ubuntu/Components/plugin/plugin.cpp (+2/-0) src/Ubuntu/Components/plugin/ucalarm.cpp (+12/-1) src/Ubuntu/Components/plugin/ucalarm.h (+3/-0) src/Ubuntu/Components/plugin/ucalarm_p.h (+2/-0) src/Ubuntu/Components/plugin/ucalarmmodel.cpp (+25/-9) src/Ubuntu/Components/plugin/ucalarmmodel.h (+4/-0) tests/resources/alarm/Alarms.qml (+2/-0) tests/unit/tst_alarms/tst_alarms.cpp (+37/-0) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/expose-alarm-id |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cris Dywan | Needs Information | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Nekhelesh Ramananthan | Pending | ||
Review via email: mp+254084@code.launchpad.net |
Commit message
Exposing Alarm.identifier and AlarmModel.
Description of the change
Exposing Alarm.identifier and AlarmModel.
PS Jenkins bot (ps-jenkins) wrote : | # |
Cris Dywan (kalikiana) wrote : | # |
442 UCAlarm::~UCAlarm()
443 {
444 + if (!objectName(
445 + qDebug() << "DESTROYING" << objectName();
446 + }
Forgotten debug line? Or if this was intentional it should be a critical.
Zsombor Egri (zsombi) wrote : | # |
> 442 UCAlarm::~UCAlarm()
> 443 {
> 444 + if (!objectName(
> 445 + qDebug() << "DESTROYING" << objectName();
> 446 + }
>
> Forgotten debug line? Or if this was intentional it should be a critical.
Fixed. Thanks!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1433
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1434
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1435
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
- 1436. By Zsombor Egri
-
staging sync
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1436
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
What's up with this?
Unmerged revisions
- 1436. By Zsombor Egri
-
staging sync
- 1435. By Zsombor Egri
-
staging sync
- 1434. By Zsombor Egri
-
rogue debug removed
- 1433. By Zsombor Egri
-
staging merge
- 1432. By Zsombor Egri
-
alarms returned by get() and find() invokables are hashed to avoid OOM situation
- 1431. By Zsombor Egri
-
tests
- 1430. By Zsombor Egri
-
move JSON conversions into AlarmDataAdapter; data version handling added
- 1429. By Zsombor Egri
-
moving common code in separate functions
- 1428. By Zsombor Egri
-
store alarm ID as separate extended detail from activation URL; use private getter fro identifier, should be applied for the entire property set to simplify the code
- 1427. By Zsombor Egri
-
AlarmModel.find added
Preview Diff
1 | === modified file 'components.api' | |||
2 | --- components.api 2015-07-24 13:31:03 +0000 | |||
3 | +++ components.api 2015-07-27 08:49:11 +0000 | |||
4 | @@ -81,11 +81,12 @@ | |||
5 | 81 | Ubuntu.Components.ActivityIndicator 1.3: AnimatedItem | 81 | Ubuntu.Components.ActivityIndicator 1.3: AnimatedItem |
6 | 82 | property bool onScreen | 82 | property bool onScreen |
7 | 83 | property bool running | 83 | property bool running |
9 | 84 | Ubuntu.Components.Alarm 1.0 0.1: QtObject | 84 | Ubuntu.Components.Alarm 1.2 1.0 0.1: QtObject |
10 | 85 | property QDateTime date | 85 | property QDateTime date |
11 | 86 | property DaysOfWeek daysOfWeek | 86 | property DaysOfWeek daysOfWeek |
12 | 87 | property bool enabled | 87 | property bool enabled |
13 | 88 | readonly property int error | 88 | readonly property int error |
14 | 89 | readonly property string identifier 1.2 | ||
15 | 89 | property string message | 90 | property string message |
16 | 90 | function save() | 91 | function save() |
17 | 91 | function cancel() | 92 | function cancel() |
18 | @@ -134,10 +135,11 @@ | |||
19 | 134 | Fail | 135 | Fail |
20 | 135 | InProgress | 136 | InProgress |
21 | 136 | Ready | 137 | Ready |
23 | 137 | Ubuntu.Components.AlarmModel 1.0 0.1: QAbstractListModel | 138 | Ubuntu.Components.AlarmModel 1.2 1.0 0.1: QAbstractListModel |
24 | 138 | readonly property int count | 139 | readonly property int count |
26 | 139 | function refresh() 1.0 | 140 | function refresh() 1.2 |
27 | 140 | function UCAlarm* get(int index) | 141 | function UCAlarm* get(int index) |
28 | 142 | function UCAlarm* find(string alarmId) 1.2 | ||
29 | 141 | Ubuntu.Components.Argument 1.0 0.1: QtObject | 143 | Ubuntu.Components.Argument 1.0 0.1: QtObject |
30 | 142 | property string help | 144 | property string help |
31 | 143 | function var at(int i) | 145 | function var at(int i) |
32 | 144 | 146 | ||
33 | === modified file 'src/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp' | |||
34 | --- src/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp 2015-03-24 16:51:39 +0000 | |||
35 | +++ src/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp 2015-07-27 08:49:11 +0000 | |||
36 | @@ -29,6 +29,8 @@ | |||
37 | 29 | #include <QtCore/QJsonDocument> | 29 | #include <QtCore/QJsonDocument> |
38 | 30 | #include <QtCore/QJsonObject> | 30 | #include <QtCore/QJsonObject> |
39 | 31 | #include <QtCore/QJsonArray> | 31 | #include <QtCore/QJsonArray> |
40 | 32 | #include <QtCore/QUuid> | ||
41 | 33 | #include <QtCore/QUrlQuery> | ||
42 | 32 | #include <QtCore/QDebug> | 34 | #include <QtCore/QDebug> |
43 | 33 | 35 | ||
44 | 34 | #define ALARM_DATABASE "%1/alarms.json" | 36 | #define ALARM_DATABASE "%1/alarms.json" |
45 | @@ -43,11 +45,46 @@ | |||
46 | 43 | #define ALARM_COLLECTION "Alarms" | 45 | #define ALARM_COLLECTION "Alarms" |
47 | 44 | 46 | ||
48 | 45 | // special tags used as workaround for bug #1361702 | 47 | // special tags used as workaround for bug #1361702 |
51 | 46 | const char *tagAlarmService = "x-canonical-alarm"; | 48 | const char *tagAlarmService = "x-canonical-alarm"; |
52 | 47 | const char *tagDisabledAlarm = "x-canonical-disabled"; | 49 | const char *tagDisabledAlarm = "x-canonical-disabled"; |
53 | 50 | const char *tagAlarmVersion = "x-canonical-alarm-version"; | ||
54 | 51 | const char *tagAlarmId = "x-canonical-alarm-id"; | ||
55 | 52 | const char *tagActivationUrl = "x-canonical-activation-url"; | ||
56 | 53 | |||
57 | 54 | const char *currentAlarmsVersion= "1.1"; | ||
58 | 48 | 55 | ||
59 | 49 | QTORGANIZER_USE_NAMESPACE | 56 | QTORGANIZER_USE_NAMESPACE |
60 | 50 | 57 | ||
61 | 58 | QString getEventDetail(const QOrganizerItem &item, const char *detailTag) | ||
62 | 59 | { | ||
63 | 60 | QList<QOrganizerItemDetail> details = item.details(QOrganizerItemDetail::TypeExtendedDetail); | ||
64 | 61 | for (int i = 0; i < details.count(); i++) { | ||
65 | 62 | QOrganizerItemDetail detail = details[i]; | ||
66 | 63 | if (detail.value(QOrganizerItemExtendedDetail::FieldName).toString() == QLatin1String(detailTag)) { | ||
67 | 64 | return detail.value(QOrganizerItemExtendedDetail::FieldData).toString(); | ||
68 | 65 | } | ||
69 | 66 | } | ||
70 | 67 | return QString(); | ||
71 | 68 | } | ||
72 | 69 | |||
73 | 70 | void setEventDetail(QOrganizerItem &item, const char *detailTag, const QString &data) | ||
74 | 71 | { | ||
75 | 72 | // remove all previous identifiers from event | ||
76 | 73 | QList<QOrganizerItemDetail> details = item.details(QOrganizerItemDetail::TypeExtendedDetail); | ||
77 | 74 | for (int i = 0; i < details.count(); i++) { | ||
78 | 75 | QOrganizerItemDetail detail = details[i]; | ||
79 | 76 | if (detail.value(QOrganizerItemExtendedDetail::FieldName).toString() == QLatin1String(detailTag)) { | ||
80 | 77 | item.removeDetail(&detail); | ||
81 | 78 | break; | ||
82 | 79 | } | ||
83 | 80 | } | ||
84 | 81 | // save the new detail | ||
85 | 82 | QOrganizerItemExtendedDetail exData; | ||
86 | 83 | exData.setName(detailTag); | ||
87 | 84 | exData.setData(data); | ||
88 | 85 | item.saveDetail(&exData); | ||
89 | 86 | } | ||
90 | 87 | |||
91 | 51 | /*----------------------------------------------------------------------------- | 88 | /*----------------------------------------------------------------------------- |
92 | 52 | * Adaptation layer for Alarm Data. | 89 | * Adaptation layer for Alarm Data. |
93 | 53 | */ | 90 | */ |
94 | @@ -171,6 +208,43 @@ | |||
95 | 171 | return true; | 208 | return true; |
96 | 172 | } | 209 | } |
97 | 173 | 210 | ||
98 | 211 | // retrieve the identifier | ||
99 | 212 | QString AlarmDataAdapter::identifier() | ||
100 | 213 | { | ||
101 | 214 | QString alarmId = getEventDetail(event, tagAlarmId); | ||
102 | 215 | return alarmId; | ||
103 | 216 | } | ||
104 | 217 | |||
105 | 218 | // creates a new identifier and sets it to the event | ||
106 | 219 | void AlarmDataAdapter::resetIdentifier(const QString &savedId) | ||
107 | 220 | { | ||
108 | 221 | QString alarmId = savedId.isNull() ? QUuid::createUuid().toString() : savedId; | ||
109 | 222 | setEventDetail(event, tagAlarmId, alarmId); | ||
110 | 223 | changes |= AlarmManager::Identifier; | ||
111 | 224 | |||
112 | 225 | // update activation url as well | ||
113 | 226 | QUrl url("alarm://open"); | ||
114 | 227 | QUrlQuery query; | ||
115 | 228 | query.addQueryItem("alarmId", alarmId); | ||
116 | 229 | url.setQuery(query); | ||
117 | 230 | setEventDetail(event, tagActivationUrl, url.toString()); | ||
118 | 231 | } | ||
119 | 232 | |||
120 | 233 | // upgrade alarm data to the current version; returns true if upgare was needed | ||
121 | 234 | bool AlarmDataAdapter::upgradeAlarmData() | ||
122 | 235 | { | ||
123 | 236 | QString version = getEventDetail(event, tagAlarmVersion); | ||
124 | 237 | if (version.isEmpty() || version == QStringLiteral("1.0")) { | ||
125 | 238 | // version 1.0, upgrade | ||
126 | 239 | resetIdentifier(); | ||
127 | 240 | // finally upgare to the current version | ||
128 | 241 | setEventDetail(event, tagAlarmVersion, currentAlarmsVersion); | ||
129 | 242 | return true; | ||
130 | 243 | } | ||
131 | 244 | return false; | ||
132 | 245 | } | ||
133 | 246 | |||
134 | 247 | |||
135 | 174 | QVariant AlarmDataAdapter::cookie() const | 248 | QVariant AlarmDataAdapter::cookie() const |
136 | 175 | { | 249 | { |
137 | 176 | return QVariant::fromValue(event.id()); | 250 | return QVariant::fromValue(event.id()); |
138 | @@ -214,6 +288,12 @@ | |||
139 | 214 | if (event.id().managerUri().isEmpty()) { | 288 | if (event.id().managerUri().isEmpty()) { |
140 | 215 | changes = AlarmManager::AllFields; | 289 | changes = AlarmManager::AllFields; |
141 | 216 | } | 290 | } |
142 | 291 | |||
143 | 292 | // make sure the alarm has an identifier set | ||
144 | 293 | if (identifier().isEmpty()) { | ||
145 | 294 | resetIdentifier(); | ||
146 | 295 | } | ||
147 | 296 | |||
148 | 217 | QOrganizerItemSaveRequest *saveRequest = new QOrganizerItemSaveRequest(q_ptr); | 297 | QOrganizerItemSaveRequest *saveRequest = new QOrganizerItemSaveRequest(q_ptr); |
149 | 218 | saveRequest->setItem(event); | 298 | saveRequest->setItem(event); |
150 | 219 | request = saveRequest; | 299 | request = saveRequest; |
151 | @@ -375,6 +455,37 @@ | |||
152 | 375 | } | 455 | } |
153 | 376 | } | 456 | } |
154 | 377 | 457 | ||
155 | 458 | void AlarmDataAdapter::eventFromJson(const QJsonObject &object) | ||
156 | 459 | { | ||
157 | 460 | q_ptr->setMessage(object["message"].toString()); | ||
158 | 461 | q_ptr->setDate(QDateTime::fromString(object["date"].toString())); | ||
159 | 462 | q_ptr->setSound(object["sound"].toString()); | ||
160 | 463 | q_ptr->setType(static_cast<UCAlarm::AlarmType>(object["type"].toInt())); | ||
161 | 464 | q_ptr->setDaysOfWeek(static_cast<UCAlarm::DaysOfWeek>(object["days"].toInt())); | ||
162 | 465 | q_ptr->setEnabled(object["enabled"].toBool()); | ||
163 | 466 | setEventDetail(event, tagAlarmId, object[tagAlarmId].toString()); | ||
164 | 467 | setEventDetail(event, tagActivationUrl, object[tagActivationUrl].toString()); | ||
165 | 468 | setEventDetail(event, tagAlarmVersion, object[tagAlarmVersion].toString()); | ||
166 | 469 | // call checkAlarm to complete field checks (i.e. type vs daysOfWeek, kick date, etc) | ||
167 | 470 | checkAlarm(); | ||
168 | 471 | } | ||
169 | 472 | |||
170 | 473 | QJsonObject AlarmDataAdapter::eventToJson() | ||
171 | 474 | { | ||
172 | 475 | QJsonObject object; | ||
173 | 476 | object[tagAlarmVersion] = QJsonValue(currentAlarmsVersion); | ||
174 | 477 | object["message"] = message(); | ||
175 | 478 | object["date"] = date().toString(); | ||
176 | 479 | object["sound"] = sound().toString(); | ||
177 | 480 | object["type"] = QJsonValue(type()); | ||
178 | 481 | object["days"] = QJsonValue(daysOfWeek()); | ||
179 | 482 | object["enabled"] = QJsonValue(enabled()); | ||
180 | 483 | object[tagAlarmId] = QJsonValue(identifier()); | ||
181 | 484 | object[tagActivationUrl] = QJsonValue(getEventDetail(event, tagActivationUrl)); | ||
182 | 485 | return object; | ||
183 | 486 | } | ||
184 | 487 | |||
185 | 488 | |||
186 | 378 | /*----------------------------------------------------------------------------- | 489 | /*----------------------------------------------------------------------------- |
187 | 379 | * Adaptation layer for Alarms. | 490 | * Adaptation layer for Alarms. |
188 | 380 | */ | 491 | */ |
189 | @@ -475,6 +586,9 @@ | |||
190 | 475 | if (!file.open(QFile::ReadOnly)) { | 586 | if (!file.open(QFile::ReadOnly)) { |
191 | 476 | return; | 587 | return; |
192 | 477 | } | 588 | } |
193 | 589 | // block the manager signals till we load the alarm data into memory | ||
194 | 590 | manager->blockSignals(true); | ||
195 | 591 | |||
196 | 478 | QByteArray data = file.readAll(); | 592 | QByteArray data = file.readAll(); |
197 | 479 | QJsonDocument document(QJsonDocument::fromJson(data)); | 593 | QJsonDocument document(QJsonDocument::fromJson(data)); |
198 | 480 | QJsonArray array = document.array(); | 594 | QJsonArray array = document.array(); |
199 | @@ -483,20 +597,14 @@ | |||
200 | 483 | 597 | ||
201 | 484 | // use UCAlarm to save store JSON data | 598 | // use UCAlarm to save store JSON data |
202 | 485 | UCAlarm alarm; | 599 | UCAlarm alarm; |
203 | 486 | alarm.setMessage(object["message"].toString()); | ||
204 | 487 | alarm.setDate(QDateTime::fromString(object["date"].toString())); | ||
205 | 488 | alarm.setSound(object["sound"].toString()); | ||
206 | 489 | alarm.setType(static_cast<UCAlarm::AlarmType>(object["type"].toInt())); | ||
207 | 490 | alarm.setDaysOfWeek(static_cast<UCAlarm::DaysOfWeek>(object["days"].toInt())); | ||
208 | 491 | alarm.setEnabled(object["enabled"].toBool()); | ||
209 | 492 | |||
210 | 493 | AlarmDataAdapter *pAlarm = static_cast<AlarmDataAdapter*>(UCAlarmPrivate::get(&alarm)); | 600 | AlarmDataAdapter *pAlarm = static_cast<AlarmDataAdapter*>(UCAlarmPrivate::get(&alarm)); |
213 | 494 | // call checkAlarm to complete field checks (i.e. type vs daysOfWeek, kick date, etc) | 601 | pAlarm->eventFromJson(object); |
212 | 495 | pAlarm->checkAlarm(); | ||
214 | 496 | QOrganizerTodo event = pAlarm->data(); | 602 | QOrganizerTodo event = pAlarm->data(); |
215 | 497 | manager->saveItem(&event); | 603 | manager->saveItem(&event); |
216 | 498 | } | 604 | } |
217 | 499 | file.close(); | 605 | file.close(); |
218 | 606 | // unblock signals | ||
219 | 607 | manager->blockSignals(false); | ||
220 | 500 | } | 608 | } |
221 | 501 | 609 | ||
222 | 502 | // save fallback manager data only | 610 | // save fallback manager data only |
223 | @@ -517,13 +625,8 @@ | |||
224 | 517 | for(int i = 0; i < alarmList.count(); i++) { | 625 | for(int i = 0; i < alarmList.count(); i++) { |
225 | 518 | // create an UCAlarm and set its event to ease conversions | 626 | // create an UCAlarm and set its event to ease conversions |
226 | 519 | const UCAlarm *alarm = alarmList[i]; | 627 | const UCAlarm *alarm = alarmList[i]; |
234 | 520 | QJsonObject object; | 628 | AlarmDataAdapter *pAlarm = static_cast<AlarmDataAdapter*>(UCAlarmPrivate::get(alarm)); |
235 | 521 | object["message"] = alarm->message(); | 629 | QJsonObject object = pAlarm->eventToJson(); |
229 | 522 | object["date"] = alarm->date().toString(); | ||
230 | 523 | object["sound"] = alarm->sound().toString(); | ||
231 | 524 | object["type"] = QJsonValue(alarm->type()); | ||
232 | 525 | object["days"] = QJsonValue(alarm->daysOfWeek()); | ||
233 | 526 | object["enabled"] = QJsonValue(alarm->enabled()); | ||
236 | 527 | data.append(object); | 630 | data.append(object); |
237 | 528 | 631 | ||
238 | 529 | } | 632 | } |
239 | @@ -662,6 +765,12 @@ | |||
240 | 662 | return false; | 765 | return false; |
241 | 663 | } | 766 | } |
242 | 664 | 767 | ||
243 | 768 | UCAlarm *AlarmsAdapter::findAlarm(const QString &alarmId) const | ||
244 | 769 | { | ||
245 | 770 | Q_ASSERT(!alarmId.isEmpty()); | ||
246 | 771 | return const_cast<UCAlarm*>(alarmList.find(alarmId)); | ||
247 | 772 | } | ||
248 | 773 | |||
249 | 665 | // returns a todo event from an ID, which can be an occurence | 774 | // returns a todo event from an ID, which can be an occurence |
250 | 666 | QOrganizerTodo AlarmsAdapter::todoItem(const QOrganizerItemId &id) | 775 | QOrganizerTodo AlarmsAdapter::todoItem(const QOrganizerItemId &id) |
251 | 667 | { | 776 | { |
252 | @@ -756,6 +865,12 @@ | |||
253 | 756 | 865 | ||
254 | 757 | QSet<QOrganizerItemId> parentId; | 866 | QSet<QOrganizerItemId> parentId; |
255 | 758 | QOrganizerTodo event; | 867 | QOrganizerTodo event; |
256 | 868 | bool upgraded = false; | ||
257 | 869 | |||
258 | 870 | // disable manager signals till we fetch the alarms so in case we must upgrade | ||
259 | 871 | // an alarm we won't get update signals | ||
260 | 872 | manager->blockSignals(true); | ||
261 | 873 | |||
262 | 759 | Q_FOREACH(const QOrganizerItem &item, fetchRequest->items()) { | 874 | Q_FOREACH(const QOrganizerItem &item, fetchRequest->items()) { |
263 | 760 | // repeating alarms may be fetched as occurences, therefore check their parent event | 875 | // repeating alarms may be fetched as occurences, therefore check their parent event |
264 | 761 | if (item.type() == QOrganizerItemType::TypeTodoOccurrence) { | 876 | if (item.type() == QOrganizerItemType::TypeTodoOccurrence) { |
265 | @@ -776,10 +891,26 @@ | |||
266 | 776 | UCAlarm alarm; | 891 | UCAlarm alarm; |
267 | 777 | AlarmDataAdapter *pAlarm = static_cast<AlarmDataAdapter*>(UCAlarmPrivate::get(&alarm)); | 892 | AlarmDataAdapter *pAlarm = static_cast<AlarmDataAdapter*>(UCAlarmPrivate::get(&alarm)); |
268 | 778 | pAlarm->setData(event); | 893 | pAlarm->setData(event); |
269 | 894 | // check if we need to upgrade the event to the current version | ||
270 | 895 | if (pAlarm->upgradeAlarmData()) { | ||
271 | 896 | // use synchronous save so we omit async signal replies | ||
272 | 897 | event = pAlarm->data(); | ||
273 | 898 | manager->saveItem(&event); | ||
274 | 899 | saveAlarms(); | ||
275 | 900 | upgraded = true; | ||
276 | 901 | } | ||
277 | 779 | adjustAlarmOccurrence(*pAlarm); | 902 | adjustAlarmOccurrence(*pAlarm); |
278 | 780 | alarmList.insert(alarm); | 903 | alarmList.insert(alarm); |
279 | 781 | } | 904 | } |
280 | 782 | 905 | ||
281 | 906 | // save upgrades | ||
282 | 907 | if (upgraded) { | ||
283 | 908 | saveAlarms(); | ||
284 | 909 | } | ||
285 | 910 | |||
286 | 911 | // re-enable manager signals | ||
287 | 912 | manager->blockSignals(false); | ||
288 | 913 | |||
289 | 783 | completed = true; | 914 | completed = true; |
290 | 784 | Q_EMIT q_ptr->alarmsRefreshed(); | 915 | Q_EMIT q_ptr->alarmsRefreshed(); |
291 | 785 | } | 916 | } |
292 | 786 | 917 | ||
293 | === modified file 'src/Ubuntu/Components/plugin/adapters/alarmsadapter_p.h' | |||
294 | --- src/Ubuntu/Components/plugin/adapters/alarmsadapter_p.h 2015-03-24 16:51:39 +0000 | |||
295 | +++ src/Ubuntu/Components/plugin/adapters/alarmsadapter_p.h 2015-07-27 08:49:11 +0000 | |||
296 | @@ -49,6 +49,8 @@ | |||
297 | 49 | bool setDaysOfWeek(UCAlarm::DaysOfWeek days); | 49 | bool setDaysOfWeek(UCAlarm::DaysOfWeek days); |
298 | 50 | QUrl sound() const; | 50 | QUrl sound() const; |
299 | 51 | bool setSound(const QUrl &sound); | 51 | bool setSound(const QUrl &sound); |
300 | 52 | QString identifier(); | ||
301 | 53 | void resetIdentifier(const QString &savedId = QString()); | ||
302 | 52 | QVariant cookie() const; | 54 | QVariant cookie() const; |
303 | 53 | UCAlarm::Error checkAlarm(); | 55 | UCAlarm::Error checkAlarm(); |
304 | 54 | 56 | ||
305 | @@ -62,6 +64,7 @@ | |||
306 | 62 | 64 | ||
307 | 63 | // adaptation specific data | 65 | // adaptation specific data |
308 | 64 | void adjustDowSettings(UCAlarm::AlarmType type, UCAlarm::DaysOfWeek days); | 66 | void adjustDowSettings(UCAlarm::AlarmType type, UCAlarm::DaysOfWeek days); |
309 | 67 | bool upgradeAlarmData(); | ||
310 | 65 | static QSet<Qt::DayOfWeek> daysToSet(int days); | 68 | static QSet<Qt::DayOfWeek> daysToSet(int days); |
311 | 66 | static UCAlarm::DaysOfWeek daysFromSet(const QSet<Qt::DayOfWeek> &set); | 69 | static UCAlarm::DaysOfWeek daysFromSet(const QSet<Qt::DayOfWeek> &set); |
312 | 67 | 70 | ||
313 | @@ -71,6 +74,9 @@ | |||
314 | 71 | } | 74 | } |
315 | 72 | void setData(const QOrganizerTodo &data); | 75 | void setData(const QOrganizerTodo &data); |
316 | 73 | 76 | ||
317 | 77 | void eventFromJson(const QJsonObject &object); | ||
318 | 78 | QJsonObject eventToJson(); | ||
319 | 79 | |||
320 | 74 | protected: | 80 | protected: |
321 | 75 | QOrganizerTodo event; | 81 | QOrganizerTodo event; |
322 | 76 | UCAlarm::AlarmType alarmType; | 82 | UCAlarm::AlarmType alarmType; |
323 | @@ -140,6 +146,18 @@ | |||
324 | 140 | UCAlarm *alarm = takeAt(index); | 146 | UCAlarm *alarm = takeAt(index); |
325 | 141 | delete alarm; | 147 | delete alarm; |
326 | 142 | } | 148 | } |
327 | 149 | // find an alarm from its ID | ||
328 | 150 | const UCAlarm *find(const QString &alarmId) const | ||
329 | 151 | { | ||
330 | 152 | QMapIterator< QPair<QDateTime, QOrganizerItemId>, UCAlarm* > i(data); | ||
331 | 153 | while (i.hasNext()) { | ||
332 | 154 | i.next(); | ||
333 | 155 | if (UCAlarmPrivate::get(i.value())->identifier() == alarmId) { | ||
334 | 156 | return i.value(); | ||
335 | 157 | } | ||
336 | 158 | } | ||
337 | 159 | return NULL; | ||
338 | 160 | } | ||
339 | 143 | 161 | ||
340 | 144 | protected: | 162 | protected: |
341 | 145 | // removes alarm data at index and returns the alarm pointer | 163 | // removes alarm data at index and returns the alarm pointer |
342 | @@ -183,6 +201,7 @@ | |||
343 | 183 | int alarmCount(); | 201 | int alarmCount(); |
344 | 184 | UCAlarm *getAlarmAt(int index) const; | 202 | UCAlarm *getAlarmAt(int index) const; |
345 | 185 | bool findAlarm(const UCAlarm &alarm, const QVariant &cookie) const; | 203 | bool findAlarm(const UCAlarm &alarm, const QVariant &cookie) const; |
346 | 204 | UCAlarm *findAlarm(const QString &alarmId) const; | ||
347 | 186 | void adjustAlarmOccurrence(AlarmDataAdapter &alarm); | 205 | void adjustAlarmOccurrence(AlarmDataAdapter &alarm); |
348 | 187 | 206 | ||
349 | 188 | void loadAlarms(); | 207 | void loadAlarms(); |
350 | 189 | 208 | ||
351 | === modified file 'src/Ubuntu/Components/plugin/alarmmanager_p.cpp' | |||
352 | --- src/Ubuntu/Components/plugin/alarmmanager_p.cpp 2015-02-26 15:09:23 +0000 | |||
353 | +++ src/Ubuntu/Components/plugin/alarmmanager_p.cpp 2015-07-27 08:49:11 +0000 | |||
354 | @@ -78,6 +78,11 @@ | |||
355 | 78 | return &alarm; | 78 | return &alarm; |
356 | 79 | } | 79 | } |
357 | 80 | 80 | ||
358 | 81 | UCAlarm *AlarmManager::findAlarm(const QString &alarmId) const | ||
359 | 82 | { | ||
360 | 83 | return d_ptr->findAlarm(alarmId); | ||
361 | 84 | } | ||
362 | 85 | |||
363 | 81 | bool AlarmManager::verifyChange(UCAlarm *alarm, Change change, const QVariant &newData) | 86 | bool AlarmManager::verifyChange(UCAlarm *alarm, Change change, const QVariant &newData) |
364 | 82 | { | 87 | { |
365 | 83 | return d_ptr->verifyChange(alarm, change, newData); | 88 | return d_ptr->verifyChange(alarm, change, newData); |
366 | 84 | 89 | ||
367 | === modified file 'src/Ubuntu/Components/plugin/alarmmanager_p.h' | |||
368 | --- src/Ubuntu/Components/plugin/alarmmanager_p.h 2015-02-26 10:27:56 +0000 | |||
369 | +++ src/Ubuntu/Components/plugin/alarmmanager_p.h 2015-07-27 08:49:11 +0000 | |||
370 | @@ -89,6 +89,7 @@ | |||
371 | 89 | Sound = 0x0008, | 89 | Sound = 0x0008, |
372 | 90 | Type = 0x0010, | 90 | Type = 0x0010, |
373 | 91 | Days = 0x0020, | 91 | Days = 0x0020, |
374 | 92 | Identifier = 0x0040, | ||
375 | 92 | AllFields = 0x00FF | 93 | AllFields = 0x00FF |
376 | 93 | }; | 94 | }; |
377 | 94 | 95 | ||
378 | @@ -100,6 +101,7 @@ | |||
379 | 100 | int alarmCount(); | 101 | int alarmCount(); |
380 | 101 | UCAlarm *alarmAt(int index); | 102 | UCAlarm *alarmAt(int index); |
381 | 102 | UCAlarm *findAlarm(const QVariant &cookie) const; | 103 | UCAlarm *findAlarm(const QVariant &cookie) const; |
382 | 104 | UCAlarm *findAlarm(const QString &alarmId) const; | ||
383 | 103 | 105 | ||
384 | 104 | bool verifyChange(UCAlarm *alarm, Change change, const QVariant &newData); | 106 | bool verifyChange(UCAlarm *alarm, Change change, const QVariant &newData); |
385 | 105 | static UCAlarmPrivate *createAlarmData(UCAlarm *alarm); | 107 | static UCAlarmPrivate *createAlarmData(UCAlarm *alarm); |
386 | 106 | 108 | ||
387 | === modified file 'src/Ubuntu/Components/plugin/alarmmanager_p_p.h' | |||
388 | --- src/Ubuntu/Components/plugin/alarmmanager_p_p.h 2015-02-26 15:09:23 +0000 | |||
389 | +++ src/Ubuntu/Components/plugin/alarmmanager_p_p.h 2015-07-27 08:49:11 +0000 | |||
390 | @@ -47,6 +47,7 @@ | |||
391 | 47 | virtual int alarmCount() = 0; | 47 | virtual int alarmCount() = 0; |
392 | 48 | virtual UCAlarm *getAlarmAt(int index) const = 0; | 48 | virtual UCAlarm *getAlarmAt(int index) const = 0; |
393 | 49 | virtual bool findAlarm(const UCAlarm &alarm, const QVariant &cookie) const = 0; | 49 | virtual bool findAlarm(const UCAlarm &alarm, const QVariant &cookie) const = 0; |
394 | 50 | virtual UCAlarm *findAlarm(const QString &alarmId) const = 0; | ||
395 | 50 | 51 | ||
396 | 51 | // function to verify whether the given alarm property has a given value set | 52 | // function to verify whether the given alarm property has a given value set |
397 | 52 | // used for testing purposes | 53 | // used for testing purposes |
398 | 53 | 54 | ||
399 | === modified file 'src/Ubuntu/Components/plugin/plugin.cpp' | |||
400 | --- src/Ubuntu/Components/plugin/plugin.cpp 2015-07-19 17:44:46 +0000 | |||
401 | +++ src/Ubuntu/Components/plugin/plugin.cpp 2015-07-27 08:49:11 +0000 | |||
402 | @@ -197,6 +197,8 @@ | |||
403 | 197 | qmlRegisterType<UCServiceProperties, 1>(uri, 1, 1, "ServiceProperties"); | 197 | qmlRegisterType<UCServiceProperties, 1>(uri, 1, 1, "ServiceProperties"); |
404 | 198 | 198 | ||
405 | 199 | // register 1.2 only API | 199 | // register 1.2 only API |
406 | 200 | qmlRegisterType<UCAlarm, 1>(uri, 1, 2, "Alarm"); | ||
407 | 201 | qmlRegisterType<UCAlarmModel, 1>(uri, 1, 2, "AlarmModel"); | ||
408 | 200 | qmlRegisterType<UCListItem>(uri, 1, 2, "ListItem"); | 202 | qmlRegisterType<UCListItem>(uri, 1, 2, "ListItem"); |
409 | 201 | qmlRegisterType<UCListItemDivider>(); | 203 | qmlRegisterType<UCListItemDivider>(); |
410 | 202 | qmlRegisterUncreatableType<UCSwipeEvent>(uri, 1, 2, "SwipeEvent", "This is an event object."); | 204 | qmlRegisterUncreatableType<UCSwipeEvent>(uri, 1, 2, "SwipeEvent", "This is an event object."); |
411 | 203 | 205 | ||
412 | === modified file 'src/Ubuntu/Components/plugin/ucalarm.cpp' | |||
413 | --- src/Ubuntu/Components/plugin/ucalarm.cpp 2015-03-03 13:47:48 +0000 | |||
414 | +++ src/Ubuntu/Components/plugin/ucalarm.cpp 2015-07-27 08:49:11 +0000 | |||
415 | @@ -41,6 +41,7 @@ | |||
416 | 41 | setMessage(UbuntuI18n::instance().tr("Alarm")); | 41 | setMessage(UbuntuI18n::instance().tr("Alarm")); |
417 | 42 | setType(UCAlarm::OneTime); | 42 | setType(UCAlarm::OneTime); |
418 | 43 | setDaysOfWeek(UCAlarm::AutoDetect); | 43 | setDaysOfWeek(UCAlarm::AutoDetect); |
419 | 44 | resetIdentifier(); | ||
420 | 44 | } | 45 | } |
421 | 45 | 46 | ||
422 | 46 | void UCAlarmPrivate::_q_syncStatus(int operation, int status, int error) { | 47 | void UCAlarmPrivate::_q_syncStatus(int operation, int status, int error) { |
423 | @@ -64,6 +65,8 @@ | |||
424 | 64 | Q_EMIT q->typeChanged(); | 65 | Q_EMIT q->typeChanged(); |
425 | 65 | if (changes & AlarmManager::Days) | 66 | if (changes & AlarmManager::Days) |
426 | 66 | Q_EMIT q->daysOfWeekChanged(); | 67 | Q_EMIT q->daysOfWeekChanged(); |
427 | 68 | if (changes & AlarmManager::Identifier) | ||
428 | 69 | Q_EMIT q->identifierChanged(); | ||
429 | 67 | changes = 0; | 70 | changes = 0; |
430 | 68 | } | 71 | } |
431 | 69 | 72 | ||
432 | @@ -482,7 +485,7 @@ | |||
433 | 482 | * The property holds the alarm's sound to be played when the alarm is triggered. | 485 | * The property holds the alarm's sound to be played when the alarm is triggered. |
434 | 483 | * An empty url will mean to play the default sound. | 486 | * An empty url will mean to play the default sound. |
435 | 484 | * | 487 | * |
437 | 485 | * The defaul tvalue is an empty url. | 488 | * The default value is an empty url. |
438 | 486 | */ | 489 | */ |
439 | 487 | QUrl UCAlarm::sound() const | 490 | QUrl UCAlarm::sound() const |
440 | 488 | { | 491 | { |
441 | @@ -497,6 +500,14 @@ | |||
442 | 497 | } | 500 | } |
443 | 498 | 501 | ||
444 | 499 | /*! | 502 | /*! |
445 | 503 | * \qmlproperty string Alarm::identifier | ||
446 | 504 | * \readonly | ||
447 | 505 | * \since Ubuntu.Components 1.2 | ||
448 | 506 | * The property specifies the unique identifier of the alarm. The identifier is | ||
449 | 507 | * set when created or when \l reset. | ||
450 | 508 | */ | ||
451 | 509 | |||
452 | 510 | /*! | ||
453 | 500 | * \qmlproperty Error Alarm::error | 511 | * \qmlproperty Error Alarm::error |
454 | 501 | * The property holds the error code occurred during the last performed operation. | 512 | * The property holds the error code occurred during the last performed operation. |
455 | 502 | * | 513 | * |
456 | 503 | 514 | ||
457 | === modified file 'src/Ubuntu/Components/plugin/ucalarm.h' | |||
458 | --- src/Ubuntu/Components/plugin/ucalarm.h 2014-10-09 13:02:27 +0000 | |||
459 | +++ src/Ubuntu/Components/plugin/ucalarm.h 2015-07-27 08:49:11 +0000 | |||
460 | @@ -37,6 +37,7 @@ | |||
461 | 37 | 37 | ||
462 | 38 | Q_PROPERTY(int error READ error NOTIFY errorChanged) | 38 | Q_PROPERTY(int error READ error NOTIFY errorChanged) |
463 | 39 | Q_PROPERTY(Status status READ status NOTIFY statusChanged) | 39 | Q_PROPERTY(Status status READ status NOTIFY statusChanged) |
464 | 40 | Q_PRIVATE_PROPERTY(d_ptr, QString identifier READ identifier NOTIFY identifierChanged REVISION 1) | ||
465 | 40 | 41 | ||
466 | 41 | Q_ENUMS(Status Operation Error AlarmType DayOfWeek) | 42 | Q_ENUMS(Status Operation Error AlarmType DayOfWeek) |
467 | 42 | Q_FLAGS(DaysOfWeek) | 43 | Q_FLAGS(DaysOfWeek) |
468 | @@ -121,6 +122,8 @@ | |||
469 | 121 | void errorChanged(); | 122 | void errorChanged(); |
470 | 122 | void statusChanged(Operation operation); | 123 | void statusChanged(Operation operation); |
471 | 123 | 124 | ||
472 | 125 | Q_REVISION(1) void identifierChanged(); | ||
473 | 126 | |||
474 | 124 | public Q_SLOTS: | 127 | public Q_SLOTS: |
475 | 125 | void save(); | 128 | void save(); |
476 | 126 | void cancel(); | 129 | void cancel(); |
477 | 127 | 130 | ||
478 | === modified file 'src/Ubuntu/Components/plugin/ucalarm_p.h' | |||
479 | --- src/Ubuntu/Components/plugin/ucalarm_p.h 2015-03-24 16:51:39 +0000 | |||
480 | +++ src/Ubuntu/Components/plugin/ucalarm_p.h 2015-07-27 08:49:11 +0000 | |||
481 | @@ -51,6 +51,8 @@ | |||
482 | 51 | virtual bool setDaysOfWeek(UCAlarm::DaysOfWeek days) = 0; | 51 | virtual bool setDaysOfWeek(UCAlarm::DaysOfWeek days) = 0; |
483 | 52 | virtual QUrl sound() const = 0; | 52 | virtual QUrl sound() const = 0; |
484 | 53 | virtual bool setSound(const QUrl &sound) = 0; | 53 | virtual bool setSound(const QUrl &sound) = 0; |
485 | 54 | virtual QString identifier() = 0; | ||
486 | 55 | virtual void resetIdentifier(const QString &savedId = QString()) = 0; | ||
487 | 54 | virtual QVariant cookie() const = 0; | 56 | virtual QVariant cookie() const = 0; |
488 | 55 | virtual UCAlarm::Error checkAlarm() = 0; | 57 | virtual UCAlarm::Error checkAlarm() = 0; |
489 | 56 | 58 | ||
490 | 57 | 59 | ||
491 | === modified file 'src/Ubuntu/Components/plugin/ucalarmmodel.cpp' | |||
492 | --- src/Ubuntu/Components/plugin/ucalarmmodel.cpp 2015-06-16 13:15:41 +0000 | |||
493 | +++ src/Ubuntu/Components/plugin/ucalarmmodel.cpp 2015-07-27 08:49:11 +0000 | |||
494 | @@ -22,7 +22,6 @@ | |||
495 | 22 | #include "alarmmanager_p.h" | 22 | #include "alarmmanager_p.h" |
496 | 23 | #include <QtQml/QQmlPropertyMap> | 23 | #include <QtQml/QQmlPropertyMap> |
497 | 24 | #include <QtQml/QQmlInfo> | 24 | #include <QtQml/QQmlInfo> |
498 | 25 | #include <QtQml/QQmlEngine> | ||
499 | 26 | 25 | ||
500 | 27 | /*! | 26 | /*! |
501 | 28 | * \qmltype AlarmModel | 27 | * \qmltype AlarmModel |
502 | @@ -156,6 +155,19 @@ | |||
503 | 156 | refresh(); | 155 | refresh(); |
504 | 157 | } | 156 | } |
505 | 158 | 157 | ||
506 | 158 | UCAlarm *UCAlarmModel::hashedAlarm(UCAlarm *alarm) | ||
507 | 159 | { | ||
508 | 160 | UCAlarm *result = 0; | ||
509 | 161 | const QString &id = UCAlarmPrivate::get(alarm)->identifier(); | ||
510 | 162 | result = alarmHash.value(id).data(); | ||
511 | 163 | if (!result) { | ||
512 | 164 | result = new UCAlarm(this); | ||
513 | 165 | UCAlarmPrivate::get(result)->copyAlarmData(*alarm); | ||
514 | 166 | alarmHash.insert(id, QPointer<UCAlarm>(result)); | ||
515 | 167 | } | ||
516 | 168 | return result; | ||
517 | 169 | } | ||
518 | 170 | |||
519 | 159 | int UCAlarmModel::rowCount(const QModelIndex &parent) const | 171 | int UCAlarmModel::rowCount(const QModelIndex &parent) const |
520 | 160 | { | 172 | { |
521 | 161 | Q_UNUSED(parent); | 173 | Q_UNUSED(parent); |
522 | @@ -215,14 +227,18 @@ | |||
523 | 215 | */ | 227 | */ |
524 | 216 | UCAlarm* UCAlarmModel::get(int index) | 228 | UCAlarm* UCAlarmModel::get(int index) |
525 | 217 | { | 229 | { |
534 | 218 | UCAlarm *alarm = AlarmManager::instance().alarmAt(index); | 230 | return hashedAlarm(AlarmManager::instance().alarmAt(index)); |
535 | 219 | if (alarm) { | 231 | } |
536 | 220 | UCAlarm *tempAlarm = new UCAlarm(this); | 232 | |
537 | 221 | UCAlarmPrivate::get(tempAlarm)->copyAlarmData(*alarm); | 233 | /*! |
538 | 222 | alarm = tempAlarm; | 234 | * \qmlmethod Alarm AlarmModel::find(string alarmId) |
539 | 223 | QQmlEngine::setObjectOwnership(tempAlarm, QQmlEngine::JavaScriptOwnership); | 235 | * \since Ubuntu.Components 1.2 |
540 | 224 | } | 236 | * The function returns the alarm identified by the \c alarmId. The \c alarmId |
541 | 225 | return alarm; | 237 | * cannot be an empty string. Returns null on error. |
542 | 238 | */ | ||
543 | 239 | UCAlarm *UCAlarmModel::find(const QString &alarmId) | ||
544 | 240 | { | ||
545 | 241 | return hashedAlarm(AlarmManager::instance().findAlarm(alarmId)); | ||
546 | 226 | } | 242 | } |
547 | 227 | 243 | ||
548 | 228 | /*! | 244 | /*! |
549 | 229 | 245 | ||
550 | === modified file 'src/Ubuntu/Components/plugin/ucalarmmodel.h' | |||
551 | --- src/Ubuntu/Components/plugin/ucalarmmodel.h 2015-06-16 11:34:02 +0000 | |||
552 | +++ src/Ubuntu/Components/plugin/ucalarmmodel.h 2015-07-27 08:49:11 +0000 | |||
553 | @@ -43,6 +43,7 @@ | |||
554 | 43 | 43 | ||
555 | 44 | // invokables | 44 | // invokables |
556 | 45 | Q_INVOKABLE UCAlarm *get(int index); | 45 | Q_INVOKABLE UCAlarm *get(int index); |
557 | 46 | Q_REVISION(1) Q_INVOKABLE UCAlarm *find(const QString &alarmId); | ||
558 | 46 | 47 | ||
559 | 47 | // property getters | 48 | // property getters |
560 | 48 | int count() const; | 49 | int count() const; |
561 | @@ -65,7 +66,10 @@ | |||
562 | 65 | void moveFinished(); | 66 | void moveFinished(); |
563 | 66 | 67 | ||
564 | 67 | private: | 68 | private: |
565 | 69 | QHash<QString, QPointer<UCAlarm> > alarmHash; | ||
566 | 68 | bool m_moved:1; | 70 | bool m_moved:1; |
567 | 71 | |||
568 | 72 | UCAlarm *hashedAlarm(UCAlarm *alarm); | ||
569 | 69 | }; | 73 | }; |
570 | 70 | 74 | ||
571 | 71 | #endif // UCALARMSMODEL_H | 75 | #endif // UCALARMSMODEL_H |
572 | 72 | 76 | ||
573 | === modified file 'tests/resources/alarm/Alarms.qml' | |||
574 | --- tests/resources/alarm/Alarms.qml 2015-03-03 13:20:06 +0000 | |||
575 | +++ tests/resources/alarm/Alarms.qml 2015-07-27 08:49:11 +0000 | |||
576 | @@ -26,6 +26,8 @@ | |||
577 | 26 | height: units.gu(71) | 26 | height: units.gu(71) |
578 | 27 | objectName: "mainView" | 27 | objectName: "mainView" |
579 | 28 | 28 | ||
580 | 29 | applicationName: "com.canonical.alarmtest" | ||
581 | 30 | |||
582 | 29 | AlarmModel{ | 31 | AlarmModel{ |
583 | 30 | id: alarmModel | 32 | id: alarmModel |
584 | 31 | } | 33 | } |
585 | 32 | 34 | ||
586 | === modified file 'tests/unit/tst_alarms/tst_alarms.cpp' | |||
587 | --- tests/unit/tst_alarms/tst_alarms.cpp 2014-11-20 06:36:45 +0000 | |||
588 | +++ tests/unit/tst_alarms/tst_alarms.cpp 2015-07-27 08:49:11 +0000 | |||
589 | @@ -103,6 +103,15 @@ | |||
590 | 103 | return false; | 103 | return false; |
591 | 104 | } | 104 | } |
592 | 105 | 105 | ||
593 | 106 | QString createOneTime(const QString &message) | ||
594 | 107 | { | ||
595 | 108 | UCAlarm alarm(QDateTime::currentDateTime(), UCAlarm::AutoDetect, "test_" + message); | ||
596 | 109 | alarm.setSound(QUrl("file:///usr/share/sounds/ubuntu/ringtones/Bliss.ogg")); | ||
597 | 110 | alarm.save(); | ||
598 | 111 | waitForInsert(); | ||
599 | 112 | return UCAlarmPrivate::get(&alarm)->identifier(); | ||
600 | 113 | } | ||
601 | 114 | |||
602 | 106 | private Q_SLOTS: | 115 | private Q_SLOTS: |
603 | 107 | 116 | ||
604 | 108 | void initTestCase() | 117 | void initTestCase() |
605 | @@ -583,6 +592,34 @@ | |||
606 | 583 | // check the tags | 592 | // check the tags |
607 | 584 | QVERIFY(AlarmManager::instance().verifyChange(&alarm, AlarmManager::Enabled, enabled)); | 593 | QVERIFY(AlarmManager::instance().verifyChange(&alarm, AlarmManager::Enabled, enabled)); |
608 | 585 | } | 594 | } |
609 | 595 | |||
610 | 596 | void test_alarm_identifier() | ||
611 | 597 | { | ||
612 | 598 | UCAlarm alarm; | ||
613 | 599 | QVERIFY(!UCAlarmPrivate::get(&alarm)->identifier().isEmpty()); | ||
614 | 600 | } | ||
615 | 601 | |||
616 | 602 | void test_alarm_identifier_differs_on_reset() | ||
617 | 603 | { | ||
618 | 604 | UCAlarm alarm; | ||
619 | 605 | QString id = UCAlarmPrivate::get(&alarm)->identifier(); | ||
620 | 606 | alarm.reset(); | ||
621 | 607 | QVERIFY(!UCAlarmPrivate::get(&alarm)->identifier().isEmpty()); | ||
622 | 608 | QVERIFY(UCAlarmPrivate::get(&alarm)->identifier() != id); | ||
623 | 609 | } | ||
624 | 610 | |||
625 | 611 | void test_find_alarm_by_id() | ||
626 | 612 | { | ||
627 | 613 | QStringList ids; | ||
628 | 614 | for (int i = 0; i < 5; i++) { | ||
629 | 615 | ids << createOneTime(QString("find_alarm_by_id_%1").arg(i)); | ||
630 | 616 | } | ||
631 | 617 | |||
632 | 618 | UCAlarmModel model; | ||
633 | 619 | for (int i = 0; i < ids.count(); i++) { | ||
634 | 620 | QVERIFY(model.find(ids[i])); | ||
635 | 621 | } | ||
636 | 622 | } | ||
637 | 586 | }; | 623 | }; |
638 | 587 | 624 | ||
639 | 588 | QTEST_MAIN(tst_UCAlarms) | 625 | QTEST_MAIN(tst_UCAlarms) |
PASSED: Continuous integration, rev:1431 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1604/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 2005 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-amd64- ci/331 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/334 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-armhf- ci/334/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- vivid-i386- ci/331 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 1766 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2003 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2003/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 19225
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/1604/ rebuild
http://