|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "caltestlib.h" |
|
17 #include <calentry.h> |
|
18 #include <calentryview.h> |
|
19 #include <calalarm.h> |
|
20 #include <calattachment.h> |
|
21 #include <calattachmentmanager.h> |
|
22 #include <calcategory.h> |
|
23 #include <calcategorymanager.h> |
|
24 #include <calsession.h> |
|
25 #include <calinstance.h> |
|
26 #include <caliterator.h> |
|
27 #include <calinstanceview.h> |
|
28 #include <calrrule.h> |
|
29 #include <e32test.h> |
|
30 #include <s32file.h> |
|
31 |
|
32 // Uncomment this line to test manually |
|
33 // #define TEST_MANUALLY |
|
34 |
|
35 static RTest test(_L("tcal_removable_media")); |
|
36 _LIT(KRemovableMediaTestFile, "removable_media"); |
|
37 |
|
38 class CCalRemovableMediaTest : public CBase, public MCalProgressCallBack |
|
39 { |
|
40 public: |
|
41 static CCalRemovableMediaTest* NewLC(); |
|
42 ~CCalRemovableMediaTest(); |
|
43 |
|
44 void DoTestsL(); |
|
45 |
|
46 // from MCalProgressCallBack |
|
47 void Progress(TInt aPercentageCompleted); |
|
48 void Completed(TInt aError); |
|
49 TBool NotifyProgress(); |
|
50 |
|
51 private: |
|
52 CCalRemovableMediaTest(); |
|
53 void ConstructL(); |
|
54 |
|
55 void NextStepL(TInt aStep); |
|
56 |
|
57 void InitialiseFileL(); |
|
58 void StoreEntriesL(TBool aTestStoreL); |
|
59 void UpdateEntriesL(); |
|
60 void DeleteEntriesByUidL(); |
|
61 void DeleteEntriesByLocalUidL(); |
|
62 void DeleteEntriesAsynchronouslyByTimeL(); |
|
63 void DeleteInstanceL(); |
|
64 void AddCategoryL(TBool aTestAdd); |
|
65 void DeleteCategoryL(); |
|
66 |
|
67 void GetNumEntriesL(); |
|
68 void CheckUpdateL(); |
|
69 void CheckDeleteAsynchronouslyByTime(); |
|
70 void CheckNumEntriesL(); |
|
71 void CheckNumAttachmentsL(); |
|
72 void TestAfterMediaRemovedL(); |
|
73 |
|
74 void CheckNumCategoriesL(); |
|
75 void CheckDeleteCategory(); |
|
76 void CheckDeleteInstanceL(); |
|
77 void AddSecondCategoryL(); |
|
78 |
|
79 void AddAttachmentL(TBool aTesting); |
|
80 void UpdateAttachmentL(); |
|
81 void DeleteAttachmentL(); |
|
82 void CheckDeleteAttachmentL(); |
|
83 void ChangeAttachmentDriveL(); |
|
84 |
|
85 TInt AttachmentFileCountL() const; |
|
86 |
|
87 void SetupTestLibL(); |
|
88 void ClearTestLib(); |
|
89 |
|
90 void FindEntriesWithTextL(RPointerArray<CCalInstance>& aInstances, const TDesC& aText); |
|
91 void RemoveMedia(); |
|
92 void ReplaceMedia(); |
|
93 TBool MediaRemoved() const; |
|
94 |
|
95 private: |
|
96 enum |
|
97 { |
|
98 ETestStore, |
|
99 ECheckStore, |
|
100 ETestUpdate, |
|
101 ECheckUpdate, |
|
102 ETestDeleteByTime, |
|
103 ECheckDeleteByTime, |
|
104 ETestDeleteByLocalUid, |
|
105 ECheckDeleteByLocalUid, |
|
106 ETestDeleteByUid, |
|
107 ECheckDeleteByUid, |
|
108 ETestAddCategory, |
|
109 ECheckAddCategory, |
|
110 ETestAddSecondCategory, |
|
111 ECheckAddSecondCategory, |
|
112 ETestDeleteCategory, |
|
113 ECheckDeleteCategory, |
|
114 ETestDeleteInstance, |
|
115 ECheckDeleteInstance, |
|
116 ETestAddAttachment, |
|
117 ECheckAddAttachment, |
|
118 ETestUpdateAttachment, |
|
119 ECheckUpdateAttachment, |
|
120 ETestDeleteAttachment, |
|
121 ECheckDeleteAttachment, |
|
122 EChangeAttachmentDrive, |
|
123 ETestAfterMediaRemoved, |
|
124 EFinishedTests, |
|
125 |
|
126 // edit this to change where the test starts |
|
127 EFirstStep = ETestStore, |
|
128 }; |
|
129 |
|
130 CCalTestLibrary* iTestLib; |
|
131 CCalCategoryManager* iCatMan; |
|
132 CCalAttachmentManager* iAttMan; |
|
133 TBuf<32> iCalendarName; |
|
134 TInt iError; |
|
135 TInt iNumEntries; |
|
136 TInt iNumAttachments; |
|
137 TBool iMediaRemoved; |
|
138 }; |
|
139 |
|
140 void CCalRemovableMediaTest::Progress(TInt ) |
|
141 { |
|
142 } |
|
143 |
|
144 void CCalRemovableMediaTest::Completed(TInt aError) |
|
145 { |
|
146 iError = aError; |
|
147 test.Printf(_L("Completed with error %d \n"), aError); |
|
148 CActiveScheduler::Stop(); |
|
149 } |
|
150 |
|
151 TBool CCalRemovableMediaTest::NotifyProgress() |
|
152 { |
|
153 return EFalse; |
|
154 } |
|
155 |
|
156 void CCalRemovableMediaTest::RemoveMedia() |
|
157 { |
|
158 #ifdef TEST_MANUALLY |
|
159 test.Printf(_L("Remove the media and press any key.\n")); test.Getch(); |
|
160 #else |
|
161 iTestLib->FileSession().SetErrorCondition(KErrNotReady, 0); |
|
162 User::After(500000); |
|
163 #endif |
|
164 iMediaRemoved = ETrue; |
|
165 } |
|
166 |
|
167 void CCalRemovableMediaTest::ReplaceMedia() |
|
168 { |
|
169 #ifdef TEST_MANUALLY |
|
170 test.Printf(_L("Reinsert the media and press any key...\n")); test.Getch(); |
|
171 #else |
|
172 User::After(500000); |
|
173 #endif |
|
174 iMediaRemoved = EFalse; |
|
175 } |
|
176 |
|
177 TBool CCalRemovableMediaTest::MediaRemoved() const |
|
178 { |
|
179 return iMediaRemoved; |
|
180 } |
|
181 |
|
182 void CCalRemovableMediaTest::NextStepL(TInt aStep) |
|
183 { |
|
184 if (MediaRemoved()) |
|
185 { |
|
186 ReplaceMedia(); |
|
187 } |
|
188 |
|
189 TRAPD(err, SetupTestLibL()); |
|
190 if (err != KErrNone) |
|
191 { |
|
192 test.Printf(_L("Failed to re-open calendar file, error %d\n"), err); |
|
193 test(0); |
|
194 } |
|
195 |
|
196 switch (aStep) |
|
197 { |
|
198 case ETestStore: |
|
199 StoreEntriesL(ETrue); |
|
200 break; |
|
201 case ECheckStore: |
|
202 CheckNumEntriesL(); |
|
203 break; |
|
204 case ETestUpdate: |
|
205 UpdateEntriesL(); |
|
206 break; |
|
207 case ECheckUpdate: |
|
208 CheckUpdateL(); |
|
209 CheckNumEntriesL(); |
|
210 break; |
|
211 case ETestDeleteByTime: |
|
212 DeleteEntriesAsynchronouslyByTimeL(); |
|
213 break; |
|
214 case ECheckDeleteByTime: |
|
215 CheckDeleteAsynchronouslyByTime(); |
|
216 CheckNumEntriesL(); |
|
217 break; |
|
218 case ETestDeleteByLocalUid: |
|
219 DeleteEntriesByLocalUidL(); |
|
220 break; |
|
221 case ECheckDeleteByLocalUid: |
|
222 CheckNumEntriesL(); |
|
223 break; |
|
224 case ETestDeleteByUid: |
|
225 DeleteEntriesByUidL(); |
|
226 break; |
|
227 case ECheckDeleteByUid: |
|
228 CheckNumEntriesL(); |
|
229 break; |
|
230 case ETestAddCategory: |
|
231 AddCategoryL(ETrue); |
|
232 break; |
|
233 case ECheckAddCategory: |
|
234 CheckNumCategoriesL(); |
|
235 break; |
|
236 case ETestAddSecondCategory: |
|
237 AddSecondCategoryL(); |
|
238 break; |
|
239 case ECheckAddSecondCategory: |
|
240 CheckNumCategoriesL(); |
|
241 break; |
|
242 case ETestDeleteCategory: |
|
243 DeleteCategoryL(); |
|
244 break; |
|
245 case ECheckDeleteCategory: |
|
246 CheckDeleteCategory(); |
|
247 CheckNumCategoriesL(); |
|
248 break; |
|
249 case ETestDeleteInstance: |
|
250 DeleteInstanceL(); |
|
251 break; |
|
252 case ECheckDeleteInstance: |
|
253 CheckDeleteInstanceL(); |
|
254 break; |
|
255 case ETestAddAttachment: |
|
256 AddAttachmentL(ETrue); |
|
257 break; |
|
258 case ECheckAddAttachment: |
|
259 CheckNumAttachmentsL(); |
|
260 break; |
|
261 case ETestUpdateAttachment: |
|
262 UpdateAttachmentL(); |
|
263 break; |
|
264 case ECheckUpdateAttachment: |
|
265 CheckNumEntriesL(); |
|
266 CheckNumAttachmentsL(); |
|
267 break; |
|
268 case ETestDeleteAttachment: |
|
269 DeleteAttachmentL(); |
|
270 break; |
|
271 case ECheckDeleteAttachment: |
|
272 CheckDeleteAttachmentL(); |
|
273 break; |
|
274 case EChangeAttachmentDrive: |
|
275 ChangeAttachmentDriveL(); |
|
276 break; |
|
277 case ETestAfterMediaRemoved: |
|
278 TestAfterMediaRemovedL(); |
|
279 break; |
|
280 } |
|
281 |
|
282 ClearTestLib(); |
|
283 } |
|
284 |
|
285 void CCalRemovableMediaTest::InitialiseFileL() |
|
286 { |
|
287 // ensure there are at least 10 entries in file |
|
288 GetNumEntriesL(); |
|
289 if (iNumEntries < 10) |
|
290 { |
|
291 StoreEntriesL(EFalse); |
|
292 GetNumEntriesL(); |
|
293 } |
|
294 } |
|
295 |
|
296 void CCalRemovableMediaTest::StoreEntriesL(TBool aTestStoreL) |
|
297 { |
|
298 if (aTestStoreL) |
|
299 { |
|
300 test.Next(_L("Test StoreL")); |
|
301 } |
|
302 |
|
303 const TInt KNumEntries = 10; |
|
304 test.Printf(_L("Creating %d non-repeating entries \n"), KNumEntries); |
|
305 TTime time; |
|
306 time.HomeTime(); |
|
307 |
|
308 GetNumEntriesL(); |
|
309 test.Printf(_L("Number of entries before add is %d\n"), iNumEntries); |
|
310 |
|
311 RPointerArray<CCalEntry> entryArray; |
|
312 CleanupResetAndDestroyPushL(entryArray); |
|
313 |
|
314 for (TInt i = 0; i < KNumEntries; ++i) |
|
315 { |
|
316 time -= TTimeIntervalDays(1); |
|
317 TBuf8<64> buf; |
|
318 iTestLib->RandomText8(buf); |
|
319 CCalEntry::TType type = CCalEntry::EAppt; |
|
320 if (i % 2 == 0) |
|
321 { |
|
322 type = CCalEntry::ETodo; |
|
323 } |
|
324 HBufC8* bufAlloc = buf.AllocLC(); |
|
325 CCalEntry* entry = iTestLib->CreateCalEntryL(type, bufAlloc); |
|
326 CleanupStack::Pop(); // buf.AllocLC() |
|
327 CleanupStack::PushL(entry); |
|
328 iTestLib->SetEntryStartAndEndTimeL(entry, time, time); |
|
329 entryArray.AppendL(entry); |
|
330 CleanupStack::Pop(entry); |
|
331 } |
|
332 |
|
333 if (aTestStoreL) |
|
334 { |
|
335 RemoveMedia(); |
|
336 } |
|
337 |
|
338 TInt success(0); |
|
339 test.Printf(_L("Adding entries...")); |
|
340 TRAPD(err, iTestLib->SynCGetEntryViewL().StoreL(entryArray, success)); |
|
341 test.Printf(_L("StoreL gave error %d, num successfully added=%d\n"), err, success); |
|
342 |
|
343 if (aTestStoreL) |
|
344 { |
|
345 test(err == KErrNotReady); |
|
346 test(success == 0); |
|
347 } |
|
348 else |
|
349 { |
|
350 User::LeaveIfError(err); |
|
351 test(success == KNumEntries); |
|
352 } |
|
353 CleanupStack::PopAndDestroy(&entryArray); |
|
354 } |
|
355 |
|
356 void CCalRemovableMediaTest::FindEntriesWithTextL(RPointerArray<CCalInstance>& aInstances, const TDesC& aText) |
|
357 { |
|
358 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll | CalCommon::EIncludeRptsNextInstanceOnly; |
|
359 |
|
360 TCalTime minTime; |
|
361 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
362 TCalTime maxTime; |
|
363 maxTime.SetTimeUtcL(TCalTime::MaxTime()); |
|
364 CalCommon::TCalTimeRange timeRange(minTime, maxTime); |
|
365 |
|
366 CCalInstanceView::TCalSearchParams searchParams(aText, CalCommon::EFoldedTextSearch); |
|
367 |
|
368 iTestLib->SynCGetInstanceViewL().FindInstanceL(aInstances, filter, timeRange, searchParams); |
|
369 } |
|
370 |
|
371 void CCalRemovableMediaTest::UpdateEntriesL() |
|
372 { |
|
373 test.Next(_L("Test UpdateL\n")); |
|
374 InitialiseFileL(); |
|
375 |
|
376 test.Printf(_L("Updating %d entries \n"), iNumEntries); |
|
377 |
|
378 RPointerArray<CCalInstance> instArray; |
|
379 CleanupResetAndDestroyPushL(instArray); |
|
380 |
|
381 FindEntriesWithTextL(instArray, KNullDesC); |
|
382 |
|
383 RPointerArray<CCalEntry> entryArray; |
|
384 CleanupClosePushL(entryArray); |
|
385 for (TInt i = 0; i < instArray.Count(); ++i) |
|
386 { |
|
387 CCalEntry* entry = &instArray[i]->Entry(); |
|
388 entry->SetSummaryL(_L("updated summary")); |
|
389 entryArray.AppendL(entry); |
|
390 } |
|
391 |
|
392 RemoveMedia(); |
|
393 |
|
394 TInt success(0); |
|
395 test.Printf(_L("Updating entries...")); |
|
396 TRAPD(err, iTestLib->SynCGetEntryViewL().UpdateL(entryArray, success)); |
|
397 test.Printf(_L("UpdateL gave error %d, num successfully updated=%d\n"), err, success); |
|
398 |
|
399 test(err == KErrNotReady); |
|
400 test(success == 0); |
|
401 |
|
402 CleanupStack::PopAndDestroy(&entryArray); // Close() |
|
403 CleanupStack::PopAndDestroy(&instArray); // ResetAndDestroy() |
|
404 } |
|
405 |
|
406 void CCalRemovableMediaTest::CheckUpdateL() |
|
407 { |
|
408 RPointerArray<CCalInstance> instArray; |
|
409 CleanupResetAndDestroyPushL(instArray); |
|
410 |
|
411 // check that no entries were updated |
|
412 test.Printf(_L("Checking no entries were updated...")); |
|
413 FindEntriesWithTextL(instArray, _L("updated summary")); |
|
414 test.Printf(_L("%d entries were updated\n"), instArray.Count()); |
|
415 test(instArray.Count() == 0); |
|
416 |
|
417 CleanupStack::PopAndDestroy(&instArray); // ResetAndDestroy |
|
418 } |
|
419 |
|
420 void CCalRemovableMediaTest::GetNumEntriesL() |
|
421 { |
|
422 RArray<TCalLocalUid> localUids; |
|
423 CleanupClosePushL(localUids); |
|
424 |
|
425 TCalTime minTime; |
|
426 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
427 iTestLib->SynCGetEntryViewL().GetIdsModifiedSinceDateL(minTime, localUids); |
|
428 iNumEntries = localUids.Count(); |
|
429 CleanupStack::PopAndDestroy(&localUids); // Close() |
|
430 |
|
431 iNumAttachments = AttachmentFileCountL(); |
|
432 } |
|
433 |
|
434 TInt CCalRemovableMediaTest::AttachmentFileCountL() const |
|
435 { |
|
436 CCalAttachmentIterator* attachments = iAttMan->FetchAttachmentsL(CCalAttachmentManager::ESortBySizeLargestFirst); |
|
437 TInt count = attachments->Count(); |
|
438 delete attachments; |
|
439 return count; |
|
440 } |
|
441 |
|
442 void CCalRemovableMediaTest::CheckNumEntriesL() |
|
443 { |
|
444 RArray<TCalLocalUid> localUids; |
|
445 CleanupClosePushL(localUids); |
|
446 |
|
447 TCalTime minTime; |
|
448 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
449 test.Printf(_L("Checking number of entries: expected=%d..."), iNumEntries); |
|
450 iTestLib->SynCGetEntryViewL().GetIdsModifiedSinceDateL(minTime, localUids); |
|
451 test.Printf(_L("Number of entries found=%d\n"), localUids.Count()); |
|
452 test(iNumEntries == localUids.Count()); |
|
453 CleanupStack::PopAndDestroy(&localUids); // Close() |
|
454 } |
|
455 |
|
456 void CCalRemovableMediaTest::CheckNumAttachmentsL() |
|
457 { |
|
458 if (iNumAttachments > 0) |
|
459 { |
|
460 test.Printf(_L("Checking number of attachments: expected=%d...Number of entries found=%d\n"), iNumAttachments, AttachmentFileCountL()); |
|
461 test(iNumAttachments == AttachmentFileCountL()); |
|
462 } |
|
463 } |
|
464 |
|
465 void CCalRemovableMediaTest::DeleteEntriesByLocalUidL() |
|
466 { |
|
467 test.Next(_L("Test DeleteL by local UID\n")); |
|
468 InitialiseFileL(); |
|
469 |
|
470 test.Printf(_L("Deleting all entries by local uid \n")); |
|
471 |
|
472 test.Printf(_L("Number of entries before delete is %d\n"), iNumEntries); |
|
473 RArray<TCalLocalUid> localUids; |
|
474 CleanupClosePushL(localUids); |
|
475 |
|
476 TCalTime minTime; |
|
477 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
478 iTestLib->SynCGetEntryViewL().GetIdsModifiedSinceDateL(minTime, localUids); |
|
479 test(localUids.Count() == iNumEntries); // check all local uids found |
|
480 |
|
481 RemoveMedia(); |
|
482 |
|
483 TInt success = 0; |
|
484 test.Printf(_L("Doing delete...")); |
|
485 TRAPD(err, iTestLib->SynCGetEntryViewL().DeleteL(localUids, success)); |
|
486 test.Printf(_L("DeleteL gave err %d, num successfully deleted=%d\n"), err, success); |
|
487 test(err == KErrNotReady); |
|
488 test(success == 0); |
|
489 |
|
490 CleanupStack::PopAndDestroy(&localUids); // Close() |
|
491 } |
|
492 void CCalRemovableMediaTest::DeleteEntriesByUidL() |
|
493 { |
|
494 test.Next(_L("Test DeleteL by GUID\n")); |
|
495 InitialiseFileL(); |
|
496 |
|
497 RPointerArray<CCalEntry> entries; |
|
498 CleanupResetAndDestroyPushL(entries); |
|
499 |
|
500 CDesC8Array* uidArray = new (ELeave) CDesC8ArraySeg(8); |
|
501 CleanupStack::PushL(uidArray); |
|
502 |
|
503 CCalIter& iter = iTestLib->GetIterL(); |
|
504 |
|
505 TPtrC8 uid = iter.FirstL(); |
|
506 while (uid.Length() > 0) |
|
507 { |
|
508 uidArray->AppendL(uid); |
|
509 uid.Set(iter.NextL()); |
|
510 } |
|
511 |
|
512 test(iNumEntries == uidArray->Count()); |
|
513 test.Printf(_L("Found %d entries before delete\n"), iNumEntries); |
|
514 |
|
515 RemoveMedia(); |
|
516 |
|
517 test.Printf(_L("Deleting entries...")); |
|
518 TRAPD(err, iTestLib->SynCGetEntryViewL().DeleteL(*uidArray)); |
|
519 test(err == KErrNotReady); |
|
520 test.Printf(_L("DeleteL gave error %d...\n"), err); |
|
521 |
|
522 CleanupStack::PopAndDestroy(uidArray); |
|
523 CleanupStack::PopAndDestroy(&entries); |
|
524 } |
|
525 |
|
526 void CCalRemovableMediaTest::DeleteEntriesAsynchronouslyByTimeL() |
|
527 { |
|
528 test.Next(_L("Test DeleteL by time\n")); |
|
529 InitialiseFileL(); |
|
530 |
|
531 TCalTime minTime; |
|
532 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
533 TCalTime maxTime; |
|
534 maxTime.SetTimeUtcL(TCalTime::MaxTime()); |
|
535 CalCommon::TCalTimeRange timeRange(minTime, maxTime); |
|
536 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
537 |
|
538 RemoveMedia(); |
|
539 |
|
540 test.Printf(_L("Deleting entries...\n")); |
|
541 TRAPD(err, iTestLib->SynCGetEntryViewL().DeleteL(timeRange, filter, *this)); |
|
542 test.Printf(_L("DeleteL gave error %d...\n"), err); |
|
543 test(err == KErrNone); |
|
544 |
|
545 CActiveScheduler::Start(); |
|
546 } |
|
547 |
|
548 void CCalRemovableMediaTest::CheckDeleteAsynchronouslyByTime() |
|
549 { |
|
550 test(iError == KErrNotReady); |
|
551 } |
|
552 |
|
553 void CCalRemovableMediaTest::AddCategoryL(TBool aTestAdd) |
|
554 { |
|
555 if (aTestAdd) |
|
556 { |
|
557 test.Next(_L("Test AddCategoryL\n")); |
|
558 } |
|
559 |
|
560 iNumEntries = iCatMan->CategoryCountL(); |
|
561 |
|
562 test.Printf(_L("Adding a category...\n")); |
|
563 TBuf<24> categoryName; |
|
564 TTime now; |
|
565 now.UniversalTime(); |
|
566 categoryName.AppendNum(now.Int64()); |
|
567 CCalCategory* category = CCalCategory::NewL(categoryName); |
|
568 CleanupStack::PushL(category); |
|
569 |
|
570 if (aTestAdd) |
|
571 { |
|
572 RemoveMedia(); |
|
573 } |
|
574 |
|
575 TRAPD(err, iCatMan->AddCategoryL(*category)); |
|
576 CleanupStack::PopAndDestroy(category); |
|
577 if (aTestAdd) |
|
578 { |
|
579 test.Printf(_L("Adding category gave error %d...\n"), err); |
|
580 test(err == KErrNotReady); |
|
581 } |
|
582 else |
|
583 { |
|
584 test(err == KErrNone); |
|
585 } |
|
586 } |
|
587 |
|
588 void CCalRemovableMediaTest::AddSecondCategoryL() |
|
589 { |
|
590 test.Next(_L("Test AddSecondCategoryL\n")); |
|
591 AddCategoryL(EFalse); |
|
592 |
|
593 iNumEntries = iCatMan->CategoryCountL(); |
|
594 |
|
595 test.Printf(_L("Adding a second category...\n")); |
|
596 TBuf<24> categoryName; |
|
597 TTime now; |
|
598 now.UniversalTime(); |
|
599 categoryName.AppendNum(now.Int64()+1); |
|
600 CCalCategory* category = CCalCategory::NewL(categoryName); |
|
601 CleanupStack::PushL(category); |
|
602 |
|
603 RemoveMedia(); |
|
604 |
|
605 TRAPD(err, iCatMan->AddCategoryL(*category)); |
|
606 CleanupStack::PopAndDestroy(category); |
|
607 test.Printf(_L("Adding second category gave error %d...\n"), err); |
|
608 test(err == KErrNotReady); |
|
609 } |
|
610 |
|
611 void CCalRemovableMediaTest::CheckNumCategoriesL() |
|
612 { |
|
613 TInt newCategoryCount = iCatMan->CategoryCountL(); |
|
614 test.Printf(_L("Number of categories expected=%d, number found=%d\n"), iNumEntries, newCategoryCount); |
|
615 test(newCategoryCount == iNumEntries); |
|
616 } |
|
617 |
|
618 void CCalRemovableMediaTest::DeleteCategoryL() |
|
619 { |
|
620 test.Next(_L("Test DeleteCategoryL\n")); |
|
621 AddCategoryL(EFalse); |
|
622 |
|
623 iNumEntries = iCatMan->CategoryCountL(); |
|
624 test(iCatMan->CategoryCountL() > 12); // 12 is the number of default categories, this checks at least one has been added |
|
625 |
|
626 test.Printf(_L("Deleting category...\n")); |
|
627 CCalCategory* cat = iCatMan->CategoryL(iNumEntries-1); |
|
628 CleanupStack::PushL(cat); |
|
629 |
|
630 RemoveMedia(); |
|
631 |
|
632 TRAPD(err, iCatMan->DeleteCategoryL(*cat, *this)); |
|
633 test.Printf(_L("DeleteCategoryL gave error %d\n"), err); |
|
634 |
|
635 test(err == KErrNone); |
|
636 CActiveScheduler::Start(); |
|
637 |
|
638 CleanupStack::PopAndDestroy(cat); |
|
639 } |
|
640 |
|
641 void CCalRemovableMediaTest::CheckDeleteCategory() |
|
642 { |
|
643 test(iError == KErrNotReady); |
|
644 } |
|
645 |
|
646 void CCalRemovableMediaTest::AddAttachmentL(TBool aTesting) |
|
647 { |
|
648 if (aTesting) |
|
649 { |
|
650 test.Next(_L("Test add attachment\n")); |
|
651 } |
|
652 GetNumEntriesL(); |
|
653 |
|
654 _LIT8(KBinaryData, "001010110100001010010001010110100001010010001010110100001010010001010110100001010010...is this binary?"); |
|
655 _LIT8(KGuid, "AddAttachmentL_guid"); |
|
656 |
|
657 HBufC8* guid = KGuid().AllocLC(); |
|
658 CCalEntry* entry = CCalEntry::NewL(CCalEntry::ETodo, guid, CCalEntry::EMethodNone, 0); |
|
659 CleanupStack::Pop(guid); |
|
660 CleanupStack::PushL(entry); |
|
661 |
|
662 HBufC8* binaryData = KBinaryData().AllocLC(); |
|
663 CCalAttachment* attachment = CCalAttachment::NewFileL(binaryData); |
|
664 CleanupStack::Pop(binaryData); |
|
665 CleanupStack::PushL(attachment); |
|
666 #ifdef TEST_MANUALLY |
|
667 _LIT(KDrive, "d:"); |
|
668 TDriveName drive = KDrive(); |
|
669 attachment->FileAttachment()->SetDriveL(drive); |
|
670 #endif |
|
671 entry->AddAttachmentL(*attachment); |
|
672 CleanupStack::Pop(attachment); |
|
673 |
|
674 RPointerArray<CCalEntry> entryArray; |
|
675 CleanupClosePushL(entryArray); |
|
676 TInt success = 0; |
|
677 entryArray.AppendL(entry); |
|
678 |
|
679 if (aTesting) |
|
680 { |
|
681 RemoveMedia(); |
|
682 } |
|
683 |
|
684 TRAPD(err, iTestLib->SynCGetEntryViewL().StoreL(entryArray, success)); |
|
685 |
|
686 if (aTesting) |
|
687 { |
|
688 test.Printf(_L("AddAttachmentL gave error %d\n"), err); |
|
689 test(success == 0); |
|
690 test(err == KErrNotReady); |
|
691 } |
|
692 else |
|
693 { |
|
694 test(success == entryArray.Count()); |
|
695 test(err == KErrNone); |
|
696 } |
|
697 CleanupStack::PopAndDestroy(&entryArray); // entryArray.Close() |
|
698 CleanupStack::PopAndDestroy(entry); |
|
699 } |
|
700 |
|
701 void CCalRemovableMediaTest::UpdateAttachmentL() |
|
702 { |
|
703 test.Next(_L("Test update attachment\n")); |
|
704 AddAttachmentL(EFalse); |
|
705 |
|
706 GetNumEntriesL(); |
|
707 |
|
708 CCalAttachmentIterator* attachments = iAttMan->FetchAttachmentsL(CCalAttachmentManager::ESortBySizeLargestFirst); |
|
709 CleanupStack::PushL(attachments); |
|
710 |
|
711 test(attachments->HasMore()); |
|
712 CCalAttachment* currentAttachment = attachments->NextL(); |
|
713 CleanupStack::PushL(currentAttachment); |
|
714 |
|
715 RArray<TCalLocalUid> localUids; |
|
716 CleanupClosePushL(localUids); |
|
717 iAttMan->EntriesReferencingFileAttachmentL(localUids, *currentAttachment); |
|
718 test(localUids.Count() == 1); |
|
719 |
|
720 CCalEntry* entry = iTestLib->SynCGetEntryViewL().FetchL(localUids[0]); |
|
721 test(entry != NULL); |
|
722 |
|
723 CleanupStack::PopAndDestroy(&localUids); // localUids.Close() |
|
724 CleanupStack::PushL(entry); |
|
725 |
|
726 entry->DeleteAttachmentL(*currentAttachment); |
|
727 |
|
728 _LIT8(KBinaryData, "zxcvbnmzxcvbnmzxcvbnzmxcvbnmzxcvbznxmcvbnmzxcvbzxcvbnmzxvcbmn"); |
|
729 HBufC8* data = KBinaryData().AllocLC(); |
|
730 CCalAttachment* newAttachment = CCalAttachment::NewFileL(data); |
|
731 CleanupStack::Pop(data); |
|
732 CleanupStack::PushL(newAttachment); |
|
733 entry->AddAttachmentL(*newAttachment); |
|
734 CleanupStack::Pop(newAttachment); |
|
735 |
|
736 RPointerArray<CCalEntry> entryArray; |
|
737 CleanupClosePushL(entryArray); |
|
738 |
|
739 RemoveMedia(); |
|
740 |
|
741 entryArray.AppendL(entry); |
|
742 TInt success = 0; |
|
743 TRAPD(err, iTestLib->SynCGetEntryViewL().StoreL(entryArray, success)); |
|
744 test.Printf(_L("UpdateAttachmentL gave error %d\n"), err); |
|
745 test(success == 0); |
|
746 test(err == KErrNotReady); |
|
747 |
|
748 CleanupStack::PopAndDestroy(&entryArray); // entryArray.Close() |
|
749 |
|
750 CleanupStack::PopAndDestroy(entry); |
|
751 CleanupStack::PopAndDestroy(currentAttachment); |
|
752 CleanupStack::PopAndDestroy(attachments); |
|
753 } |
|
754 |
|
755 void CCalRemovableMediaTest::DeleteAttachmentL() |
|
756 { |
|
757 test.Next(_L("Test delete attachment\n")); |
|
758 // ensure at least one entry exists |
|
759 iNumEntries = AttachmentFileCountL(); |
|
760 if (iNumEntries == 0) |
|
761 { |
|
762 AddAttachmentL(EFalse); |
|
763 iNumEntries = AttachmentFileCountL(); |
|
764 test(iNumEntries != 0); |
|
765 } |
|
766 |
|
767 CCalAttachmentIterator* attachments = iAttMan->FetchAttachmentsL(CCalAttachmentManager::ESortBySizeLargestFirst); |
|
768 CleanupStack::PushL(attachments); |
|
769 |
|
770 test(attachments->HasMore()); |
|
771 CCalAttachment* currentAttachment = attachments->NextL(); |
|
772 CleanupStack::PushL(currentAttachment); |
|
773 |
|
774 RArray<TCalLocalUid> localUids; |
|
775 CleanupClosePushL(localUids); |
|
776 iAttMan->EntriesReferencingFileAttachmentL(localUids, *currentAttachment); |
|
777 test(localUids.Count() == 1); |
|
778 |
|
779 RemoveMedia(); |
|
780 TInt success = 0; |
|
781 TRAPD(err, iTestLib->SynCGetEntryViewL().DeleteL(localUids, success)); |
|
782 test.Printf(_L("DeleteAttachmentL gave error %d\n"), err); |
|
783 test(err == KErrNotReady); |
|
784 test(success == 0); |
|
785 |
|
786 CleanupStack::PopAndDestroy(&localUids); // localUids.Close() |
|
787 |
|
788 CleanupStack::PopAndDestroy(currentAttachment); |
|
789 CleanupStack::PopAndDestroy(attachments); |
|
790 } |
|
791 |
|
792 void CCalRemovableMediaTest::CheckDeleteAttachmentL() |
|
793 { |
|
794 test.Printf(_L("Checking number of attachments: expected=%d...Number of entries found=%d\n"), iNumAttachments, AttachmentFileCountL()); |
|
795 test(iNumAttachments == AttachmentFileCountL()); |
|
796 } |
|
797 |
|
798 void CCalRemovableMediaTest::ChangeAttachmentDriveL() |
|
799 { |
|
800 #ifdef TEST_MANUALLY |
|
801 _LIT(KDriveC, "C:"); |
|
802 _LIT(KDriveD, "D:"); |
|
803 _LIT8(KGuidCopy, "guid_copy"); |
|
804 |
|
805 test.Next(_L("Create an attachment, copy it then set the drive to be different")); |
|
806 // add an attachment |
|
807 AddAttachmentL(EFalse); |
|
808 |
|
809 // fetch the entry containing this attachment |
|
810 CCalAttachmentIterator* attachments = iAttMan->FetchAttachmentsL(CCalAttachmentManager::ESortBySizeLargestFirst); |
|
811 CleanupStack::PushL(attachments); |
|
812 |
|
813 test(attachments->HasMore()); |
|
814 CCalAttachment* currentAttachment = attachments->NextL(); |
|
815 CleanupStack::PushL(currentAttachment); |
|
816 |
|
817 RArray<TCalLocalUid> localUids; |
|
818 CleanupClosePushL(localUids); |
|
819 iAttMan->EntriesReferencingFileAttachmentL(localUids, *currentAttachment); |
|
820 test(localUids.Count() == 1); |
|
821 |
|
822 TInt luid1 = localUids[0]; |
|
823 CCalEntry* entry = iTestLib->SynCGetEntryViewL().FetchL(luid1); |
|
824 test(entry != NULL); |
|
825 CleanupStack::PopAndDestroy(&localUids); |
|
826 CleanupStack::PopAndDestroy(currentAttachment); |
|
827 CleanupStack::PopAndDestroy(attachments); |
|
828 |
|
829 CleanupStack::PushL(entry); |
|
830 |
|
831 // create a copy of the entry |
|
832 HBufC8* guid = KGuidCopy().AllocLC(); |
|
833 CCalEntry* copyOfEntry = CCalEntry::NewL(entry->EntryTypeL(), guid, CCalEntry::EMethodNone, 0); |
|
834 CleanupStack::Pop(guid); |
|
835 CleanupStack::PushL(copyOfEntry); |
|
836 copyOfEntry->CopyFromL(*entry, CCalEntry::EDontCopyId); |
|
837 |
|
838 // edit the copy to place the attachment on a different drive |
|
839 test(copyOfEntry->AttachmentCountL() == 1); |
|
840 CCalAttachment* attach = copyOfEntry->AttachmentL(0); |
|
841 test(attach != NULL); |
|
842 attach->FileAttachment()->SetDriveL(KDriveC()); |
|
843 |
|
844 iTestLib->StoreEntryL(*copyOfEntry); |
|
845 TCalLocalUid luid2 = copyOfEntry->LocalUidL(); |
|
846 CleanupStack::PopAndDestroy(copyOfEntry); |
|
847 CleanupStack::PopAndDestroy(entry); |
|
848 |
|
849 // fetch the copied entry and check its attachment |
|
850 CCalEntry* fetchedCopiedEntry = iTestLib->SynCGetEntryViewL().FetchL(luid2); |
|
851 test(fetchedCopiedEntry != NULL); |
|
852 CleanupStack::PushL(fetchedCopiedEntry); |
|
853 |
|
854 test(fetchedCopiedEntry->AttachmentCountL() == 1); |
|
855 attach = fetchedCopiedEntry->AttachmentL(0); |
|
856 test(attach != NULL); |
|
857 attach->FileAttachment()->LoadBinaryDataL(); |
|
858 test(attach->Value().Length() > 10); |
|
859 TDriveName drive = attach->FileAttachment()->Drive(); |
|
860 drive.UpperCase(); |
|
861 test(drive == KDriveC()); |
|
862 CleanupStack::PopAndDestroy(fetchedCopiedEntry); |
|
863 |
|
864 |
|
865 |
|
866 // fetch the original entry |
|
867 entry = iTestLib->SynCGetEntryViewL().FetchL(luid1); |
|
868 CleanupStack::PushL(entry); |
|
869 |
|
870 // create a copy of the entry |
|
871 guid = KGuidCopy().AllocLC(); |
|
872 copyOfEntry = CCalEntry::NewL(entry->EntryTypeL(), guid, CCalEntry::EMethodNone, 0); |
|
873 CleanupStack::Pop(guid); |
|
874 CleanupStack::PushL(copyOfEntry); |
|
875 copyOfEntry->CopyFromL(*entry, CCalEntry::EDontCopyId); |
|
876 |
|
877 // edit the copy to place the attachment on the same drive (but change the flag) |
|
878 test(copyOfEntry->AttachmentCountL() == 1); |
|
879 attach = copyOfEntry->AttachmentL(0); |
|
880 test(attach != NULL); |
|
881 attach->FileAttachment()->SetDriveL(KDriveC()); |
|
882 attach->FileAttachment()->SetDriveL(KDriveD()); |
|
883 |
|
884 iTestLib->StoreEntryL(*copyOfEntry); |
|
885 TCalLocalUid luid3 = copyOfEntry->LocalUidL(); |
|
886 CleanupStack::PopAndDestroy(copyOfEntry); |
|
887 CleanupStack::PopAndDestroy(entry); |
|
888 |
|
889 // fetch the copied entry and check its attachment |
|
890 fetchedCopiedEntry = iTestLib->SynCGetEntryViewL().FetchL(luid3); |
|
891 test(fetchedCopiedEntry != NULL); |
|
892 CleanupStack::PushL(fetchedCopiedEntry); |
|
893 |
|
894 test(fetchedCopiedEntry->AttachmentCountL() == 1); |
|
895 attach = fetchedCopiedEntry->AttachmentL(0); |
|
896 test(attach != NULL); |
|
897 attach->FileAttachment()->LoadBinaryDataL(); |
|
898 test(attach->Value().Length() > 10); |
|
899 drive = attach->FileAttachment()->Drive(); |
|
900 drive.UpperCase(); |
|
901 test(drive == KDriveD()); |
|
902 CleanupStack::PopAndDestroy(fetchedCopiedEntry); |
|
903 #endif |
|
904 } |
|
905 void CCalRemovableMediaTest::DeleteInstanceL() |
|
906 { |
|
907 test.Next(_L("Test Delete Instance\n")); |
|
908 RPointerArray<CCalInstance> instances; |
|
909 CleanupResetAndDestroyPushL(instances); |
|
910 |
|
911 iTestLib->FetchAllInstancesL(instances); |
|
912 if (instances.Count() == 0) |
|
913 { |
|
914 InitialiseFileL(); |
|
915 iTestLib->FetchAllInstancesL(instances); |
|
916 test(instances.Count() > 0); |
|
917 } |
|
918 |
|
919 iNumEntries = instances[0]->Entry().LocalUidL(); |
|
920 |
|
921 RemoveMedia(); |
|
922 test.Printf(_L("Deleting instance...\n")); |
|
923 TRAPD(err, iTestLib->SynCGetInstanceViewL().DeleteL(instances[0], CalCommon::EThisAndAll)); |
|
924 test.Printf(_L("Deleting instance gave error %d...\n"), err); |
|
925 test(err == KErrNotReady); |
|
926 |
|
927 CleanupStack::PopAndDestroy(&instances); // instances.ResetAndDestroy() |
|
928 } |
|
929 |
|
930 void CCalRemovableMediaTest::CheckDeleteInstanceL() |
|
931 { |
|
932 test.Printf(_L("Checking instance not deleted...\n")); |
|
933 CCalEntry* entry = iTestLib->SynCGetEntryViewL().FetchL(iNumEntries); |
|
934 test(entry != NULL); |
|
935 delete entry; |
|
936 } |
|
937 |
|
938 void CCalRemovableMediaTest::TestAfterMediaRemovedL() |
|
939 { |
|
940 test.Printf(_L("Testing read-only operations after media removed\n")); |
|
941 |
|
942 StoreEntriesL(EFalse); // add some entries to begin with |
|
943 |
|
944 StoreEntriesL(ETrue); // remove media |
|
945 |
|
946 // test find instances after media removed |
|
947 RPointerArray<CCalInstance> instances; |
|
948 CleanupResetAndDestroyPushL(instances); |
|
949 TRAPD(err, FindEntriesWithTextL(instances, KNullDesC())); |
|
950 test(err == KErrNotReady); |
|
951 CleanupStack::PopAndDestroy(&instances); |
|
952 |
|
953 // test iterator |
|
954 TRAP(err, iTestLib->GetIterL().FirstL()); |
|
955 test(err == KErrNotReady); |
|
956 |
|
957 // test next instance |
|
958 TCalTime startTime; |
|
959 startTime.SetTimeLocalL(TCalTime::MinTime()); |
|
960 TRAP(err, iTestLib->SynCGetInstanceViewL().NextInstanceL(CalCommon::EIncludeAll, startTime)); |
|
961 test(err == KErrNotReady); |
|
962 } |
|
963 |
|
964 CCalRemovableMediaTest* CCalRemovableMediaTest::NewLC() |
|
965 { |
|
966 CCalRemovableMediaTest* app = new (ELeave) CCalRemovableMediaTest(); |
|
967 CleanupStack::PushL(app); |
|
968 app->ConstructL(); |
|
969 return app; |
|
970 } |
|
971 |
|
972 void CCalRemovableMediaTest::ConstructL() |
|
973 { |
|
974 iTestLib = CCalTestLibrary::NewL(); |
|
975 |
|
976 #ifdef TEST_MANUALLY |
|
977 #ifdef __WINS__ |
|
978 iCalendarName.Copy(_L("d:")); |
|
979 iCalendarName.Append(KRemovableMediaTestFile); |
|
980 #else |
|
981 // find the first drive letter after drive c which exists |
|
982 TDriveList list; |
|
983 iTestLib->FileSession().DriveList(list); |
|
984 |
|
985 TChar driveLetter; |
|
986 TInt i = EDriveD; |
|
987 while (i < EDriveZ) |
|
988 { |
|
989 TVolumeInfo volInfo; |
|
990 TInt err = iTestLib->FileSession().Volume(volInfo, i); |
|
991 if (err == KErrNone) |
|
992 { |
|
993 break; |
|
994 } |
|
995 ++i; |
|
996 } |
|
997 |
|
998 User::LeaveIfError(iTestLib->FileSession().DriveToChar(i, driveLetter)); |
|
999 iCalendarName.Zero(); |
|
1000 iCalendarName.Append(driveLetter); |
|
1001 test.Printf(_L("Using drive %S as external drive\n"), &iCalendarName); |
|
1002 test(iCalendarName.Length() == 1); |
|
1003 iCalendarName.Append(_L(":")); |
|
1004 iCalendarName.Append(KRemovableMediaTestFile); |
|
1005 #endif |
|
1006 #else |
|
1007 iCalendarName.Copy(_L("c:")); |
|
1008 iCalendarName.Append(KRemovableMediaTestFile); |
|
1009 #endif |
|
1010 |
|
1011 TRAP_IGNORE(iTestLib->ReplaceFileL(iCalendarName)); |
|
1012 } |
|
1013 |
|
1014 void CCalRemovableMediaTest::SetupTestLibL() |
|
1015 { |
|
1016 #ifndef TEST_MANUALLY |
|
1017 iTestLib->FileSession().SetErrorCondition(0); |
|
1018 User::After(500000); |
|
1019 #endif |
|
1020 test.Printf(_L("Re-opening calendar file\n")); |
|
1021 iTestLib->OpenFileL(iCalendarName); |
|
1022 if (!iCatMan) |
|
1023 { |
|
1024 iCatMan = CCalCategoryManager::NewL(iTestLib->GetSession()); |
|
1025 } |
|
1026 if (!iAttMan) |
|
1027 { |
|
1028 iAttMan = CCalAttachmentManager::NewL(iTestLib->GetSession(), *iTestLib); |
|
1029 CActiveScheduler::Start(); |
|
1030 } |
|
1031 } |
|
1032 |
|
1033 void CCalRemovableMediaTest::ClearTestLib() |
|
1034 { |
|
1035 delete iCatMan; |
|
1036 iCatMan = NULL; |
|
1037 delete iAttMan; |
|
1038 iAttMan = NULL; |
|
1039 } |
|
1040 |
|
1041 CCalRemovableMediaTest::CCalRemovableMediaTest() |
|
1042 { |
|
1043 } |
|
1044 |
|
1045 CCalRemovableMediaTest::~CCalRemovableMediaTest() |
|
1046 { |
|
1047 ClearTestLib(); |
|
1048 delete iTestLib; |
|
1049 } |
|
1050 |
|
1051 void CCalRemovableMediaTest::DoTestsL() |
|
1052 { |
|
1053 TInt step = EFirstStep; |
|
1054 while (step != EFinishedTests) |
|
1055 { |
|
1056 // this test suite can work only under debug mode because the file server failure |
|
1057 // simulation feature |
|
1058 #ifdef _DEBUG |
|
1059 NextStepL(step); |
|
1060 #endif |
|
1061 ++step; |
|
1062 } |
|
1063 // clean up files |
|
1064 iTestLib->FileSession().SetErrorCondition(0); |
|
1065 User::After(500000); |
|
1066 iTestLib->DeleteFileL(KRemovableMediaTestFile, 1); |
|
1067 } |
|
1068 |
|
1069 |
|
1070 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
1071 * DoTestL() |
|
1072 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
|
1073 |
|
1074 static void DoTestL() |
|
1075 { |
|
1076 #ifdef TEST_MANUALLY |
|
1077 test.Printf(_L("Manual test\n")); |
|
1078 #ifdef __WINS__ |
|
1079 test.Printf(_L("\n")); |
|
1080 test.Printf(_L("Ensure the epoc.ini file is set up with the D: drive mapped to an external drive:\n")); |
|
1081 test.Printf(_L(" _epoc_drive_d f:\n")); |
|
1082 #endif |
|
1083 test.Printf(_L("\n")); |
|
1084 test.Printf(_L("Put an MMC card in the external drive and remove/replace it when prompted.\n")); |
|
1085 test.Printf(_L("Press any key.\n")); |
|
1086 test.Getch(); |
|
1087 #endif |
|
1088 |
|
1089 |
|
1090 CCalRemovableMediaTest* testManager = CCalRemovableMediaTest::NewLC(); |
|
1091 |
|
1092 |
|
1093 TPerformanceTimer timer(test); |
|
1094 timer.Start(); |
|
1095 |
|
1096 |
|
1097 // Run the test suite |
|
1098 |
|
1099 testManager->DoTestsL(); |
|
1100 |
|
1101 |
|
1102 timer.Stop(); |
|
1103 test.Printf(_L("Done\n")); |
|
1104 // printout performance time |
|
1105 timer.PrintOut(); |
|
1106 |
|
1107 |
|
1108 CleanupStack::PopAndDestroy(testManager); |
|
1109 } |
|
1110 |
|
1111 |
|
1112 /**@SYMTestCaseID PIM-TCAL-REMOVABLE-MEDIA-0001*/TInt E32Main() |
|
1113 { |
|
1114 __UHEAP_MARK; |
|
1115 |
|
1116 test.Start(_L("@SYMTESTCaseID:PIM-TCAL-REMOVABLE-MEDIA-0001 Calendar Interim API Removable Media test suite")); |
|
1117 test.Title(); |
|
1118 |
|
1119 CTrapCleanup* trapCleanup = CTrapCleanup::New(); |
|
1120 if (!trapCleanup) |
|
1121 { |
|
1122 return KErrNoMemory; |
|
1123 } |
|
1124 |
|
1125 CActiveScheduler* scheduler = new CActiveScheduler(); |
|
1126 if (!scheduler) |
|
1127 { |
|
1128 delete trapCleanup; |
|
1129 return KErrNoMemory; |
|
1130 } |
|
1131 CActiveScheduler::Install(scheduler); |
|
1132 |
|
1133 TRAPD(ret, DoTestL()); |
|
1134 test(ret == KErrNone); |
|
1135 |
|
1136 delete scheduler; |
|
1137 delete trapCleanup; |
|
1138 |
|
1139 test.End(); |
|
1140 test.Close(); |
|
1141 |
|
1142 __UHEAP_MARKEND; |
|
1143 |
|
1144 return (KErrNone); |
|
1145 } |
|
1146 |