|
1 /* |
|
2 * Copyright (c) 2010 Sun Microsystems, Inc. and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributor: |
|
10 * Maximilian Odendahl |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Caldav Test Suite |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "CalDavTest.h" |
|
19 #include <e32base.h> |
|
20 #include <e32std.h> |
|
21 #include <e32base.h> |
|
22 #include <calentry.h> |
|
23 #include <calentryview.h> |
|
24 #include <caleninterimutils2.h> |
|
25 #include <calcalendarinfo.h> |
|
26 #include <calsession.h> |
|
27 #include "caldavengine.h" |
|
28 #include "httpclient.h" |
|
29 #include <caldavsession.h> |
|
30 _LIT(KTextConsoleTitle, "Console"); |
|
31 _LIT(KTextFailed, " failed, leave code = %d"); |
|
32 _LIT(KTextPressAnyKey, " [press any key]\n"); |
|
33 // Global Variables |
|
34 LOCAL_D CConsoleBase* console; // write all messages to this |
|
35 |
|
36 _LIT8(urlAries,"http://aries.demo.sun.com:3080/davserver/dav/home/modendahl@demo.sun.com/calendar/"); |
|
37 _LIT8(urlAriesPrincipal,"http://aries.demo.sun.com:3080/davserver/dav/principals/modendahl/"); |
|
38 _LIT8(urlAriesHome,"http://aries.demo.sun.com:3080/davserver/dav/home/modendahl@demo.sun.com/"); |
|
39 _LIT8(urlWN,"http://whatsnew.demo.iplanet.com:3080/dav/home/modendahl/calendar/"); |
|
40 _LIT8(userSUN,"modendahl"); |
|
41 _LIT8(passwordSUN,"secret"); |
|
42 _LIT8(urlGoogle,"https://www.google.com/calendar/dav/maximilian.odendahl@sun.com/events/"); |
|
43 _LIT8(urlGooglePrincipal,"https://www.google.com/calendar/dav/maximilian.odendahl@sun.com/user/"); |
|
44 _LIT8(userGoogle,"maximilian.odendahl@sun.com"); |
|
45 _LIT8(passwordGoogle,"iplanetiplanet"); |
|
46 _LIT8(urlChandler,"https://hub.chandlerproject.org/dav/mod/f16c9eb0-6373-11de-979e-cdd32d46e10a11111/"); |
|
47 _LIT8(urlChandlerPrincipal,"https://hub.chandlerproject.org/dav/users/mod/"); |
|
48 _LIT8(userChandler,"mod"); |
|
49 _LIT8(passwordChandler,"modmod"); |
|
50 _LIT8(urlBedework,"http://bedework.org:8585/ucaldav/user/testuser29/calendar/"); |
|
51 _LIT8(urlBedeWorkPrincipal,"http://bedework.org:8585/ucaldav/principals/users/testuser29"); |
|
52 _LIT8(userBedework,"testuser29"); |
|
53 _LIT8(passwordbedework,"bedework"); |
|
54 _LIT8(urlYahoo,"https://caldav.calendar.yahoo.com/dav/lkz633/Calendar/lkz633/"); |
|
55 _LIT8(urlYahooPrincipal,"https://caldav.calendar.yahoo.com/principals/users/lkz633/"); |
|
56 _LIT8(userYahoo,"lkz633"); |
|
57 _LIT8(passwordYahoo,"iplanetiplanet"); |
|
58 _LIT8(urlOracle,"http://kingsknight.sfbay.sun.com:7777/caldav/Sun/home/7B7B.65E6.user.6FCA54EE73AD4821811999F4D7679F6E000000000070%40email.invalid/calendars/MyCalendar"); |
|
59 _LIT8(urlOraclePrincipal,"http://kingsknight.sfbay.sun.com:7777/caldav/Sun/principals/individuals/7B7B.65E6.user.6FCA54EE73AD4821811999F4D7679F6E000000000070%40email.invalid"); |
|
60 _LIT8(userOracle,"symbian"); |
|
61 _LIT8(passwordOracle,"Secret12"); |
|
62 _LIT8(urlSogo,"http://sogo-demo.inverse.ca/SOGo/dav/sogo3/Calendar/personal/"); |
|
63 _LIT8(userSogo,"sogo3"); |
|
64 _LIT8(passwordSogo,"sogo3"); |
|
65 _LIT8(urlDAV,"http://dhcp-usca15-127-168.red.iplanet.com/dav/calendar/"); |
|
66 _LIT8(userDAV,"max"); |
|
67 _LIT8(passwordDAV,"max"); |
|
68 _LIT8(urlApple,"http://zeta.macosforge.org:8008/calendars/__uids__/1E872019-0078-412D-8EE0-85A5680365C2/calendar/"); |
|
69 _LIT8(principalAplle,"http://zeta.macosforge.org:8008/calendars/__uids__/1E872019-0078-412D-8EE0-85A5680365C2/calendar/"); |
|
70 _LIT8(userApple,"trial1"); |
|
71 _LIT8(passwordApple,"lompywickets"); |
|
72 _LIT8(urlKerio,"http://iop.test.kerio.com/calendars/iop.test.kerio.com/user1/Calendar"); |
|
73 _LIT8(principalKerio,"http://iop.test.kerio.com/caldav/iop.test.kerio.com/user1/"); |
|
74 _LIT8(userKerio,"user1"); |
|
75 _LIT8(passwordkerio,"x"); |
|
76 _LIT8(urlDaviCal,"http://dev.davical.org:8008/caldav.php/user1/home/"); |
|
77 _LIT8(principalDaviCal,"http://dev.davical.org:8008/caldav.php/user1/"); |
|
78 _LIT8(userDaviCal,"user1"); |
|
79 _LIT8(passwordDaviCal,"user1"); |
|
80 _LIT8(urlblabla,"http://www.blablabalbalabal.com/calendar/"); |
|
81 _LIT8(passwordblabla,"bla"); |
|
82 _LIT8(userblabla,"blabla"); |
|
83 _LIT(calendar, "c:calendar12345"); |
|
84 _LIT8(KFixedUIDics,"123456.ics"); |
|
85 |
|
86 #define TWOSECONDS TTimeIntervalMicroSeconds32(2000000) |
|
87 |
|
88 void CreateCalFileL() |
|
89 { |
|
90 CCalSession* session = CCalSession::NewL(); |
|
91 CleanupStack::PushL(session); |
|
92 TRAPD(err, session->CreateCalFileL(calendar)); |
|
93 if (err == KErrAlreadyExists) |
|
94 { |
|
95 session->DeleteCalFileL(calendar); |
|
96 session->CreateCalFileL(calendar); |
|
97 } |
|
98 CleanupStack::PopAndDestroy(session); |
|
99 } |
|
100 |
|
101 void DeleteCalFileL() |
|
102 { |
|
103 CCalSession* session = CCalSession::NewL(); |
|
104 CleanupStack::PushL(session); |
|
105 session->DeleteCalFileL(calendar); |
|
106 CleanupStack::PopAndDestroy(session); |
|
107 } |
|
108 |
|
109 TBool GetBoolFromProperties2(CCalCalendarInfo* info, const TDesC8 &aKey) |
|
110 { |
|
111 TBool boolean; |
|
112 TPckgC<TBool> pckgboolean(boolean); |
|
113 pckgboolean.Set(info->PropertyValueL(aKey)); |
|
114 return pckgboolean(); |
|
115 } |
|
116 |
|
117 TCalTime GetTimeFromProperties2(CCalCalendarInfo* info, const TDesC8 &aKey) |
|
118 { |
|
119 TCalTime time; |
|
120 TPckgC<TCalTime> pckgtime(time); |
|
121 pckgtime.Set(info->PropertyValueL(aKey)); |
|
122 return pckgtime(); |
|
123 } |
|
124 |
|
125 void NewApptL(HBufC8* aUid, TBool aEvent, CCalEntryView* iCalEntryView) |
|
126 { |
|
127 CCalEntry* appt = CCalEntry::NewL(aEvent ? CCalEntry::EEvent |
|
128 : CCalEntry::ETodo, aUid, CCalEntry::EMethodNone, 0); |
|
129 CleanupStack::PushL(appt); |
|
130 |
|
131 //Some data |
|
132 TBuf16<100> summary; |
|
133 summary.Copy(*aUid); |
|
134 appt->SetSummaryL(summary); |
|
135 appt->SetLocationL(_L("Location2")); |
|
136 appt->SetDescriptionL(_L("Description3")); |
|
137 |
|
138 //Start / end date |
|
139 TTime start; |
|
140 start.UniversalTime(); |
|
141 TTime end; |
|
142 end.UniversalTime(); |
|
143 TCalTime startCalTime; |
|
144 startCalTime.SetTimeUtcL(start); |
|
145 TCalTime endCalTime; |
|
146 endCalTime.SetTimeUtcL(end); |
|
147 |
|
148 //Set it |
|
149 appt->SetStartAndEndTimeL(startCalTime, endCalTime); |
|
150 |
|
151 //Store this new Entry |
|
152 |
|
153 RPointerArray<CCalEntry> entryArray; |
|
154 CleanupClosePushL(entryArray); |
|
155 entryArray.AppendL(appt); |
|
156 TInt success(0); |
|
157 iCalEntryView->StoreL(entryArray, success); |
|
158 entryArray.Reset(); |
|
159 CleanupStack::PopAndDestroy(&entryArray); |
|
160 CleanupStack::PopAndDestroy(appt); |
|
161 } |
|
162 |
|
163 CalDavTest::CalDavTest(CConsoleBase* console) |
|
164 { |
|
165 iConsole = console; |
|
166 TInt connect = iFileLogger.Connect(); |
|
167 TTime home; |
|
168 home.UniversalTime(); |
|
169 _LIT(KDateFormat,"%H%T%S"); |
|
170 TBuf<20> StringTime; |
|
171 home.FormatL(StringTime, KDateFormat); |
|
172 StringTime.Append(_L(".txt")); |
|
173 iFileLogger.CreateLog(_L("CalDav"),StringTime, EFileLoggingModeOverwrite); |
|
174 } |
|
175 |
|
176 CalDavTest::~CalDavTest() |
|
177 { |
|
178 iFileLogger.CloseLog(); |
|
179 iFileLogger.Close(); |
|
180 } |
|
181 |
|
182 void CalDavTest::Write(TBool aSuccess, const char* aMessage) |
|
183 { |
|
184 TBuf<500> buffer; |
|
185 TPtrC8 ptr(reinterpret_cast<const TUint8*> (aMessage)); |
|
186 buffer.Copy(ptr); |
|
187 |
|
188 Write(aSuccess, buffer); |
|
189 } |
|
190 |
|
191 void CalDavTest::Write(TBool aSuccess, const TDesC &aMessage) |
|
192 { |
|
193 // convert char* into tbug |
|
194 TBuf<500> buffer; |
|
195 buffer.Append(aMessage); |
|
196 |
|
197 if (aSuccess) |
|
198 buffer.Append(_L("....PASSED\n")); |
|
199 else |
|
200 buffer.Append(_L("....FAILED\n")); |
|
201 |
|
202 // write to console and file |
|
203 Write(buffer); |
|
204 } |
|
205 |
|
206 void CalDavTest::TestClientServerL(TInt aSucces, const TDesC8 &aUrl, |
|
207 const TDesC8 &aUser, const TDesC8 &aPassword) |
|
208 { |
|
209 TBuf16<500> url; |
|
210 url.Copy(aUrl); |
|
211 Write(_L("\n\nStarting CalDav client-server test...")); |
|
212 Write(url); |
|
213 |
|
214 CreateCalFileL(); |
|
215 |
|
216 CCalDavSession *server = CCalDavSession::NewLC(); |
|
217 iSession = server; |
|
218 |
|
219 if (ConfigureSessionL(aSucces, aUrl, aUser, aPassword) == KErrNone) |
|
220 { |
|
221 OptionSession(); |
|
222 } |
|
223 |
|
224 CleanupStack::PopAndDestroy(server); |
|
225 iSession = NULL; |
|
226 DeleteCalFileL(); |
|
227 |
|
228 Write(_L("\nFinished CalDav client-server test...")); |
|
229 Write(_L("\n\n")); |
|
230 } |
|
231 |
|
232 void CalDavTest::TestGeneralEngineL() |
|
233 { |
|
234 CreateCalFileL(); |
|
235 CCalDavEngine* store = CCalDavEngine::NewLC(calendar); |
|
236 iEngine = store; |
|
237 |
|
238 CalendarInfoL(); |
|
239 GetUIDByUrl(); |
|
240 GetBaseUrl(); |
|
241 |
|
242 CleanupStack::PopAndDestroy(store); |
|
243 iEngine = NULL; |
|
244 DeleteCalFileL(); |
|
245 } |
|
246 |
|
247 void CalDavTest::TestEngineL(TInt aSucces, const TDesC8 &aUrl, |
|
248 const TDesC8 &aUser, const TDesC8 &aPassword, TBool aWebdavsync, |
|
249 TBool aCtag, TBool aEvent, TBool aTodo, TBool aFreeBusy, TBool aJournal) |
|
250 { |
|
251 Write(_L("\n\nStarting CalDav Engine test...")); |
|
252 TBuf16<500> url; |
|
253 url.Copy(aUrl); |
|
254 Write(url); |
|
255 Write(_L("\n")); |
|
256 |
|
257 CreateCalFileL(); |
|
258 |
|
259 CCalDavEngine* store = CCalDavEngine::NewLC(calendar); |
|
260 |
|
261 iEngine = store; |
|
262 iWebdavSync = aWebdavsync; |
|
263 iCtag = aCtag; |
|
264 |
|
265 iVEVENT = aEvent; |
|
266 iVTODO = aTodo; |
|
267 iVFREEBUSY = aFreeBusy; |
|
268 iVJOURNAL = aJournal; |
|
269 |
|
270 Write(_L("\n\nStarting init and option tests...\n")); |
|
271 |
|
272 Enabled(EFalse); |
|
273 if (EnableL(aSucces, aUrl, aUser, aPassword) == KErrNone) |
|
274 { |
|
275 Enabled(ETrue); |
|
276 OptionsL(); |
|
277 CTagL(ETrue); |
|
278 SynctokenL(ETrue); |
|
279 |
|
280 /******* Test events ******/ |
|
281 Write(_L("\nStarting VEvent engine tests...\n\n")); |
|
282 |
|
283 HBufC8* newuid = iEngine->iCalIntermimUtils2->GlobalUidL(); |
|
284 // need to save it, as it will be destroyed by CCalEntry::NewL |
|
285 TBuf8<100> uid; |
|
286 uid.Append(*newuid); |
|
287 // does entry exists locally |
|
288 DoesExistL(EFalse, uid); |
|
289 // add new local event with UID |
|
290 NewApptL(newuid, ETrue, iEngine->iCalEntryView); |
|
291 // does entry exists locally |
|
292 DoesExistL(ETrue, uid); |
|
293 |
|
294 // send to server using handle |
|
295 unsigned long local = iEngine->DoesEntryExistL(uid); |
|
296 // send existing event to server |
|
297 SendL(local); |
|
298 // available on server |
|
299 if (iEngine->iOptions.VEVENT) |
|
300 { |
|
301 HeadL(ETrue, uid); |
|
302 //download from server |
|
303 DownloadLGetL(local); |
|
304 DownloadLMultiGetL(local); |
|
305 // delete on server |
|
306 DeleteServerL(local); |
|
307 // available on server |
|
308 HeadL(EFalse, uid); |
|
309 } |
|
310 else |
|
311 HeadL(EFalse, uid); |
|
312 |
|
313 // delete locally |
|
314 DeleteClientL(uid); |
|
315 // should be gone now |
|
316 DoesExistL(EFalse, uid); |
|
317 /**************************/ |
|
318 |
|
319 CTagL(!iEngine->iOptions.VEVENT); |
|
320 SynctokenL(!iEngine->iOptions.VEVENT); |
|
321 |
|
322 User::After(TWOSECONDS); |
|
323 SyncL(); |
|
324 |
|
325 CTagL(ETrue); |
|
326 SynctokenL(ETrue); |
|
327 |
|
328 // test synchronization method, put/delete on server using http calls |
|
329 if (iEngine->iOptions.VEVENT) |
|
330 { |
|
331 Write(_L("\nStarting VEvent http and sync tests...\n\n")); |
|
332 // create directly on server using only http calls |
|
333 SendL(ETrue); |
|
334 // we should not have this yet |
|
335 DoesExistL(EFalse, KFixedUIDics); |
|
336 User::After(TWOSECONDS); |
|
337 SyncL(); |
|
338 // now we should |
|
339 DoesExistL(ETrue, KFixedUIDics); |
|
340 // delete directly on server |
|
341 DeleteServerL(); |
|
342 // we should still have it |
|
343 DoesExistL(ETrue, KFixedUIDics); |
|
344 User::After(TWOSECONDS); |
|
345 SyncL(); |
|
346 // now it should be gone locally |
|
347 DoesExistL(EFalse, KFixedUIDics); |
|
348 } |
|
349 |
|
350 /******* Test VTodo ******/ |
|
351 |
|
352 Write(_L("\n\nStarting VTodo tests...\n\n")); |
|
353 |
|
354 HBufC8* newuid2 = iEngine->iCalIntermimUtils2->GlobalUidL(); |
|
355 // need to save it, as it will be destroyed by CCalEntry::NewL |
|
356 TBuf8<100> uid2; |
|
357 uid2.Append(*newuid2); |
|
358 // does entry exists locally |
|
359 DoesExistL(EFalse, uid2); |
|
360 // add new local event with UID |
|
361 NewApptL(newuid2, EFalse, iEngine->iCalEntryView); |
|
362 // does entry exists locally |
|
363 DoesExistL(ETrue, uid2); |
|
364 |
|
365 // send to server using handle |
|
366 unsigned long local2 = iEngine->DoesEntryExistL(uid2); |
|
367 // send existing event to server |
|
368 SendL(local2); |
|
369 |
|
370 if (iEngine->iOptions.VTODO) |
|
371 { |
|
372 // available on server |
|
373 HeadL(ETrue, uid2); |
|
374 //download from server |
|
375 DownloadLGetL(local2); |
|
376 DownloadLMultiGetL(local2); |
|
377 // delete on server |
|
378 DeleteServerL(local2); |
|
379 // available on server |
|
380 HeadL(EFalse, uid2); |
|
381 } |
|
382 else |
|
383 HeadL(EFalse, uid2); |
|
384 // delete locally |
|
385 DeleteClientL(uid2); |
|
386 // should be gone now |
|
387 DoesExistL(EFalse, uid2); |
|
388 /**************************/ |
|
389 |
|
390 CTagL(!iEngine->iOptions.VTODO); |
|
391 SynctokenL(!iEngine->iOptions.VTODO); |
|
392 |
|
393 // test synchronization method, put/delete on server using http calls |
|
394 if (iEngine->iOptions.VTODO) |
|
395 { |
|
396 Write(_L("\nStarting VTodo http and sync tests...\n\n")); |
|
397 // create directly on server using only http calls |
|
398 SendL(EFalse); |
|
399 // we should not have this yet |
|
400 DoesExistL(EFalse, KFixedUIDics); |
|
401 User::After(TWOSECONDS); |
|
402 SyncL(); |
|
403 // now we should |
|
404 DoesExistL(ETrue, KFixedUIDics); |
|
405 // delete directly on server |
|
406 DeleteServerL(); |
|
407 // we should still have it |
|
408 DoesExistL(ETrue, KFixedUIDics); |
|
409 User::After(TWOSECONDS); |
|
410 SyncL(); |
|
411 // now it should be gone locally as well |
|
412 DoesExistL(EFalse, KFixedUIDics); |
|
413 } |
|
414 |
|
415 /**** Test Calendar ******/ |
|
416 /* |
|
417 // creating calendars under home calendar should not be allowed |
|
418 if (iEngine->iOptions.MKCALENDAR) |
|
419 { |
|
420 Write(_L("\n\nStarting Calendar tests...\n\n")); |
|
421 _LIT8(howareyou, "howareyoudoingtoday"); |
|
422 MkCalendarL(KErrNone, howareyou); |
|
423 MkCalendarL(KErrArgument, howareyou); |
|
424 DeleteCalendarL(howareyou); |
|
425 } |
|
426 */ |
|
427 /**************************/ |
|
428 iEngine->DisableL(); |
|
429 } |
|
430 |
|
431 CleanupStack::PopAndDestroy(store); |
|
432 iEngine = NULL; |
|
433 DeleteCalFileL(); |
|
434 |
|
435 Write(_L("\n\nFinished CalDav Engine test...")); |
|
436 Write(_L("\n\n")); |
|
437 } |
|
438 |
|
439 void CalDavTest::Write(const TDesC &aMessage) |
|
440 { |
|
441 iConsole->Write(aMessage); |
|
442 iFileLogger.Write(aMessage); |
|
443 } |
|
444 |
|
445 void CalDavTest::Enabled(TBool aEnabled) |
|
446 { |
|
447 Write(iEngine->EnabledSync() == aEnabled, __FUNCTION__); |
|
448 } |
|
449 |
|
450 void CalDavTest::DoesExistL(TBool aExists, const unsigned long localuid) |
|
451 { |
|
452 CCalEntry* entry = iEngine->iCalEntryView->FetchL(localuid); |
|
453 CleanupStack::PushL(entry); |
|
454 unsigned long uid = iEngine->DoesEntryExistL(entry->UidL()); |
|
455 Write(aExists ? uid > 0 : uid == 0, __FUNCTION__); |
|
456 |
|
457 CleanupStack::PopAndDestroy(entry); |
|
458 } |
|
459 |
|
460 void CalDavTest::DoesExistL(TBool aExists, const TDesC8 &aUID) |
|
461 { |
|
462 unsigned long uid = iEngine->DoesEntryExistL(aUID); |
|
463 Write(aExists ? uid > 0 : uid == 0, __FUNCTION__); |
|
464 } |
|
465 |
|
466 void CalDavTest::HeadL(TBool aExists, const TDesC8 &aUid) |
|
467 { |
|
468 TBool del = iEngine->HeadL(aUid) == OK; |
|
469 Write(aExists == del, __FUNCTION__); |
|
470 } |
|
471 |
|
472 void CalDavTest::MkCalendarL(TInt aSuccess, const TDesC8 &aName) |
|
473 { |
|
474 TInt ret = iEngine->MkcalendarL(aName); |
|
475 Write(ret == aSuccess, __FUNCTION__); |
|
476 } |
|
477 |
|
478 void CalDavTest::DeleteCalendarL(const TDesC8 &aName) |
|
479 { |
|
480 Write(iEngine->DeleteCalendarL(aName) == KErrNone, __FUNCTION__); |
|
481 } |
|
482 |
|
483 void CalDavTest::OptionsL() |
|
484 { |
|
485 TBuf<500> message; |
|
486 message.Append(_L("Options Displayname ")); |
|
487 CCalCalendarInfo* info = iEngine->iCalSession->CalendarInfoL(); |
|
488 TBuf<500> display; |
|
489 display.Copy(info->NameL()); |
|
490 message.Append(display); |
|
491 delete info; |
|
492 Write(display != KNullDesC, message); |
|
493 Write(iEngine->iOptions.sync_collection == iWebdavSync, _L("Options Webdav Sync")); |
|
494 Write(iEngine->iOptions.sync_ctag == iCtag, _L("Options Ctag")); |
|
495 Write(iEngine->iOptions.VEVENT == iVEVENT, _L("Options VEVENT")); |
|
496 Write(iEngine->iOptions.VTODO == iVTODO, _L("Options VTODO")); |
|
497 Write(iEngine->iOptions.VFREEBUSY == iVFREEBUSY, _L("FREEBUSY")); |
|
498 Write(iEngine->iOptions.VJOURNAL == iVJOURNAL, _L("VJOURNAL")); |
|
499 } |
|
500 |
|
501 void CalDavTest::CalendarInfoL() |
|
502 { |
|
503 _LIT8(user,"user"); |
|
504 _LIT8(password,"pass"); |
|
505 _LIT8(url,"http://neindanke/"); |
|
506 iEngine->SetUserL(user); |
|
507 iEngine->SetUrlL(url); |
|
508 iEngine->SetPasswordL(password); |
|
509 iEngine->SetSyncIntervalL(TTimeIntervalMinutes(5)); |
|
510 iEngine->SetPastDaysL(TTimeIntervalDays(10)); |
|
511 iEngine->SetKeepServerEntryL(EFalse); |
|
512 iEngine->SetImmediateSyncL(ETrue); |
|
513 iEngine->EnableL(); |
|
514 |
|
515 iEngine->iCalSession = CCalSession::NewL(); |
|
516 iEngine->iCalSession->OpenL(calendar); |
|
517 |
|
518 CCalCalendarInfo* calendarInfo = iEngine->iCalSession->CalendarInfoL(); |
|
519 CleanupStack::PushL(calendarInfo); |
|
520 |
|
521 Write(!GetBoolFromProperties2(calendarInfo, KCaldavEnabled), _L("CalendarInfo: enabled")); |
|
522 Write(!GetBoolFromProperties2(calendarInfo, KCaldavKeepServer), _L("CalendarInfo: Keepserver")); |
|
523 Write(GetBoolFromProperties2(calendarInfo, KCaldavImmediateSync), _L("CalendarInfo: ImmediateSync")); |
|
524 Write(calendarInfo->PropertyValueL(KCaldavUrl) == url, _L("CalendarInfo: url")); |
|
525 Write(calendarInfo->PropertyValueL(KCaldavUser) == user, _L("CalendarInfo: user")); |
|
526 Write(calendarInfo->PropertyValueL(KCaldavPassword) == password, _L("CalendarInfo: password")); |
|
527 |
|
528 TTimeIntervalDays pastday; |
|
529 TPckgC<TTimeIntervalDays> pastdays(pastday); |
|
530 pastdays.Set(calendarInfo->PropertyValueL(KCaldavPastDays)); |
|
531 Write(TTimeIntervalDays(10) == pastdays(), _L("CalendarInfo: pastdays")); |
|
532 |
|
533 TTimeIntervalMinutes syncintervals; |
|
534 TPckgC<TTimeIntervalMinutes> syncinterval(syncintervals); |
|
535 syncinterval.Set(calendarInfo->PropertyValueL(KCaldavSyncInterval)); |
|
536 Write(TTimeIntervalMinutes(5) == syncinterval(), _L("CalendarInfo: syncinterval")); |
|
537 |
|
538 /* |
|
539 Write(calendarInfo->PropertyValueL(KCaldavSynctoken) ==KNullDesC8, _L("CalendarInfo: SyncToken")); |
|
540 Write(calendarInfo->PropertyValueL(KCaldavCtag) == KNullDesC8, _L("CalendarInfo: CTag")); |
|
541 Write(GetTimeFromProperties2(calendarInfo,KCaldavTime).TimeUtcL()== TCalTime().TimeUtcL(), _L("CalendarInfo: LastTime")); |
|
542 */ |
|
543 |
|
544 // access point |
|
545 CleanupStack::PopAndDestroy(calendarInfo); |
|
546 |
|
547 delete iEngine->iCalSession; |
|
548 iEngine->iCalSession = NULL; |
|
549 } |
|
550 |
|
551 void CalDavTest::GetUIDByUrl() |
|
552 { |
|
553 _LIT8(url,"1234"); |
|
554 _LIT8(url1,"/hi/1234.ics"); |
|
555 _LIT8(url2,"/1234.ics"); |
|
556 _LIT8(url3,"1234.ics"); |
|
557 _LIT8(url4,"1234"); |
|
558 |
|
559 Write(iEngine->GetUIDByUrl(url1) == url, __FUNCTION__); |
|
560 Write(iEngine->GetUIDByUrl(url2) == url, __FUNCTION__); |
|
561 Write(iEngine->GetUIDByUrl(url3) == url, __FUNCTION__); |
|
562 Write(iEngine->GetUIDByUrl(url4) == url, __FUNCTION__); |
|
563 } |
|
564 |
|
565 void CalDavTest::GetBaseUrl() |
|
566 { |
|
567 _LIT8(url1,"http://www.ok.de/1234.ics"); |
|
568 _LIT8(url,"http://www.ok.de"); |
|
569 _LIT8(url2,"https://www.ok.de:80/123444444.ics"); |
|
570 _LIT8(urlport,"https://www.ok.de:80"); |
|
571 |
|
572 iEngine->GetBaseUrl(url1); |
|
573 Write(*iEngine->iBaseUrl == url, __FUNCTION__); |
|
574 |
|
575 iEngine->GetBaseUrl(url2); |
|
576 Write(*iEngine->iBaseUrl == urlport, __FUNCTION__); |
|
577 } |
|
578 |
|
579 void CalDavTest::CTagL(TBool aEqual) |
|
580 { |
|
581 if (iEngine->iOptions.sync_ctag && !iEngine->iOptions.sync_collection) |
|
582 { |
|
583 HBufC8* tag = iEngine->GetCTagL(); |
|
584 Write(aEqual ? *tag == *iEngine->iCTag : *tag != *iEngine->iCTag, _L("CTag")); |
|
585 if (aEqual && (*tag != *iEngine->iCTag)) |
|
586 { |
|
587 TBuf<500> name; |
|
588 name.Append(_L("saved cTag: ")); |
|
589 TBuf<100> one; |
|
590 one.Copy(*iEngine->iCTag); |
|
591 name.Append(one); |
|
592 name.Append(_L(" current server cTag: ")); |
|
593 TBuf<100> two; |
|
594 two.Copy(*tag); |
|
595 name.Append(two); |
|
596 Write(ETrue, name); |
|
597 } |
|
598 delete tag; |
|
599 } |
|
600 } |
|
601 |
|
602 void CalDavTest::SynctokenL(TBool aEqual) |
|
603 { |
|
604 if (iEngine->iOptions.sync_collection) |
|
605 { |
|
606 HBufC8* tag = iEngine->GetSyncTokenL(); |
|
607 Write(aEqual ? *tag == *iEngine->iSynctoken : *tag |
|
608 != *iEngine->iSynctoken, _L("SyncToken")); |
|
609 if (aEqual && (*tag != *iEngine->iSynctoken)) |
|
610 { |
|
611 TBuf<500> name; |
|
612 name.Append(_L("saved Syntoken: ")); |
|
613 TBuf<100> one; |
|
614 one.Copy(*iEngine->iSynctoken); |
|
615 name.Append(one); |
|
616 name.Append(_L(" current server Synctoken: ")); |
|
617 TBuf<100> two; |
|
618 two.Copy(*tag); |
|
619 name.Append(two); |
|
620 Write(ETrue, name); |
|
621 } |
|
622 delete tag; |
|
623 } |
|
624 } |
|
625 |
|
626 void CalDavTest::SendL(const unsigned long localuid) |
|
627 { |
|
628 Write(iEngine->UploadEntryL(localuid, MCalChangeCallBack2::EChangeAdd, |
|
629 MCalChangeCallBack2::EChangeEntryAll) == KErrNone, __FUNCTION__); |
|
630 } |
|
631 |
|
632 void CalDavTest::SendL(TBool aVEvent) |
|
633 { |
|
634 TBuf8<500> url; |
|
635 url.Append(*iEngine->iUrl); |
|
636 url.Append(KFixedUIDics); |
|
637 _LIT8(KEntry1, "BEGIN:VCALENDAR\r\n" |
|
638 "PRODID:Symbian\r\n" |
|
639 "VERSION:2.0\r\n" |
|
640 "BEGIN:VEVENT\r\n" |
|
641 "UID:123456\r\n" |
|
642 "SUMMARY:first entry\r\n" |
|
643 "DESCRIPTION:a description\r\n" |
|
644 "DTSTAMP:20100411T100000Z\r\n" |
|
645 "DTSTART:20100411T100000Z\r\n" |
|
646 "DTEND:20100412T120000Z\r\n" |
|
647 "END:VEVENT\r\n" |
|
648 "END:VCALENDAR\r\n"); |
|
649 _LIT8(KEntry2, "BEGIN:VCALENDAR\r\n" |
|
650 "PRODID:Symbian\r\n" |
|
651 "VERSION:2.0\r\n" |
|
652 "BEGIN:VTODO\r\n" |
|
653 "DTSTAMP:20100205T235335Z\r\n" |
|
654 "DUE;VALUE=DATE:20110104\r\n" |
|
655 "SUMMARY:Task #1\r\n" |
|
656 "UID:123456\r\n" |
|
657 "END:VTODO\r\n" |
|
658 "END:VCALENDAR\r\n"); |
|
659 |
|
660 CBufFlat* response = CBufFlat::NewL(500); |
|
661 CleanupStack::PushL(response); |
|
662 TInt Ret = iEngine->iHttp->PutL(url, aVEvent ? KEntry1() : KEntry2(), |
|
663 response); |
|
664 CleanupStack::PopAndDestroy(response); |
|
665 |
|
666 if (Ret==PRECONDFAILED) |
|
667 { |
|
668 //might be still there from an older run |
|
669 TBuf8<500> url; |
|
670 url.Append(*iEngine->iUrl); |
|
671 url.Append(KFixedUIDics); |
|
672 iEngine->iHttp->DeleteL(url); |
|
673 |
|
674 CBufFlat* response = CBufFlat::NewL(500); |
|
675 CleanupStack::PushL(response); |
|
676 Ret = iEngine->iHttp->PutL(url, aVEvent ? KEntry1() : KEntry2(), |
|
677 response); |
|
678 CleanupStack::PopAndDestroy(response); |
|
679 |
|
680 // locally as well maybe: |
|
681 iEngine->DeleteLocalEntryL(KFixedUIDics); |
|
682 } |
|
683 Write((Ret == CREATED) || (Ret == NOCONTENT) || (Ret == OK), __FUNCTION__); |
|
684 } |
|
685 |
|
686 void CalDavTest::SyncL() |
|
687 { |
|
688 Write(iEngine->SyncL(), __FUNCTION__); |
|
689 } |
|
690 |
|
691 void CalDavTest::DownloadLGetL(const unsigned long localuid) |
|
692 { |
|
693 TInt aPos = iEngine->iLocalUidArray.Find(localuid); |
|
694 if (aPos != KErrNotFound) |
|
695 Write(iEngine->DownloadEntryL(iEngine->iGlobalUidArray[aPos]) |
|
696 == KErrNone, __FUNCTION__); |
|
697 else |
|
698 Write(EFalse, __FUNCTION__); |
|
699 } |
|
700 void CalDavTest::DownloadLMultiGetL(const unsigned long localuid) |
|
701 { |
|
702 if (iEngine->iOptions.MULTIGET) |
|
703 { |
|
704 TInt aPos = iEngine->iLocalUidArray.Find(localuid); |
|
705 if (aPos != KErrNotFound) |
|
706 { |
|
707 TBuf8<500> url; |
|
708 url.Append(iEngine->iUrl->Mid(iEngine->iBaseUrl->Length())); |
|
709 url.Append(iEngine->iGlobalUidArray[aPos]); |
|
710 url.Append(KIcs); |
|
711 CDesC8ArrayFlat *multiget = new (ELeave) CDesC8ArrayFlat(4); |
|
712 CleanupStack::PushL(multiget); |
|
713 multiget->AppendL(url); |
|
714 multiget->AppendL(url); |
|
715 Write(iEngine->DownloadEntryL(multiget) == KErrNone, __FUNCTION__); |
|
716 multiget->Reset(); |
|
717 CleanupStack::PopAndDestroy(multiget); |
|
718 } |
|
719 else |
|
720 Write(EFalse, __FUNCTION__); |
|
721 } |
|
722 } |
|
723 |
|
724 TInt CalDavTest::ConfigureSessionL(TInt aSucces, const TDesC8 &aUrl, |
|
725 const TDesC8 &aUser, const TDesC8 &aPassword) |
|
726 { |
|
727 iSession->SetUrl(calendar, aUrl); |
|
728 iSession->SetUsername(calendar, aUser); |
|
729 iSession->SetPassword(calendar, aPassword); |
|
730 TInt ret = iSession->Enable(calendar); |
|
731 Write(ret == aSucces, __FUNCTION__); |
|
732 return ret; |
|
733 } |
|
734 |
|
735 void CalDavTest::OptionSession() |
|
736 { |
|
737 TTimeIntervalDays pastdays = 0; |
|
738 TTimeIntervalMinutes syncinterval = 0; |
|
739 TBool immediatesync = EFalse; |
|
740 TBool keepserverentry = EFalse; |
|
741 TBuf8<500> url, username, password; |
|
742 |
|
743 // retreive standard values |
|
744 iSession->PastDays(calendar, pastdays); |
|
745 iSession->SyncInterval(calendar, syncinterval); |
|
746 iSession->ImmediateSync(calendar, immediatesync); |
|
747 iSession->KeepServerEntry(calendar, keepserverentry); |
|
748 iSession->Url(calendar, url); |
|
749 iSession->Username(calendar, username); |
|
750 iSession->Password(calendar, password); |
|
751 |
|
752 Write(pastdays.Int() == DEFAULT_PAST_DAYS, __FUNCTION__); |
|
753 Write(syncinterval.Int() == DEFAULT_SYNC_MINUTES, __FUNCTION__); |
|
754 Write(immediatesync, __FUNCTION__); |
|
755 Write(keepserverentry, __FUNCTION__); |
|
756 Write(url == urlAries, __FUNCTION__); |
|
757 Write(password == passwordSUN, __FUNCTION__); |
|
758 Write(username == userSUN, __FUNCTION__); |
|
759 |
|
760 // set new values |
|
761 pastdays = TTimeIntervalDays(100); |
|
762 syncinterval = TTimeIntervalMinutes(4); |
|
763 immediatesync = EFalse; |
|
764 keepserverentry = EFalse; |
|
765 iSession->SetPastDays(calendar, pastdays); |
|
766 iSession->SetSyncInterval(calendar, syncinterval); |
|
767 iSession->SetImmediateSync(calendar, immediatesync); |
|
768 iSession->SetKeepServerEntry(calendar, keepserverentry); |
|
769 iSession->SetUrl(calendar, urlGooglePrincipal); |
|
770 iSession->SetUsername(calendar, userGoogle); |
|
771 iSession->SetPassword(calendar, passwordGoogle); |
|
772 |
|
773 // check if new values are set correctly |
|
774 TTimeIntervalDays pastdays1(10000); |
|
775 TTimeIntervalMinutes syncinterval1(4000); |
|
776 TBool immediatesync1 = ETrue; |
|
777 TBool keepserverentry1 = ETrue; |
|
778 TBuf8<500> url1, username1, password1; |
|
779 |
|
780 iSession->PastDays(calendar, pastdays1); |
|
781 iSession->SyncInterval(calendar, syncinterval1); |
|
782 iSession->ImmediateSync(calendar, immediatesync1); |
|
783 iSession->KeepServerEntry(calendar, keepserverentry1); |
|
784 iSession->Url(calendar, url1); |
|
785 iSession->Username(calendar, username1); |
|
786 iSession->Password(calendar, password1); |
|
787 |
|
788 Write(pastdays1.Int() == 100, __FUNCTION__); |
|
789 Write(syncinterval1.Int() == 4, __FUNCTION__); |
|
790 Write(!immediatesync1, __FUNCTION__); |
|
791 Write(!keepserverentry1, __FUNCTION__); |
|
792 Write(url1 == urlGooglePrincipal, __FUNCTION__); |
|
793 Write(username1 == userGoogle, __FUNCTION__); |
|
794 Write(password1 == passwordGoogle, __FUNCTION__); |
|
795 } |
|
796 |
|
797 TInt CalDavTest::EnableL(TInt aSucces, const TDesC8 &aUrl, const TDesC8 &aUser, |
|
798 const TDesC8 &aPassword) |
|
799 { |
|
800 iEngine->SetUrlL(aUrl); |
|
801 iEngine->SetUserL(aUser); |
|
802 iEngine->SetPasswordL(aPassword); |
|
803 TInt ret = iEngine->EnableL(); |
|
804 Write(ret == aSucces, __FUNCTION__); |
|
805 return ret; |
|
806 } |
|
807 |
|
808 void CalDavTest::DeleteServerL(const unsigned long localuid) |
|
809 { |
|
810 Write(iEngine->DeleteEntryL(localuid) == KErrNone, __FUNCTION__); |
|
811 } |
|
812 |
|
813 void CalDavTest::DeleteServerL() |
|
814 { |
|
815 TBuf8<500> url; |
|
816 url.Append(*iEngine->iUrl); |
|
817 url.Append(KFixedUIDics); |
|
818 TInt Return = iEngine->iHttp->DeleteL(url); |
|
819 Write((Return == NOCONTENT) || (Return == OK), __FUNCTION__); |
|
820 } |
|
821 |
|
822 void CalDavTest::DeleteClientL(const TDesC8 &aUid) |
|
823 { |
|
824 Write(iEngine->DeleteLocalEntryL(aUid) == KErrNone, __FUNCTION__); |
|
825 } |
|
826 |
|
827 LOCAL_C void DoStartL() |
|
828 { |
|
829 |
|
830 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); |
|
831 CleanupStack::PushL(scheduler); |
|
832 CActiveScheduler::Install(scheduler); |
|
833 |
|
834 for (TInt i = 0; i <= 10; i++) |
|
835 { |
|
836 CalDavTest* aTest = new (ELeave) CalDavTest(console); |
|
837 |
|
838 aTest->TestClientServerL(KErrNone, urlAries, userSUN, passwordSUN); |
|
839 aTest->TestClientServerL(KErrArgument, urlblabla, userblabla, |
|
840 passwordblabla); |
|
841 |
|
842 aTest->TestGeneralEngineL(); |
|
843 |
|
844 //Test syntax: (url, username,password,webdav sync,ctag, aEvent, aTodo, aFreeBusy, aJournal) |
|
845 |
|
846 aTest->TestEngineL(KErrNone, urlWN, userSUN, passwordSUN, ETrue, ETrue, |
|
847 ETrue, ETrue, ETrue, EFalse); |
|
848 |
|
849 aTest->TestEngineL(KErrNone, urlAriesHome, userSUN, passwordSUN, ETrue, |
|
850 ETrue, ETrue, ETrue, ETrue, EFalse); |
|
851 aTest->TestEngineL(KErrNone, urlAries, userSUN, passwordSUN, ETrue, |
|
852 ETrue, ETrue, ETrue, ETrue, EFalse); |
|
853 aTest->TestEngineL(KErrNone, urlAriesPrincipal, userSUN, passwordSUN, |
|
854 ETrue, ETrue, ETrue, ETrue, ETrue, EFalse); |
|
855 |
|
856 aTest->TestEngineL(KErrNone, urlApple, userApple, passwordApple, |
|
857 EFalse, ETrue, ETrue, ETrue, ETrue, ETrue); |
|
858 aTest->TestEngineL(KErrNone, principalAplle, userApple, passwordApple, |
|
859 EFalse, ETrue, ETrue, ETrue, ETrue, ETrue); |
|
860 |
|
861 aTest->TestEngineL(KErrNone, urlGoogle, userGoogle, passwordGoogle, |
|
862 EFalse, ETrue, ETrue, EFalse, EFalse, EFalse); |
|
863 aTest->TestEngineL(KErrNone, urlGooglePrincipal, userGoogle, |
|
864 passwordGoogle, EFalse, ETrue, ETrue, EFalse, EFalse, EFalse); |
|
865 |
|
866 aTest->TestEngineL(KErrNone, urlChandler, userChandler, |
|
867 passwordChandler, EFalse, ETrue, ETrue, ETrue, ETrue, ETrue); |
|
868 aTest->TestEngineL(KErrNone, urlChandlerPrincipal, userChandler, |
|
869 passwordChandler, EFalse, ETrue, ETrue, ETrue, ETrue, ETrue); |
|
870 |
|
871 aTest->TestEngineL(KErrNone, urlOracle, userOracle, passwordOracle, |
|
872 EFalse, ETrue, ETrue, ETrue, EFalse, EFalse); |
|
873 aTest->TestEngineL(KErrNone, urlOraclePrincipal, userOracle, |
|
874 passwordOracle, EFalse, ETrue, ETrue, ETrue, EFalse, EFalse); |
|
875 |
|
876 aTest->TestEngineL(KErrNone, urlSogo, userSogo, passwordSogo, EFalse, |
|
877 ETrue, ETrue, ETrue, EFalse, EFalse); |
|
878 aTest->TestEngineL(KErrNone, urlDAV, userDAV, passwordDAV, EFalse, |
|
879 EFalse, ETrue, ETrue, EFalse, EFalse); |
|
880 |
|
881 aTest->TestEngineL(KErrNone, urlYahoo, userYahoo, passwordYahoo, |
|
882 EFalse, ETrue, ETrue, EFalse, ETrue, EFalse); |
|
883 aTest->TestEngineL(KErrNone, urlYahooPrincipal, userYahoo, |
|
884 passwordYahoo, EFalse, ETrue, ETrue, EFalse, ETrue, EFalse); |
|
885 |
|
886 aTest->TestEngineL(KErrNone, urlDaviCal, userDaviCal, passwordDaviCal, |
|
887 EFalse, ETrue, ETrue, ETrue, ETrue, ETrue); |
|
888 aTest->TestEngineL(KErrNone, principalDaviCal, userDaviCal, |
|
889 passwordDaviCal, EFalse, ETrue, ETrue, ETrue, ETrue, ETrue); |
|
890 |
|
891 aTest->TestEngineL(KErrNone, urlKerio, userKerio, passwordkerio, |
|
892 EFalse, ETrue, ETrue, ETrue, ETrue, EFalse); |
|
893 aTest->TestEngineL(KErrNone, principalKerio, userKerio, passwordkerio, |
|
894 EFalse, ETrue, ETrue, ETrue, ETrue, EFalse); |
|
895 |
|
896 aTest->TestEngineL(KErrNone, urlBedework, userBedework, |
|
897 passwordbedework, EFalse, ETrue, ETrue, ETrue, |
|
898 EFalse, EFalse); |
|
899 aTest->TestEngineL(KErrNone, urlBedeWorkPrincipal, userBedework, |
|
900 passwordbedework, EFalse, ETrue, ETrue, ETrue, |
|
901 EFalse, EFalse); |
|
902 |
|
903 aTest->TestEngineL(KErrArgument, urlAries, userSUN, passwordblabla, |
|
904 ETrue, ETrue, ETrue, ETrue, ETrue, EFalse); |
|
905 |
|
906 aTest->TestEngineL(KErrArgument, urlblabla, userblabla, passwordblabla, |
|
907 EFalse, EFalse, ETrue, ETrue, EFalse, EFalse); |
|
908 |
|
909 delete aTest; |
|
910 } |
|
911 |
|
912 // Delete active scheduler |
|
913 CleanupStack::PopAndDestroy(scheduler); |
|
914 } |
|
915 |
|
916 // Global Functions |
|
917 GLDEF_C TInt E32Main() |
|
918 { |
|
919 __UHEAP_MARK; |
|
920 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
921 TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize( |
|
922 KConsFullScreen, KConsFullScreen))); |
|
923 if (createError) |
|
924 return createError; |
|
925 TRAPD(mainError, DoStartL()); |
|
926 if (mainError) |
|
927 console->Printf(KTextFailed, mainError); |
|
928 console->Printf(KTextPressAnyKey); |
|
929 console->Getch(); |
|
930 |
|
931 delete console; |
|
932 delete cleanup; |
|
933 __UHEAP_MARKEND; |
|
934 return KErrNone; |
|
935 } |
|
936 |