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 |
||
25 |
#include <calentry.h>//for CCalEntry |
|
26 |
#include <calinstanceview.h>//for CCalInstance |
|
27 |
#include <calcommon.h>//for Filter Type Enum Constants |
|
28 |
#include <calinstance.h> |
|
29 |
#include <caltime.h> |
|
30 |
||
31 |
// USER INCLUDE FILES |
|
32 |
#include "caldeltestcases.h" |
|
33 |
#include "calendarheader.h" |
|
34 |
#include "calendarservice.h" |
|
35 |
#include "entryattributes.h" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
36 |
#include<ascliclientutils.h> |
19 | 37 |
|
38 |
#include "teststartconsolealarmserver.h" |
|
39 |
||
40 |
||
41 |
||
42 |
||
43 |
||
44 |
_LIT(KCalName ,"c:Calendar"); |
|
45 |
||
46 |
||
47 |
||
48 |
CCalDelTestCases* CCalDelTestCases::NewL( TInt& aResult) //1 means VCal else ICal |
|
49 |
{ |
|
50 |
CCalDelTestCases* self = new(ELeave)CCalDelTestCases( aResult); //1 means VCal else ICal; |
|
51 |
||
52 |
self->ConstructL(); |
|
53 |
||
54 |
return self; |
|
55 |
} |
|
56 |
||
57 |
CCalDelTestCases::~CCalDelTestCases() |
|
58 |
{ |
|
59 |
Cancel(); |
|
60 |
||
61 |
if(iWaitSchedular->IsStarted()) |
|
62 |
iWaitSchedular->AsyncStop(); |
|
63 |
||
64 |
if(iCalendarService) |
|
65 |
delete iCalendarService; |
|
66 |
||
67 |
if(iWaitSchedular) |
|
68 |
delete iWaitSchedular; |
|
69 |
||
70 |
if(iArruids.Count()) |
|
71 |
iArruids.ResetAndDestroy(); |
|
72 |
} |
|
73 |
||
74 |
||
75 |
_LIT(KDelTestCalNameDeleteCal ,"c:deletecalendarcasecal"); |
|
76 |
||
77 |
TInt CCalDelTestCases::TestDeleteCalendarL() |
|
78 |
{ |
|
79 |
//No need to set it but for the sake of semanitics set to sync value |
|
80 |
iTestCaseType = KDeleteSync; |
|
81 |
||
82 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteCal.operator()() ) ); |
|
83 |
||
84 |
if( iResult == KErrNone ) |
|
85 |
{ |
|
86 |
TRAP( iResult ,iCalendarService->DeleteL( KDelTestCalNameDeleteCal.operator()() ) ); |
|
87 |
} |
|
88 |
||
89 |
return iResult; |
|
90 |
} |
|
91 |
||
92 |
||
93 |
TInt CCalDelTestCases::TestDeleteDefaultCalendarL() |
|
94 |
{ |
|
95 |
//No need to set it but for the sake of semanitics set to sync value |
|
96 |
iTestCaseType = KDeleteSync; |
|
97 |
||
98 |
TRAP( iResult , iCalendarService->DeleteL( KCalName.operator()() ) ); |
|
99 |
||
100 |
if( iResult == KErrNotSupported ) |
|
101 |
iResult = KErrNone; |
|
102 |
||
103 |
return iResult; |
|
104 |
} |
|
105 |
||
106 |
_LIT(KDelTestCalNameDeleteAll ,"c:deleteallcal"); |
|
107 |
||
108 |
TInt CCalDelTestCases::TestDeleteAllEntriesL() |
|
109 |
{ |
|
110 |
//No need to set it but for the sake of semanitics set to sync value |
|
111 |
iTestCaseType = KDeleteSync; |
|
112 |
||
113 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteAll.operator()()); |
|
114 |
||
115 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteAll.operator()() ) ); |
|
116 |
||
117 |
if( iResult == KErrNone ) |
|
118 |
{ |
|
119 |
addSomeEntries( KDelTestCalNameDeleteAll.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
120 |
||
121 |
||
122 |
||
123 |
CCalendarFilter *getListfilter1 = CCalendarFilter::NewL(); |
|
124 |
||
125 |
RPointerArray<CCalInstance> calInstanceArray; |
|
126 |
||
127 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
128 |
||
129 |
iCalendarService->GetListL( KDelTestCalNameDeleteAll.operator()(), getListfilter1 , calInstanceArray ); |
|
130 |
||
131 |
if ( calInstanceArray.Count() == 0 ) |
|
132 |
{ |
|
133 |
iResult = KErrGeneral; |
|
134 |
||
135 |
calInstanceArray.ResetAndDestroy(); |
|
136 |
||
137 |
return iResult; |
|
138 |
} |
|
139 |
||
140 |
delete getListfilter1; |
|
141 |
||
142 |
||
143 |
CCalendarFilter *filter = CCalendarFilter::NewL(); |
|
144 |
||
145 |
filter->SetDeleteAll( ETrue ); |
|
146 |
||
147 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteAll.operator()() , filter , NULL) ); |
|
148 |
||
149 |
delete filter; |
|
150 |
||
151 |
||
152 |
CCalendarFilter *getListfilter2 = CCalendarFilter::NewL(); |
|
153 |
||
154 |
RPointerArray<CCalInstance> calInstanceArray2; |
|
155 |
||
156 |
getListfilter2->SetFilterTypeL( KIncludeAll ); |
|
157 |
||
158 |
iCalendarService->GetListL( KDelTestCalNameDeleteAll.operator()(), getListfilter2 , calInstanceArray2 ); |
|
159 |
||
160 |
delete getListfilter2; |
|
161 |
||
162 |
if ( calInstanceArray2.Count() != 0 ) |
|
163 |
{ |
|
164 |
iResult = KErrGeneral; |
|
165 |
} |
|
166 |
calInstanceArray.ResetAndDestroy(); |
|
167 |
||
168 |
calInstanceArray2.ResetAndDestroy(); |
|
169 |
} |
|
170 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteAll.operator()()); |
|
171 |
||
172 |
return iResult; |
|
173 |
} |
|
174 |
||
175 |
||
176 |
||
177 |
_LIT(KDelTestCalNameDeleteForGuids ,"c:deleteforGuidscal"); |
|
178 |
||
179 |
TInt CCalDelTestCases::TestDeleteUsingGUidL() |
|
180 |
{ |
|
181 |
//No need to set it but for the sake of semanitics set to sync value |
|
182 |
iTestCaseType = KDeleteSync; |
|
183 |
||
184 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuids.operator()()); |
|
185 |
||
186 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForGuids.operator()() ) ); |
|
187 |
||
188 |
if( iResult == KErrNone ) |
|
189 |
{ |
|
190 |
addSomeEntries( KDelTestCalNameDeleteForGuids.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
191 |
||
192 |
||
193 |
||
194 |
CCalendarFilter *getListfilter1 = CCalendarFilter::NewL(); |
|
195 |
||
196 |
RPointerArray<CCalInstance> calInstanceArray; |
|
197 |
||
198 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
199 |
||
200 |
iCalendarService->GetListL( KDelTestCalNameDeleteForGuids.operator()(), getListfilter1 , calInstanceArray ); |
|
201 |
||
202 |
delete getListfilter1; |
|
203 |
||
204 |
if ( calInstanceArray.Count() == 0 ) |
|
205 |
{ |
|
206 |
iResult = KErrGeneral; |
|
207 |
||
208 |
calInstanceArray.ResetAndDestroy(); |
|
209 |
||
210 |
return iResult; |
|
211 |
} |
|
212 |
||
213 |
||
214 |
CCalendarFilter *filter = CCalendarFilter::NewL(); |
|
215 |
||
216 |
for( TInt x = 0; x < iArruids.Count(); ++x ) |
|
217 |
{ |
|
218 |
filter->AddGuidL( *(iArruids[x])->iGlobalUID ); |
|
219 |
} |
|
220 |
||
221 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForGuids.operator()() , filter , NULL) ); |
|
222 |
||
223 |
delete filter; |
|
224 |
||
225 |
||
226 |
CCalendarFilter *getListfilter2 = CCalendarFilter::NewL(); |
|
227 |
||
228 |
RPointerArray<CCalInstance> calInstanceArray2; |
|
229 |
||
230 |
getListfilter2->SetFilterTypeL( KIncludeAll ); |
|
231 |
||
232 |
iCalendarService->GetListL( KDelTestCalNameDeleteForGuids.operator()(), getListfilter2 , calInstanceArray2 ); |
|
233 |
||
234 |
delete getListfilter2; |
|
235 |
||
236 |
if ( calInstanceArray2.Count() != 0 ) |
|
237 |
{ |
|
238 |
iResult = KErrGeneral; |
|
239 |
} |
|
240 |
calInstanceArray.ResetAndDestroy(); |
|
241 |
||
242 |
calInstanceArray2.ResetAndDestroy(); |
|
243 |
} |
|
244 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuids.operator()()); |
|
245 |
||
246 |
return iResult; |
|
247 |
} |
|
248 |
||
249 |
||
250 |
||
251 |
_LIT(KDelTestCalNameDeleteForLuids ,"c:deleteforLuidscal"); |
|
252 |
||
253 |
//Asynchronous test cases so setting the iTestCaseType as it is to be handled in RunL |
|
254 |
TInt CCalDelTestCases::TestDeleteUsingLocalUidL() |
|
255 |
{ |
|
256 |
//No need to set it but for the sake of semanitics set to sync value |
|
257 |
iTestCaseType = KDeleteSync; |
|
258 |
||
259 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuids.operator()()); |
|
260 |
||
261 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForLuids.operator()() ) ); |
|
262 |
||
263 |
if( iResult == KErrNone ) |
|
264 |
{ |
|
265 |
addSomeEntries( KDelTestCalNameDeleteForLuids.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
266 |
||
267 |
||
268 |
||
269 |
CCalendarFilter *getListfilter1 = CCalendarFilter::NewL(); |
|
270 |
||
271 |
RPointerArray<CCalInstance> calInstanceArray; |
|
272 |
||
273 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
274 |
||
275 |
iCalendarService->GetListL( KDelTestCalNameDeleteForLuids.operator()(), getListfilter1 , calInstanceArray ); |
|
276 |
||
277 |
delete getListfilter1; |
|
278 |
||
279 |
if ( calInstanceArray.Count() == 0 ) |
|
280 |
{ |
|
281 |
iResult = KErrGeneral; |
|
282 |
||
283 |
calInstanceArray.ResetAndDestroy(); |
|
284 |
||
285 |
return iResult; |
|
286 |
} |
|
287 |
||
288 |
||
289 |
CCalendarFilter *filter = CCalendarFilter::NewL(); |
|
290 |
||
291 |
for( TInt x = 0; x < iArruids.Count(); ++x ) |
|
292 |
{ |
|
293 |
filter->AddLocalUid( (iArruids[x])->iLocalUID ); |
|
294 |
} |
|
295 |
||
296 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForLuids.operator()() , filter , NULL) ); |
|
297 |
||
298 |
delete filter; |
|
299 |
||
300 |
||
301 |
CCalendarFilter *getListfilter2 = CCalendarFilter::NewL(); |
|
302 |
||
303 |
RPointerArray<CCalInstance> calInstanceArray2; |
|
304 |
||
305 |
getListfilter2->SetFilterTypeL( KIncludeAll ); |
|
306 |
||
307 |
iCalendarService->GetListL( KDelTestCalNameDeleteForLuids.operator()(), getListfilter2 , calInstanceArray2 ); |
|
308 |
||
309 |
if ( calInstanceArray2.Count() != 0 ) |
|
310 |
{ |
|
311 |
iResult = KErrGeneral; |
|
312 |
} |
|
313 |
calInstanceArray.ResetAndDestroy(); |
|
314 |
||
315 |
calInstanceArray2.ResetAndDestroy(); |
|
316 |
||
317 |
delete filter; |
|
318 |
} |
|
319 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuids.operator()()); |
|
320 |
||
321 |
return iResult; |
|
322 |
} |
|
323 |
||
324 |
_LIT(KDelTestCalNameDeleteForLuidsAndTm ,"c:deleteforLuidsAndTmcal"); |
|
325 |
||
326 |
TInt CCalDelTestCases::TestDeleteTmRgLocalUidL() |
|
327 |
{ |
|
328 |
//No need to set it but for the sake of semanitics set to sync value |
|
329 |
iTestCaseType = KDeleteSync; |
|
330 |
||
331 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuidsAndTm.operator()()); |
|
332 |
||
333 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForLuidsAndTm.operator()() ) ); |
|
334 |
||
335 |
if( iResult == KErrNone ) |
|
336 |
{ |
|
337 |
addSomeEntries( KDelTestCalNameDeleteForLuidsAndTm.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
338 |
||
339 |
||
340 |
||
341 |
CCalendarFilter *getListfilter1 = CCalendarFilter::NewL(); |
|
342 |
||
343 |
RPointerArray<CCalInstance> calInstanceArray; |
|
344 |
||
345 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
346 |
||
347 |
iCalendarService->GetListL( KDelTestCalNameDeleteForLuidsAndTm.operator()(), getListfilter1 , calInstanceArray ); |
|
348 |
||
349 |
delete getListfilter1; |
|
350 |
||
351 |
if ( calInstanceArray.Count() == 0 ) |
|
352 |
{ |
|
353 |
iResult = KErrGeneral; |
|
354 |
||
355 |
calInstanceArray.ResetAndDestroy(); |
|
356 |
||
357 |
return iResult; |
|
358 |
} |
|
359 |
||
360 |
||
361 |
CCalendarFilter *filter = CCalendarFilter::NewL(); |
|
362 |
||
363 |
for( TInt x = 0; x < iArruids.Count(); ++x ) |
|
364 |
{ |
|
365 |
filter->AddLocalUid( (iArruids[x])->iLocalUID ); |
|
366 |
} |
|
367 |
||
368 |
||
369 |
filter->SetStartTimeL( TTime(TDateTime(2005, EDecember, 30, 0, 0, 0, 0)) ); |
|
370 |
||
371 |
filter->SetEndTimeL( TTime(TDateTime(2100, EDecember, 30, 0, 0, 0, 0)) ); |
|
372 |
||
373 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForLuidsAndTm.operator()() , filter , NULL) ); |
|
374 |
||
375 |
delete filter; |
|
376 |
||
377 |
||
378 |
CCalendarFilter *getListfilter2 = CCalendarFilter::NewL(); |
|
379 |
||
380 |
RPointerArray<CCalInstance> calInstanceArray2; |
|
381 |
||
382 |
getListfilter2->SetFilterTypeL( KIncludeAll ); |
|
383 |
||
384 |
iCalendarService->GetListL( KDelTestCalNameDeleteForLuidsAndTm.operator()(), getListfilter2 , calInstanceArray2 ); |
|
385 |
||
386 |
if ( calInstanceArray2.Count() != 0 ) |
|
387 |
{ |
|
388 |
iResult = KErrGeneral; |
|
389 |
} |
|
390 |
calInstanceArray.ResetAndDestroy(); |
|
391 |
||
392 |
calInstanceArray2.ResetAndDestroy(); |
|
393 |
||
394 |
delete getListfilter2; |
|
395 |
} |
|
396 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuidsAndTm.operator()()); |
|
397 |
||
398 |
return iResult; |
|
399 |
} |
|
400 |
||
401 |
||
402 |
||
403 |
_LIT(KDelTestCalNameDeleteForGuidsAndTm ,"c:deleteforGuidsAndTmcal"); |
|
404 |
||
405 |
TInt CCalDelTestCases::TestDeleteTmRgGUidL() |
|
406 |
{ |
|
407 |
//No need to set it but for the sake of semanitics set to sync value |
|
408 |
iTestCaseType = KDeleteSync; |
|
409 |
||
410 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuidsAndTm.operator()()); |
|
411 |
||
412 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForGuidsAndTm.operator()() ) ); |
|
413 |
||
414 |
if( iResult == KErrNone ) |
|
415 |
{ |
|
416 |
addSomeEntries( KDelTestCalNameDeleteForGuidsAndTm.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
417 |
||
418 |
||
419 |
||
420 |
CCalendarFilter *getListfilter1 = CCalendarFilter::NewL(); |
|
421 |
||
422 |
RPointerArray<CCalInstance> calInstanceArray; |
|
423 |
||
424 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
425 |
||
426 |
iCalendarService->GetListL( KDelTestCalNameDeleteForGuidsAndTm.operator()(), getListfilter1 , calInstanceArray ); |
|
427 |
||
428 |
delete getListfilter1; |
|
429 |
||
430 |
if ( calInstanceArray.Count() == 0 ) |
|
431 |
{ |
|
432 |
iResult = KErrGeneral; |
|
433 |
||
434 |
calInstanceArray.ResetAndDestroy(); |
|
435 |
||
436 |
return iResult; |
|
437 |
} |
|
438 |
||
439 |
||
440 |
CCalendarFilter *filter = CCalendarFilter::NewL(); |
|
441 |
||
442 |
for( TInt x = 0; x < iArruids.Count(); ++x ) |
|
443 |
{ |
|
444 |
filter->AddGuidL( *(iArruids[x])->iGlobalUID ); |
|
445 |
} |
|
446 |
||
447 |
filter->SetStartTimeL( TTime(TDateTime(2005, EDecember, 30, 0, 0, 0, 0)) ); |
|
448 |
||
449 |
filter->SetEndTimeL( TTime(TDateTime(2100, EDecember, 30, 0, 0, 0, 0)) ); |
|
450 |
||
451 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForGuidsAndTm.operator()() , filter , NULL) ); |
|
452 |
||
453 |
delete filter; |
|
454 |
||
455 |
||
456 |
||
457 |
CCalendarFilter *getListfilter2 = CCalendarFilter::NewL(); |
|
458 |
||
459 |
RPointerArray<CCalInstance> calInstanceArray2; |
|
460 |
||
461 |
getListfilter2->SetFilterTypeL( KIncludeAll ); |
|
462 |
||
463 |
iCalendarService->GetListL( KDelTestCalNameDeleteForGuidsAndTm.operator()(), getListfilter2 , calInstanceArray2 ); |
|
464 |
||
465 |
if ( calInstanceArray2.Count() != 0 ) |
|
466 |
{ |
|
467 |
iResult = KErrGeneral; |
|
468 |
} |
|
469 |
calInstanceArray.ResetAndDestroy(); |
|
470 |
||
471 |
calInstanceArray2.ResetAndDestroy(); |
|
472 |
delete getListfilter2; |
|
473 |
} |
|
474 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuidsAndTm.operator()()); |
|
475 |
||
476 |
return iResult; |
|
477 |
} |
|
478 |
||
479 |
||
480 |
||
481 |
_LIT(KDelTestCalNameDeleteForTm ,"c:deleteforTmcal"); |
|
482 |
||
483 |
TInt CCalDelTestCases::TestDeleteTmRgL() |
|
484 |
{ |
|
485 |
//No need to set it but for the sake of semanitics set to sync value |
|
486 |
iTestCaseType = KDeleteSync; |
|
487 |
||
488 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForTm.operator()()); |
|
489 |
||
490 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForTm.operator()() ) ); |
|
491 |
||
492 |
if( iResult == KErrNone ) |
|
493 |
{ |
|
494 |
addSomeEntries( KDelTestCalNameDeleteForTm.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
495 |
||
496 |
||
497 |
||
498 |
CCalendarFilter *getListfilter1 = CCalendarFilter::NewL(); |
|
499 |
||
500 |
RPointerArray<CCalInstance> calInstanceArray; |
|
501 |
||
502 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
503 |
||
504 |
iCalendarService->GetListL( KDelTestCalNameDeleteForTm.operator()(), getListfilter1 , calInstanceArray ); |
|
505 |
||
506 |
delete getListfilter1; |
|
507 |
||
508 |
if ( calInstanceArray.Count() == 0 ) |
|
509 |
{ |
|
510 |
iResult = KErrGeneral; |
|
511 |
||
512 |
calInstanceArray.ResetAndDestroy(); |
|
513 |
||
514 |
return iResult; |
|
515 |
} |
|
516 |
||
517 |
||
518 |
||
519 |
CCalendarFilter *filter = CCalendarFilter::NewL(); |
|
520 |
||
521 |
filter->SetStartTimeL( TTime(TDateTime(2005, EDecember, 30, 0, 0, 0, 0)) ); |
|
522 |
||
523 |
filter->SetEndTimeL( TTime(TDateTime(2100, EDecember, 30, 0, 0, 0, 0)) ); |
|
524 |
||
525 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForTm.operator()() , filter , NULL) ); |
|
526 |
||
527 |
||
528 |
delete filter; |
|
529 |
||
530 |
||
531 |
CCalendarFilter *getListfilter2 = CCalendarFilter::NewL(); |
|
532 |
||
533 |
RPointerArray<CCalInstance> calInstanceArray2; |
|
534 |
||
535 |
getListfilter2->SetFilterTypeL( KIncludeAll ); |
|
536 |
||
537 |
iCalendarService->GetListL( KDelTestCalNameDeleteForTm.operator()(), getListfilter2 , calInstanceArray2 ); |
|
538 |
||
539 |
if ( calInstanceArray2.Count() != 0 ) |
|
540 |
{ |
|
541 |
iResult = KErrGeneral; |
|
542 |
} |
|
543 |
calInstanceArray.ResetAndDestroy(); |
|
544 |
||
545 |
calInstanceArray2.ResetAndDestroy(); |
|
546 |
delete getListfilter2; |
|
547 |
} |
|
548 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForTm.operator()()); |
|
549 |
||
550 |
return iResult; |
|
551 |
} |
|
552 |
||
553 |
||
554 |
||
555 |
_LIT(KDelTestCalNameDeleteForGuidsAsync ,"c:deleteforGuidscalasync"); |
|
556 |
||
557 |
_LIT(KDelTestCalNameDeleteForLuidsAsync ,"c:deleteforLuidscalasync"); |
|
558 |
||
559 |
_LIT(KDelTestCalNameDeleteForGuidsAndTmAsync ,"c:deleteforGuidsandtmcalasync"); |
|
560 |
||
561 |
_LIT(KDelTestCalNameDeleteForLuidsAndTmAsync ,"c:deleteforLuidsandtmcalasync"); |
|
562 |
||
563 |
_LIT(KDelTestCalNameDeleteAllAsync ,"c:deleteallcalasync"); |
|
564 |
||
565 |
_LIT(KDelTestCalNameDeleteForTmAsync ,"c:deleteforTmcalasync"); |
|
566 |
||
567 |
||
568 |
//Async things start here *************************************************** |
|
569 |
void CCalDelTestCases::TestDeleteAllEntriesAsyncL() |
|
570 |
{ |
|
571 |
iTestCaseType = KDeleteAllAsync; |
|
572 |
||
573 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteAllAsync.operator()()); |
|
574 |
||
575 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteAllAsync.operator()() ) ); |
|
576 |
||
577 |
if(iResult == KErrNone ) |
|
578 |
Start(); |
|
579 |
} |
|
580 |
||
581 |
||
582 |
void CCalDelTestCases::TestDeleteUsingGUidAsyncL() |
|
583 |
{ |
|
584 |
iTestCaseType = KDeleteUsingGuidsAsync; |
|
585 |
||
586 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuidsAsync.operator()()); |
|
587 |
||
588 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForGuidsAsync.operator()() ) ); |
|
589 |
||
590 |
if(iResult == KErrNone ) |
|
591 |
Start(); |
|
592 |
} |
|
593 |
||
594 |
||
595 |
//Asynchronous test cases so setting the iTestCaseType as it is to be handled in RunL |
|
596 |
void CCalDelTestCases::TestDeleteUsingLocalUidAsyncL() |
|
597 |
{ |
|
598 |
iTestCaseType = KDeleteUsingLuidsAsync; |
|
599 |
||
600 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuidsAsync.operator()()); |
|
601 |
||
602 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForLuidsAsync.operator()() ) ); |
|
603 |
||
604 |
if(iResult == KErrNone ) |
|
605 |
Start(); |
|
606 |
} |
|
607 |
||
608 |
||
609 |
void CCalDelTestCases::TestDeleteTmRgLocalUidAsyncL() |
|
610 |
{ |
|
611 |
iTestCaseType = KDeleteUsingLuidsAndTmRgAsync; |
|
612 |
||
613 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuidsAndTmAsync.operator()()); |
|
614 |
||
615 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForLuidsAndTmAsync.operator()() ) ); |
|
616 |
||
617 |
if(iResult == KErrNone ) |
|
618 |
Start(); |
|
619 |
} |
|
620 |
||
621 |
||
622 |
void CCalDelTestCases::TestDeleteTmRgGUidAsyncL() |
|
623 |
{ |
|
624 |
iTestCaseType = KDeleteUsingGuidsAndTmRgAsync; |
|
625 |
||
626 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuidsAndTmAsync.operator()()); |
|
627 |
||
628 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForGuidsAndTmAsync.operator()() ) ); |
|
629 |
||
630 |
if(iResult == KErrNone ) |
|
631 |
Start(); |
|
632 |
} |
|
633 |
||
634 |
||
635 |
||
636 |
void CCalDelTestCases::TestDeleteTmRgAsyncL() |
|
637 |
{ |
|
638 |
iTestCaseType = KDeleteUsingTmRgAsync; |
|
639 |
||
640 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForTmAsync.operator()()); |
|
641 |
||
642 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForTmAsync.operator()() ) ); |
|
643 |
||
644 |
if(iResult == KErrNone ) |
|
645 |
Start(); |
|
646 |
} |
|
647 |
||
648 |
TInt CCalDelTestCases::Result() |
|
649 |
{ |
|
650 |
return iResult; |
|
651 |
} |
|
652 |
||
653 |
void CCalDelTestCases::ConstructL() |
|
654 |
{ |
|
655 |
iCalendarService = CCalendarService::NewL(); |
|
656 |
||
657 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
658 |
} |
|
659 |
||
660 |
CCalDelTestCases::CCalDelTestCases( TInt& aResult) : CActive(EPriorityStandard), iResult(aResult) |
|
661 |
{ |
|
662 |
||
663 |
} |
|
664 |
||
665 |
//for the sake of ActiveObject |
|
666 |
void CCalDelTestCases::DoCancel() |
|
667 |
{ |
|
668 |
||
669 |
} |
|
670 |
||
671 |
||
672 |
void CCalDelTestCases::RunL() |
|
673 |
{ |
|
674 |
CCalendarFilter *getListfilter1 = CCalendarFilter::NewL(); |
|
675 |
||
676 |
RPointerArray<CCalInstance> calInstanceArray; |
|
677 |
||
678 |
CCalendarFilter *filter = CCalendarFilter::NewL(); |
|
679 |
||
680 |
||
681 |
switch( iTestCaseType ) |
|
682 |
{ |
|
683 |
case KDeleteAllAsync: |
|
684 |
||
685 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteAllAsync.operator()()); |
|
686 |
||
687 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteAllAsync.operator()() ) ); |
|
688 |
||
689 |
addSomeEntries( KDelTestCalNameDeleteAllAsync.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
690 |
||
691 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
692 |
||
693 |
iCalendarService->GetListL( KDelTestCalNameDeleteAllAsync.operator()(), getListfilter1 , calInstanceArray ); |
|
694 |
||
695 |
if ( calInstanceArray.Count() == 0 ) |
|
696 |
{ |
|
697 |
iResult = KErrGeneral; |
|
698 |
} |
|
699 |
||
700 |
filter->SetDeleteAll( ETrue ); |
|
701 |
||
702 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteAllAsync.operator()() , filter , this ) ); |
|
703 |
||
704 |
break; |
|
705 |
||
706 |
case KDeleteUsingGuidsAsync: |
|
707 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuidsAsync.operator()()); |
|
708 |
||
709 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForGuidsAsync.operator()() ) ); |
|
710 |
||
711 |
addSomeEntries( KDelTestCalNameDeleteForGuidsAsync.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
712 |
||
713 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
714 |
||
715 |
iCalendarService->GetListL( KDelTestCalNameDeleteForGuidsAsync.operator()(), getListfilter1 , calInstanceArray ); |
|
716 |
||
717 |
if ( calInstanceArray.Count() == 0 ) |
|
718 |
{ |
|
719 |
iResult = KErrGeneral; |
|
720 |
} |
|
721 |
||
722 |
for( TInt x = 0; x < iArruids.Count(); ++x ) |
|
723 |
{ |
|
724 |
filter->AddGuidL( *(iArruids[x])->iGlobalUID ); |
|
725 |
} |
|
726 |
||
727 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForGuidsAsync.operator()() , filter , this ) ); |
|
728 |
||
729 |
break; |
|
730 |
||
731 |
case KDeleteUsingLuidsAsync: |
|
732 |
||
733 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuidsAsync.operator()()); |
|
734 |
||
735 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForLuidsAsync.operator()() ) ); |
|
736 |
||
737 |
addSomeEntries( KDelTestCalNameDeleteForLuidsAsync.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
738 |
||
739 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
740 |
||
741 |
iCalendarService->GetListL( KDelTestCalNameDeleteForLuidsAsync.operator()(), getListfilter1 , calInstanceArray ); |
|
742 |
||
743 |
if ( calInstanceArray.Count() == 0 ) |
|
744 |
{ |
|
745 |
iResult = KErrGeneral; |
|
746 |
} |
|
747 |
||
748 |
for( TInt x = 0; x < iArruids.Count(); ++x ) |
|
749 |
{ |
|
750 |
filter->AddLocalUid( (iArruids[x])->iLocalUID ); |
|
751 |
} |
|
752 |
||
753 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForLuidsAsync.operator()() , filter , this ) ); |
|
754 |
||
755 |
break; |
|
756 |
||
757 |
case KDeleteUsingGuidsAndTmRgAsync: |
|
758 |
||
759 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuidsAndTmAsync.operator()()); |
|
760 |
||
761 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForGuidsAndTmAsync.operator()() ) ); |
|
762 |
||
763 |
addSomeEntries( KDelTestCalNameDeleteForGuidsAndTmAsync.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
764 |
||
765 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
766 |
||
767 |
iCalendarService->GetListL( KDelTestCalNameDeleteForGuidsAndTmAsync.operator()(), getListfilter1 , calInstanceArray ); |
|
768 |
||
769 |
if ( calInstanceArray.Count() == 0 ) |
|
770 |
{ |
|
771 |
iResult = KErrGeneral; |
|
772 |
} |
|
773 |
||
774 |
for( TInt x = 0; x < iArruids.Count(); ++x ) |
|
775 |
{ |
|
776 |
filter->AddGuidL( *(iArruids[x])->iGlobalUID ); |
|
777 |
} |
|
778 |
||
779 |
filter->SetStartTimeL( TTime(TDateTime(2005, EDecember, 30, 0, 0, 0, 0)) ); |
|
780 |
||
781 |
filter->SetEndTimeL( TTime(TDateTime(2100, EDecember, 30, 0, 0, 0, 0)) ); |
|
782 |
||
783 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForGuidsAndTmAsync.operator()() , filter , this ) ); |
|
784 |
||
785 |
break; |
|
786 |
||
787 |
case KDeleteUsingLuidsAndTmRgAsync: |
|
788 |
||
789 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuidsAndTmAsync.operator()()); |
|
790 |
||
791 |
TRAP( iResult , iCalendarService->AddL( KDelTestCalNameDeleteForLuidsAndTmAsync.operator()() ) ); |
|
792 |
||
793 |
addSomeEntries( KDelTestCalNameDeleteForLuidsAndTmAsync.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
794 |
||
795 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
796 |
||
797 |
iCalendarService->GetListL( KDelTestCalNameDeleteForLuidsAndTmAsync.operator()(), getListfilter1 , calInstanceArray ); |
|
798 |
||
799 |
if ( calInstanceArray.Count() == 0 ) |
|
800 |
{ |
|
801 |
iResult = KErrGeneral; |
|
802 |
} |
|
803 |
||
804 |
for( TInt x = 0; x < iArruids.Count(); ++x ) |
|
805 |
{ |
|
806 |
filter->AddLocalUid( (iArruids[x])->iLocalUID ); |
|
807 |
} |
|
808 |
||
809 |
filter->SetStartTimeL( TTime(TDateTime(2005, EDecember, 30, 0, 0, 0, 0)) ); |
|
810 |
||
811 |
filter->SetEndTimeL( TTime(TDateTime(2100, EDecember, 30, 0, 0, 0, 0)) ); |
|
812 |
||
813 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForLuidsAndTmAsync.operator()() , filter , this ) ); |
|
814 |
||
815 |
break; |
|
816 |
||
817 |
case KDeleteUsingTmRgAsync: |
|
818 |
||
819 |
addSomeEntries( KDelTestCalNameDeleteForTmAsync.operator()() );//adds the entries and fills up iArruids with UIDSets |
|
820 |
||
821 |
getListfilter1->SetFilterTypeL( KIncludeAll ); |
|
822 |
||
823 |
iCalendarService->GetListL( KDelTestCalNameDeleteForTmAsync.operator()(), getListfilter1 , calInstanceArray ); |
|
824 |
||
825 |
if ( calInstanceArray.Count() == 0 ) |
|
826 |
{ |
|
827 |
iResult = KErrGeneral; |
|
828 |
} |
|
829 |
||
830 |
filter->SetStartTimeL( TTime(TDateTime(2005, EDecember, 30, 0, 0, 0, 0)) ); |
|
831 |
||
832 |
filter->SetEndTimeL( TTime(TDateTime(2100, EDecember, 30, 0, 0, 0, 0)) ); |
|
833 |
||
834 |
TRAP( iResult, iCalendarService->DeleteL( KDelTestCalNameDeleteForTmAsync.operator()() , filter , this ) ); |
|
835 |
||
836 |
break; |
|
837 |
} |
|
838 |
||
839 |
delete getListfilter1; |
|
840 |
delete filter; |
|
841 |
Final: |
|
842 |
calInstanceArray.ResetAndDestroy(); |
|
843 |
} |
|
844 |
||
845 |
void CCalDelTestCases::Start() |
|
846 |
{ |
|
847 |
CActiveScheduler::Add(this); |
|
848 |
||
849 |
SetActive(); |
|
850 |
||
851 |
TRequestStatus* temp = &iStatus; |
|
852 |
||
853 |
User::RequestComplete(temp, KErrNone); |
|
854 |
||
855 |
iWaitSchedular->Start(); |
|
856 |
} |
|
857 |
||
858 |
||
859 |
void CCalDelTestCases::NotifyResultL(TInt aErrCode, TAny* aResult) |
|
860 |
{ |
|
861 |
//******************* set iResult **************************** |
|
862 |
iResult = aErrCode; |
|
863 |
//******************* set iResult **************************** |
|
864 |
||
865 |
//write the iResult to the corresponding file basing on the iTestCaseType |
|
866 |
||
867 |
CCalendarFilter *getListfilter2 = CCalendarFilter::NewL(); |
|
868 |
||
869 |
RPointerArray<CCalInstance> calInstanceArray2; |
|
870 |
||
871 |
getListfilter2->SetFilterTypeL( KIncludeAll ); |
|
872 |
||
873 |
switch( iTestCaseType ) |
|
874 |
{ |
|
875 |
case KDeleteAllAsync: |
|
876 |
iCalendarService->GetListL( KDelTestCalNameDeleteAllAsync.operator()(), getListfilter2 , calInstanceArray2 ); |
|
877 |
||
878 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteAllAsync.operator()()); |
|
879 |
||
880 |
break; |
|
881 |
||
882 |
case KDeleteUsingGuidsAsync: |
|
883 |
iCalendarService->GetListL( KDelTestCalNameDeleteForGuidsAsync.operator()(), getListfilter2 , calInstanceArray2 ); |
|
884 |
||
885 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuidsAsync.operator()()); |
|
886 |
||
887 |
break; |
|
888 |
||
889 |
case KDeleteUsingLuidsAsync: |
|
890 |
iCalendarService->GetListL( KDelTestCalNameDeleteForLuidsAsync.operator()(), getListfilter2 , calInstanceArray2 ); |
|
891 |
||
892 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuidsAsync.operator()()); |
|
893 |
||
894 |
break; |
|
895 |
||
896 |
case KDeleteUsingGuidsAndTmRgAsync: |
|
897 |
iCalendarService->GetListL( KDelTestCalNameDeleteForGuidsAndTmAsync.operator()(), getListfilter2 , calInstanceArray2 ); |
|
898 |
||
899 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForGuidsAndTmAsync.operator()()); |
|
900 |
||
901 |
break; |
|
902 |
||
903 |
case KDeleteUsingLuidsAndTmRgAsync: |
|
904 |
iCalendarService->GetListL( KDelTestCalNameDeleteForLuidsAndTmAsync.operator()(), getListfilter2 , calInstanceArray2 ); |
|
905 |
||
906 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForLuidsAndTmAsync.operator()()); |
|
907 |
||
908 |
break; |
|
909 |
||
910 |
case KDeleteUsingTmRgAsync: |
|
911 |
iCalendarService->GetListL( KDelTestCalNameDeleteForTmAsync.operator()(), getListfilter2 , calInstanceArray2 ); |
|
912 |
||
913 |
RemoveCalendarFile(iCalendarService, KDelTestCalNameDeleteForTmAsync.operator()()); |
|
914 |
||
915 |
break; |
|
916 |
} |
|
917 |
||
918 |
if ( calInstanceArray2.Count() != 0 ) |
|
919 |
{ |
|
920 |
iResult = KErrGeneral; |
|
921 |
} |
|
922 |
||
923 |
calInstanceArray2.ResetAndDestroy(); |
|
924 |
||
925 |
delete getListfilter2; |
|
926 |
||
927 |
||
928 |
iWaitSchedular->AsyncStop(); |
|
929 |
} |
|
930 |
||
931 |
||
932 |
void CCalDelTestCases::addSomeEntries( const TDesC& aName) |
|
933 |
{ |
|
934 |
TUIDSet* uids = NULL; |
|
935 |
||
936 |
if(AddAppointment(iCalendarService, aName, uids) == KErrNone && uids) |
|
937 |
{ |
|
938 |
iArruids.Append(uids); |
|
939 |
uids = NULL; |
|
940 |
} |
|
941 |
||
942 |
if(AddEvent(iCalendarService, aName, uids) == KErrNone && uids) |
|
943 |
{ |
|
944 |
iArruids.Append(uids); |
|
945 |
uids = NULL; |
|
946 |
} |
|
947 |
||
948 |
if(AddReminder(iCalendarService, aName, uids) == KErrNone && uids) |
|
949 |
{ |
|
950 |
iArruids.Append(uids); |
|
951 |
uids = NULL; |
|
952 |
} |
|
953 |
||
954 |
/* if(AddAnny(iCalendarService, aName, uids) == KErrNone && uids) |
|
955 |
{ |
|
956 |
iArruids.Append(uids); |
|
957 |
uids = NULL; |
|
958 |
}*/ |
|
959 |
||
960 |
if(AddToDo(iCalendarService, aName, uids) == KErrNone && uids) |
|
961 |
{ |
|
962 |
iArruids.Append(uids); |
|
963 |
uids = NULL; |
|
964 |
} |
|
965 |
} |
|
966 |
/* |
|
967 |
EAppt An appointment, which has a start time and end time. |
|
968 |
||
969 |
ETodo A to-do, which can have a start time and end time (the end time is the due date), or can be undated. |
|
970 |
||
971 |
EEvent An event, which has a start time and end time. |
|
972 |
||
973 |
EReminder A reminder, which has a start time only. |
|
974 |
||
975 |
EAnniv An anniversary, which has a start time and end time. |
|
976 |
*/ |
|
977 |
||
978 |
||
979 |
void CCalDelTestCases::ExportAllToFileL( const TDesC16 &aCalFileName, const TDesC16 &aFileName) |
|
980 |
{ |
|
981 |
||
982 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL(); |
|
983 |
||
984 |
HBufC8* buffer; |
|
985 |
||
986 |
TRAPD( err ,iCalendarService->ExportL( aCalFileName , KFormatVCal.operator()() , expParams ,buffer ) ); |
|
987 |
||
988 |
delete buffer; |
|
989 |
} |