author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "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 Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// SYSTEM INCLUDE FILES |
|
22 |
#include <e32base.h> |
|
23 |
#include <f32file.h> //for RFile and Rfs |
|
24 |
#include <calentry.h>//for CCalEntry |
|
25 |
#include <calinstance.h> |
|
26 |
||
27 |
#include "teststartconsolealarmserver.h" |
|
28 |
||
29 |
// USER INCLUDE FILES |
|
30 |
#include "exportestcases.h" |
|
31 |
#include "calendarheader.h" |
|
32 |
#include "calendarservice.h" |
|
33 |
||
34 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
35 |
#include<ascliclientutils.h> |
19 | 36 |
|
37 |
_LIT(KCalName ,"c:Calendar"); |
|
38 |
||
39 |
_LIT(KTestCal1Name ,"c:testcal1"); |
|
40 |
_LIT(KTestCal2Name ,"c:testcal2"); |
|
41 |
_LIT(KTestCal3Name ,"c:testcal3"); |
|
42 |
||
43 |
||
44 |
_LIT(KExportAllFileName ,"C:\\exportAll.txt"); |
|
45 |
_LIT(KExportAllAsyncFileName ,"C:\\exportAllAsync.txt"); |
|
46 |
||
47 |
_LIT(KExportGuidsFileName ,"C:\\exportForGuids.txt"); |
|
48 |
_LIT(KExportGuidsAsyncFileName,"C:\\exportForGuidsAsync.txt"); |
|
49 |
||
50 |
_LIT(KExportLuidsFileName ,"C:\\exportForLuids.txt"); |
|
51 |
_LIT(KExportLuidsAsyncFileName,"C:\\exportForLuidsAsync.txt"); |
|
52 |
||
53 |
_LIT(KICALExportAllFileName ,"C:\\icalexportAll.txt"); |
|
54 |
_LIT(KICALExportAllAsyncFileName ,"C:\\icalexportAllAsync.txt"); |
|
55 |
||
56 |
_LIT(KICALExportGuidsFileName ,"C:\\icalexportForGuids.txt"); |
|
57 |
_LIT(KICALExportGuidsAsyncFileName,"C:\\icalexportForGuidsAsync.txt"); |
|
58 |
||
59 |
_LIT(KICALExportLuidsFileName ,"C:\\icalexportForLuids.txt"); |
|
60 |
_LIT(KICALExportLuidsAsyncFileName,"C:\\icalexportForLuidsAsync.txt"); |
|
61 |
||
62 |
||
63 |
CCalExpTestCases* CCalExpTestCases::NewL(TInt& aResult, TInt aVCalOrICal) //1 means VCal else ICal |
|
64 |
{ |
|
65 |
CCalExpTestCases* self = new(ELeave)CCalExpTestCases(aResult, aVCalOrICal); //1 means VCal else ICal; |
|
66 |
||
67 |
self->ConstructL(); |
|
68 |
||
69 |
return self; |
|
70 |
} |
|
71 |
||
72 |
CCalExpTestCases::~CCalExpTestCases() |
|
73 |
{ |
|
74 |
Cancel(); |
|
75 |
||
76 |
if(iWaitSchedular->IsStarted()) |
|
77 |
iWaitSchedular->AsyncStop(); |
|
78 |
||
79 |
if(iCalendarService) |
|
80 |
delete iCalendarService; |
|
81 |
||
82 |
if(iWaitSchedular) |
|
83 |
delete iWaitSchedular; |
|
84 |
||
85 |
iArruids.ResetAndDestroy(); |
|
86 |
} |
|
87 |
||
88 |
||
89 |
||
90 |
||
91 |
TInt CCalExpTestCases::TestExportCasesL() |
|
92 |
{ |
|
93 |
//No need to set it but for the sake of semanitics set to sync value |
|
94 |
iTestCaseType = KExportSync; |
|
95 |
||
96 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
97 |
||
98 |
AddCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
99 |
||
100 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
101 |
||
102 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
103 |
||
104 |
||
105 |
RPointerArray<TUIDSet> arruids(5); |
|
106 |
||
107 |
TUIDSet* uids = NULL; |
|
108 |
||
109 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
110 |
{ |
|
111 |
arruids.Append(uids); |
|
112 |
uids = NULL; |
|
113 |
} |
|
114 |
||
115 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
116 |
{ |
|
117 |
arruids.Append(uids); |
|
118 |
uids = NULL; |
|
119 |
} |
|
120 |
||
121 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
122 |
{ |
|
123 |
arruids.Append(uids); |
|
124 |
uids = NULL; |
|
125 |
} |
|
126 |
||
127 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
128 |
{ |
|
129 |
arruids.Append(uids); |
|
130 |
uids = NULL; |
|
131 |
} |
|
132 |
||
133 |
if(AddToDo(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
134 |
{ |
|
135 |
arruids.Append(uids); |
|
136 |
uids = NULL; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL(); |
|
141 |
||
142 |
// export to cal file - default cal |
|
143 |
expParams->SetExportFileNameL(KCalName); |
|
144 |
TInt err_export; |
|
145 |
TInt err_import,count; |
|
146 |
||
147 |
HBufC8* buffer = NULL; |
|
148 |
if( iVCalOrICal == 1) |
|
149 |
{ |
|
150 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) ); |
|
151 |
} |
|
152 |
else |
|
153 |
{ |
|
154 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) ); |
|
155 |
} |
|
156 |
||
157 |
||
158 |
if(err_export != KErrPathNotFound) |
|
159 |
iResult = KErrGeneral; |
|
160 |
||
161 |
//set null desc for file name |
|
162 |
||
163 |
TRAPD(err_setfile,expParams->SetExportFileNameL(KNullDesC)); |
|
164 |
||
165 |
if( iVCalOrICal == 1) |
|
166 |
{ |
|
167 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) ); |
|
168 |
} |
|
169 |
else |
|
170 |
{ |
|
171 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) ); |
|
172 |
} |
|
173 |
||
174 |
||
175 |
||
176 |
RPointerArray<TUIDSet> uSet(5); |
|
177 |
expParams->SetExportFileNameL(KExportGuidsFileName); |
|
178 |
||
179 |
if( iVCalOrICal == 1) |
|
180 |
{ |
|
181 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) ); |
|
182 |
} |
|
183 |
else |
|
184 |
{ |
|
185 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) ); |
|
186 |
} |
|
187 |
||
188 |
||
189 |
if( iVCalOrICal == 1) |
|
190 |
{ |
|
191 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KExportGuidsFileName.operator()() ,uSet ) ); |
|
192 |
} |
|
193 |
else |
|
194 |
{ |
|
195 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KExportGuidsFileName.operator()() ,uSet ) ); |
|
196 |
} |
|
197 |
||
198 |
count = uSet.Count(); |
|
199 |
uSet.ResetAndDestroy(); |
|
200 |
||
201 |
||
202 |
if( iVCalOrICal == 1) |
|
203 |
{ |
|
204 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *buffer ,uSet ) ); |
|
205 |
} |
|
206 |
else |
|
207 |
{ |
|
208 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *buffer ,uSet ) ); |
|
209 |
} |
|
210 |
||
211 |
TInt new_count = uSet.Count(); |
|
212 |
||
213 |
if(count != new_count) |
|
214 |
iResult = KErrGeneral; |
|
215 |
||
216 |
if(buffer != NULL) |
|
217 |
{ |
|
218 |
delete buffer; |
|
219 |
buffer = NULL; |
|
220 |
} |
|
221 |
||
222 |
delete expParams; |
|
223 |
arruids.ResetAndDestroy(); |
|
224 |
uSet.ResetAndDestroy(); |
|
225 |
delete uids; |
|
226 |
uids = NULL; |
|
227 |
||
228 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
229 |
||
230 |
return iResult; |
|
231 |
||
232 |
} |
|
233 |
||
234 |
||
235 |
||
236 |
||
237 |
TInt CCalExpTestCases::TestExportForGuidsL() |
|
238 |
{ |
|
239 |
TInt cells = User::CountAllocCells(); |
|
240 |
||
241 |
||
242 |
//No need to set it but for the sake of semanitics set to sync value |
|
243 |
iTestCaseType = KExportSync; |
|
244 |
||
245 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
246 |
||
247 |
AddCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
248 |
||
249 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
250 |
||
251 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
252 |
||
253 |
||
254 |
RPointerArray<TUIDSet> arruids(5); |
|
255 |
||
256 |
TUIDSet* uids = NULL; |
|
257 |
||
258 |
||
259 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
260 |
{ |
|
261 |
arruids.Append(uids); |
|
262 |
uids = NULL; |
|
263 |
} |
|
264 |
||
265 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
266 |
{ |
|
267 |
arruids.Append(uids); |
|
268 |
uids = NULL; |
|
269 |
} |
|
270 |
||
271 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
272 |
{ |
|
273 |
arruids.Append(uids); |
|
274 |
uids = NULL; |
|
275 |
} |
|
276 |
||
277 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
278 |
{ |
|
279 |
arruids.Append(uids); |
|
280 |
uids = NULL; |
|
281 |
} |
|
282 |
||
283 |
if(AddToDo(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
284 |
{ |
|
285 |
arruids.Append(uids); |
|
286 |
uids = NULL; |
|
287 |
} |
|
288 |
||
289 |
||
290 |
||
291 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL(); |
|
292 |
CCalendarExportParams *new_expParams = CCalendarExportParams::NewL(); |
|
293 |
||
294 |
TInt count = arruids.Count() -1 ; |
|
295 |
||
296 |
expParams->AddGuidL( (arruids[0]->iGlobalUID)->Des() ); |
|
297 |
expParams->AddGuidL( (arruids[1]->iGlobalUID)->Des() ); |
|
298 |
||
299 |
||
300 |
count =0; |
|
301 |
||
302 |
||
303 |
HBufC8* buffer = NULL; |
|
304 |
HBufC8* new_buffer = NULL; |
|
305 |
||
306 |
TInt err_export; |
|
307 |
if( iVCalOrICal == 1) |
|
308 |
{ |
|
309 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) ); |
|
310 |
} |
|
311 |
else |
|
312 |
{ |
|
313 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) ); |
|
314 |
} |
|
315 |
||
316 |
expParams->AddGuidL( (arruids[2]->iGlobalUID)->Des() ); |
|
317 |
||
318 |
delete buffer; |
|
319 |
buffer = NULL; |
|
320 |
||
321 |
if( iVCalOrICal == 1) |
|
322 |
{ |
|
323 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,new_buffer ) ); |
|
324 |
} |
|
325 |
else |
|
326 |
{ |
|
327 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,new_buffer ) ); |
|
328 |
} |
|
329 |
||
330 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
331 |
||
332 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
333 |
||
334 |
||
335 |
RPointerArray<TUIDSet> uIDSet(5); |
|
336 |
TInt err_import; |
|
337 |
||
338 |
if( iVCalOrICal == 1) |
|
339 |
{ |
|
340 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *new_buffer ,uIDSet ) ); |
|
341 |
} |
|
342 |
else |
|
343 |
{ |
|
344 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *new_buffer ,uIDSet ) ); |
|
345 |
} |
|
346 |
||
347 |
||
348 |
count = uIDSet.Count(); |
|
349 |
if(count != 3) |
|
350 |
iResult = KErrGeneral; |
|
351 |
||
352 |
// count =0; |
|
353 |
uIDSet.ResetAndDestroy(); |
|
354 |
delete new_buffer; |
|
355 |
new_buffer = NULL; |
|
356 |
||
357 |
err_export = KErrNone; |
|
358 |
err_import = KErrNone; |
|
359 |
||
360 |
new_expParams->SetExportFileNameL(KExportGuidsFileName); |
|
361 |
||
362 |
new_expParams->AddGuidL( (arruids[0]->iGlobalUID)->Des() ); |
|
363 |
new_expParams->AddGuidL( (arruids[1]->iGlobalUID)->Des() ); |
|
364 |
||
365 |
if( iVCalOrICal == 1) |
|
366 |
{ |
|
367 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , new_expParams ,buffer ) ); |
|
368 |
} |
|
369 |
else |
|
370 |
{ |
|
371 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , new_expParams ,buffer ) ); |
|
372 |
} |
|
373 |
||
374 |
||
375 |
new_expParams->AddGuidL( (arruids[2]->iGlobalUID)->Des() ); |
|
376 |
new_expParams->SetExportFileNameL(KExportGuidsFileName); |
|
377 |
||
378 |
if( iVCalOrICal == 1) |
|
379 |
{ |
|
380 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , new_expParams ,new_buffer ) ); |
|
381 |
} |
|
382 |
else |
|
383 |
{ |
|
384 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , new_expParams ,new_buffer ) ); |
|
385 |
} |
|
386 |
||
387 |
||
388 |
||
389 |
if( iVCalOrICal == 1) |
|
390 |
{ |
|
391 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KExportGuidsFileName.operator()() ,uIDSet ) ); |
|
392 |
} |
|
393 |
else |
|
394 |
{ |
|
395 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KExportGuidsFileName.operator()() ,uIDSet ) ); |
|
396 |
} |
|
397 |
||
398 |
||
399 |
TInt new_count = uIDSet.Count(); |
|
400 |
||
401 |
if(count != new_count && iResult == KErrNone) |
|
402 |
iResult = KErrGeneral; |
|
403 |
||
404 |
||
405 |
if(buffer) |
|
406 |
delete buffer; |
|
407 |
if(new_buffer) |
|
408 |
delete new_buffer; |
|
409 |
||
410 |
delete expParams; |
|
411 |
delete new_expParams; |
|
412 |
arruids.ResetAndDestroy(); |
|
413 |
uIDSet.ResetAndDestroy(); |
|
414 |
delete uids; |
|
415 |
uids = NULL; |
|
416 |
arruids.Close() ; |
|
417 |
uIDSet.Close() ; |
|
418 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
419 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
420 |
||
421 |
cells = User::CountAllocCells(); |
|
422 |
||
423 |
return iResult; |
|
424 |
||
425 |
} |
|
426 |
||
427 |
||
428 |
||
429 |
||
430 |
||
431 |
TInt CCalExpTestCases::TestExportForLuidsL() |
|
432 |
{ |
|
433 |
//No need to set it but for the sake of semanitics set to sync value |
|
434 |
iTestCaseType = KExportSync; |
|
435 |
||
436 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
437 |
||
438 |
iResult = AddCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
439 |
||
440 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
441 |
||
442 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
443 |
||
444 |
||
445 |
if(iResult != KErrNone) |
|
446 |
return iResult ; |
|
447 |
||
448 |
RPointerArray<TUIDSet> arruids(5); |
|
449 |
||
450 |
TUIDSet* uids = NULL; |
|
451 |
||
452 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
453 |
{ |
|
454 |
arruids.Append(uids); |
|
455 |
uids = NULL; |
|
456 |
} |
|
457 |
||
458 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
459 |
{ |
|
460 |
arruids.Append(uids); |
|
461 |
uids = NULL; |
|
462 |
} |
|
463 |
||
464 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
465 |
{ |
|
466 |
arruids.Append(uids); |
|
467 |
uids = NULL; |
|
468 |
} |
|
469 |
||
470 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
471 |
{ |
|
472 |
arruids.Append(uids); |
|
473 |
uids = NULL; |
|
474 |
} |
|
475 |
||
476 |
if(AddToDo(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
477 |
{ |
|
478 |
arruids.Append(uids); |
|
479 |
uids = NULL; |
|
480 |
} |
|
481 |
||
482 |
||
483 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL(); |
|
484 |
||
485 |
TInt count = arruids.Count(); |
|
486 |
for(TInt index = 0; index < count; ++index) |
|
487 |
{ |
|
488 |
expParams->AddLocalUid( (arruids[index]->iLocalUID) ); |
|
489 |
} |
|
490 |
HBufC8* buffer = NULL; |
|
491 |
if( iVCalOrICal == 1) |
|
492 |
{ |
|
493 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) ); |
|
494 |
} |
|
495 |
else |
|
496 |
{ |
|
497 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) ); |
|
498 |
} |
|
499 |
||
500 |
delete expParams; |
|
501 |
||
502 |
if(iResult != KErrNone) |
|
503 |
{ |
|
504 |
delete buffer; |
|
505 |
arruids.ResetAndDestroy(); |
|
506 |
return iResult; |
|
507 |
} |
|
508 |
||
509 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
510 |
||
511 |
iResult = AddCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
512 |
||
513 |
if(iResult != KErrNone) |
|
514 |
return iResult ; |
|
515 |
||
516 |
RPointerArray<TUIDSet> uIDSet(5); |
|
517 |
||
518 |
if( iVCalOrICal == 1) |
|
519 |
{ |
|
520 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *buffer ,uIDSet ) ); |
|
521 |
} |
|
522 |
else |
|
523 |
{ |
|
524 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *buffer ,uIDSet ) ); |
|
525 |
} |
|
526 |
||
527 |
||
528 |
if(iResult != KErrNone) |
|
529 |
{ |
|
530 |
delete buffer; |
|
531 |
arruids.ResetAndDestroy(); |
|
532 |
uIDSet.ResetAndDestroy(); |
|
533 |
return iResult; |
|
534 |
} |
|
535 |
||
536 |
if ( arruids.Count() != uIDSet.Count() ) |
|
537 |
iResult = KErrGeneral; |
|
538 |
||
539 |
delete buffer; |
|
540 |
arruids.ResetAndDestroy(); |
|
541 |
uIDSet.ResetAndDestroy(); |
|
542 |
||
543 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
544 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
545 |
||
546 |
return iResult; |
|
547 |
} |
|
548 |
||
549 |
||
550 |
||
551 |
||
552 |
void CCalExpTestCases::TestExportForGuidsBufAsyncL() |
|
553 |
{ |
|
554 |
iTestCaseType = KExportForGuidsBufAsync; |
|
555 |
Start(); |
|
556 |
||
557 |
} |
|
558 |
||
559 |
||
560 |
||
561 |
void CCalExpTestCases::TestExportForGuidsFileAsyncL() |
|
562 |
{ |
|
563 |
iTestCaseType = KExportForGuidsFileAsync; |
|
564 |
Start(); |
|
565 |
} |
|
566 |
||
567 |
void CCalExpTestCases::TestExportForLuidAsyncL() |
|
568 |
{ |
|
569 |
iTestCaseType = KExportAllAsyncVCAL; |
|
570 |
Start(); |
|
571 |
} |
|
572 |
||
573 |
void CCalExpTestCases::TestExportCaseAsyncL() |
|
574 |
{ |
|
575 |
iTestCaseType = KExportAllAsync; |
|
576 |
Start(); |
|
577 |
} |
|
578 |
||
579 |
||
580 |
||
581 |
||
582 |
TInt CCalExpTestCases::Result() |
|
583 |
{ |
|
584 |
return iResult; |
|
585 |
} |
|
586 |
||
587 |
void CCalExpTestCases::ConstructL() |
|
588 |
{ |
|
589 |
iCalendarService = CCalendarService::NewL(); |
|
590 |
||
591 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
592 |
} |
|
593 |
||
594 |
CCalExpTestCases::CCalExpTestCases(TInt& aResult, TInt aVCalOrICal ) : |
|
595 |
CActive(EPriorityStandard), iResult( aResult ) , |
|
596 |
iVCalOrICal(aVCalOrICal) |
|
597 |
{ |
|
598 |
||
599 |
} |
|
600 |
||
601 |
//for the sake of ActiveObject |
|
602 |
void CCalExpTestCases::DoCancel() |
|
603 |
{ |
|
604 |
||
605 |
} |
|
606 |
||
607 |
void CCalExpTestCases::RunL() |
|
608 |
{ |
|
609 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
610 |
||
611 |
iResult = AddCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
612 |
||
613 |
if(iResult != KErrNone) |
|
614 |
goto Final; |
|
615 |
||
616 |
TUIDSet* uids = NULL; |
|
617 |
||
618 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
619 |
{ |
|
620 |
iArruids.Append(uids); |
|
621 |
uids = NULL; |
|
622 |
} |
|
623 |
||
624 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
625 |
{ |
|
626 |
iArruids.Append(uids); |
|
627 |
uids = NULL; |
|
628 |
} |
|
629 |
||
630 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
631 |
{ |
|
632 |
iArruids.Append(uids); |
|
633 |
uids = NULL; |
|
634 |
} |
|
635 |
||
636 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
637 |
{ |
|
638 |
iArruids.Append(uids); |
|
639 |
uids = NULL; |
|
640 |
} |
|
641 |
||
642 |
if(AddToDo(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
643 |
{ |
|
644 |
iArruids.Append(uids); |
|
645 |
uids = NULL; |
|
646 |
} |
|
647 |
||
648 |
delete uids; |
|
649 |
uids = NULL; |
|
650 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL(); |
|
651 |
||
652 |
TInt count; |
|
653 |
||
654 |
switch( iTestCaseType ) |
|
655 |
{ |
|
656 |
case KExportAllAsyncVCAL: |
|
657 |
if( iVCalOrICal == 1) |
|
658 |
{ |
|
659 |
TRAP( iResult, iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams , this )); |
|
660 |
} |
|
661 |
else |
|
662 |
{ |
|
663 |
TRAP( iResult, iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams , this )); |
|
664 |
} |
|
665 |
||
666 |
break; |
|
667 |
||
668 |
case KExportForGuidsBufAsync: |
|
669 |
count = iArruids.Count(); |
|
670 |
for(TInt index = 0; index < count; ++index) |
|
671 |
{ |
|
672 |
expParams->AddGuidL( (iArruids[index]->iGlobalUID)->Des() ); |
|
673 |
} |
|
674 |
||
675 |
if( iVCalOrICal == 1) |
|
676 |
{ |
|
677 |
TRAP( iResult, iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams, this ) ); |
|
678 |
} |
|
679 |
else |
|
680 |
{ |
|
681 |
TRAP( iResult, iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams, this ) ); |
|
682 |
} |
|
683 |
||
684 |
break; |
|
685 |
||
686 |
case KExportForGuidsFileAsync: |
|
687 |
count = iArruids.Count(); |
|
688 |
for(TInt index = 0; index < count; ++index) |
|
689 |
{ |
|
690 |
expParams->AddLocalUid( (iArruids[index]->iLocalUID) ); |
|
691 |
} |
|
692 |
||
693 |
expParams->SetExportFileNameL(KExportGuidsAsyncFileName); |
|
694 |
if( iVCalOrICal == 1) |
|
695 |
{ |
|
696 |
TRAP( iResult, iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams, this ) ); |
|
697 |
} |
|
698 |
else |
|
699 |
{ |
|
700 |
TRAP( iResult, iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams, this ) ); |
|
701 |
} |
|
702 |
||
703 |
break; |
|
704 |
||
705 |
case KExportAllAsync : |
|
706 |
expParams->SetExportFileNameL(KCalName); |
|
707 |
if( iVCalOrICal == 1) |
|
708 |
{ |
|
709 |
TRAP( iResult, iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams , this )); |
|
710 |
} |
|
711 |
else |
|
712 |
{ |
|
713 |
TRAP( iResult, iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams , this )); |
|
714 |
} |
|
715 |
||
716 |
break; |
|
717 |
} |
|
718 |
delete expParams; |
|
719 |
Final: ; |
|
720 |
} |
|
721 |
||
722 |
void CCalExpTestCases::Start() |
|
723 |
{ |
|
724 |
CActiveScheduler::Add(this); |
|
725 |
||
726 |
SetActive(); |
|
727 |
||
728 |
TRequestStatus* temp = &iStatus; |
|
729 |
||
730 |
User::RequestComplete(temp, KErrNone); |
|
731 |
||
732 |
iWaitSchedular->Start(); |
|
733 |
} |
|
734 |
||
735 |
||
736 |
void CCalExpTestCases::NotifyResultL(TInt aErrCode, TAny* aResult) |
|
737 |
{ |
|
738 |
//******************* set iResult **************************** |
|
739 |
iResult = aErrCode; |
|
740 |
||
741 |
||
742 |
//******************* set iResult **************************** |
|
743 |
||
744 |
||
745 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
746 |
||
747 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
748 |
TInt count; |
|
749 |
||
750 |
||
751 |
RPointerArray<TUIDSet> uSet(5); |
|
752 |
||
753 |
switch(iTestCaseType) |
|
754 |
{ |
|
755 |
case KExportForGuidsBufAsync: |
|
756 |
if( iVCalOrICal == 1) |
|
757 |
{ |
|
758 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *(HBufC8*)aResult ,uSet ) ); |
|
759 |
} |
|
760 |
else |
|
761 |
{ |
|
762 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *(HBufC8*)aResult ,uSet ) ); |
|
763 |
} |
|
764 |
count = uSet.Count(); |
|
765 |
if(count != 5) |
|
766 |
iResult = KErrGeneral; |
|
767 |
break; |
|
768 |
case KExportForGuidsFileAsync: |
|
769 |
if( iVCalOrICal == 1) |
|
770 |
{ |
|
771 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KExportGuidsAsyncFileName.operator()() ,uSet ) ); |
|
772 |
} |
|
773 |
else |
|
774 |
{ |
|
775 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KExportGuidsAsyncFileName.operator()() ,uSet ) ); |
|
776 |
} |
|
777 |
count = uSet.Count(); |
|
778 |
if(count != 5) |
|
779 |
iResult = KErrGeneral; |
|
780 |
break; |
|
781 |
||
782 |
case KExportAllAsyncVCAL : |
|
783 |
if( iVCalOrICal == 1) |
|
784 |
{ |
|
785 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *(HBufC8*)aResult ,uSet ) ); |
|
786 |
} |
|
787 |
else |
|
788 |
{ |
|
789 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *(HBufC8*)aResult ,uSet ) ); |
|
790 |
} |
|
791 |
count = uSet.Count(); |
|
792 |
if(count != 5) |
|
793 |
iResult = KErrGeneral; |
|
794 |
break; |
|
795 |
||
796 |
case KExportAllAsync : |
|
797 |
if(iResult != KErrPathNotFound) |
|
798 |
iResult = KErrGeneral; |
|
799 |
else |
|
800 |
iResult = KErrNone; |
|
801 |
||
802 |
} |
|
803 |
||
804 |
||
805 |
uSet.ResetAndDestroy(); |
|
806 |
||
807 |
||
808 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
809 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
810 |
||
811 |
iWaitSchedular->AsyncStop(); |
|
812 |
} |
|
813 |