|
1 // Copyright (c) 1997-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 <calentry.h> |
|
17 #include <calentryview.h> |
|
18 #include <calinstanceview.h> |
|
19 #include <calsession.h> |
|
20 #include <e32test.h> |
|
21 #include <caliterator.h> |
|
22 #include <caluser.h> |
|
23 #include <calrrule.h> |
|
24 #include <calcategorymanager.h> |
|
25 #include <calcategory.h> |
|
26 #include <calinstance.h> |
|
27 |
|
28 #include "caltestlib.h" |
|
29 |
|
30 RTest test(_L("tcal_delete")); |
|
31 |
|
32 _LIT(KCalendarFile,"tcal_delete"); |
|
33 _LIT(KCalendarFile2, "tcal_delete_calendar_copy"); |
|
34 _LIT(KOriginalDeleteCalendar, "z:\\private\\10003A5B\\tcal_delete_calendar"); |
|
35 _LIT8( KGUIDInc081869, "Guid081869" ); |
|
36 |
|
37 _LIT(KRecurrIdLocalTime, "20030500:000000."); // June 1, 2003 00:00:00 |
|
38 |
|
39 // This number must be even and greater than the highest defined value in |
|
40 // KTidyCallbackRate, currently 24. |
|
41 // This would ensure the callback feature gets triggered for testing. |
|
42 const TInt KNumberOfEntries = 26; |
|
43 |
|
44 class CDummyCalendarApp; |
|
45 |
|
46 // Progress call back utility class |
|
47 class CProgressCallBack : public CBase, public MCalProgressCallBack |
|
48 { |
|
49 public: |
|
50 void Progress(TInt aPercentageCompleted); |
|
51 void Completed(TInt aError); |
|
52 TBool NotifyProgress(); |
|
53 }; |
|
54 |
|
55 void CProgressCallBack::Progress(TInt aPercentageCompleted) |
|
56 { |
|
57 test.Printf(_L("DeleteL is %d%% complete\n"), aPercentageCompleted); |
|
58 } |
|
59 |
|
60 void CProgressCallBack::Completed(TInt aError) |
|
61 { |
|
62 test.Printf(_L("DeleteL has completed with error code %d\n"), aError); |
|
63 __ASSERT_ALWAYS(aError == KErrNone, User::Invariant()); |
|
64 CActiveScheduler::Stop(); |
|
65 } |
|
66 |
|
67 TBool CProgressCallBack::NotifyProgress() |
|
68 { |
|
69 return ETrue; |
|
70 } |
|
71 |
|
72 // a dummy test app that runs in a different thread |
|
73 class CSecondThreadApp : public CBase |
|
74 { |
|
75 public: |
|
76 static CSecondThreadApp* NewL(); |
|
77 ~CSecondThreadApp(); |
|
78 |
|
79 void RunTestL(); |
|
80 void TestFileLockL(TInt aError); |
|
81 |
|
82 private: |
|
83 void ConstructL(); |
|
84 CSecondThreadApp(); |
|
85 |
|
86 public: |
|
87 CCalTestLibrary* iCalTestLib; |
|
88 TInt iNumEntriesAdded; |
|
89 }; |
|
90 |
|
91 CSecondThreadApp* CSecondThreadApp::NewL() |
|
92 { |
|
93 CSecondThreadApp* self = new(ELeave) CSecondThreadApp; |
|
94 CleanupStack::PushL(self); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop(self); |
|
97 return self; |
|
98 } |
|
99 |
|
100 void CSecondThreadApp::ConstructL() |
|
101 { |
|
102 iCalTestLib = CCalTestLibrary::NewL(); |
|
103 iCalTestLib->OpenFileL(KCalendarFile); |
|
104 } |
|
105 |
|
106 CSecondThreadApp::CSecondThreadApp() |
|
107 { |
|
108 } |
|
109 |
|
110 CSecondThreadApp::~CSecondThreadApp() |
|
111 { |
|
112 delete iCalTestLib; |
|
113 } |
|
114 |
|
115 void CSecondThreadApp::RunTestL() |
|
116 { |
|
117 RThread thread; |
|
118 |
|
119 thread.Rendezvous(KErrNone); |
|
120 |
|
121 // wait for the other thread to call DeleteL |
|
122 thread.Suspend(); |
|
123 |
|
124 // test that the file is locked |
|
125 TestFileLockL(KErrLocked); |
|
126 |
|
127 // wait for the DeleteL to finish |
|
128 thread.Suspend(); |
|
129 |
|
130 // test that the file is now unlocked |
|
131 TestFileLockL(KErrNone); |
|
132 } |
|
133 |
|
134 void CSecondThreadApp::TestFileLockL(TInt aError) |
|
135 { |
|
136 TCalTime from; |
|
137 from.SetTimeLocalL(TDateTime(2005, ESeptember, 11, 0, 0, 0, 0)); |
|
138 TCalTime resultTime; |
|
139 |
|
140 // NextInstanceL |
|
141 RDebug::Printf("Test NextInstanceL"); |
|
142 TInt error(KErrNone); |
|
143 TRAP(error, resultTime = iCalTestLib->SynCGetInstanceViewL().NextInstanceL(CalCommon::EIncludeAll, from)); |
|
144 if (error != aError) |
|
145 { |
|
146 User::Leave(KErrGeneral); |
|
147 } |
|
148 |
|
149 // PreviousInstanceL |
|
150 RDebug::Printf("Test PreviousInstanceL"); |
|
151 error = KErrNone; |
|
152 TRAP(error, resultTime = iCalTestLib->SynCGetInstanceViewL().PreviousInstanceL(CalCommon::EIncludeAll, from)); |
|
153 if (error != aError) |
|
154 { |
|
155 User::Leave(KErrGeneral); |
|
156 } |
|
157 |
|
158 // GetIdsModifiedSinceDateL |
|
159 RDebug::Printf("Test GetIdsModifiedSinceDateL"); |
|
160 RArray<TCalLocalUid> uids; |
|
161 CleanupClosePushL(uids); |
|
162 error = KErrNone; |
|
163 TRAP(error, iCalTestLib->SynCGetEntryViewL().GetIdsModifiedSinceDateL(from, uids)); |
|
164 if (error != aError) |
|
165 { |
|
166 User::Leave(KErrGeneral); |
|
167 } |
|
168 if (aError != KErrNone && uids.Count() != 0) |
|
169 { |
|
170 User::Leave(KErrGeneral); |
|
171 } |
|
172 CleanupStack::PopAndDestroy(&uids); |
|
173 |
|
174 // FindInstanceL |
|
175 RDebug::Printf("Test FindInstanceL"); |
|
176 RPointerArray<CCalInstance> instanceList; |
|
177 CleanupResetAndDestroyPushL(instanceList); |
|
178 |
|
179 TCalTime start; |
|
180 start.SetTimeLocalL(TDateTime(2004, EMay, 12, 10, 30, 0, 0)); |
|
181 TCalTime end; |
|
182 end.SetTimeLocalL(TDateTime(2007, EMay, 12, 10, 30, 0, 0)); |
|
183 |
|
184 CalCommon::TCalTimeRange timeRange(start, end); |
|
185 |
|
186 error = KErrNone; |
|
187 TRAP(error, iCalTestLib->SynCGetInstanceViewL().FindInstanceL(instanceList, CalCommon::EIncludeAll, timeRange)); |
|
188 if (error != aError) |
|
189 { |
|
190 User::Leave(KErrGeneral); |
|
191 } |
|
192 if (aError != KErrNone && instanceList.Count() != 0) |
|
193 { |
|
194 User::Leave(KErrGeneral); |
|
195 } |
|
196 |
|
197 CleanupStack::PopAndDestroy(&instanceList); |
|
198 |
|
199 // StoreL |
|
200 RPointerArray<CCalEntry> entryArray; |
|
201 CleanupResetAndDestroyPushL(entryArray); |
|
202 |
|
203 HBufC8* guid = NULL; |
|
204 CCalEntry* entry = iCalTestLib->CreateCalEntryL(CCalEntry::EAppt, guid); |
|
205 CleanupStack::PushL(entry); |
|
206 iCalTestLib->SetEntryStartAndEndTimeL(entry, TDateTime(2005, EMay, 23, 10, 30, 0, 0), |
|
207 TDateTime(2005, EMay, 23, 11, 0, 0, 0)); |
|
208 entryArray.AppendL(entry); |
|
209 CleanupStack::Pop(entry); |
|
210 TInt numSuc; |
|
211 error = KErrNone; |
|
212 TRAP(error, iCalTestLib->SynCGetEntryViewL().StoreL(entryArray, numSuc)); |
|
213 if (error != aError) |
|
214 { |
|
215 User::Leave(KErrGeneral); |
|
216 } |
|
217 |
|
218 // UpdateL |
|
219 error = KErrNone; |
|
220 TRAP(error, iCalTestLib->SynCGetEntryViewL().UpdateL(entryArray, numSuc)); |
|
221 if (error != aError && error != KErrNotFound) |
|
222 { |
|
223 User::Leave(KErrGeneral); |
|
224 } |
|
225 // FetchL |
|
226 error = KErrNone; |
|
227 TRAP(error, iCalTestLib->SynCGetEntryViewL().FetchL(*guid, entryArray)); |
|
228 if (error != aError) |
|
229 { |
|
230 User::Leave(KErrGeneral); |
|
231 } |
|
232 |
|
233 // DeleteL |
|
234 error = KErrNone; |
|
235 TRAP(error, iCalTestLib->SynCGetEntryViewL().DeleteL(*entry)); |
|
236 if (error != aError) |
|
237 { |
|
238 User::Leave(KErrGeneral); |
|
239 } |
|
240 |
|
241 CleanupStack::PopAndDestroy(&entryArray); |
|
242 |
|
243 // CategoryManager |
|
244 CCalCategoryManager* categoryManager = CCalCategoryManager::NewL(iCalTestLib->GetSession()); |
|
245 CleanupStack::PushL(categoryManager); |
|
246 |
|
247 CCalCategory* funCategory = CCalCategory::NewL(_L("Fun")); |
|
248 CleanupStack::PushL(funCategory); |
|
249 error = KErrNone; |
|
250 TRAP(error, categoryManager->AddCategoryL(*funCategory)); |
|
251 if (error != aError) |
|
252 { |
|
253 User::Leave(KErrGeneral); |
|
254 } |
|
255 CleanupStack::PopAndDestroy(funCategory); |
|
256 |
|
257 error = KErrNone; |
|
258 TRAP(error, delete categoryManager->CategoryL(0)); |
|
259 if (error != aError) |
|
260 { |
|
261 User::Leave(KErrGeneral); |
|
262 } |
|
263 |
|
264 CleanupStack::PopAndDestroy(categoryManager); |
|
265 |
|
266 // CCalIter |
|
267 CCalIter* calIter = CCalIter::NewL(iCalTestLib->GetSession()); |
|
268 CleanupStack::PushL(calIter); |
|
269 |
|
270 error = KErrNone; |
|
271 TRAP(error, const TDesC8& guidRefFirst = calIter->FirstL()); |
|
272 if (error != aError) |
|
273 { |
|
274 User::Leave(KErrGeneral); |
|
275 } |
|
276 |
|
277 error = KErrNone; |
|
278 TRAP(error, const TDesC8& guidRefNext = calIter->NextL()); |
|
279 if (error != aError && error != KErrCorrupt) |
|
280 { |
|
281 User::Leave(KErrGeneral); |
|
282 } |
|
283 |
|
284 CleanupStack::PopAndDestroy(calIter); |
|
285 // |
|
286 } |
|
287 |
|
288 static void DoSecondThreadMainL() |
|
289 { |
|
290 CSecondThreadApp* secondThreadApp = CSecondThreadApp::NewL(); |
|
291 CleanupStack::PushL(secondThreadApp); |
|
292 secondThreadApp->RunTestL(); |
|
293 CleanupStack::PopAndDestroy(secondThreadApp); |
|
294 } |
|
295 |
|
296 // The entry point for the other thread |
|
297 static TInt SecondThreadMain(TAny* /*aRef*/) |
|
298 { |
|
299 __UHEAP_MARK; |
|
300 CTrapCleanup* trapCleanup = CTrapCleanup::New(); |
|
301 if (!trapCleanup) |
|
302 { |
|
303 return KErrNoMemory; |
|
304 } |
|
305 |
|
306 CActiveScheduler* scheduler = new CActiveScheduler(); |
|
307 if (!scheduler) |
|
308 { |
|
309 delete trapCleanup; |
|
310 return KErrNoMemory; |
|
311 } |
|
312 CActiveScheduler::Install(scheduler); |
|
313 TRAPD(ret, DoSecondThreadMainL()); |
|
314 delete scheduler; |
|
315 delete trapCleanup; |
|
316 __UHEAP_MARKEND; |
|
317 return (ret); |
|
318 } |
|
319 |
|
320 |
|
321 class CAppActive : public CActive |
|
322 { |
|
323 public: |
|
324 enum TDummyAppStep |
|
325 { |
|
326 EStepOpenModel, |
|
327 ESimpleEntryDeleteAll, |
|
328 ESimpleEntryDeleteSome, |
|
329 EDeleteRestEntry, |
|
330 ERepeatEntryDelete, |
|
331 EDeleteAllTodos, |
|
332 EDeleteAndCheckProgress, |
|
333 ERepeatExceptedEntryCreate, |
|
334 ERepeatExceptedEntryFetchInstances, |
|
335 ERepeatExceptedEntryEditInstances, |
|
336 ERepeatExceptedEntryDelete, |
|
337 ELockedInOtherThreadDuringDelete, |
|
338 EDeleteRemiderAndMore, |
|
339 EDeleteEntryWithMinTime, |
|
340 EAddForDeleteBeforeDateWithException, |
|
341 EDeleteBeforeDateWithException, |
|
342 EDeleteAllBeforeDateWithException, |
|
343 EDeleteAllMemosBegin, |
|
344 EDeleteAllMemosMiddle, |
|
345 EDeleteAllMemosEnd, |
|
346 EEnd |
|
347 }; |
|
348 |
|
349 CAppActive(CDummyCalendarApp& aApp); |
|
350 ~CAppActive(); |
|
351 void DoCancel(); |
|
352 void RunL(); |
|
353 void Start(); |
|
354 TInt GetStep(); |
|
355 void SetStep(TDummyAppStep aStep); |
|
356 |
|
357 |
|
358 private: |
|
359 |
|
360 CDummyCalendarApp& iApp; |
|
361 TDummyAppStep iStep; |
|
362 RPointerArray<CCalInstance> iInstances; |
|
363 }; |
|
364 |
|
365 class CDummyCalendarApp : public CCalTestLibrary |
|
366 { |
|
367 public: |
|
368 |
|
369 enum TEntryType |
|
370 { |
|
371 EApp, |
|
372 ETodo, |
|
373 EReminder, |
|
374 EAll |
|
375 }; |
|
376 |
|
377 static CDummyCalendarApp* NewLC(); |
|
378 ~CDummyCalendarApp(); |
|
379 |
|
380 void Progress(TInt aPercentageCompleted); |
|
381 void Completed(TInt aError); |
|
382 TBool NotifyProgress(); |
|
383 |
|
384 void Close(); |
|
385 void OpenModelL(); |
|
386 void AddAOAndStartL(); |
|
387 |
|
388 void AddEntryL(TInt aNumToAdd, TBool isParent, TBool isRepeat); |
|
389 void StoreSimpleEntryL(); |
|
390 void StoreRepeatEntryL(); |
|
391 void DeleteEntryL(const TTime& aStart, const TTime& aEnd, CalCommon::TCalViewFilter aFilter); |
|
392 void DeleteAllTodosL(); |
|
393 void DeleteAllMemosBeginL(); |
|
394 void DeleteAllMemosEndL(); |
|
395 TBool CheckEntryNumL(TEntryType aType, TInt aNumEntry); |
|
396 void DeleteWhileAnotherThreadAccessesCalendarL(); |
|
397 void StoreManyEntriesL(TInt aCount); |
|
398 void RepeatExceptedEntryCreateL(); |
|
399 void RepeatExceptedEntryFetchInstancesL(RPointerArray<CCalInstance>& aInstances); |
|
400 void RepeatExceptedEntryEditInstancesL(RPointerArray<CCalInstance>& aInstances); |
|
401 |
|
402 TInt ProgressNotificationCount(); |
|
403 void Add3ReminderAnd1ApptL(); |
|
404 void AddFloatingEntryWithMinStartTimeL(); |
|
405 |
|
406 private: |
|
407 |
|
408 void ConstructL(); |
|
409 |
|
410 |
|
411 private: // member data |
|
412 |
|
413 CCalEntryView* iLocalEntryView;// doesn't own |
|
414 RPointerArray<CCalEntry> iEntries; |
|
415 CAppActive* iActive; |
|
416 TInt iProgressNotifications; |
|
417 CCalTestLibrary* iTestLib; |
|
418 }; |
|
419 |
|
420 |
|
421 CDummyCalendarApp* CDummyCalendarApp::NewLC() |
|
422 { |
|
423 CDummyCalendarApp* self = new (ELeave) CDummyCalendarApp(); |
|
424 |
|
425 CleanupStack::PushL(self); |
|
426 self->ConstructL(); |
|
427 |
|
428 return (self); |
|
429 } |
|
430 |
|
431 |
|
432 CDummyCalendarApp::~CDummyCalendarApp() |
|
433 { |
|
434 delete iActive; |
|
435 delete iTestLib; |
|
436 iEntries.ResetAndDestroy(); |
|
437 iEntries.Close(); |
|
438 } |
|
439 |
|
440 |
|
441 CAppActive::CAppActive(CDummyCalendarApp& aApp) |
|
442 : CActive(EPriorityHigh),iApp(aApp) |
|
443 { |
|
444 iStep = EStepOpenModel; |
|
445 } |
|
446 |
|
447 |
|
448 CAppActive::~CAppActive() |
|
449 { |
|
450 iInstances.Close(); |
|
451 Cancel(); |
|
452 } |
|
453 |
|
454 |
|
455 void CAppActive::Start() |
|
456 { |
|
457 if (!IsActive()) |
|
458 { |
|
459 SetActive(); |
|
460 } |
|
461 |
|
462 TRequestStatus* status = &iStatus; |
|
463 User::RequestComplete(status, KErrNone); |
|
464 } |
|
465 |
|
466 |
|
467 void CAppActive::DoCancel() |
|
468 { |
|
469 iApp.Close(); |
|
470 } |
|
471 |
|
472 TInt CAppActive::GetStep() |
|
473 { |
|
474 return iStep; |
|
475 } |
|
476 |
|
477 void CAppActive::SetStep(TDummyAppStep aStep) |
|
478 { |
|
479 iStep = aStep; |
|
480 } |
|
481 |
|
482 void CDummyCalendarApp::ConstructL() |
|
483 { |
|
484 BaseConstructL(); |
|
485 iActive = new (ELeave) CAppActive(*this); |
|
486 } |
|
487 |
|
488 |
|
489 void CDummyCalendarApp::DeleteWhileAnotherThreadAccessesCalendarL() |
|
490 { |
|
491 test.Printf(_L("Adding 1000 entries")); |
|
492 |
|
493 const TInt KNumEntriesToAdd(1000); |
|
494 |
|
495 for (TInt i(0) ; i < KNumEntriesToAdd ; ++i) |
|
496 { |
|
497 HBufC8* guid = NULL; |
|
498 CCalEntry* entry = CreateCalEntryL(CCalEntry::EAppt, guid); |
|
499 CleanupStack::PushL(entry); |
|
500 |
|
501 SetEntryStartAndEndTimeL(entry, |
|
502 TDateTime(2005, ESeptember, 12, 0, 0, 0, 0), |
|
503 TDateTime(2005, ESeptember, 12, 1, 0, 0, 0)); |
|
504 |
|
505 RPointerArray<CCalEntry> entryArray; |
|
506 CleanupClosePushL(entryArray); |
|
507 |
|
508 entryArray.AppendL(entry); |
|
509 TInt num; |
|
510 SynCGetEntryViewL().StoreL(entryArray, num); |
|
511 |
|
512 CleanupStack::PopAndDestroy(&entryArray); |
|
513 CleanupStack::PopAndDestroy(entry); |
|
514 |
|
515 test.Printf(_L(".")); |
|
516 } |
|
517 |
|
518 // start the second thread and wait for it to signal |
|
519 // that it is ready to recieve notifications |
|
520 RThread thread; |
|
521 CleanupClosePushL(thread); |
|
522 User::LeaveIfError(thread.Create(_L("SecondThread"), SecondThreadMain, |
|
523 KDefaultStackSize, |
|
524 KDefaultStackSize * 20, // this is the minimum heap size |
|
525 KDefaultStackSize * 40, // this is the maximum heap size |
|
526 NULL)); |
|
527 thread.SetPriority(EPriorityMore); |
|
528 thread.Resume(); |
|
529 |
|
530 // wait untill the second thread is ready |
|
531 TRequestStatus status; |
|
532 thread.Rendezvous(status); |
|
533 User::WaitForRequest(status); |
|
534 |
|
535 TCalTime start; |
|
536 start.SetTimeLocalL(TDateTime(2005, ESeptember, 0, 0, 0, 0, 0)); |
|
537 TCalTime end; |
|
538 end.SetTimeLocalL(TDateTime(2006, EJanuary, 0, 0, 0, 0, 0)); |
|
539 |
|
540 CalCommon::TCalTimeRange timeRange(start, end); |
|
541 |
|
542 CProgressCallBack* progress = new(ELeave) CProgressCallBack; |
|
543 CleanupStack::PushL(progress); |
|
544 |
|
545 test.Printf(_L("Start DeleteL\n")); |
|
546 SynCGetEntryViewL().DeleteL(timeRange, CalCommon::EIncludeAll, *progress); |
|
547 thread.Resume(); |
|
548 // signal to the other thread that we have called delete |
|
549 // and it should start testing that the file is locked |
|
550 CActiveScheduler::Start(); |
|
551 thread.Resume(); |
|
552 |
|
553 CleanupStack::PopAndDestroy(progress); |
|
554 |
|
555 // Wait for the other thread to exit |
|
556 // and test that the exit reason was KErrNone |
|
557 thread.Logon(status); |
|
558 User::WaitForRequest(status); |
|
559 |
|
560 // If the other thread's testing was unsuccessful |
|
561 // the exit reason will be KErrGeneral |
|
562 test(status.Int() == KErrNone); |
|
563 |
|
564 CleanupStack::PopAndDestroy(&thread); |
|
565 } |
|
566 |
|
567 void CDummyCalendarApp::Progress(TInt aPercentageCompleted) |
|
568 { |
|
569 test.Printf(_L("MCalProgress callback - Percent complete=%d"), aPercentageCompleted); |
|
570 test.Printf( _L( "\n" ) ); |
|
571 iProgressNotifications++; |
|
572 if(iActive->GetStep() == CAppActive::EDeleteAllMemosMiddle && aPercentageCompleted > 50) |
|
573 { |
|
574 CActiveScheduler::Stop(); |
|
575 } |
|
576 } |
|
577 |
|
578 |
|
579 void CDummyCalendarApp::Completed(TInt aError) |
|
580 { |
|
581 test.Printf(_L("MCalProgress callback - Completed, err=%d"), aError); |
|
582 test.Printf( _L ( "\n") ); |
|
583 iActive->Start(); |
|
584 } |
|
585 |
|
586 |
|
587 TBool CDummyCalendarApp::NotifyProgress() |
|
588 { |
|
589 return ETrue; |
|
590 } |
|
591 |
|
592 |
|
593 void CDummyCalendarApp::OpenModelL() |
|
594 { |
|
595 ReplaceFileL(KCalendarFile); |
|
596 OpenFileL(KCalendarFile); |
|
597 iLocalEntryView = &AsynCGetEntryViewL(); |
|
598 } |
|
599 |
|
600 |
|
601 TBool CDummyCalendarApp::CheckEntryNumL(TEntryType aType, TInt aNumEntry) |
|
602 { |
|
603 CCalIter& iter = GetIterL(); |
|
604 |
|
605 TPtrC8 Uid(iter.FirstL()); |
|
606 |
|
607 TInt ii=0; |
|
608 while (Uid!=KNullDesC8()) |
|
609 { |
|
610 ++ii; |
|
611 |
|
612 RPointerArray<CCalEntry> entryList; |
|
613 CleanupResetAndDestroyPushL(entryList); |
|
614 iLocalEntryView->FetchL(Uid, entryList); |
|
615 CCalEntry* entry = entryList[0]; |
|
616 if(aType==EApp) |
|
617 { |
|
618 test(entry->EntryTypeL()==CCalEntry::EAppt); |
|
619 } |
|
620 else if (aType==ETodo) |
|
621 { |
|
622 test(entry->EntryTypeL()==CCalEntry::ETodo); |
|
623 } |
|
624 else if(aType == EReminder) |
|
625 { |
|
626 test(entry->EntryTypeL()==CCalEntry::EReminder); |
|
627 } |
|
628 |
|
629 CleanupStack::PopAndDestroy(&entryList); |
|
630 |
|
631 Uid.Set(iter.NextL()); |
|
632 } |
|
633 |
|
634 return (ii==aNumEntry); |
|
635 } |
|
636 |
|
637 |
|
638 void CDummyCalendarApp::StoreSimpleEntryL() |
|
639 { |
|
640 AddEntryL(KNumberOfEntries, ETrue, EFalse); |
|
641 test(CheckEntryNumL(EAll,KNumberOfEntries)); |
|
642 } |
|
643 |
|
644 |
|
645 void CDummyCalendarApp::StoreRepeatEntryL() |
|
646 { |
|
647 AddEntryL(KNumberOfEntries, ETrue, ETrue); |
|
648 test(CheckEntryNumL(EAll,KNumberOfEntries)); |
|
649 AddEntryL(KNumberOfEntries, EFalse, ETrue); |
|
650 test(CheckEntryNumL(EAll,KNumberOfEntries)); |
|
651 } |
|
652 |
|
653 |
|
654 |
|
655 void CDummyCalendarApp::AddEntryL(TInt aNumToAdd, TBool isParent, TBool isRepeat) |
|
656 { |
|
657 test.Next(_L("Adding entries")); |
|
658 |
|
659 TBuf<50> summary; |
|
660 TBuf<50> location; |
|
661 TBuf<50> description; |
|
662 |
|
663 |
|
664 |
|
665 iEntries.ResetAndDestroy(); |
|
666 for (TInt index=0; index<aNumToAdd; index++) |
|
667 { |
|
668 TBuf8<255> buf; |
|
669 buf.Append(_L("GuidId")); |
|
670 buf.AppendNum(index); |
|
671 HBufC8* guid = buf.AllocLC(); // need to be pushed to ... |
|
672 |
|
673 CCalEntry::TType entryType=(index%2==0)?CCalEntry::ETodo:CCalEntry::EAppt; |
|
674 |
|
675 CCalEntry* entry = NULL; |
|
676 if(isParent) |
|
677 { |
|
678 entry = CreateCalEntryL(entryType, guid); |
|
679 } |
|
680 else |
|
681 { |
|
682 TTime localTime(KRecurrIdLocalTime); |
|
683 TCalTime recurrenceId; |
|
684 recurrenceId.SetTimeLocalL(localTime); |
|
685 entry = CCalEntry::NewL(entryType, guid, CCalEntry::EMethodAdd, 1, recurrenceId, CalCommon::EThisAndFuture); |
|
686 } |
|
687 CleanupStack::Pop(guid); |
|
688 iEntries.AppendL(entry); |
|
689 |
|
690 TInt year = -1; |
|
691 TInt month = -1; |
|
692 TInt day = -1; |
|
693 |
|
694 if (isParent) |
|
695 { |
|
696 year = index % 5 + 2001; // Any year in the range: 2001 - 2005 |
|
697 month = index % 12; |
|
698 day = index % 28; |
|
699 } |
|
700 else |
|
701 { |
|
702 // if this is a child entry, use the recurrence local time as the entry start time |
|
703 // so it won't be out of range |
|
704 TCalTime recurrId = entry->RecurrenceIdL(); |
|
705 TDateTime localTime = recurrId.TimeLocalL().DateTime(); |
|
706 year = localTime.Year(); |
|
707 month = localTime.Month(); |
|
708 day = localTime.Day(); |
|
709 } |
|
710 |
|
711 TTime start(TDateTime(year, (TMonth)month, day, 0, 0, 0, 0)); |
|
712 TTime end(TDateTime(year, (TMonth)month, day, 0, 0, 0, 0)); |
|
713 end += TTimeIntervalDays(1); |
|
714 |
|
715 SetEntryStartAndEndTimeL(entry,start,end); |
|
716 |
|
717 RandomText(summary); |
|
718 entry->SetSummaryL(summary); |
|
719 |
|
720 RandomText(location); |
|
721 entry->SetLocationL(location); |
|
722 |
|
723 RandomText(description); |
|
724 entry->SetDescriptionL(description); |
|
725 |
|
726 if(isRepeat) |
|
727 { |
|
728 //create a daily repeat rule and make sure its repeat start\end date is within the deleting time range |
|
729 TCalRRule rpt(TCalRRule::EDaily); |
|
730 rpt.SetInterval(1); |
|
731 TCalTime repeatStart; |
|
732 TCalTime repeatend; |
|
733 if(isParent) |
|
734 { |
|
735 //make sure the repeat time is within the delete time range |
|
736 repeatStart.SetTimeLocalL(TDateTime(2000, EJune, 0, 0, 0, 0, 0)); |
|
737 repeatend.SetTimeLocalL(TDateTime(2006, EJune, 0, 0, 0, 0, 0)); |
|
738 } |
|
739 else if (index<aNumToAdd/2) |
|
740 { |
|
741 // if this is a child entry, use the entry's recurrance time as repeating rule |
|
742 // start time |
|
743 TCalTime recurrId = entry->RecurrenceIdL(); |
|
744 |
|
745 // make sure the repeat time is within the delete time range for the first half entries |
|
746 repeatStart.SetTimeLocalL(recurrId.TimeLocalL()); // June 1, 2003 00:00:00 |
|
747 repeatend.SetTimeLocalL(recurrId.TimeLocalL() + TTimeIntervalMonths(1)); // July 1, 2003 00:00:00 |
|
748 } |
|
749 else |
|
750 { |
|
751 //make sure the repeat time is out of the delete time range for the second half entries |
|
752 repeatStart.SetTimeLocalL(TDateTime(2003, EJune, 0, 0, 0, 0, 0)); |
|
753 repeatend.SetTimeLocalL(TDateTime(2007, EJune, 0, 0, 0, 0, 0)); |
|
754 } |
|
755 |
|
756 rpt.SetDtStart(repeatStart); |
|
757 rpt.SetUntil(repeatend); |
|
758 entry->SetRRuleL(rpt); |
|
759 } |
|
760 } |
|
761 |
|
762 TInt entriesStored(0); |
|
763 iLocalEntryView->StoreL(iEntries, entriesStored); //temp |
|
764 test(entriesStored == iEntries.Count()); |
|
765 } |
|
766 |
|
767 |
|
768 void CDummyCalendarApp::DeleteEntryL(const TTime& aStart,const TTime& aEnd, CalCommon::TCalViewFilter aFilter) |
|
769 { |
|
770 TCalTime startTime; |
|
771 TCalTime endTime; |
|
772 startTime.SetTimeLocalL(aStart); |
|
773 endTime.SetTimeLocalL(aEnd); |
|
774 CalCommon::TCalTimeRange range(startTime,endTime); |
|
775 iProgressNotifications = 0; |
|
776 iLocalEntryView->DeleteL(range, aFilter, *this); |
|
777 } |
|
778 |
|
779 void CDummyCalendarApp::DeleteAllTodosL() |
|
780 { |
|
781 delete iTestLib; |
|
782 iTestLib = NULL; |
|
783 |
|
784 TBuf<60> dtBuf; |
|
785 iTestLib = CCalTestLibrary::NewL(); |
|
786 |
|
787 TRAPD(err, iTestLib->PIMTestServer().DeleteFileL(KCalendarFile2)); |
|
788 if(err != KErrNotFound || err != KErrPathNotFound) |
|
789 { |
|
790 User::LeaveIfError(err); |
|
791 } |
|
792 iTestLib->PIMTestServer().CopyFileL(KOriginalDeleteCalendar, _L("c:\\private\\10003A5B\\tcal_delete_calendar_copy")); |
|
793 iTestLib->RegisterCalFileL(KCalendarFile2); |
|
794 iTestLib->OpenFileL(KCalendarFile2); |
|
795 iTestLib->PIMTestServer().SetTimeZoneL(_L8("Europe/Helsinki")); |
|
796 |
|
797 TCalTime minTime; |
|
798 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
799 TCalTime maxTime; |
|
800 maxTime.SetTimeUtcL(TCalTime::MaxTime()); |
|
801 CalCommon::TCalTimeRange timeRange(minTime, maxTime); |
|
802 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
803 |
|
804 //DeleteL has to be placed in the end of the function |
|
805 //because it is a long running operation and it needs |
|
806 //to wait for callback in order to go to the next step. |
|
807 iTestLib->SynCGetEntryViewL().DeleteL(timeRange, filter, *this); |
|
808 } |
|
809 |
|
810 void CDummyCalendarApp::DeleteAllMemosBeginL() |
|
811 { |
|
812 test.Printf(_L("Test: DeleteAllMemosBeginL\r\n")); |
|
813 //Add 1000 entries |
|
814 test.Printf(_L("Adding 1000 Memos...\r\n")); |
|
815 |
|
816 const TInt KNumEntriesToAdd(1000); |
|
817 |
|
818 iTestLib->OpenFileL(KCalendarFile); |
|
819 |
|
820 for (TInt i(0) ; i < KNumEntriesToAdd ; ++i) |
|
821 { |
|
822 HBufC8* guid = NULL; |
|
823 CCalEntry* entry = iTestLib->CreateCalEntryL(CCalEntry::EReminder, guid); |
|
824 CleanupStack::PushL(entry); |
|
825 |
|
826 SetEntryStartAndEndTimeL(entry, |
|
827 TDateTime(2005, ESeptember, 12, 0, 0, 0, 0), |
|
828 TDateTime(2005, ESeptember, 12, 1, 0, 0, 0)); |
|
829 |
|
830 RPointerArray<CCalEntry> entryArray; |
|
831 CleanupClosePushL(entryArray); |
|
832 |
|
833 entryArray.AppendL(entry); |
|
834 TInt num; |
|
835 iTestLib->SynCGetEntryViewL().StoreL(entryArray, num); |
|
836 |
|
837 CleanupStack::PopAndDestroy(&entryArray); |
|
838 CleanupStack::PopAndDestroy(entry); |
|
839 |
|
840 test.Printf(_L(".")); |
|
841 } |
|
842 |
|
843 TCalTime minTime; |
|
844 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
845 TCalTime maxTime; |
|
846 maxTime.SetTimeUtcL(TCalTime::MaxTime()); |
|
847 CalCommon::TCalTimeRange timeRange(minTime, maxTime); |
|
848 |
|
849 iActive->SetStep(CAppActive::EDeleteAllMemosMiddle); |
|
850 |
|
851 //Attempt to delete all the entries |
|
852 test.Printf(_L("Deleting all the entries...\r\n")); |
|
853 iTestLib->SynCGetEntryViewL().DeleteL(timeRange, CCalEntry::EReminder, *this); |
|
854 CActiveScheduler::Start(); |
|
855 delete iTestLib; |
|
856 iTestLib = NULL; |
|
857 } |
|
858 |
|
859 void CDummyCalendarApp::DeleteAllMemosEndL() |
|
860 { |
|
861 test.Printf(_L("Test: DeleteAllMemosEndL\r\n")); |
|
862 test.Printf(_L("Interrupting the delete...\r\n")); |
|
863 |
|
864 //Get a time range |
|
865 TCalTime minTime; |
|
866 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
867 TCalTime maxTime; |
|
868 maxTime.SetTimeUtcL(TCalTime::MaxTime()); |
|
869 CalCommon::TCalTimeRange timeRange(minTime, maxTime); |
|
870 |
|
871 test.Printf(_L("Done!\r\n")); |
|
872 |
|
873 iTestLib = CCalTestLibrary::NewL(EFalse); |
|
874 iTestLib->OpenFileL(KCalendarFile); |
|
875 |
|
876 test.Printf(_L("Deleteing all the entiries again...\r\n")); |
|
877 iTestLib->SynCGetEntryViewL().DeleteL(timeRange, CCalEntry::EReminder, *this); |
|
878 } |
|
879 void CDummyCalendarApp::StoreManyEntriesL(TInt aCount) |
|
880 { |
|
881 AddEntryL(aCount, ETrue, EFalse); |
|
882 test(CheckEntryNumL(EAll,aCount)); |
|
883 } |
|
884 |
|
885 |
|
886 |
|
887 void CDummyCalendarApp::RepeatExceptedEntryCreateL() |
|
888 { |
|
889 test.Next(_L("Add entry, repeat twice, set excepted and delete")); |
|
890 |
|
891 iEntries.ResetAndDestroy(); |
|
892 |
|
893 // Create new calendar entry. |
|
894 CCalEntry* entry = NULL; |
|
895 HBufC8* guid = KGUIDInc081869().AllocLC(); |
|
896 entry = CreateCalEntryL(CCalEntry::EAppt, guid); |
|
897 CleanupStack::Pop(guid); |
|
898 |
|
899 iEntries.AppendL(entry); |
|
900 |
|
901 // Set start and end date. |
|
902 TTime start(TDateTime(2006, EMarch, 6, 10, 0, 0, 0)); |
|
903 TTime end(TDateTime(2006, EMarch, 6, 14, 0, 0, 0)); |
|
904 SetEntryStartAndEndTimeL(entry, start, end); |
|
905 |
|
906 TBuf<50> summary; |
|
907 RandomText(summary); |
|
908 entry->SetSummaryL(summary); |
|
909 |
|
910 TBuf<50> location; |
|
911 RandomText(location); |
|
912 entry->SetLocationL(location); |
|
913 |
|
914 TBuf<50> description; |
|
915 RandomText(description); |
|
916 entry->SetDescriptionL(description); |
|
917 |
|
918 // Create a daily repeating rule that occurs for 2 days. |
|
919 TCalRRule rpt(TCalRRule::EDaily); |
|
920 rpt.SetInterval(1); |
|
921 rpt.SetCount(2); |
|
922 |
|
923 // Make sure the repeat time is within the delete time range. |
|
924 TCalTime repeatStart; |
|
925 TCalTime repeatEnd; |
|
926 repeatStart.SetTimeLocalL(TDateTime(2006, EMarch, 6, 0, 0, 0, 0)); |
|
927 repeatEnd.SetTimeLocalL(TDateTime(2006, EMarch, 8, 0, 0, 0, 0)); |
|
928 rpt.SetDtStart(repeatStart); |
|
929 rpt.SetUntil(repeatEnd); |
|
930 entry->SetRRuleL(rpt); |
|
931 |
|
932 // Store the entry. Because it repeats over 2 days, there will |
|
933 // be 2 entries. |
|
934 TInt entriesStored(0); |
|
935 SynCGetEntryViewL().StoreL(iEntries, entriesStored); |
|
936 test(entriesStored == iEntries.Count()); |
|
937 } |
|
938 |
|
939 void CDummyCalendarApp::RepeatExceptedEntryFetchInstancesL( |
|
940 RPointerArray<CCalInstance>& aInstances ) |
|
941 { |
|
942 // Create a time range filter that returns all instances. |
|
943 TCalTime minTime; |
|
944 minTime.SetTimeUtcL(TCalTime::MinTime()); |
|
945 TCalTime maxTime; |
|
946 maxTime.SetTimeUtcL(TCalTime::MaxTime()); |
|
947 CalCommon::TCalTimeRange timeRange(minTime, maxTime); |
|
948 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
949 |
|
950 CleanupResetAndDestroyPushL(aInstances); |
|
951 |
|
952 // Get all instances. |
|
953 AsynCGetInstanceViewL().FindInstanceL(aInstances, filter, timeRange); |
|
954 test(aInstances.Count() >= 2); |
|
955 CleanupStack::Pop(&aInstances); |
|
956 } |
|
957 |
|
958 void CDummyCalendarApp::RepeatExceptedEntryEditInstancesL( |
|
959 RPointerArray<CCalInstance>& aInstances ) |
|
960 { |
|
961 CleanupResetAndDestroyPushL(aInstances); |
|
962 |
|
963 // Delete all entries. |
|
964 iEntries.ResetAndDestroy(); |
|
965 |
|
966 TTime start(TDateTime(2006, EMarch, 6, 10, 0, 0, 0)); |
|
967 TTime end(TDateTime(2006, EMarch, 6, 14, 0, 0, 0)); |
|
968 |
|
969 // Re-create all the entries that previously existed. |
|
970 CCalEntry* entry = NULL; |
|
971 for (TUint i = 0; i < aInstances.Count(); ++i) |
|
972 { |
|
973 HBufC8* guid = KGUIDInc081869().AllocLC(); |
|
974 entry = CCalEntry::NewL( CCalEntry::EAppt, guid, CCalEntry::EMethodAdd, |
|
975 i, aInstances[i]->Time(), CalCommon::EThisOnly ); |
|
976 CleanupStack::Pop( guid ); |
|
977 iEntries.AppendL( entry ); |
|
978 |
|
979 SetEntryStartAndEndTimeL(entry, start, end); |
|
980 } |
|
981 |
|
982 CleanupStack::PopAndDestroy(&aInstances); |
|
983 |
|
984 // Store the entries again, there should be 2. |
|
985 TInt entriesStored = 0; |
|
986 SynCGetEntryViewL().StoreL(iEntries, entriesStored); |
|
987 test(entriesStored == iEntries.Count()); |
|
988 } |
|
989 |
|
990 TInt CDummyCalendarApp::ProgressNotificationCount() |
|
991 { |
|
992 return iProgressNotifications; |
|
993 } |
|
994 |
|
995 |
|
996 |
|
997 void CDummyCalendarApp::Add3ReminderAnd1ApptL() |
|
998 { |
|
999 test.Next(_L("Create some entries including day note and delete them")); |
|
1000 |
|
1001 |
|
1002 //Create entries |
|
1003 iEntries.ResetAndDestroy(); |
|
1004 //create reminder 1 |
|
1005 TBuf8<255> buf; |
|
1006 buf.Append(_L("GuidId_Reminder_1")); |
|
1007 HBufC8* guid = buf.AllocLC(); |
|
1008 CCalEntry* reminder1 = CCalEntry::NewL(CCalEntry::EReminder, guid, CCalEntry::EMethodAdd, 0); |
|
1009 CleanupStack::Pop(guid); |
|
1010 iEntries.AppendL(reminder1); |
|
1011 |
|
1012 TCalTime starttime; |
|
1013 starttime.SetTimeLocalL(TDateTime(2006, EMarch, 5, 0, 0, 0, 0)); |
|
1014 reminder1->SetStartAndEndTimeL(starttime, starttime); |
|
1015 |
|
1016 TBuf<50> summary; |
|
1017 RandomText(summary); |
|
1018 reminder1->SetSummaryL(summary); |
|
1019 |
|
1020 //create reminder 2 |
|
1021 buf.Delete(buf.Length()-1,1); |
|
1022 buf.Append(2); |
|
1023 guid = buf.AllocLC(); |
|
1024 CCalEntry* reminder2 = CCalEntry::NewL(CCalEntry::EReminder, guid, CCalEntry::EMethodAdd, 0); |
|
1025 CleanupStack::Pop(guid); |
|
1026 iEntries.AppendL(reminder2); |
|
1027 starttime.SetTimeLocalL(TDateTime(2006, EMarch, 6, 0, 0, 0, 0)); |
|
1028 reminder2->SetStartAndEndTimeL(starttime, starttime); |
|
1029 RandomText(summary); |
|
1030 reminder2->SetSummaryL(summary); |
|
1031 |
|
1032 //create reminder 3 |
|
1033 buf.Delete(buf.Length()-1,1); |
|
1034 buf.Append(3); |
|
1035 guid = buf.AllocLC(); |
|
1036 CCalEntry* reminder3 = CCalEntry::NewL(CCalEntry::EReminder, guid, CCalEntry::EMethodAdd, 0); |
|
1037 CleanupStack::Pop(guid); |
|
1038 iEntries.AppendL(reminder3); |
|
1039 starttime.SetTimeLocalL(TDateTime(2006, EMarch, 7, 0, 0, 0, 0)); |
|
1040 reminder3->SetStartAndEndTimeL(starttime, starttime); |
|
1041 RandomText(summary); |
|
1042 reminder3->SetSummaryL(summary); |
|
1043 |
|
1044 //Create appt |
|
1045 buf.Zero(); |
|
1046 buf.Append(_L("GuidId_Appt")); |
|
1047 guid = buf.AllocLC(); |
|
1048 CCalEntry* appt = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodAdd, 0); |
|
1049 CleanupStack::Pop(guid); |
|
1050 iEntries.AppendL(appt); |
|
1051 |
|
1052 starttime.SetTimeLocalL(TDateTime(2006, EMarch, 7, 14, 0, 0, 0)); |
|
1053 TTime endtimetime(TDateTime(2006, EMarch, 7, 14, 0, 0, 0)); |
|
1054 endtimetime +=TTimeIntervalHours(1); |
|
1055 TCalTime endtime; |
|
1056 endtime.SetTimeLocalL(endtimetime); |
|
1057 appt->SetStartAndEndTimeL(starttime, endtime); |
|
1058 |
|
1059 RandomText(summary); |
|
1060 appt->SetSummaryL(summary); |
|
1061 |
|
1062 //store 4 entries |
|
1063 TInt entriesStored(0); |
|
1064 SynCGetEntryViewL().StoreL(iEntries, entriesStored); |
|
1065 test(entriesStored == 4); |
|
1066 iEntries.ResetAndDestroy(); |
|
1067 } |
|
1068 |
|
1069 |
|
1070 void CDummyCalendarApp::AddFloatingEntryWithMinStartTimeL() |
|
1071 {//Defect fix for PDEF111562 - when a floating entry with miniman start time will never get deleted. |
|
1072 iEntries.ResetAndDestroy(); |
|
1073 |
|
1074 _LIT8(KUid, "UID_MinEntry"); |
|
1075 HBufC8* guid = KUid().AllocLC(); |
|
1076 CCalEntry* entry = iTestLib->CreateCalEntryL(CCalEntry::EReminder, guid); |
|
1077 CleanupStack::Pop(guid); |
|
1078 CleanupStack::PushL(entry); |
|
1079 TCalTime caltimestart,caltimeend; |
|
1080 TTime min(TDateTime(1900, EJanuary, 0, 0, 0, 0, 0)); |
|
1081 caltimestart.SetTimeLocalFloatingL(min); |
|
1082 entry->SetStartAndEndTimeL(caltimestart,caltimestart); |
|
1083 iEntries.AppendL(entry); |
|
1084 CleanupStack::Pop(entry); |
|
1085 TInt entriesStored(0); |
|
1086 SynCGetEntryViewL().StoreL(iEntries, entriesStored); //temp |
|
1087 iEntries.ResetAndDestroy(); |
|
1088 } |
|
1089 |
|
1090 void CAppActive::RunL() |
|
1091 { |
|
1092 TTime start(TDateTime(2000, EJanuary, 0, 0, 0, 0, 0)); |
|
1093 TTime end(TDateTime(2006, EDecember, 0, 0, 0, 0, 0)); |
|
1094 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
1095 switch (iStep) |
|
1096 { |
|
1097 case EStepOpenModel: |
|
1098 iApp.OpenModelL(); |
|
1099 iStep = ESimpleEntryDeleteAll; |
|
1100 break; |
|
1101 |
|
1102 case ESimpleEntryDeleteAll: |
|
1103 // Create half todos and half appointments and store the entries |
|
1104 // to the file. |
|
1105 iApp.StoreSimpleEntryL(); |
|
1106 iApp.DeleteEntryL(start, end, filter); |
|
1107 iStep = ESimpleEntryDeleteSome; |
|
1108 break; |
|
1109 |
|
1110 case ESimpleEntryDeleteSome: |
|
1111 // Check whether all entries have been deleted. |
|
1112 test(iApp.CheckEntryNumL(CDummyCalendarApp::EAll,0)); |
|
1113 |
|
1114 // Store entry back to the file. |
|
1115 iApp.StoreSimpleEntryL(); |
|
1116 |
|
1117 // Delete only Appointments from the file. |
|
1118 filter = CalCommon::EIncludeAppts; |
|
1119 iApp.DeleteEntryL(start, end, filter); |
|
1120 iStep = EDeleteRestEntry; |
|
1121 break; |
|
1122 |
|
1123 case EDeleteRestEntry: |
|
1124 //Check only Todos are left in file . |
|
1125 test(iApp.CheckEntryNumL(CDummyCalendarApp::ETodo,KNumberOfEntries/2)); |
|
1126 filter = CalCommon::EIncludeAll; |
|
1127 |
|
1128 //Delete the rest of entries |
|
1129 iApp.DeleteEntryL(start, end, filter); |
|
1130 iStep = ERepeatEntryDelete; |
|
1131 break; |
|
1132 |
|
1133 case ERepeatEntryDelete: |
|
1134 // Check all entries are deleted. |
|
1135 test(iApp.CheckEntryNumL(CDummyCalendarApp::EAll,0)); |
|
1136 |
|
1137 // Store KNumberOfEntries mumber of parent entries |
|
1138 // and KNumberOfEntries mumber of children entries |
|
1139 // half of children entries are within the delete time range |
|
1140 // The other half are not |
|
1141 iApp.StoreRepeatEntryL(); |
|
1142 |
|
1143 // Delete entries |
|
1144 iApp.DeleteEntryL(start, end, filter); |
|
1145 iStep = EDeleteAndCheckProgress; |
|
1146 break; |
|
1147 |
|
1148 case EDeleteAndCheckProgress: |
|
1149 // Check parent and its children entries have been deleted only if |
|
1150 // all of them are within the time range are not deleted. |
|
1151 test( iApp.CheckEntryNumL( CDummyCalendarApp::EAll, KNumberOfEntries/2 ) ); |
|
1152 |
|
1153 // Add enough entries to force Progress Notifications during delete |
|
1154 iApp.StoreManyEntriesL(50); |
|
1155 |
|
1156 // Delete all the entries |
|
1157 iApp.DeleteEntryL(TCalTime::MinTime(), TCalTime::MaxTime(), filter); |
|
1158 iStep = EDeleteAllTodos; |
|
1159 break; |
|
1160 |
|
1161 case EDeleteAllTodos: |
|
1162 // Check that we received some progress notifications. |
|
1163 test( iApp.ProgressNotificationCount() > 0 ); |
|
1164 |
|
1165 // Check all entries are deleted |
|
1166 test(iApp.CheckEntryNumL(CDummyCalendarApp::EAll,0)); |
|
1167 //Delete a thousand entries contained in the calendar file. |
|
1168 iApp.DeleteAllTodosL(); |
|
1169 iStep = ERepeatExceptedEntryCreate; |
|
1170 break; |
|
1171 |
|
1172 case ERepeatExceptedEntryCreate: |
|
1173 // Check all entries are deleted. |
|
1174 test( iApp.CheckEntryNumL( CDummyCalendarApp::EAll, 0 ) ); |
|
1175 |
|
1176 // Make sure the databse is clean for the next test case. |
|
1177 iApp.CleanDatabaseL(); |
|
1178 |
|
1179 // Create the entry with repeating rule. There will be 2 entries |
|
1180 // after this. |
|
1181 iApp.RepeatExceptedEntryCreateL(); |
|
1182 |
|
1183 // Being an active object, we need to kick it for the next loop. |
|
1184 Start(); |
|
1185 iStep = ERepeatExceptedEntryFetchInstances; |
|
1186 break; |
|
1187 |
|
1188 case ERepeatExceptedEntryFetchInstances: |
|
1189 // Fetch the 2 entries for modification. |
|
1190 iApp.RepeatExceptedEntryFetchInstancesL( iInstances ); |
|
1191 iStep = ERepeatExceptedEntryEditInstances; |
|
1192 break; |
|
1193 |
|
1194 case ERepeatExceptedEntryEditInstances: |
|
1195 // Modify the entries and commit. |
|
1196 iApp.RepeatExceptedEntryEditInstancesL( iInstances ); |
|
1197 Start(); |
|
1198 iStep = ERepeatExceptedEntryDelete; |
|
1199 break; |
|
1200 |
|
1201 case ERepeatExceptedEntryDelete: |
|
1202 // Delete all the entries. |
|
1203 iApp.DeleteEntryL( TCalTime::MinTime(), TCalTime::MaxTime(), CalCommon::EIncludeAll ); |
|
1204 iStep = EDeleteRemiderAndMore; |
|
1205 break; |
|
1206 |
|
1207 case EDeleteRemiderAndMore: |
|
1208 //Check all entries are deleted. |
|
1209 test(iApp.CheckEntryNumL(CDummyCalendarApp::EAll,0)); |
|
1210 |
|
1211 iApp.Add3ReminderAnd1ApptL(); |
|
1212 end = TDateTime(2006, EMarch, 7, 0, 0, 0, 0); |
|
1213 iApp.DeleteEntryL(TCalTime::MinTime(), end, filter); |
|
1214 iStep = ELockedInOtherThreadDuringDelete; |
|
1215 break; |
|
1216 case ELockedInOtherThreadDuringDelete: |
|
1217 iApp.DeleteWhileAnotherThreadAccessesCalendarL(); |
|
1218 iStep = EDeleteEntryWithMinTime; |
|
1219 Start(); |
|
1220 break; |
|
1221 |
|
1222 case EDeleteEntryWithMinTime: |
|
1223 test(iApp.CheckEntryNumL(CDummyCalendarApp::EApp, 1)); |
|
1224 _LIT8(KHong_Kong, "Asia/Hong_Kong"); |
|
1225 iApp.SetTimeZoneL(KHong_Kong); |
|
1226 iApp.AddFloatingEntryWithMinStartTimeL(); |
|
1227 iApp.DeleteEntryL(TCalTime::MinTime(), TCalTime::MaxTime(), filter); |
|
1228 iStep = EAddForDeleteBeforeDateWithException; |
|
1229 break; |
|
1230 |
|
1231 case EAddForDeleteBeforeDateWithException: |
|
1232 // Make sure the databse is clean for the next test case. |
|
1233 iApp.CleanDatabaseL(); |
|
1234 // Add a repeat entry; startdate 6 March 2006 - enddate 8 March 2006 |
|
1235 iApp.RepeatExceptedEntryCreateL(); |
|
1236 Start(); |
|
1237 iStep = EDeleteBeforeDateWithException; |
|
1238 break; |
|
1239 |
|
1240 case EDeleteBeforeDateWithException: |
|
1241 { |
|
1242 TTime startSingleDelete(TDateTime(2006, EMarch, 8, 0, 0, 0, 0)); |
|
1243 TTime endSingleDelete(TDateTime(2006, EMarch, 8, 23, 59, 0, 0)); |
|
1244 // Delete last instance |
|
1245 iApp.DeleteEntryL(startSingleDelete, endSingleDelete, filter); |
|
1246 iStep = EDeleteAllBeforeDateWithException; |
|
1247 } |
|
1248 break; |
|
1249 |
|
1250 case EDeleteAllBeforeDateWithException: |
|
1251 { |
|
1252 // Delete everything before 8th March 2006 |
|
1253 TTime startBeforeDelete(TCalTime::MinTime()); |
|
1254 TTime endBeforeDelete(TDateTime(TDateTime(2006, EMarch, 8, 23, 59, 0, 0)));//2006, EJune, 1, 1, 0, 0, 0)); |
|
1255 iApp.DeleteEntryL(startBeforeDelete, endBeforeDelete, filter); |
|
1256 iStep = EDeleteAllMemosBegin; |
|
1257 } |
|
1258 break; |
|
1259 case EDeleteAllMemosBegin: |
|
1260 { |
|
1261 iApp.CleanDatabaseL(); |
|
1262 iApp.DeleteAllMemosBeginL(); |
|
1263 iStep = EDeleteAllMemosEnd; |
|
1264 } |
|
1265 break; |
|
1266 case EDeleteAllMemosEnd: |
|
1267 { |
|
1268 iApp.DeleteAllMemosEndL(); |
|
1269 iStep = EEnd; |
|
1270 } |
|
1271 break; |
|
1272 |
|
1273 case EEnd: |
|
1274 test(iApp.CheckEntryNumL(CDummyCalendarApp::EAll, 0)); |
|
1275 iApp.SetTimeZoneL(KDefaultTimeZone); |
|
1276 iApp.Close(); |
|
1277 break; |
|
1278 |
|
1279 default: |
|
1280 break; |
|
1281 } |
|
1282 } |
|
1283 |
|
1284 |
|
1285 void CDummyCalendarApp::Close() |
|
1286 { |
|
1287 CActiveScheduler::Stop(); |
|
1288 } |
|
1289 |
|
1290 |
|
1291 void CDummyCalendarApp::AddAOAndStartL() |
|
1292 { |
|
1293 CActiveScheduler::Add(iActive); |
|
1294 iActive->Start(); |
|
1295 } |
|
1296 |
|
1297 |
|
1298 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
1299 * DoTestL() |
|
1300 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
|
1301 |
|
1302 static void DoTestL() |
|
1303 { |
|
1304 CDummyCalendarApp* testManager = CDummyCalendarApp::NewLC(); |
|
1305 |
|
1306 |
|
1307 TPerformanceTimer timer(test); |
|
1308 timer.Start(); |
|
1309 |
|
1310 |
|
1311 // Run the test suite |
|
1312 |
|
1313 testManager->AddAOAndStartL(); |
|
1314 CActiveScheduler::Start(); |
|
1315 |
|
1316 |
|
1317 timer.Stop(); |
|
1318 test.Printf(_L("Done\n")); |
|
1319 // printout performance time |
|
1320 timer.PrintOut(); |
|
1321 |
|
1322 |
|
1323 CleanupStack::PopAndDestroy(testManager); |
|
1324 } |
|
1325 |
|
1326 |
|
1327 /** |
|
1328 |
|
1329 @SYMTestCaseID PIM-TCAL-DELETE-0001 |
|
1330 |
|
1331 */ |
|
1332 |
|
1333 TInt E32Main() |
|
1334 { |
|
1335 __UHEAP_MARK; |
|
1336 |
|
1337 test.Start(_L("@SYMTESTCaseID:PIM-TCAL-DELETE-0001 Calendar Interim API Delete test suite")); |
|
1338 |
|
1339 test.Title(); |
|
1340 |
|
1341 CTrapCleanup* trapCleanup = CTrapCleanup::New(); |
|
1342 if (!trapCleanup) |
|
1343 { |
|
1344 return KErrNoMemory; |
|
1345 } |
|
1346 |
|
1347 CActiveScheduler* scheduler = new CActiveScheduler(); |
|
1348 if (!scheduler) |
|
1349 { |
|
1350 delete trapCleanup; |
|
1351 return KErrNoMemory; |
|
1352 } |
|
1353 CActiveScheduler::Install(scheduler); |
|
1354 |
|
1355 TRAPD(ret, DoTestL()); |
|
1356 test(ret == KErrNone); |
|
1357 |
|
1358 delete scheduler; |
|
1359 delete trapCleanup; |
|
1360 |
|
1361 test.End(); |
|
1362 test.Close(); |
|
1363 |
|
1364 __UHEAP_MARKEND; |
|
1365 |
|
1366 return (KErrNone); |
|
1367 } |