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

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 29
Merged at revision: 25
Proposed branch: lp:~renatofilho/qtorganizer5-eds/fix-1240505
Merge into: lp:qtorganizer5-eds
Diff against target: 555 lines (+329/-20)
9 files modified
qorganizer/CMakeLists.txt (+2/-0)
qorganizer/qorganizer-eds-engine.cpp (+46/-3)
qorganizer/qorganizer-eds-engine.h (+4/-0)
qorganizer/qorganizer-eds-enginedata.h (+2/-1)
qorganizer/qorganizer-eds-removebyidrequestdata.cpp (+131/-0)
qorganizer/qorganizer-eds-removebyidrequestdata.h (+55/-0)
qorganizer/qorganizer-eds-removerequestdata.cpp (+11/-8)
qorganizer/qorganizer-eds-removerequestdata.h (+1/-0)
tests/unittest/event-test.cpp (+77/-8)
To merge this branch: bzr merge lp:~renatofilho/qtorganizer5-eds/fix-1240505
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+200436@code.launchpad.net

Commit message

Implemented remove item by id;

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
26. By Renato Araujo Oliveira Filho

Added missing files.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
27. By Renato Araujo Oliveira Filho

Make sure that the item remove signal is fired.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
28. By Renato Araujo Oliveira Filho

Used Qstring to represet collectionId.
The function QOrganizerCollectionId::fromString does not work if the plugin is not installed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
29. By Renato Araujo Oliveira Filho

Emit the itemRemoved signal only once.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qorganizer/CMakeLists.txt'
2--- qorganizer/CMakeLists.txt 2013-12-03 18:45:04 +0000
3+++ qorganizer/CMakeLists.txt 2014-01-05 21:25:57 +0000
4@@ -11,6 +11,7 @@
5 qorganizer-eds-engineid.cpp
6 qorganizer-eds-removecollectionrequestdata.cpp
7 qorganizer-eds-removerequestdata.cpp
8+ qorganizer-eds-removebyidrequestdata.cpp
9 qorganizer-eds-requestdata.cpp
10 qorganizer-eds-savecollectionrequestdata.cpp
11 qorganizer-eds-saverequestdata.cpp
12@@ -27,6 +28,7 @@
13 qorganizer-eds-engineid.h
14 qorganizer-eds-removecollectionrequestdata.h
15 qorganizer-eds-removerequestdata.h
16+ qorganizer-eds-removebyidrequestdata.h
17 qorganizer-eds-requestdata.h
18 qorganizer-eds-savecollectionrequestdata.h
19 qorganizer-eds-saverequestdata.h
20
21=== modified file 'qorganizer/qorganizer-eds-engine.cpp'
22--- qorganizer/qorganizer-eds-engine.cpp 2013-12-11 15:23:52 +0000
23+++ qorganizer/qorganizer-eds-engine.cpp 2014-01-05 21:25:57 +0000
24@@ -24,6 +24,7 @@
25 #include "qorganizer-eds-fetchbyidrequestdata.h"
26 #include "qorganizer-eds-saverequestdata.h"
27 #include "qorganizer-eds-removerequestdata.h"
28+#include "qorganizer-eds-removebyidrequestdata.h"
29 #include "qorganizer-eds-savecollectionrequestdata.h"
30 #include "qorganizer-eds-removecollectionrequestdata.h"
31 #include "qorganizer-eds-viewwatcher.h"
32@@ -43,6 +44,7 @@
33 #include <QtOrganizer/QOrganizerItemFetchByIdRequest>
34 #include <QtOrganizer/QOrganizerItemSaveRequest>
35 #include <QtOrganizer/QOrganizerItemRemoveRequest>
36+#include <QtOrganizer/QOrganizerItemRemoveByIdRequest>
37 #include <QtOrganizer/QOrganizerCollectionFetchRequest>
38 #include <QtOrganizer/QOrganizerCollectionSaveRequest>
39 #include <QtOrganizer/QOrganizerCollectionRemoveRequest>
40@@ -457,7 +459,9 @@
41 QOrganizerItem &item = items[i];
42 const gchar *uid = static_cast<const gchar*>(g_slist_nth_data(uids, i));
43
44- item.setCollectionId(QOrganizerCollectionId::fromString(data->currentCollection()));
45+ QOrganizerEDSCollectionEngineId *edsCollectionId = new QOrganizerEDSCollectionEngineId(data->currentCollection());
46+ item.setCollectionId(QOrganizerCollectionId(edsCollectionId));
47+
48 QOrganizerEDSEngineId *eid = new QOrganizerEDSEngineId(data->currentCollection(),
49 QString::fromUtf8(uid));
50 item.setId(QOrganizerItemId(eid));
51@@ -497,6 +501,44 @@
52 return true;
53 }
54
55+void QOrganizerEDSEngine::removeItemsByIdAsync(QOrganizerItemRemoveByIdRequest *req)
56+{
57+ qDebug() << Q_FUNC_INFO;
58+ if (req->itemIds().count() == 0) {
59+ QOrganizerManagerEngine::updateItemRemoveByIdRequest(req,
60+ QOrganizerManager::NoError,
61+ QMap<int, QOrganizerManager::Error>(),
62+ QOrganizerAbstractRequest::FinishedState);
63+ return;
64+ }
65+
66+ RemoveByIdRequestData *data = new RemoveByIdRequestData(this, req);
67+ removeItemsByIdAsyncStart(data);
68+}
69+
70+void QOrganizerEDSEngine::removeItemsByIdAsyncStart(RemoveByIdRequestData *data)
71+{
72+ qDebug() << Q_FUNC_INFO;
73+ QString collectionId = data->next();
74+ for(; !collectionId.isNull(); collectionId = data->next()) {
75+ EClient *client = data->parent()->d->m_sourceRegistry->client(collectionId);
76+ data->setClient(client);
77+ g_object_unref(client);
78+ GSList *ids = data->compIds();
79+ GError *gError = 0;
80+ e_cal_client_remove_objects_sync(data->client(), ids, E_CAL_OBJ_MOD_ALL, 0, 0);
81+ QCoreApplication::processEvents();
82+ if (gError) {
83+ qWarning() << "Fail to remove Items" << gError->message;
84+ g_error_free(gError);
85+ gError = 0;
86+ }
87+ data->commit();
88+ }
89+ data->finish();
90+ delete data;
91+}
92+
93 void QOrganizerEDSEngine::removeItemsAsync(QOrganizerItemRemoveRequest *req)
94 {
95 qDebug() << Q_FUNC_INFO;
96@@ -746,6 +788,9 @@
97 case QOrganizerAbstractRequest::ItemRemoveRequest:
98 removeItemsAsync(qobject_cast<QOrganizerItemRemoveRequest*>(req));
99 break;
100+ case QOrganizerAbstractRequest::ItemRemoveByIdRequest:
101+ removeItemsByIdAsync(qobject_cast<QOrganizerItemRemoveByIdRequest*>(req));
102+ break;
103 case QOrganizerAbstractRequest::CollectionSaveRequest:
104 saveCollectionAsync(qobject_cast<QOrganizerCollectionSaveRequest*>(req));
105 break;
106@@ -2019,5 +2064,3 @@
107
108 return comps;
109 }
110-
111-
112
113=== modified file 'qorganizer/qorganizer-eds-engine.h'
114--- qorganizer/qorganizer-eds-engine.h 2013-12-06 16:24:23 +0000
115+++ qorganizer/qorganizer-eds-engine.h 2014-01-05 21:25:57 +0000
116@@ -40,6 +40,7 @@
117 class FetchByIdRequestData;
118 class SaveRequestData;
119 class RemoveRequestData;
120+class RemoveByIdRequestData;
121 class SaveCollectionRequestData;
122 class RemoveCollectionRequestData;
123 class ViewWatcher;
124@@ -207,6 +208,9 @@
125 static void saveItemsAsyncCreated(GObject *source_object, GAsyncResult *res, SaveRequestData *data);
126 static void saveItemsAsyncModified(GObject *source_object, GAsyncResult *res, SaveRequestData *data);
127
128+ void removeItemsByIdAsync(QtOrganizer::QOrganizerItemRemoveByIdRequest *req);
129+ static void removeItemsByIdAsyncStart(RemoveByIdRequestData *data);
130+
131 void removeItemsAsync(QtOrganizer::QOrganizerItemRemoveRequest *req);
132 static void removeItemsAsyncStart(RemoveRequestData *data);
133
134
135=== modified file 'qorganizer/qorganizer-eds-enginedata.h'
136--- qorganizer/qorganizer-eds-enginedata.h 2013-12-01 17:29:50 +0000
137+++ qorganizer/qorganizer-eds-enginedata.h 2014-01-05 21:25:57 +0000
138@@ -41,8 +41,9 @@
139 template<class K>
140 void emitSharedSignals(K* cs)
141 {
142- Q_FOREACH(QtOrganizer::QOrganizerManagerEngine* engine, m_sharedEngines)
143+ Q_FOREACH(QtOrganizer::QOrganizerManagerEngine* engine, m_sharedEngines) {
144 cs->emitSignals(engine);
145+ }
146 }
147
148 ViewWatcher* watch(const QString &collectionId);
149
150=== added file 'qorganizer/qorganizer-eds-removebyidrequestdata.cpp'
151--- qorganizer/qorganizer-eds-removebyidrequestdata.cpp 1970-01-01 00:00:00 +0000
152+++ qorganizer/qorganizer-eds-removebyidrequestdata.cpp 2014-01-05 21:25:57 +0000
153@@ -0,0 +1,131 @@
154+/*
155+ * Copyright 2013 Canonical Ltd.
156+ *
157+ * This file is part of ubuntu-pim-service.
158+ *
159+ * contact-service-app is free software; you can redistribute it and/or modify
160+ * it under the terms of the GNU General Public License as published by
161+ * the Free Software Foundation; version 3.
162+ *
163+ * contact-service-app is distributed in the hope that it will be useful,
164+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
165+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
166+ * GNU General Public License for more details.
167+ *
168+ * You should have received a copy of the GNU General Public License
169+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
170+ */
171+
172+#include "qorganizer-eds-removebyidrequestdata.h"
173+#include "qorganizer-eds-engineid.h"
174+#include "qorganizer-eds-enginedata.h"
175+
176+#include <QtOrganizer/QOrganizerManagerEngine>
177+#include <QtOrganizer/QOrganizerItemRemoveByIdRequest>
178+
179+using namespace QtOrganizer;
180+
181+RemoveByIdRequestData::RemoveByIdRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req)
182+ : RequestData(engine, req),
183+ m_sessionStaterd(0),
184+ m_currentCompIds(0)
185+{
186+ Q_FOREACH(const QOrganizerItemId &id, request<QOrganizerItemRemoveByIdRequest>()->itemIds()) {
187+ QString strId = id.toString();
188+ QString collectionId;
189+ if (strId.contains("/")) {
190+ collectionId = strId.split("/").first();
191+ QSet<QOrganizerItemId> ids = m_pending.value(collectionId);
192+ ids << id;
193+ m_pending.insert(collectionId, ids);
194+ }
195+ }
196+}
197+
198+RemoveByIdRequestData::~RemoveByIdRequestData()
199+{
200+}
201+
202+void RemoveByIdRequestData::finish(QtOrganizer::QOrganizerManager::Error error)
203+{
204+ QOrganizerManagerEngine::updateItemRemoveByIdRequest(request<QOrganizerItemRemoveByIdRequest>(),
205+ error,
206+ QMap<int, QOrganizerManager::Error>(),
207+ QOrganizerAbstractRequest::FinishedState);
208+ //The signal will be fired by the view watcher. Check ViewWatcher::onObjectsRemoved
209+ //emitChangeset(&m_changeSet);
210+}
211+
212+GSList *RemoveByIdRequestData::compIds() const
213+{
214+ return m_currentCompIds;
215+}
216+
217+void RemoveByIdRequestData::commit()
218+{
219+ Q_ASSERT(m_sessionStaterd);
220+ QOrganizerManagerEngine::updateItemRemoveByIdRequest(request<QOrganizerItemRemoveByIdRequest>(),
221+ QtOrganizer::QOrganizerManager::NoError,
222+ QMap<int, QOrganizerManager::Error>(),
223+ QOrganizerAbstractRequest::ActiveState);
224+ reset();
225+}
226+
227+GSList *RemoveByIdRequestData::parseIds(QSet<QOrganizerItemId> iids)
228+{
229+ GSList *ids = 0;
230+ Q_FOREACH(const QOrganizerItemId &iid, iids) {
231+ ECalComponentId *id = g_new0(ECalComponentId, 1);
232+ id->uid = g_strdup(QOrganizerEDSEngineId::toComponentId(iid).toUtf8().data());
233+ id->rid = NULL;
234+ ids = g_slist_append(ids, id);
235+ }
236+
237+ return ids;
238+}
239+
240+QString RemoveByIdRequestData::next()
241+{
242+ Q_ASSERT(!m_sessionStaterd);
243+
244+ if (m_pending.count() > 0) {
245+ m_sessionStaterd = true;
246+ m_currentCollectionId = m_pending.keys().first();
247+ m_currentIds = m_pending[m_currentCollectionId];
248+ m_currentCompIds = parseIds(m_currentIds);
249+ m_pending.remove(m_currentCollectionId);
250+ return m_currentCollectionId;
251+ }
252+ return QString(QString::null);
253+}
254+
255+
256+void RemoveByIdRequestData::reset()
257+{
258+ m_currentIds.clear();
259+ m_currentCollectionId = QString(QString::null);
260+ if (m_currentCompIds) {
261+ g_slist_free_full(m_currentCompIds, (GDestroyNotify)e_cal_component_free_id);
262+ m_currentCompIds = 0;
263+ }
264+ m_sessionStaterd = false;
265+}
266+
267+void RemoveByIdRequestData::cancel()
268+{
269+ Q_ASSERT(m_sessionStaterd);
270+ RequestData::cancel();
271+ clear();
272+}
273+
274+void RemoveByIdRequestData::clear()
275+{
276+ reset();
277+ m_pending.clear();
278+ setClient(0);
279+}
280+
281+QString RemoveByIdRequestData::collectionId() const
282+{
283+ return m_currentCollectionId;
284+}
285
286=== added file 'qorganizer/qorganizer-eds-removebyidrequestdata.h'
287--- qorganizer/qorganizer-eds-removebyidrequestdata.h 1970-01-01 00:00:00 +0000
288+++ qorganizer/qorganizer-eds-removebyidrequestdata.h 2014-01-05 21:25:57 +0000
289@@ -0,0 +1,55 @@
290+/*
291+ * Copyright 2013 Canonical Ltd.
292+ *
293+ * This file is part of ubuntu-pim-service.
294+ *
295+ * contact-service-app is free software; you can redistribute it and/or modify
296+ * it under the terms of the GNU General Public License as published by
297+ * the Free Software Foundation; version 3.
298+ *
299+ * contact-service-app is distributed in the hope that it will be useful,
300+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
301+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
302+ * GNU General Public License for more details.
303+ *
304+ * You should have received a copy of the GNU General Public License
305+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
306+ */
307+
308+#ifndef __QORGANIZER_EDS_REMOVEBYIDQUESTDATA_H__
309+#define __QORGANIZER_EDS_REMOVEBYIDQUESTDATA_H__
310+
311+#include "qorganizer-eds-requestdata.h"
312+
313+#include <glib.h>
314+
315+class RemoveByIdRequestData : public RequestData
316+{
317+public:
318+ RemoveByIdRequestData(QOrganizerEDSEngine *engine, QtOrganizer::QOrganizerAbstractRequest *req);
319+ ~RemoveByIdRequestData();
320+
321+ QString collectionId() const;
322+
323+ void finish(QtOrganizer::QOrganizerManager::Error error = QtOrganizer::QOrganizerManager::NoError);
324+
325+ GSList *compIds() const;
326+
327+ QString next();
328+ void commit();
329+ virtual void cancel();
330+
331+private:
332+ QHash<QString, QSet<QtOrganizer::QOrganizerItemId> > m_pending;
333+ QSet<QtOrganizer::QOrganizerItemId> m_currentIds;
334+ QString m_currentCollectionId;
335+
336+ bool m_sessionStaterd;
337+ GSList *m_currentCompIds;
338+
339+ void reset();
340+ void clear();
341+ GSList *parseIds(QSet<QtOrganizer::QOrganizerItemId> iids);
342+};
343+
344+#endif
345
346=== modified file 'qorganizer/qorganizer-eds-removerequestdata.cpp'
347--- qorganizer/qorganizer-eds-removerequestdata.cpp 2013-12-11 13:16:50 +0000
348+++ qorganizer/qorganizer-eds-removerequestdata.cpp 2014-01-05 21:25:57 +0000
349@@ -74,7 +74,8 @@
350 QMap<int, QOrganizerManager::Error>(),
351 QOrganizerAbstractRequest::FinishedState);
352
353- emitChangeset(&m_changeSet);
354+ //The signal will be fired by the view watcher. Check ViewWatcher::onObjectsRemoved
355+ //emitChangeset(&m_changeSet);
356 }
357
358 GSList *RemoveRequestData::compIds() const
359@@ -89,10 +90,7 @@
360 QtOrganizer::QOrganizerManager::NoError,
361 QMap<int, QOrganizerManager::Error>(),
362 QOrganizerAbstractRequest::ActiveState);
363-
364- m_changeSet.insertRemovedItems(m_currentIds);
365- m_currentCollectionId = QOrganizerCollectionId();
366- clear();
367+ reset();
368 }
369
370 QOrganizerCollectionId RemoveRequestData::next()
371@@ -116,12 +114,11 @@
372 clear();
373 }
374
375-void RemoveRequestData::clear()
376+void RemoveRequestData::reset()
377 {
378- m_changeSet.clearAll();
379+ m_currentCollectionId = QOrganizerCollectionId();
380 m_currentIds.clear();
381
382- setClient(0);
383 if (m_currentCompIds) {
384 g_slist_free_full(m_currentCompIds, (GDestroyNotify)e_cal_component_free_id);
385 m_currentCompIds = 0;
386@@ -129,6 +126,12 @@
387 m_sessionStaterd = false;
388 }
389
390+void RemoveRequestData::clear()
391+{
392+ reset();
393+ setClient(0);
394+}
395+
396 QOrganizerCollectionId RemoveRequestData::collectionId() const
397 {
398 return m_currentCollectionId;
399
400=== modified file 'qorganizer/qorganizer-eds-removerequestdata.h'
401--- qorganizer/qorganizer-eds-removerequestdata.h 2013-12-01 21:48:44 +0000
402+++ qorganizer/qorganizer-eds-removerequestdata.h 2014-01-05 21:25:57 +0000
403@@ -50,6 +50,7 @@
404 QtOrganizer::QOrganizerCollectionId m_currentCollectionId;
405
406 void clear();
407+ void reset();
408 GSList* takeItemsIds(QtOrganizer::QOrganizerCollectionId collectionId);
409 };
410
411
412=== modified file 'tests/unittest/event-test.cpp'
413--- tests/unittest/event-test.cpp 2013-12-11 13:16:50 +0000
414+++ tests/unittest/event-test.cpp 2014-01-05 21:25:57 +0000
415@@ -37,17 +37,22 @@
416 static const QString defaultTaskCollectionName;
417 static const QString collectionTypePropertyName;
418 static const QString taskListTypeName;
419+ static int signalIndex;
420
421 QDateTime m_itemRemovedTime;
422 QDateTime m_requestFinishedTime;
423 QOrganizerEDSEngine *m_engine;
424 QOrganizerCollection m_collection;
425
426+
427 private Q_SLOTS:
428 void init()
429 {
430 EDSBaseTest::init(0);
431
432+ signalIndex = 0;
433+ m_itemRemovedTime = QDateTime();
434+ m_requestFinishedTime = QDateTime();
435 m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>());
436
437 QtOrganizer::QOrganizerManager::Error error;
438@@ -69,12 +74,16 @@
439 void itemRemoved()
440 {
441 m_itemRemovedTime = QDateTime::currentDateTime();
442+ // avoid both signals to be fired at the same time
443+ QTest::qSleep(100);
444 }
445
446 void requestFinished(QOrganizerAbstractRequest::State state)
447 {
448 if (state == QOrganizerAbstractRequest::FinishedState) {
449- m_requestFinishedTime = QDateTime::currentDateTime();
450+ m_requestFinishedTime = QDateTime::currentDateTime();
451+ // avoid both signals to be fired at the same time
452+ QTest::qSleep(100);
453 }
454 }
455
456@@ -177,15 +186,13 @@
457 &error);
458 QVERIFY(saveResult);
459 QCOMPARE(error, QOrganizerManager::NoError);
460+ QCOMPARE(items.size(), 1);
461 QVERIFY(errorMap.isEmpty());
462 QVERIFY(!items[0].id().isNull());
463
464 // append new item to be removed after the test
465 appendToRemove(items[0].id());
466
467- m_itemRemovedTime = QDateTime();
468- m_requestFinishedTime = QDateTime();
469-
470 QOrganizerItemRemoveRequest req;
471 connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)),
472 this, SLOT(requestFinished(QOrganizerAbstractRequest::State)));
473@@ -197,9 +204,71 @@
474 m_engine->waitForRequestFinished(&req, -1);
475
476 // check if the signal item removed was fired after the request finish
477- QVERIFY(!m_itemRemovedTime.isValid());
478- QVERIFY(m_requestFinishedTime.isValid());
479- QVERIFY(m_requestFinishedTime > m_itemRemovedTime);
480+ QTRY_VERIFY(m_requestFinishedTime.isValid());
481+ QTRY_VERIFY(m_itemRemovedTime.isValid());
482+ QVERIFY(m_itemRemovedTime > m_requestFinishedTime);
483+ }
484+
485+ void testRemoveItemById()
486+ {
487+ static QString displayLabelValue = QStringLiteral("event to be removed");
488+ static QString descriptionValue = QStringLiteral("removable event");
489+
490+ QOrganizerTodo todo;
491+ todo.setCollectionId(m_collection.id());
492+ todo.setStartDateTime(QDateTime(QDate(2013, 9, 3), QTime(0,30,0)));
493+ todo.setDisplayLabel(displayLabelValue);
494+ todo.setDescription(descriptionValue);
495+
496+ QtOrganizer::QOrganizerManager::Error error;
497+ QMap<int, QtOrganizer::QOrganizerManager::Error> errorMap;
498+ QList<QOrganizerItem> items;
499+ items << todo;
500+ bool saveResult = m_engine->saveItems(&items,
501+ QList<QtOrganizer::QOrganizerItemDetail::DetailType>(),
502+ &errorMap,
503+ &error);
504+ QVERIFY(saveResult);
505+ QCOMPARE(error, QOrganizerManager::NoError);
506+ QVERIFY(errorMap.isEmpty());
507+ QOrganizerItemId id = items[0].id();
508+ QVERIFY(!id.isNull());
509+
510+ // append new item to be removed after the test
511+ appendToRemove(id);
512+
513+ QOrganizerItemRemoveByIdRequest req;
514+
515+ connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)),
516+ this, SLOT(requestFinished(QOrganizerAbstractRequest::State)));
517+ connect(m_engine, SIGNAL(itemsRemoved(QList<QOrganizerItemId>)),
518+ this, SLOT(itemRemoved()));
519+ req.setItemId(id);
520+
521+ m_engine->startRequest(&req);
522+ m_engine->waitForRequestFinished(&req, -1);
523+
524+ // check if the signal item removed was fired after the request finish
525+ QTRY_VERIFY(m_requestFinishedTime.isValid());
526+ QTRY_VERIFY(m_itemRemovedTime.isValid());
527+ QVERIFY(m_itemRemovedTime > m_requestFinishedTime);
528+
529+ // check if item was removed
530+ QOrganizerItemSortOrder sort;
531+ QOrganizerItemFetchHint hint;
532+ QOrganizerItemIdFilter filter;
533+
534+ QList<QOrganizerItemId> ids;
535+ ids << id;
536+ filter.setIds(ids);
537+ items = m_engine->items(filter,
538+ QDateTime(),
539+ QDateTime(),
540+ 10,
541+ sort,
542+ hint,
543+ &error);
544+ QCOMPARE(items.count(), 0);
545 }
546
547 void testCreateMultipleItemsWithSameCollection()
548@@ -325,7 +394,7 @@
549 const QString EventTest::defaultTaskCollectionName = QStringLiteral("TEST_EVENT_COLLECTION TASK LIST");
550 const QString EventTest::collectionTypePropertyName = QStringLiteral("collection-type");
551 const QString EventTest::taskListTypeName = QStringLiteral("Task List");
552-
553+int EventTest::signalIndex = 0;
554
555 QTEST_MAIN(EventTest)
556

Subscribers

People subscribed via source and target branches