Merge lp:~renatofilho/qtorganizer5-eds/fix-1440878 into lp:qtorganizer5-eds

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Charles Kerr
Approved revision: 85
Merged at revision: 81
Proposed branch: lp:~renatofilho/qtorganizer5-eds/fix-1440878
Merge into: lp:qtorganizer5-eds
Prerequisite: lp:~renatofilho/qtorganizer5-eds/fix-1426519
Diff against target: 301 lines (+164/-41)
5 files modified
organizer/qorganizer-eds-engine.cpp (+13/-9)
tests/unittest/eds-base-test.cpp (+61/-0)
tests/unittest/eds-base-test.h (+3/-0)
tests/unittest/event-test.cpp (+45/-6)
tests/unittest/run-eds-test.sh (+42/-26)
To merge this branch: bzr merge lp:~renatofilho/qtorganizer5-eds/fix-1440878
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+255725@code.launchpad.net

This proposal supersedes a proposal from 2015-04-09.

Commit message

Save a trigger for reminders with with secondsBeforeStart equals 0.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

Some inline comments below.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

The code changes LGTM.

Approving in comments, feel free to top-approve for me once you've got the Jenkins issue sorted

review: Approve
85. By Renato Araujo Oliveira Filho

Removed test workaround.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'organizer/qorganizer-eds-engine.cpp'
2--- organizer/qorganizer-eds-engine.cpp 2015-04-09 17:24:00 +0000
3+++ organizer/qorganizer-eds-engine.cpp 2015-04-09 17:24:00 +0000
4@@ -1798,11 +1798,17 @@
5
6 ECalComponentAlarmTrigger trigger;
7 e_cal_component_alarm_get_trigger(alarm, &trigger);
8+ int relSecs = 0;
9 if (trigger.type == E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START) {
10- aDetail->setSecondsBeforeStart(icaldurationtype_as_int(trigger.u.rel_duration) * -1);
11- } else {
12- aDetail->setSecondsBeforeStart(0);
13+ relSecs = - icaldurationtype_as_int(trigger.u.rel_duration);
14+ if (relSecs < 0) {
15+ relSecs = 0;
16+ qWarning() << "QOrganizer does not support triggers after event start";
17+ }
18+ } else if (trigger.type != E_CAL_COMPONENT_ALARM_TRIGGER_NONE) {
19+ qWarning() << "QOrganizer only supports triggers relative to event start.";
20 }
21+ aDetail->setSecondsBeforeStart(relSecs);
22
23 ECalComponentAlarmRepeat aRepeat;
24 e_cal_component_alarm_get_repeat(alarm, &aRepeat);
25@@ -2414,12 +2420,10 @@
26 break;
27 }
28
29- if (reminder->secondsBeforeStart() > 0) {
30- ECalComponentAlarmTrigger trigger;
31- trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
32- trigger.u.rel_duration = icaldurationtype_from_int(- reminder->secondsBeforeStart());
33- e_cal_component_alarm_set_trigger(alarm, trigger);
34- }
35+ ECalComponentAlarmTrigger trigger;
36+ trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
37+ trigger.u.rel_duration = icaldurationtype_from_int(- reminder->secondsBeforeStart());
38+ e_cal_component_alarm_set_trigger(alarm, trigger);
39
40 ECalComponentAlarmRepeat aRepeat;
41 // TODO: check if this is really necessary
42
43=== modified file 'tests/unittest/eds-base-test.cpp'
44--- tests/unittest/eds-base-test.cpp 2015-03-24 17:56:44 +0000
45+++ tests/unittest/eds-base-test.cpp 2015-04-09 17:24:00 +0000
46@@ -27,6 +27,26 @@
47
48 using namespace QtOrganizer;
49
50+class GScopedPointerUnref
51+{
52+public:
53+ static inline void cleanup(void *pointer)
54+ {
55+ if (pointer) {
56+ g_clear_object(&pointer);
57+ }
58+ }
59+};
60+
61+template<class KLASS>
62+class GScopedPointer : public QScopedPointer<KLASS, GScopedPointerUnref>
63+{
64+public:
65+ GScopedPointer(KLASS* obj = 0)
66+ : QScopedPointer<KLASS, GScopedPointerUnref>(obj)
67+ {}
68+};
69+
70 EDSBaseTest::EDSBaseTest()
71 {
72 qRegisterMetaType<QList<QOrganizerCollectionId> >();
73@@ -52,6 +72,47 @@
74 {
75 }
76
77+QString EDSBaseTest::getEventFromEvolution(const QOrganizerItemId &id,
78+ const QOrganizerCollectionId &collectionId)
79+{
80+ QString uid = id.toString().split("/").last();
81+ GError *error = 0;
82+ GScopedPointer<ESourceRegistry> sourceRegistry(e_source_registry_new_sync(0, &error));
83+ if (error) {
84+ qWarning() << "Fail to create source registry" << error->message;
85+ g_error_free(error);
86+ return QString();
87+ }
88+ GScopedPointer<ESource> calendar;
89+ if (collectionId.isNull()) {
90+ calendar.reset(e_source_registry_ref_default_calendar(sourceRegistry.data()));
91+ } else {
92+ calendar.reset(e_source_registry_ref_source(sourceRegistry.data(),
93+ collectionId.toString().toUtf8().data()));
94+ }
95+ GScopedPointer<EClient> client(e_cal_client_connect_sync(calendar.data(),
96+ E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
97+ 0,
98+ &error));
99+ if (error) {
100+ qWarning() << "Fail to connect to calendar" << error->message;
101+ g_error_free(error);
102+ return QString();
103+ }
104+
105+ icalcomponent *obj = 0;
106+ e_cal_client_get_object_sync(reinterpret_cast<ECalClient*>(client.data()),
107+ uid.toUtf8().data(), 0, &obj, 0, &error);
108+ if (error) {
109+ qWarning() << "Fail to retrieve object:" << error->message;
110+ g_error_free(error);
111+ }
112+
113+ QString result = QString::fromUtf8(icalcomponent_as_ical_string(obj));
114+ icalcomponent_free (obj);
115+ return result;
116+}
117+
118 QString EDSBaseTest::uniqueCollectionName() const
119 {
120 return QUuid::createUuid().toString();
121
122=== modified file 'tests/unittest/eds-base-test.h'
123--- tests/unittest/eds-base-test.h 2014-10-06 14:46:49 +0000
124+++ tests/unittest/eds-base-test.h 2015-04-09 17:24:00 +0000
125@@ -36,6 +36,9 @@
126 virtual void init();
127 virtual void cleanup();
128
129+
130+ QString getEventFromEvolution(const QtOrganizer::QOrganizerItemId &id,
131+ const QtOrganizer::QOrganizerCollectionId &collectionId = QtOrganizer::QOrganizerCollectionId());
132 QString uniqueCollectionName() const;
133 };
134
135
136=== modified file 'tests/unittest/event-test.cpp'
137--- tests/unittest/event-test.cpp 2015-04-09 17:24:00 +0000
138+++ tests/unittest/event-test.cpp 2015-04-09 17:24:00 +0000
139@@ -47,7 +47,6 @@
140 void initTestCase()
141 {
142 EDSBaseTest::init();
143- qDebug() << "INIT TEST CASE";
144
145 m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>());
146
147@@ -61,8 +60,6 @@
148 QVERIFY(saveResult);
149 QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError);
150 QTRY_COMPARE(createdCollection.count(), 1);
151-
152- qDebug() << "END TEST CASE";
153 }
154
155 void cleanupTestCase()
156@@ -377,7 +374,6 @@
157
158 QList<QOrganizerItemId> ids;
159 ids << items[0].id();
160- qDebug() << "Check for item id:" << ids;
161 items = m_engine->items(ids, hint, 0, 0);
162 QCOMPARE(items.count(), 1);
163 QOrganizerCollection collection = m_engine->defaultCollection(0);
164@@ -819,10 +815,53 @@
165 QCOMPARE(newAttendee.participationStatus(), attendee.participationStatus());
166 }
167
168+ // BUG: #1440878
169+ void testReminderOnTime()
170+ {
171+ static QString displayLabelValue = QStringLiteral("event reminder");
172+ static QString descriptionValue = QStringLiteral("event with reminder");
173+
174+ QOrganizerEvent event;
175+ QOrganizerItemAudibleReminder aReminder;
176+ event.setStartDateTime(QDateTime::currentDateTime());
177+ event.setDisplayLabel(displayLabelValue);
178+ event.setDescription(descriptionValue);
179+ aReminder.setSecondsBeforeStart(0);
180+ aReminder.setDataUrl(QString());
181+ event.saveDetail(&aReminder);
182+
183+ QOrganizerEvent event2;
184+ aReminder = QOrganizerItemAudibleReminder();
185+ event2.setStartDateTime(QDateTime::currentDateTime().addDays(2));
186+ event2.setDisplayLabel(displayLabelValue + "_2");
187+ event2.setDescription(descriptionValue);
188+ aReminder.setSecondsBeforeStart(60);
189+ aReminder.setDataUrl(QString());
190+ event2.saveDetail(&aReminder);
191+
192+ QtOrganizer::QOrganizerManager::Error error;
193+ QMap<int, QtOrganizer::QOrganizerManager::Error> errorMap;
194+ QList<QOrganizerItem> items;
195+ QSignalSpy createdItem(m_engine, SIGNAL(itemsAdded(QList<QOrganizerItemId>)));
196+ items << event << event2;
197+ bool saveResult = m_engine->saveItems(&items,
198+ QList<QtOrganizer::QOrganizerItemDetail::DetailType>(),
199+ &errorMap,
200+ &error);
201+ QTRY_COMPARE(createdItem.count(), 1);
202+ QVERIFY(saveResult);
203+
204+ QString vcard = getEventFromEvolution(items[0].id());
205+ QVERIFY(vcard.contains("TRIGGER;VALUE=DURATION;RELATED=START:PT0S"));
206+
207+ vcard = getEventFromEvolution(items[1].id());
208+ QVERIFY(vcard.contains("TRIGGER;VALUE=DURATION;RELATED=START:-PT1M"));
209+ }
210+
211 void testExtendedProperties()
212 {
213- static QString displayLabelValue = QStringLiteral("event with collection attendee");
214- static QString descriptionValue = QStringLiteral("event without collection");
215+ static QString displayLabelValue = QStringLiteral("event with extended property");
216+ static QString descriptionValue = QStringLiteral("event with extended property");
217 QOrganizerItemId itemId;
218 QDateTime currentTime = QDateTime::currentDateTime();
219
220
221=== modified file 'tests/unittest/run-eds-test.sh'
222--- tests/unittest/run-eds-test.sh 2015-04-09 17:24:00 +0000
223+++ tests/unittest/run-eds-test.sh 2015-04-09 17:24:00 +0000
224@@ -1,35 +1,51 @@
225 #!/bin/sh
226
227-#ARG1 - DBUS RUNNERN PATH
228-#ARG2 - TEST EXECUTABLE FULL PATH
229-#ARG3 - TEST NAME
230-#ARG4 - EVOLUTION_CALENDAR_FACTORY FULL PATH
231-#ARG5 - EVOLUTION_CALENDAR_FACTORY SERVICE NAME
232-#ARG6 - EVOLUTION_SOURCE_REGISTRY FULL PATH
233-
234-
235-export TEST_TMP_DIR=$(mktemp -d /tmp/$3_XXXX)
236+echo ARG0=$0 # this script
237+echo ARG1=$1 # full executable path of dbus-test-runner
238+echo ARG2=$2 # full executable path of test app
239+echo ARG3=$3 # test name
240+echo ARG4=$4 # full executable path of evolution-calendar-factory
241+echo ARG5=$5 # bus service name of calendar factory
242+echo ARG6=$6 # full exectuable path of evolution-source-registry
243+echo ARG7=$7 # full executable path of gvfs
244+echo ARG8=$8 # config files
245+
246+# set up the tmpdir and tell the shell to purge it when we exit
247+export TEST_TMP_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d $3-XXXXXXXXXX) || exit 1
248+echo "running test '$3' in ${TEST_TMP_DIR}"
249+
250+# set up the environment variables
251 export QT_QPA_PLATFORM=minimal
252-export HOME=$TEST_TMP_DIR
253-export XDG_RUNTIME_DIR=$TEST_TMP_DIR
254-export XDG_CACHE_HOME=$TEST_TMP_DIR/.cache
255-export XDG_CONFIG_HOME=$TEST_TMP_DIR/.config
256-export XDG_DATA_HOME=$TEST_TMP_DIR/.local/share
257-export XDG_DESKTOP_DIR=$TEST_TMP_DIR
258-export XDG_DOCUMENTS_DIR=$TEST_TMP_DIR
259-export XDG_DOWNLOAD_DIR=$TEST_TMP_DIR
260-export XDG_MUSIC_DIR=$TEST_TMP_DIR
261-export XDG_PICTURES_DIR=$TEST_TMP_DIR
262-export XDG_PUBLICSHARE_DIR=$TEST_TMP_DIR
263-export XDG_TEMPLATES_DIR=$TEST_TMP_DIR
264-export XDG_VIDEOS_DIR=$TEST_TMP_DIR
265+export HOME=${TEST_TMP_DIR}
266+export XDG_RUNTIME_DIR=${TEST_TMP_DIR}
267+export XDG_CACHE_HOME=${TEST_TMP_DIR}/.cache
268+export XDG_CONFIG_HOME=${TEST_TMP_DIR}/.config
269+export XDG_DATA_HOME=${TEST_TMP_DIR}/.local/share
270+export XDG_DESKTOP_DIR=${TEST_TMP_DIR}
271+export XDG_DOCUMENTS_DIR=${TEST_TMP_DIR}
272+export XDG_DOWNLOAD_DIR=${TEST_TMP_DIR}
273+export XDG_MUSIC_DIR=${TEST_TMP_DIR}
274+export XDG_PICTURES_DIR=${TEST_TMP_DIR}
275+export XDG_PUBLICSHARE_DIR=${TEST_TMP_DIR}
276+export XDG_TEMPLATES_DIR=${TEST_TMP_DIR}
277+export XDG_VIDEOS_DIR=${TEST_TMP_DIR}
278 export QORGANIZER_EDS_DEBUG=On
279-
280-echo HOMEDIR=$HOME
281-rm -rf $XDG_DATA_HOME
282+export GIO_USE_VFS=local # needed to ensure GVFS shuts down cleanly after the test is over
283+
284+echo HOMEDIR=${HOME}
285+rm -rf ${XDG_DATA_HOME}
286+
287+# run dbus-test-runner
288 $1 --keep-env --max-wait=90 \
289 --task $2 --task-name $3 --wait-until-complete --wait-for=org.gnome.evolution.dataserver.Calendar4 \
290 --task $4 --task-name "evolution" --wait-until-complete -r
291 #--task $6 --task-name "source-registry" --wait-for=org.gtk.vfs.Daemon -r \
292 #--task $7 --task-name "gvfsd" -r
293-return $?
294+rv=$?
295+
296+# if the test passed, blow away the tmpdir
297+if [ $rv -eq 0 ]; then
298+ rm -rf $TEST_TMP_DIR
299+fi
300+
301+return $rv

Subscribers

People subscribed via source and target branches