Merge lp:~renatofilho/qtorganizer5-eds/fix-1311165 into lp:qtorganizer5-eds
- fix-1311165
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Bill Filler |
Approved revision: | 80 |
Merged at revision: | 66 |
Proposed branch: | lp:~renatofilho/qtorganizer5-eds/fix-1311165 |
Merge into: | lp:qtorganizer5-eds |
Diff against target: |
1160 lines (+367/-286) 12 files modified
organizer/qorganizer-eds-engine.cpp (+48/-23) organizer/qorganizer-eds-savecollectionrequestdata.cpp (+0/-2) organizer/qorganizer-eds-viewwatcher.cpp (+0/-2) tests/unittest/CMakeLists.txt (+0/-28) tests/unittest/cancel-operation-test.cpp (+2/-8) tests/unittest/collections-test.cpp (+144/-125) tests/unittest/eds-base-test.cpp (+8/-26) tests/unittest/eds-base-test.h (+5/-7) tests/unittest/event-test.cpp (+107/-29) tests/unittest/fetchitem-test.cpp (+3/-6) tests/unittest/recurrence-test.cpp (+27/-26) tests/unittest/run-eds-test.sh (+23/-4) |
To merge this branch: | bzr merge lp:~renatofilho/qtorganizer5-eds/fix-1311165 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Approve | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Nekhelesh Ramananthan (community) | testing on mako n4 image r79 | Approve | |
Review via email:
|
Commit message
Save events in the correct timezone.
Convert UTC times to timezone format before save it.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:66
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 67. By Renato Araujo Oliveira Filho
-
Improve test reliability
Update test script to create a temporary dir every time that test runs.
Create a temporary source for each test.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:67
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 68. By Renato Araujo Oliveira Filho
-
Removed debug messages.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:68
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 69. By Renato Araujo Oliveira Filho
-
Fix tests.
Wait for collection created signal before save a collection.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:69
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 70. By Renato Araujo Oliveira Filho
-
Increased the time for wait the item creation during the collection test.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:70
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 71. By Renato Araujo Oliveira Filho
-
Revert changes.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:71
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mihir Soni (mihirsoni) wrote : | # |
I tested it on Device
It doesn't sync correctly when you create an event from calendar-app. (It creates with lag of 6-7 hours).
It works when you create an event from Google Calendar and it sync corrects to the phone.
- 72. By Renato Araujo Oliveira Filho
-
Use UTC timezone for QDateTime in UTC spec.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:72
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mihir Soni (mihirsoni) wrote : | # |
Hi Reneto ,
It works as expected from Google calendar & from mobile app and sync correctly.
Thanks for this MR.
- 73. By Renato Araujo Oliveira Filho
-
Save floating time in UTC format.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:73
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 74. By Renato Araujo Oliveira Filho
-
Consider QDateTime with invalid timezone as floating time.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:74
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 75. By Renato Araujo Oliveira Filho
-
Improve tests.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:75
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 76. By Renato Araujo Oliveira Filho
-
Avoid save invalid due date.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:76
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:76
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 77. By Renato Araujo Oliveira Filho
-
Remove all calls: QCoreApplicatio
n::processEvent s();
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:77
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 78. By Renato Araujo Oliveira Filho
-
Fix QDateTime parser for floating times.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:78
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Nekhelesh Ramananthan (nik90) wrote : | # |
I tested this MP along with https:/
- 79. By Renato Araujo Oliveira Filho
-
WORKAROUND test to work in jenkins build system.
- 80. By Renato Araujo Oliveira Filho
-
Typo fixed.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Renato Araujo Oliveira Filho (renatofilho) wrote : | # |
Is your branch in sync with latest trunk? YES
Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator? YES
Did you successfully run all tests found in your component's Test Plan on device or emulator? YES
If you changed the UI, was the change specified/approved by design? NO UI CHANGE
If you changed UI labels, did you update the pot file? NO LABEL CHANGE
If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP? NO PACKAGE CHANGE
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:80
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:80
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Charles Kerr (charlesk) wrote : | # |
Looks pretty good to me, especially considering all the different places where this could go wrong... so many different cases to cover :)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Charles Kerr (charlesk) wrote : | # |
Note for landers: <https:/
Preview Diff
1 | === modified file 'organizer/qorganizer-eds-engine.cpp' |
2 | --- organizer/qorganizer-eds-engine.cpp 2014-10-01 21:37:54 +0000 |
3 | +++ organizer/qorganizer-eds-engine.cpp 2014-10-10 14:09:33 +0000 |
4 | @@ -786,7 +786,6 @@ |
5 | |
6 | QOrganizerCollection QOrganizerEDSEngine::defaultCollection(QOrganizerManager::Error* error) |
7 | { |
8 | - qWarning() << Q_FUNC_INFO << "Not implemented"; |
9 | if (error) { |
10 | *error = QOrganizerManager::NoError; |
11 | } |
12 | @@ -873,9 +872,6 @@ |
13 | { |
14 | GError *gError = 0; |
15 | e_source_registry_create_sources_finish(registry, res, &gError); |
16 | - // WORKAROUND: |
17 | - // avoid return immediately after create the source, because EDS is not ready to write on the source |
18 | - QCoreApplication::processEvents(); |
19 | if (gError) { |
20 | qWarning() << "Fail to create sources:" << gError->message; |
21 | g_error_free(gError); |
22 | @@ -1209,15 +1205,20 @@ |
23 | uint tmTime; |
24 | |
25 | if (tzId) { |
26 | - QByteArray tzName(tzId); |
27 | - // keep only the timezone name. |
28 | - tzName = tzName.replace("/freeassociation.sourceforge.net/Tzfile/", ""); |
29 | - const icaltimezone *timezone = const_cast<const icaltimezone *>(icaltimezone_get_builtin_timezone(tzName.constData())); |
30 | + icaltimezone *timezone = icaltimezone_get_builtin_timezone_from_tzid(tzId); |
31 | + // fallback: sometimes the tzId contains the location name |
32 | + if (!timezone) { |
33 | + timezone = icaltimezone_get_builtin_timezone(tzId); |
34 | + } |
35 | tmTime = icaltime_as_timet_with_zone(value, timezone); |
36 | - return QDateTime::fromTime_t(tmTime, QTimeZone(tzId)); |
37 | + QByteArray tzLocationName(icaltimezone_get_location(timezone)); |
38 | + QTimeZone qTz(tzLocationName); |
39 | + return QDateTime::fromTime_t(tmTime, qTz); |
40 | } else { |
41 | tmTime = icaltime_as_timet(value); |
42 | - return QDateTime::fromTime_t(tmTime); |
43 | + QDateTime t = QDateTime::fromTime_t(tmTime).toUTC(); |
44 | + // floating time contains invalid timezone |
45 | + return QDateTime(t.date(), t.time(), QTimeZone()); |
46 | } |
47 | } |
48 | |
49 | @@ -1225,16 +1226,40 @@ |
50 | bool allDay, |
51 | QByteArray *tzId) |
52 | { |
53 | - |
54 | - if (dateTime.timeSpec() == Qt::TimeZone) { |
55 | - const icaltimezone *timezone = 0; |
56 | - *tzId = dateTime.timeZone().id(); |
57 | - timezone = const_cast<const icaltimezone *>(icaltimezone_get_builtin_timezone(tzId->constData())); |
58 | - return icaltime_from_timet_with_zone(dateTime.toTime_t(), allDay, timezone); |
59 | + QDateTime finalDate(dateTime); |
60 | + QTimeZone tz; |
61 | + |
62 | + switch (finalDate.timeSpec()) { |
63 | + case Qt::UTC: |
64 | + case Qt::OffsetFromUTC: |
65 | + // convert date to UTC timezone |
66 | + tz = QTimeZone("UTC"); |
67 | + finalDate = finalDate.toTimeZone(tz); |
68 | + break; |
69 | + case Qt::TimeZone: |
70 | + tz = finalDate.timeZone(); |
71 | + if (!tz.isValid()) { |
72 | + // floating time |
73 | + finalDate = QDateTime(finalDate.date(), finalDate.time(), Qt::UTC); |
74 | + } |
75 | + break; |
76 | + case Qt::LocalTime: |
77 | + tz = QTimeZone(QTimeZone::systemTimeZoneId()); |
78 | + finalDate = finalDate.toTimeZone(tz); |
79 | + break; |
80 | + default: |
81 | + break; |
82 | + } |
83 | + |
84 | + if (tz.isValid()) { |
85 | + icaltimezone *timezone = 0; |
86 | + timezone = icaltimezone_get_builtin_timezone(tz.id().constData()); |
87 | + *tzId = QByteArray(icaltimezone_get_tzid(timezone)); |
88 | + return icaltime_from_timet_with_zone(finalDate.toTime_t(), allDay, timezone); |
89 | } else { |
90 | - return icaltime_from_timet(dateTime.toTime_t(), allDay); |
91 | + *tzId = ""; |
92 | + return icaltime_from_timet(finalDate.toTime_t(), allDay); |
93 | } |
94 | - |
95 | } |
96 | |
97 | void QOrganizerEDSEngine::parseStartTime(ECalComponent *comp, QOrganizerItem *item) |
98 | @@ -1494,7 +1519,7 @@ |
99 | void QOrganizerEDSEngine::parseProgress(ECalComponent *comp, QOrganizerItem *item) |
100 | { |
101 | gint percentage = e_cal_component_get_percent_as_int(comp); |
102 | - if (percentage >= 0 && percentage <= 100) { |
103 | + if (percentage > 0 && percentage <= 100) { |
104 | QOrganizerTodoProgress tp = item->detail(QOrganizerItemDetail::TypeTodoProgress); |
105 | tp.setPercentageComplete(percentage); |
106 | item->saveDetail(&tp); |
107 | @@ -1845,13 +1870,13 @@ |
108 | void QOrganizerEDSEngine::parseTodoStartTime(const QOrganizerItem &item, ECalComponent *comp) |
109 | { |
110 | QOrganizerTodoTime etr = item.detail(QOrganizerItemDetail::TypeTodoTime); |
111 | - if (!etr.isEmpty()) { |
112 | + if (!etr.isEmpty() && !etr.startDateTime().isNull()) { |
113 | QByteArray tzId; |
114 | struct icaltimetype ict = fromQDateTime(etr.startDateTime(), etr.isAllDay(), &tzId); |
115 | ECalComponentDateTime dt; |
116 | dt.tzid = tzId.isEmpty() ? NULL : tzId.constData(); |
117 | dt.value = &ict; |
118 | - e_cal_component_set_dtstart(comp, &dt);; |
119 | + e_cal_component_set_dtstart(comp, &dt); |
120 | } |
121 | } |
122 | |
123 | @@ -2018,7 +2043,7 @@ |
124 | void QOrganizerEDSEngine::parseDueDate(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp) |
125 | { |
126 | QOrganizerTodoTime ttr = item.detail(QOrganizerItemDetail::TypeTodoTime); |
127 | - if (!ttr.isEmpty()) { |
128 | + if (!ttr.isEmpty() && !ttr.dueDateTime().isNull()) { |
129 | QByteArray tzId; |
130 | struct icaltimetype ict = fromQDateTime(ttr.dueDateTime(), ttr.isAllDay(), &tzId); |
131 | ECalComponentDateTime dt; |
132 | @@ -2031,7 +2056,7 @@ |
133 | void QOrganizerEDSEngine::parseProgress(const QtOrganizer::QOrganizerItem &item, ECalComponent *comp) |
134 | { |
135 | QOrganizerTodoProgress tp = item.detail(QOrganizerItemDetail::TypeTodoProgress); |
136 | - if (!tp.isEmpty()) { |
137 | + if (!tp.isEmpty() && (tp.percentageComplete() > 0)) { |
138 | e_cal_component_set_percent_as_int(comp, tp.percentageComplete()); |
139 | } |
140 | } |
141 | |
142 | === modified file 'organizer/qorganizer-eds-savecollectionrequestdata.cpp' |
143 | --- organizer/qorganizer-eds-savecollectionrequestdata.cpp 2014-06-05 14:04:32 +0000 |
144 | +++ organizer/qorganizer-eds-savecollectionrequestdata.cpp 2014-10-10 14:09:33 +0000 |
145 | @@ -204,7 +204,5 @@ |
146 | index++; |
147 | } |
148 | } |
149 | - |
150 | - qDebug() << "Request with" << m_sources.size() << "sources"; |
151 | } |
152 | |
153 | |
154 | === modified file 'organizer/qorganizer-eds-viewwatcher.cpp' |
155 | --- organizer/qorganizer-eds-viewwatcher.cpp 2014-04-15 19:43:05 +0000 |
156 | +++ organizer/qorganizer-eds-viewwatcher.cpp 2014-10-10 14:09:33 +0000 |
157 | @@ -109,13 +109,11 @@ |
158 | |
159 | if (m_eView) { |
160 | e_cal_client_view_stop(m_eView, 0); |
161 | - QCoreApplication::processEvents(); |
162 | g_clear_object(&m_eView); |
163 | } |
164 | |
165 | if (m_eClient) { |
166 | g_clear_object(&m_eClient); |
167 | - QCoreApplication::processEvents(); |
168 | } |
169 | } |
170 | |
171 | |
172 | === modified file 'tests/unittest/CMakeLists.txt' |
173 | --- tests/unittest/CMakeLists.txt 2014-05-24 21:56:35 +0000 |
174 | +++ tests/unittest/CMakeLists.txt 2014-10-10 14:09:33 +0000 |
175 | @@ -25,33 +25,8 @@ |
176 | ${EVOLUTION_CALENDAR_FACTORY} ${EVOLUTION_SOURCE_SERVICE_NAME} |
177 | ${EVOLUTION_SOURCE_REGISTRY} |
178 | ${GVFSD}) |
179 | - update_test_properties(${TESTNAME}) |
180 | endmacro(declare_test testname) |
181 | |
182 | -macro(update_test_properties TESTNAME) |
183 | - set(TEST_TMP_DIR "${TMP_DIR}/${TESTNAME}") |
184 | - set(ENV_VARS_LIST "") |
185 | - list(APPEND ENV_VARS_LIST "QT_QPA_PLATFORM=minimal") |
186 | - list(APPEND ENV_VARS_LIST "HOME=${TEST_TMP_DIR}") |
187 | - list(APPEND ENV_VARS_LIST "XDG_RUNTIME_DIR=${TEST_TMP_DIR}") |
188 | - list(APPEND ENV_VARS_LIST "XDG_CACHE_HOME=${TEST_TMP_DIR}/.cache") |
189 | - list(APPEND ENV_VARS_LIST "XDG_CONFIG_HOME=${TEST_TMP_DIR}/.config") |
190 | - list(APPEND ENV_VARS_LIST "XDG_DATA_HOME=${TEST_TMP_DIR}/.local/share") |
191 | - list(APPEND ENV_VARS_LIST "XDG_DESKTOP_DIR=${TEST_TMP_DIR}") |
192 | - list(APPEND ENV_VARS_LIST "XDG_DOCUMENTS_DIR=${TEST_TMP_DIR}") |
193 | - list(APPEND ENV_VARS_LIST "XDG_DOWNLOAD_DIR=${TEST_TMP_DIR}") |
194 | - list(APPEND ENV_VARS_LIST "XDG_MUSIC_DIR=${TEST_TMP_DIR}") |
195 | - list(APPEND ENV_VARS_LIST "XDG_PICTURES_DIR=${TEST_TMP_DIR}") |
196 | - list(APPEND ENV_VARS_LIST "XDG_PUBLICSHARE_DIR=${TEST_TMP_DIR}") |
197 | - list(APPEND ENV_VARS_LIST "XDG_TEMPLATES_DIR=${TEST_TMP_DIR}") |
198 | - list(APPEND ENV_VARS_LIST "XDG_VIDEOS_DIR=${TEST_TMP_DIR}") |
199 | - list(APPEND ENV_VARS_LIST "QORGANIZER_EDS_DEBUG=On") |
200 | - |
201 | - set_tests_properties(${TESTNAME} PROPERTIES |
202 | - TIMEOUT ${CTEST_TESTING_TIMEOUT} |
203 | - ENVIRONMENT "${ENV_VARS_LIST}") |
204 | -endmacro(update_test_properties) |
205 | - |
206 | include_directories( |
207 | ${CMAKE_SOURCE_DIR} |
208 | ${CMAKE_BINARY_DIR} |
209 | @@ -64,9 +39,6 @@ |
210 | |
211 | add_definitions(-DTEST_SUITE) |
212 | add_definitions(-std=c++11) |
213 | -if(NOT CTEST_TESTING_TIMEOUT) |
214 | - set(CTEST_TESTING_TIMEOUT 60) |
215 | -endif() |
216 | |
217 | declare_test(itemid-test) |
218 | declare_test(parseecal-test) |
219 | |
220 | === modified file 'tests/unittest/cancel-operation-test.cpp' |
221 | --- tests/unittest/cancel-operation-test.cpp 2014-05-25 19:46:01 +0000 |
222 | +++ tests/unittest/cancel-operation-test.cpp 2014-10-10 14:09:33 +0000 |
223 | @@ -33,8 +33,6 @@ |
224 | { |
225 | Q_OBJECT |
226 | private: |
227 | - static const QString defaultCollectionName; |
228 | - |
229 | QOrganizerEDSEngine *m_engine; |
230 | QOrganizerCollection m_collection; |
231 | |
232 | @@ -42,17 +40,16 @@ |
233 | void init() |
234 | { |
235 | EDSBaseTest::init(); |
236 | + |
237 | m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
238 | |
239 | - |
240 | QtOrganizer::QOrganizerManager::Error error; |
241 | m_collection = QOrganizerCollection(); |
242 | - m_collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
243 | + m_collection.setMetaData(QOrganizerCollection::KeyName, uniqueCollectionName()); |
244 | |
245 | bool saveResult = m_engine->saveCollection(&m_collection, &error); |
246 | QVERIFY(saveResult); |
247 | QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); |
248 | - |
249 | } |
250 | |
251 | void cleanup() |
252 | @@ -91,9 +88,6 @@ |
253 | |
254 | }; |
255 | |
256 | -const QString CancelOperationTest::defaultCollectionName = QStringLiteral("CancelOperationTest COLLECTION"); |
257 | - |
258 | - |
259 | QTEST_MAIN(CancelOperationTest) |
260 | |
261 | #include "cancel-operation-test.moc" |
262 | |
263 | === modified file 'tests/unittest/collections-test.cpp' |
264 | --- tests/unittest/collections-test.cpp 2014-05-27 11:41:03 +0000 |
265 | +++ tests/unittest/collections-test.cpp 2014-10-10 14:09:33 +0000 |
266 | @@ -21,6 +21,7 @@ |
267 | #include <QtTest> |
268 | #include <QDebug> |
269 | |
270 | + |
271 | #include <QtOrganizer> |
272 | |
273 | #include "qorganizer-eds-engine.h" |
274 | @@ -33,8 +34,6 @@ |
275 | { |
276 | Q_OBJECT |
277 | private: |
278 | - static const QString defaultCollectionName; |
279 | - static const QString defaultTaskCollectionName; |
280 | static const QString collectionTypePropertyName; |
281 | static const QString taskListTypeName; |
282 | |
283 | @@ -58,134 +57,21 @@ |
284 | EDSBaseTest::cleanup(); |
285 | } |
286 | |
287 | - void testCreateCollection() |
288 | - { |
289 | - QOrganizerCollection collection; |
290 | - QtOrganizer::QOrganizerManager::Error error; |
291 | - collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
292 | - collection.setMetaData(QOrganizerCollection::KeyColor, QStringLiteral("red")); |
293 | - |
294 | - QList<QOrganizerCollection> collections = m_engineRead->collections(&error); |
295 | - int initalCollectionCount = collections.count(); |
296 | - |
297 | - QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
298 | - QCOMPARE(error, QOrganizerManager::NoError); |
299 | - QVERIFY(!collection.id().isNull()); |
300 | - |
301 | - collections = m_engineWrite->collections(&error); |
302 | - QCOMPARE(collections.count(), initalCollectionCount + 1); |
303 | - |
304 | - collections = m_engineRead->collections(&error); |
305 | - QCOMPARE(collections.count(), initalCollectionCount + 1); |
306 | - |
307 | - // Check if data was correct saved |
308 | - QOrganizerCollection newCollection = m_engineRead->collection(collection.id(), &error); |
309 | - QCOMPARE(error, QOrganizerManager::NoError); |
310 | - QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), defaultCollectionName); |
311 | - QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("red")); |
312 | - QCOMPARE(newCollection.extendedMetaData("collection-type").toString(), QStringLiteral("Calendar")); |
313 | - QCOMPARE(newCollection.extendedMetaData("collection-selected").toBool(), false); |
314 | - } |
315 | - |
316 | - void testUpdateCollection() |
317 | - { |
318 | - QOrganizerCollection collection; |
319 | - QtOrganizer::QOrganizerManager::Error error; |
320 | - collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
321 | - collection.setMetaData(QOrganizerCollection::KeyColor, QStringLiteral("red")); |
322 | - collection.setExtendedMetaData(QStringLiteral("collection-selected"), false); |
323 | - |
324 | - QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
325 | - QCOMPARE(error, QOrganizerManager::NoError); |
326 | - QVERIFY(!collection.id().isNull()); |
327 | - |
328 | - // Check if the collection was stored correct |
329 | - QOrganizerCollection newCollection = m_engineRead->collection(collection.id(), &error); |
330 | - QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), defaultCollectionName); |
331 | - QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("red")); |
332 | - QCOMPARE(newCollection.extendedMetaData(QStringLiteral("collection-selected")).toBool(), false); |
333 | - |
334 | - |
335 | - // update the collection |
336 | - QSignalSpy updateCollection(m_engineWrite, SIGNAL(collectionsChanged(QList<QOrganizerCollectionId>))); |
337 | - collection.setMetaData(QOrganizerCollection::KeyColor, "blue"); |
338 | - collection.setExtendedMetaData("collection-selected", true); |
339 | - QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
340 | - QCOMPARE(error, QOrganizerManager::NoError); |
341 | - |
342 | - QTRY_VERIFY(updateCollection.count() > 0); |
343 | - QList<QVariant> args = updateCollection.takeFirst(); |
344 | - QCOMPARE(args.count(), 1); |
345 | - QCOMPARE(args[0].value<QList<QOrganizerCollectionId> >().at(0).toString(), collection.id().toString()); |
346 | - |
347 | - |
348 | - // Check if the collection was updated correct |
349 | - newCollection = m_engineRead->collection(collection.id(), &error); |
350 | - QCOMPARE(error, QOrganizerManager::NoError); |
351 | - QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), defaultCollectionName); |
352 | - QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("blue")); |
353 | - QCOMPARE(newCollection.extendedMetaData("collection-selected").toBool(), true); |
354 | - } |
355 | - |
356 | - void testRemoveCollection() |
357 | - { |
358 | - static QString removableCollectionName = defaultTaskCollectionName + QStringLiteral("_REMOVABLE"); |
359 | - |
360 | - // Create a collection |
361 | - QOrganizerCollection collection; |
362 | - QtOrganizer::QOrganizerManager::Error error; |
363 | - collection.setMetaData(QOrganizerCollection::KeyName, removableCollectionName); |
364 | - |
365 | - QList<QOrganizerCollection> collections = m_engineRead->collections(&error); |
366 | - int initalCollectionCount = collections.count(); |
367 | - |
368 | - QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
369 | - |
370 | - // remove recent created collection |
371 | - QVERIFY(m_engineWrite->removeCollection(collection.id(), &error)); |
372 | - |
373 | - collections = m_engineWrite->collections(&error); |
374 | - QCOMPARE(collections.count(), initalCollectionCount); |
375 | - QVERIFY(!collections.contains(collection)); |
376 | - |
377 | - collections = m_engineRead->collections(&error); |
378 | - QCOMPARE(collections.count(), initalCollectionCount); |
379 | - QVERIFY(!collections.contains(collection)); |
380 | - } |
381 | - |
382 | - void testCreateTaskList() |
383 | - { |
384 | - QOrganizerCollection collection; |
385 | - QtOrganizer::QOrganizerManager::Error error; |
386 | - collection.setMetaData(QOrganizerCollection::KeyName, defaultTaskCollectionName); |
387 | - collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); |
388 | - |
389 | - QSignalSpy createdCollection(m_engineWrite, SIGNAL(collectionsAdded(QList<QOrganizerCollectionId>))); |
390 | - QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
391 | - QCOMPARE(error, QOrganizerManager::NoError); |
392 | - QVERIFY(!collection.id().isNull()); |
393 | - |
394 | - //verify signal |
395 | - QTRY_COMPARE(createdCollection.count(), 1); |
396 | - QList<QVariant> args = createdCollection.takeFirst(); |
397 | - QCOMPARE(args.count(), 1); |
398 | - |
399 | - QVERIFY(m_engineWrite->collections(&error).contains(collection)); |
400 | - QVERIFY(m_engineRead->collections(&error).contains(collection)); |
401 | - } |
402 | - |
403 | void testCreateTask() |
404 | { |
405 | + static const QString collectionName = uniqueCollectionName(); |
406 | static QString displayLabelValue = QStringLiteral("Todo test"); |
407 | static QString descriptionValue = QStringLiteral("Todo description"); |
408 | |
409 | QOrganizerCollection collection; |
410 | QtOrganizer::QOrganizerManager::Error error; |
411 | - collection.setMetaData(QOrganizerCollection::KeyName, defaultTaskCollectionName + "2"); |
412 | + collection.setMetaData(QOrganizerCollection::KeyName, collectionName); |
413 | collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); |
414 | |
415 | + QSignalSpy createCollection(m_engineWrite, SIGNAL(collectionsAdded(QList<QOrganizerCollectionId>))); |
416 | QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
417 | QVERIFY(!collection.id().isNull()); |
418 | + QTRY_COMPARE(createCollection.count(), 1); |
419 | |
420 | QOrganizerTodo todo; |
421 | todo.setCollectionId(collection.id()); |
422 | @@ -205,12 +91,19 @@ |
423 | QCOMPARE(error, QOrganizerManager::NoError); |
424 | QVERIFY(errorMap.isEmpty()); |
425 | QVERIFY(!items[0].id().isNull()); |
426 | - appendToRemove(items[0].id()); |
427 | |
428 | //verify signal |
429 | - QTRY_COMPARE(createdItem.count(), 1); |
430 | - QList<QVariant> args = createdItem.takeFirst(); |
431 | - QCOMPARE(args.count(), 1); |
432 | + //FIXME: for some reason the signal is not get fired in jenkins build system |
433 | + do { \ |
434 | + QTRY_IMPL((createdItem.count() == 1), 5000);\ |
435 | + } while (0); |
436 | + |
437 | + if (createdItem.count() != 1) { |
438 | + QWARN("ItemsAdded signal not received will continue"); |
439 | + } else { |
440 | + QList<QVariant> args = createdItem.takeFirst(); |
441 | + QCOMPARE(args.count(), 1); |
442 | + } |
443 | |
444 | // check if the item is listead inside the correct collection |
445 | QOrganizerItemSortOrder sort; |
446 | @@ -248,10 +141,136 @@ |
447 | QCOMPARE(result.displayLabel(), todo.displayLabel()); |
448 | QCOMPARE(result.description(), todo.description()); |
449 | } |
450 | + |
451 | + void testCreateCollection() |
452 | + { |
453 | + static const QString collectionName = uniqueCollectionName(); |
454 | + |
455 | + QOrganizerCollection collection; |
456 | + QtOrganizer::QOrganizerManager::Error error; |
457 | + |
458 | + collection.setMetaData(QOrganizerCollection::KeyName, collectionName); |
459 | + collection.setMetaData(QOrganizerCollection::KeyColor, QStringLiteral("red")); |
460 | + |
461 | + QList<QOrganizerCollection> collections = m_engineRead->collections(&error); |
462 | + int initalCollectionCount = collections.count(); |
463 | + |
464 | + QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
465 | + QCOMPARE(error, QOrganizerManager::NoError); |
466 | + QVERIFY(!collection.id().isNull()); |
467 | + |
468 | + collections = m_engineWrite->collections(&error); |
469 | + QCOMPARE(collections.count(), initalCollectionCount + 1); |
470 | + |
471 | + collections = m_engineRead->collections(&error); |
472 | + QCOMPARE(collections.count(), initalCollectionCount + 1); |
473 | + |
474 | + // Check if data was correct saved |
475 | + QOrganizerCollection newCollection = m_engineRead->collection(collection.id(), &error); |
476 | + QCOMPARE(error, QOrganizerManager::NoError); |
477 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), collectionName); |
478 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("red")); |
479 | + QCOMPARE(newCollection.extendedMetaData("collection-type").toString(), QStringLiteral("Calendar")); |
480 | + QCOMPARE(newCollection.extendedMetaData("collection-selected").toBool(), false); |
481 | + } |
482 | + |
483 | + void testUpdateCollection() |
484 | + { |
485 | + static const QString collectionName = uniqueCollectionName(); |
486 | + |
487 | + QOrganizerCollection collection; |
488 | + QtOrganizer::QOrganizerManager::Error error; |
489 | + |
490 | + collection.setMetaData(QOrganizerCollection::KeyName, collectionName); |
491 | + collection.setMetaData(QOrganizerCollection::KeyColor, QStringLiteral("red")); |
492 | + collection.setExtendedMetaData(QStringLiteral("collection-selected"), false); |
493 | + |
494 | + QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
495 | + QCOMPARE(error, QOrganizerManager::NoError); |
496 | + QVERIFY(!collection.id().isNull()); |
497 | + |
498 | + // Check if the collection was stored correct |
499 | + QOrganizerCollection newCollection = m_engineRead->collection(collection.id(), &error); |
500 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), collectionName); |
501 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("red")); |
502 | + QCOMPARE(newCollection.extendedMetaData(QStringLiteral("collection-selected")).toBool(), false); |
503 | + |
504 | + |
505 | + // update the collection |
506 | + QSignalSpy updateCollection(m_engineWrite, SIGNAL(collectionsChanged(QList<QOrganizerCollectionId>))); |
507 | + collection.setMetaData(QOrganizerCollection::KeyColor, "blue"); |
508 | + collection.setExtendedMetaData("collection-selected", true); |
509 | + QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
510 | + QCOMPARE(error, QOrganizerManager::NoError); |
511 | + |
512 | + QTRY_VERIFY(updateCollection.count() > 0); |
513 | + QList<QVariant> args = updateCollection.takeFirst(); |
514 | + QCOMPARE(args.count(), 1); |
515 | + QCOMPARE(args[0].value<QList<QOrganizerCollectionId> >().at(0).toString(), collection.id().toString()); |
516 | + |
517 | + |
518 | + // Check if the collection was updated correct |
519 | + newCollection = m_engineRead->collection(collection.id(), &error); |
520 | + QCOMPARE(error, QOrganizerManager::NoError); |
521 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyName).toString(), collectionName); |
522 | + QCOMPARE(newCollection.metaData(QOrganizerCollection::KeyColor).toString(), QStringLiteral("blue")); |
523 | + QCOMPARE(newCollection.extendedMetaData("collection-selected").toBool(), true); |
524 | + } |
525 | + |
526 | + void testCreateTaskList() |
527 | + { |
528 | + static const QString collectionName = uniqueCollectionName() + QStringLiteral("_TASKS") ; |
529 | + |
530 | + QOrganizerCollection collection; |
531 | + QtOrganizer::QOrganizerManager::Error error; |
532 | + collection.setMetaData(QOrganizerCollection::KeyName, collectionName); |
533 | + collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); |
534 | + |
535 | + QSignalSpy createdCollection(m_engineWrite, SIGNAL(collectionsAdded(QList<QOrganizerCollectionId>))); |
536 | + QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
537 | + QCOMPARE(error, QOrganizerManager::NoError); |
538 | + QVERIFY(!collection.id().isNull()); |
539 | + |
540 | + //verify signal |
541 | + QTRY_COMPARE(createdCollection.count(), 1); |
542 | + QList<QVariant> args = createdCollection.takeFirst(); |
543 | + QCOMPARE(args.count(), 1); |
544 | + |
545 | + QVERIFY(m_engineWrite->collections(&error).contains(collection)); |
546 | + QVERIFY(m_engineRead->collections(&error).contains(collection)); |
547 | + } |
548 | + |
549 | + void testRemoveCollection() |
550 | + { |
551 | + static QString removableCollectionName = uniqueCollectionName(); |
552 | + |
553 | + // Create a collection |
554 | + QOrganizerCollection collection; |
555 | + QtOrganizer::QOrganizerManager::Error error; |
556 | + collection.setMetaData(QOrganizerCollection::KeyName, removableCollectionName); |
557 | + |
558 | + QList<QOrganizerCollection> collections = m_engineRead->collections(&error); |
559 | + int initalCollectionCount = collections.count(); |
560 | + |
561 | + QSignalSpy createCollection(m_engineWrite, SIGNAL(collectionsAdded(QList<QOrganizerCollectionId>))); |
562 | + QVERIFY(m_engineWrite->saveCollection(&collection, &error)); |
563 | + QTRY_COMPARE(createCollection.count(), 1); |
564 | + |
565 | + // remove recent created collection |
566 | + QSignalSpy removeCollection(m_engineWrite, SIGNAL(collectionsRemoved(QList<QOrganizerCollectionId>))); |
567 | + QVERIFY(m_engineWrite->removeCollection(collection.id(), &error)); |
568 | + QTRY_COMPARE(removeCollection.count(), 1); |
569 | + |
570 | + collections = m_engineWrite->collections(&error); |
571 | + QCOMPARE(collections.count(), initalCollectionCount); |
572 | + QVERIFY(!collections.contains(collection)); |
573 | + |
574 | + collections = m_engineRead->collections(&error); |
575 | + QCOMPARE(collections.count(), initalCollectionCount); |
576 | + QVERIFY(!collections.contains(collection)); |
577 | + } |
578 | }; |
579 | |
580 | -const QString CollectionTest::defaultCollectionName = QStringLiteral("TEST COLLECTION"); |
581 | -const QString CollectionTest::defaultTaskCollectionName = QStringLiteral("TEST COLLECTION TASK LIST"); |
582 | const QString CollectionTest::collectionTypePropertyName = QStringLiteral("collection-type"); |
583 | const QString CollectionTest::taskListTypeName = QStringLiteral("Task List"); |
584 | |
585 | |
586 | === modified file 'tests/unittest/eds-base-test.cpp' |
587 | --- tests/unittest/eds-base-test.cpp 2014-05-26 20:43:55 +0000 |
588 | +++ tests/unittest/eds-base-test.cpp 2014-10-10 14:09:33 +0000 |
589 | @@ -38,39 +38,21 @@ |
590 | { |
591 | } |
592 | |
593 | +void EDSBaseTest::initTestCase() |
594 | +{ |
595 | + QTest::qWait(1000); |
596 | +} |
597 | + |
598 | + |
599 | void EDSBaseTest::init() |
600 | { |
601 | } |
602 | |
603 | - |
604 | void EDSBaseTest::cleanup() |
605 | { |
606 | - static QStringList defaultSources; |
607 | - |
608 | - if (defaultSources.isEmpty()) { |
609 | - defaultSources << "qtorganizer:eds::birthdays" |
610 | - << "qtorganizer:eds::system-calendar" |
611 | - << "qtorganizer:eds::system-memo-list" |
612 | - << "qtorganizer:eds::system-task-list"; |
613 | - } |
614 | - QOrganizerEDSEngine *engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
615 | - Q_FOREACH(const QOrganizerCollection &col, engine->collections(0)) { |
616 | - if (defaultSources.contains(col.id().toString())) { |
617 | - continue; |
618 | - } |
619 | - QSignalSpy removeCollection(engine, SIGNAL(collectionsRemoved(QList<QOrganizerCollectionId>))); |
620 | - QVERIFY(engine->removeCollection(col.id(), 0)); |
621 | - QTRY_COMPARE(removeCollection.count(), 1); |
622 | - |
623 | - QList<QVariant> args = removeCollection.takeFirst(); |
624 | - QCOMPARE(args.count(), 1); |
625 | - QCOMPARE(args[0].value<QList<QOrganizerCollectionId> >().at(0).toString(), col.id().toString()); |
626 | - } |
627 | - |
628 | - delete engine; |
629 | } |
630 | |
631 | -void EDSBaseTest::appendToRemove(const QtOrganizer::QOrganizerItemId &id) |
632 | +QString EDSBaseTest::uniqueCollectionName() const |
633 | { |
634 | - m_newItems << id; |
635 | + return QUuid::createUuid().toString(); |
636 | } |
637 | |
638 | === modified file 'tests/unittest/eds-base-test.h' |
639 | --- tests/unittest/eds-base-test.h 2014-05-24 21:09:00 +0000 |
640 | +++ tests/unittest/eds-base-test.h 2014-10-10 14:09:33 +0000 |
641 | @@ -32,13 +32,11 @@ |
642 | ~EDSBaseTest(); |
643 | |
644 | protected: |
645 | - void init(); |
646 | - void cleanup(); |
647 | - |
648 | - void appendToRemove(const QtOrganizer::QOrganizerItemId &id); |
649 | - |
650 | -private: |
651 | - QList<QtOrganizer::QOrganizerItemId> m_newItems; |
652 | + virtual void initTestCase(); |
653 | + virtual void init(); |
654 | + virtual void cleanup(); |
655 | + |
656 | + QString uniqueCollectionName() const; |
657 | }; |
658 | |
659 | #endif |
660 | |
661 | === modified file 'tests/unittest/event-test.cpp' |
662 | --- tests/unittest/event-test.cpp 2014-09-30 13:49:21 +0000 |
663 | +++ tests/unittest/event-test.cpp 2014-10-10 14:09:33 +0000 |
664 | @@ -33,8 +33,6 @@ |
665 | { |
666 | Q_OBJECT |
667 | private: |
668 | - static const QString defaultCollectionName; |
669 | - static const QString defaultTaskCollectionName; |
670 | static const QString collectionTypePropertyName; |
671 | static const QString taskListTypeName; |
672 | static int signalIndex; |
673 | @@ -57,16 +55,19 @@ |
674 | |
675 | QtOrganizer::QOrganizerManager::Error error; |
676 | m_collection = QOrganizerCollection(); |
677 | - m_collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
678 | + m_collection.setMetaData(QOrganizerCollection::KeyName, uniqueCollectionName()); |
679 | m_collection.setExtendedMetaData(collectionTypePropertyName, taskListTypeName); |
680 | |
681 | + QSignalSpy createdCollection(m_engine, SIGNAL(collectionsAdded(QList<QOrganizerCollectionId>))); |
682 | bool saveResult = m_engine->saveCollection(&m_collection, &error); |
683 | QVERIFY(saveResult); |
684 | QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); |
685 | + QTRY_COMPARE(createdCollection.count(), 1); |
686 | } |
687 | |
688 | void cleanup() |
689 | { |
690 | + delete m_engine; |
691 | EDSBaseTest::cleanup(); |
692 | } |
693 | |
694 | @@ -122,9 +123,6 @@ |
695 | QVERIFY(saveResult); |
696 | QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); |
697 | |
698 | - // append new item to be removed after the test |
699 | - appendToRemove(items[0].id()); |
700 | - |
701 | QOrganizerItemSortOrder sort; |
702 | QOrganizerItemFetchHint hint; |
703 | QOrganizerItemIdFilter filter; |
704 | @@ -198,9 +196,6 @@ |
705 | QVERIFY(saveResult); |
706 | QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); |
707 | |
708 | - // append new item to be removed after the test |
709 | - appendToRemove(items[0].id()); |
710 | - |
711 | QOrganizerItemSortOrder sort; |
712 | QOrganizerItemFetchHint hint; |
713 | QOrganizerItemIdFilter filter; |
714 | @@ -267,9 +262,6 @@ |
715 | QVERIFY(errorMap.isEmpty()); |
716 | QVERIFY(!items[0].id().isNull()); |
717 | |
718 | - // append new item to be removed after the test |
719 | - appendToRemove(items[0].id()); |
720 | - |
721 | QOrganizerItemRemoveRequest req; |
722 | connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), |
723 | this, SLOT(requestFinished(QOrganizerAbstractRequest::State))); |
724 | @@ -316,11 +308,7 @@ |
725 | QOrganizerItemId id = items[0].id(); |
726 | QVERIFY(!id.isNull()); |
727 | |
728 | - // append new item to be removed after the test |
729 | - appendToRemove(id); |
730 | - |
731 | QOrganizerItemRemoveByIdRequest req; |
732 | - |
733 | connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), |
734 | this, SLOT(requestFinished(QOrganizerAbstractRequest::State))); |
735 | connect(m_engine, SIGNAL(itemsRemoved(QList<QOrganizerItemId>)), |
736 | @@ -377,9 +365,6 @@ |
737 | QVERIFY(errorMap.isEmpty()); |
738 | QVERIFY(!items[0].id().isNull()); |
739 | |
740 | - // append new item to be removed after the test |
741 | - appendToRemove(items[0].id()); |
742 | - |
743 | // check if item was created on the default collection |
744 | QOrganizerItemFetchHint hint; |
745 | |
746 | @@ -419,7 +404,6 @@ |
747 | QCOMPARE(evs.count(), 10); |
748 | Q_FOREACH(const QOrganizerItem &i, evs) { |
749 | QVERIFY(!i.id().isNull()); |
750 | - appendToRemove(i.id()); |
751 | } |
752 | } |
753 | |
754 | @@ -440,7 +424,7 @@ |
755 | |
756 | QtOrganizer::QOrganizerManager::Error error; |
757 | QOrganizerCollection eventCollection = QOrganizerCollection(); |
758 | - eventCollection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName + "_TEMP"); |
759 | + eventCollection.setMetaData(QOrganizerCollection::KeyName, uniqueCollectionName()); |
760 | bool saveResult = m_engine->saveCollection(&eventCollection, &error); |
761 | QVERIFY(saveResult); |
762 | |
763 | @@ -464,7 +448,6 @@ |
764 | QCOMPARE(evs.count(), 20); |
765 | Q_FOREACH(const QOrganizerItem &i, evs) { |
766 | QVERIFY(!i.id().isNull()); |
767 | - appendToRemove(i.id()); |
768 | } |
769 | } |
770 | |
771 | @@ -508,8 +491,6 @@ |
772 | QVERIFY(saveResult); |
773 | QCOMPARE(error, QOrganizerManager::NoError); |
774 | QCOMPARE(evs.count(), 2); |
775 | - appendToRemove(evs[0].id()); |
776 | - appendToRemove(evs[1].id()); |
777 | QCOMPARE(errorMap.size(), 1); |
778 | QCOMPARE(errorMap[1], QOrganizerManager::InvalidCollectionError); |
779 | } |
780 | @@ -540,9 +521,6 @@ |
781 | QOrganizerItemId id = items[0].id(); |
782 | QVERIFY(!id.isNull()); |
783 | |
784 | - // append new item to be removed after the test |
785 | - appendToRemove(id); |
786 | - |
787 | QOrganizerItemFetchHint hint; |
788 | QList<QOrganizerItemId> ids; |
789 | ids << items[0].id(); |
790 | @@ -681,10 +659,110 @@ |
791 | } |
792 | QCOMPARE(expectedTags.size(), 0); |
793 | } |
794 | + |
795 | + void testFloatingTime() |
796 | + { |
797 | + static QString displayLabelValue = QStringLiteral("event with floating time"); |
798 | + static QString descriptionValue = QStringLiteral("event with floating time descs"); |
799 | + |
800 | + QOrganizerTodo todo; |
801 | + todo.setCollectionId(m_collection.id()); |
802 | + QDateTime startDate = QDateTime::currentDateTime(); |
803 | + startDate = QDateTime(startDate.date(), startDate.time(), QTimeZone()); |
804 | + todo.setStartDateTime(startDate); |
805 | + todo.setDisplayLabel(displayLabelValue); |
806 | + todo.setDescription(descriptionValue); |
807 | + |
808 | + QtOrganizer::QOrganizerManager::Error error; |
809 | + QMap<int, QtOrganizer::QOrganizerManager::Error> errorMap; |
810 | + QList<QOrganizerItem> items; |
811 | + QSignalSpy createdItem(m_engine, SIGNAL(itemsAdded(QList<QOrganizerItemId>))); |
812 | + items << todo; |
813 | + bool saveResult = m_engine->saveItems(&items, |
814 | + QList<QtOrganizer::QOrganizerItemDetail::DetailType>(), |
815 | + &errorMap, |
816 | + &error); |
817 | + QVERIFY(saveResult); |
818 | + QCOMPARE(error, QOrganizerManager::NoError); |
819 | + QCOMPARE(items.size(), 1); |
820 | + QVERIFY(errorMap.isEmpty()); |
821 | + QVERIFY(!items[0].id().isNull()); |
822 | + // check saved item |
823 | + QTRY_COMPARE(createdItem.count(), 1); |
824 | + |
825 | + QOrganizerItemFetchHint hint; |
826 | + QList<QOrganizerItemId> ids; |
827 | + ids << items[0].id(); |
828 | + items = m_engine->items(ids, hint, &errorMap, &error); |
829 | + QCOMPARE(items.count(), 1); |
830 | + |
831 | + QOrganizerTodo newTodo = static_cast<QOrganizerTodo>(items[0]); |
832 | + QCOMPARE(newTodo.startDateTime().timeSpec(), todo.startDateTime().timeSpec()); |
833 | + QVERIFY(!newTodo.startDateTime().timeZone().isValid()); |
834 | + QCOMPARE(newTodo.startDateTime().date(), startDate.date()); |
835 | + QCOMPARE(newTodo.startDateTime().time().hour(), startDate.time().hour()); |
836 | + QCOMPARE(newTodo.startDateTime().time().minute(), startDate.time().minute()); |
837 | + QCOMPARE(newTodo.startDateTime().time().second(), startDate.time().second()); |
838 | + |
839 | + // Update floating event |
840 | + |
841 | + QSignalSpy updateItem(m_engine, SIGNAL(itemsChanged(QList<QOrganizerItemId>))); |
842 | + startDate = QDateTime::currentDateTime(); |
843 | + startDate.addSecs(360); |
844 | + startDate = QDateTime(startDate.date(), startDate.time(), QTimeZone()); |
845 | + items << newTodo; |
846 | + saveResult = m_engine->saveItems(&items, |
847 | + QList<QtOrganizer::QOrganizerItemDetail::DetailType>(), |
848 | + &errorMap, |
849 | + &error); |
850 | + QTRY_COMPARE(updateItem.count(), 1); |
851 | + |
852 | + ids.clear(); |
853 | + ids << items[0].id(); |
854 | + items = m_engine->items(ids, hint, &errorMap, &error); |
855 | + QCOMPARE(items.count(), 1); |
856 | + |
857 | + newTodo = static_cast<QOrganizerTodo>(items[0]); |
858 | + QCOMPARE(newTodo.startDateTime().timeSpec(), todo.startDateTime().timeSpec()); |
859 | + QVERIFY(!newTodo.startDateTime().timeZone().isValid()); |
860 | + QCOMPARE(newTodo.startDateTime().date(), startDate.date()); |
861 | + QCOMPARE(newTodo.startDateTime().time().hour(), startDate.time().hour()); |
862 | + QCOMPARE(newTodo.startDateTime().time().minute(), startDate.time().minute()); |
863 | + QCOMPARE(newTodo.startDateTime().time().second(), startDate.time().second()); |
864 | + |
865 | + // Remove floating event |
866 | + QOrganizerItemRemoveByIdRequest req; |
867 | + connect(&req, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), |
868 | + this, SLOT(requestFinished(QOrganizerAbstractRequest::State))); |
869 | + connect(m_engine, SIGNAL(itemsRemoved(QList<QOrganizerItemId>)), |
870 | + this, SLOT(itemRemoved())); |
871 | + req.setItemId(newTodo.id()); |
872 | + |
873 | + m_engine->startRequest(&req); |
874 | + m_engine->waitForRequestFinished(&req, -1); |
875 | + |
876 | + // check if the signal item removed was fired after the request finish |
877 | + QTRY_VERIFY(m_requestFinishedTime.isValid()); |
878 | + QTRY_VERIFY(m_itemRemovedTime.isValid()); |
879 | + QVERIFY(m_itemRemovedTime > m_requestFinishedTime); |
880 | + |
881 | + // check if item was removed |
882 | + QOrganizerItemSortOrder sort; |
883 | + QOrganizerItemIdFilter filter; |
884 | + ids.clear(); |
885 | + ids << newTodo.id(); |
886 | + filter.setIds(ids); |
887 | + items = m_engine->items(filter, |
888 | + QDateTime(), |
889 | + QDateTime(), |
890 | + 10, |
891 | + sort, |
892 | + hint, |
893 | + &error); |
894 | + QCOMPARE(items.count(), 0); |
895 | + } |
896 | }; |
897 | |
898 | -const QString EventTest::defaultCollectionName = QStringLiteral("TEST_EVENT_COLLECTION"); |
899 | -const QString EventTest::defaultTaskCollectionName = QStringLiteral("TEST_EVENT_COLLECTION TASK LIST"); |
900 | const QString EventTest::collectionTypePropertyName = QStringLiteral("collection-type"); |
901 | const QString EventTest::taskListTypeName = QStringLiteral("Task List"); |
902 | int EventTest::signalIndex = 0; |
903 | |
904 | === modified file 'tests/unittest/fetchitem-test.cpp' |
905 | --- tests/unittest/fetchitem-test.cpp 2014-05-24 21:09:00 +0000 |
906 | +++ tests/unittest/fetchitem-test.cpp 2014-10-10 14:09:33 +0000 |
907 | @@ -33,8 +33,6 @@ |
908 | { |
909 | Q_OBJECT |
910 | private: |
911 | - static const QString defaultCollectionName; |
912 | - |
913 | QOrganizerEDSEngine *m_engine; |
914 | QOrganizerCollection m_collection; |
915 | QList<QOrganizerItem> m_events; |
916 | @@ -42,13 +40,15 @@ |
917 | private Q_SLOTS: |
918 | void initTestCase() |
919 | { |
920 | + EDSBaseTest::initTestCase(); |
921 | + const QString collectionName = uniqueCollectionName(); |
922 | EDSBaseTest::init(); |
923 | m_engine = QOrganizerEDSEngine::createEDSEngine(QMap<QString, QString>()); |
924 | |
925 | // create test collection |
926 | m_collection = QOrganizerCollection(); |
927 | QtOrganizer::QOrganizerManager::Error error; |
928 | - m_collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
929 | + m_collection.setMetaData(QOrganizerCollection::KeyName, collectionName); |
930 | QVERIFY(m_engine->saveCollection(&m_collection, &error)); |
931 | |
932 | // create test events |
933 | @@ -78,7 +78,6 @@ |
934 | QCOMPARE(error, QOrganizerManager::NoError); |
935 | QVERIFY(errorMap.isEmpty()); |
936 | m_events << evs[0]; |
937 | - appendToRemove(evs[0].id()); |
938 | date = date.addDays(1); |
939 | } |
940 | } |
941 | @@ -170,8 +169,6 @@ |
942 | } |
943 | }; |
944 | |
945 | -const QString FetchItemTest::defaultCollectionName = QStringLiteral("TEST_FETCH_COLLECTION"); |
946 | - |
947 | QTEST_MAIN(FetchItemTest) |
948 | |
949 | #include "fetchitem-test.moc" |
950 | |
951 | === modified file 'tests/unittest/recurrence-test.cpp' |
952 | --- tests/unittest/recurrence-test.cpp 2014-09-22 13:18:51 +0000 |
953 | +++ tests/unittest/recurrence-test.cpp 2014-10-10 14:09:33 +0000 |
954 | @@ -71,13 +71,15 @@ |
955 | Q_ASSERT(saveResult); |
956 | Q_ASSERT(error == QtOrganizer::QOrganizerManager::NoError); |
957 | |
958 | - // append new item to be removed after the test |
959 | - appendToRemove(items[0].id()); |
960 | - |
961 | return items[0]; |
962 | } |
963 | |
964 | private Q_SLOTS: |
965 | + void initTestCase() |
966 | + { |
967 | + EDSBaseTest::initTestCase(); |
968 | + } |
969 | + |
970 | void init() |
971 | { |
972 | EDSBaseTest::init(); |
973 | @@ -86,7 +88,7 @@ |
974 | |
975 | QtOrganizer::QOrganizerManager::Error error; |
976 | m_collection = QOrganizerCollection(); |
977 | - m_collection.setMetaData(QOrganizerCollection::KeyName, defaultCollectionName); |
978 | + m_collection.setMetaData(QOrganizerCollection::KeyName, uniqueCollectionName()); |
979 | |
980 | bool saveResult = m_engine->saveCollection(&m_collection, &error); |
981 | QVERIFY(saveResult); |
982 | @@ -95,6 +97,7 @@ |
983 | |
984 | void cleanup() |
985 | { |
986 | + m_collection = QOrganizerCollection(); |
987 | delete m_engine; |
988 | m_engine = 0; |
989 | EDSBaseTest::cleanup(); |
990 | @@ -129,7 +132,7 @@ |
991 | |
992 | QVERIFY(saveResult); |
993 | QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); |
994 | - QTRY_COMPARE(itemsAdded.count(), 1); |
995 | + QTRY_COMPARE_WITH_TIMEOUT(itemsAdded.count(), 1, 10000); |
996 | } |
997 | |
998 | void testCreateWeeklyEvent() |
999 | @@ -161,13 +164,11 @@ |
1000 | QVERIFY(saveResult); |
1001 | QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); |
1002 | |
1003 | - // append new item to be removed after the test |
1004 | QOrganizerItemId parentId = items[0].id(); |
1005 | - appendToRemove(parentId); |
1006 | - |
1007 | QOrganizerItemSortOrder sort; |
1008 | QOrganizerItemFetchHint hint; |
1009 | - QOrganizerItemFilter filter; |
1010 | + QOrganizerItemCollectionFilter filter; |
1011 | + filter.setCollectionId(m_collection.id()); |
1012 | items = m_engine->items(filter, |
1013 | QDateTime(QDate(2013, 11, 30), QTime(0,0,0)), |
1014 | QDateTime(QDate(2014, 1, 1), QTime(0,0,0)), |
1015 | @@ -197,8 +198,8 @@ |
1016 | { |
1017 | static QString displayLabelValue = QStringLiteral("Monthly test"); |
1018 | static QString descriptionValue = QStringLiteral("Monthly description"); |
1019 | - static QDateTime eventStartDate = QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0), Qt::UTC); |
1020 | - static QDateTime eventEndDate = QDateTime(QDate(2013, 1, 1), QTime(0, 30, 0), Qt::UTC); |
1021 | + static QDateTime eventStartDate = QDateTime(QDate(2013, 1, 1), QTime(0, 0, 0)); |
1022 | + static QDateTime eventEndDate = QDateTime(QDate(2013, 1, 1), QTime(0, 30, 0)); |
1023 | |
1024 | QOrganizerEvent ev; |
1025 | ev.setCollectionId(m_collection.id()); |
1026 | @@ -224,12 +225,10 @@ |
1027 | QVERIFY(saveResult); |
1028 | QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); |
1029 | |
1030 | - // append new item to be removed after the test |
1031 | - appendToRemove(items[0].id()); |
1032 | - |
1033 | QOrganizerItemSortOrder sort; |
1034 | QOrganizerItemFetchHint hint; |
1035 | - QOrganizerItemFilter filter; |
1036 | + QOrganizerItemCollectionFilter filter; |
1037 | + filter.setCollectionId(m_collection.id()); |
1038 | items = m_engine->items(filter, |
1039 | eventStartDate, |
1040 | eventStartDate.addYears(1), |
1041 | @@ -243,7 +242,7 @@ |
1042 | QCOMPARE(time.startDateTime(), eventStartDate.addMonths(i)); |
1043 | |
1044 | time = items[(i*2)+1].detail(QOrganizerItemDetail::TypeEventTime); |
1045 | - QCOMPARE(time.startDateTime(), QDateTime(QDate(2013, i+1, 5), QTime(0,0,0), Qt::UTC)); |
1046 | + QCOMPARE(time.startDateTime(), QDateTime(QDate(2013, i+1, 5), QTime(0,0,0), Qt::LocalTime)); |
1047 | } |
1048 | } |
1049 | |
1050 | @@ -254,7 +253,9 @@ |
1051 | QtOrganizer::QOrganizerManager::Error error; |
1052 | QOrganizerItemSortOrder sort; |
1053 | QOrganizerItemFetchHint hint; |
1054 | - QOrganizerItemFilter filter; |
1055 | + QOrganizerItemCollectionFilter filter; |
1056 | + filter.setCollectionId(m_collection.id()); |
1057 | + |
1058 | QList<QOrganizerItem> items; |
1059 | |
1060 | items = m_engine->items(filter, |
1061 | @@ -310,7 +311,9 @@ |
1062 | QtOrganizer::QOrganizerManager::Error error; |
1063 | QOrganizerItemSortOrder sort; |
1064 | QOrganizerItemFetchHint hint; |
1065 | - QOrganizerItemFilter filter; |
1066 | + QOrganizerItemCollectionFilter filter; |
1067 | + filter.setCollectionId(m_collection.id()); |
1068 | + |
1069 | QList<QOrganizerItem> items = m_engine->items(filter, |
1070 | QDateTime(), |
1071 | QDateTime(), |
1072 | @@ -391,13 +394,11 @@ |
1073 | QVERIFY(saveResult); |
1074 | QCOMPARE(error, QtOrganizer::QOrganizerManager::NoError); |
1075 | |
1076 | - // append new item to be removed after the test |
1077 | QOrganizerItemId parentId = items[0].id(); |
1078 | - appendToRemove(parentId); |
1079 | - |
1080 | QOrganizerItemSortOrder sort; |
1081 | QOrganizerItemFetchHint hint; |
1082 | - QOrganizerItemFilter filter; |
1083 | + QOrganizerItemCollectionFilter filter; |
1084 | + filter.setCollectionId(m_collection.id()); |
1085 | |
1086 | // check if the parent was saved correct |
1087 | items = m_engine->items(QList<QOrganizerItemId>() << parentId, hint, &errorMap, &error); |
1088 | @@ -459,7 +460,8 @@ |
1089 | |
1090 | QOrganizerItemSortOrder sort; |
1091 | QOrganizerItemFetchHint hint; |
1092 | - QOrganizerItemFilter filter; |
1093 | + QOrganizerItemCollectionFilter filter; |
1094 | + filter.setCollectionId(m_collection.id()); |
1095 | QList<QOrganizerItem> items = m_engine->items(filter, |
1096 | QDateTime(QDate(2013, 11, 30), QTime(0,0,0)), |
1097 | QDateTime(QDate(2014, 1, 1), QTime(0,0,0)), |
1098 | @@ -512,7 +514,8 @@ |
1099 | QCOMPARE(req.error(), QtOrganizer::QOrganizerManager::NoError); |
1100 | |
1101 | QOrganizerItemSortOrder sort; |
1102 | - QOrganizerItemFilter filter; |
1103 | + QOrganizerItemCollectionFilter filter; |
1104 | + filter.setCollectionId(m_collection.id()); |
1105 | |
1106 | items = m_engine->items(filter, |
1107 | startInteval, |
1108 | @@ -538,8 +541,6 @@ |
1109 | } |
1110 | }; |
1111 | |
1112 | -const QString RecurrenceTest::defaultCollectionName = QStringLiteral("TEST_RECURRENCE_EVENT_COLLECTION"); |
1113 | - |
1114 | QTEST_MAIN(RecurrenceTest) |
1115 | |
1116 | #include "recurrence-test.moc" |
1117 | |
1118 | === modified file 'tests/unittest/run-eds-test.sh' |
1119 | --- tests/unittest/run-eds-test.sh 2014-05-24 21:09:00 +0000 |
1120 | +++ tests/unittest/run-eds-test.sh 2014-10-10 14:09:33 +0000 |
1121 | @@ -1,16 +1,35 @@ |
1122 | #!/bin/sh |
1123 | |
1124 | #ARG1 - DBUS RUNNERN PATH |
1125 | -#ARG2 - TEST EXECUTABLE FULL PATH |
1126 | +#ARG2 - TEST EXECUTABLE FULL PATH |
1127 | #ARG3 - TEST NAME |
1128 | #ARG4 - EVOLUTION_CALENDAR_FACTORY FULL PATH |
1129 | #ARG5 - EVOLUTION_CALENDAR_FACTORY SERVICE NAME |
1130 | #ARG6 - EVOLUTION_SOURCE_REGISTRY FULL PATH |
1131 | |
1132 | + |
1133 | +export TEST_TMP_DIR=$(mktemp -d /tmp/$3_XXXX) |
1134 | +export QT_QPA_PLATFORM=minimal |
1135 | +export HOME=$TEST_TMP_DIR |
1136 | +export XDG_RUNTIME_DIR=$TEST_TMP_DIR |
1137 | +export XDG_CACHE_HOME=$TEST_TMP_DIR}/.cache |
1138 | +export XDG_CONFIG_HOME=$TEST_TMP_DIR/.config |
1139 | +export XDG_DATA_HOME=$TEST_TMP_DIR/.local/share |
1140 | +export XDG_DESKTOP_DIR=$TEST_TMP_DIR |
1141 | +export XDG_DOCUMENTS_DIR=$TEST_TMP_DIR |
1142 | +export XDG_DOWNLOAD_DIR=$TEST_TMP_DIR |
1143 | +export XDG_MUSIC_DIR=$TEST_TMP_DIR |
1144 | +export XDG_PICTURES_DIR=$TEST_TMP_DIR |
1145 | +export XDG_PUBLICSHARE_DIR=$TEST_TMP_DIR |
1146 | +export XDG_TEMPLATES_DIR=$TEST_TMP_DIR |
1147 | +export XDG_VIDEOS_DIR=$TEST_TMP_DIR |
1148 | +export QORGANIZER_EDS_DEBUG=On |
1149 | + |
1150 | +echo HOMEDIR=$HOME |
1151 | rm -rf $XDG_DATA_HOME |
1152 | $1 --keep-env \ |
1153 | --task $2 --task-name $3 --wait-until-complete --wait-for=org.gnome.evolution.dataserver.Calendar4 \ |
1154 | ---task $4 --task-name "evolution" -r --wait-for=$5 \ |
1155 | ---task $6 --task-name "source-registry" --wait-for=org.gtk.vfs.Daemon -r \ |
1156 | ---task $7 --task-name "gvfsd" -r |
1157 | +--task $4 --task-name "evolution" -r |
1158 | +#--task $6 --task-name "source-registry" --wait-for=org.gtk.vfs.Daemon -r \ |
1159 | +#--task $7 --task-name "gvfsd" -r |
1160 | return $? |
FAILED: Continuous integration, rev:66 jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-ci/ 167/ jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-utopic- amd64-ci/ 25/console jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-utopic- armhf-ci/ 25/console jenkins. qa.ubuntu. com/job/ qtorganizer5- eds-utopic- i386-ci/ 25/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtorganizer 5-eds-ci/ 167/rebuild
http://