|
1 // Copyright (c) 2006-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 "TestCalIndexFileStepBase.h" |
|
17 #include "TestCalIndexFileDefs.h" |
|
18 #include <f32file.h> |
|
19 #include <bautils.h> |
|
20 |
|
21 #include <calsession.h> |
|
22 #include <calentryview.h> |
|
23 #include <calinstanceview.h> |
|
24 #include <calinstance.h> |
|
25 #include "caltestlib.h" |
|
26 |
|
27 // Constant Literals used. |
|
28 _LIT(KInfoPercentageCompleted, "Percentage Completed %d"); |
|
29 _LIT(KErrPercentageCompleted, "Error progress not required"); |
|
30 _LIT(KErrCompleted, "Error Completed %d"); |
|
31 |
|
32 _LIT(KDefaultDir, "private\\10003a5b"); |
|
33 _LIT(KDefaultFile, "calendar"); |
|
34 _LIT(KDefaultIdx, "calendaridx"); |
|
35 _LIT(KDrive, "drive"); |
|
36 _LIT(KCalendarName, "calendarname"); |
|
37 _LIT(KIndexName, "indexname"); |
|
38 _LIT(KIndexFileDataDir, "\\CalIndexFileTestData\\"); |
|
39 _LIT(KDefaultTestDrive, "C:"); |
|
40 _LIT(KDoubleBackslash, "\\"); |
|
41 |
|
42 |
|
43 TFileName GetFullFileName(const TDesC& aPath) |
|
44 { |
|
45 TFileName fileName; |
|
46 #ifdef __WINS__ |
|
47 fileName.Append(_L("c:")); |
|
48 #else |
|
49 TFileName fullName = RProcess().FileName(); |
|
50 TParsePtrC parse(fullName); |
|
51 fileName.Append(parse.Drive()); |
|
52 #endif |
|
53 fileName.Append(aPath); |
|
54 return fileName; |
|
55 } |
|
56 |
|
57 /*@}*/ |
|
58 |
|
59 CTestCalIndexFileStepBase::CTestCalIndexFileStepBase() |
|
60 : CTestStep() |
|
61 , iNotifyProgress(ETrue) |
|
62 , iActiveScheduler(NULL) |
|
63 , iFsSessionConnected(EFalse) |
|
64 , iSession(NULL) |
|
65 { |
|
66 } |
|
67 |
|
68 CTestCalIndexFileStepBase::~CTestCalIndexFileStepBase() |
|
69 { |
|
70 delete iSession; |
|
71 delete iActiveScheduler; |
|
72 iFsSession.Close(); |
|
73 } |
|
74 |
|
75 void CTestCalIndexFileStepBase::Progress(TInt aPercentageCompleted) |
|
76 { |
|
77 if ( iNotifyProgress ) |
|
78 { |
|
79 INFO_PRINTF2(KInfoPercentageCompleted, aPercentageCompleted); |
|
80 } |
|
81 else |
|
82 { |
|
83 ERR_PRINTF1(KErrPercentageCompleted); |
|
84 SetTestStepResult(EFail); |
|
85 } |
|
86 } |
|
87 |
|
88 void CTestCalIndexFileStepBase::Completed(TInt aError) |
|
89 { |
|
90 if ( aError!=KErrNone ) |
|
91 { |
|
92 ERR_PRINTF2(KErrCompleted, aError); |
|
93 SetTestStepResult(EFail); |
|
94 SetTestStepError(aError); |
|
95 } |
|
96 CActiveScheduler::Stop(); |
|
97 } |
|
98 |
|
99 TBool CTestCalIndexFileStepBase::NotifyProgress() |
|
100 { |
|
101 return iNotifyProgress; |
|
102 } |
|
103 |
|
104 TVerdict CTestCalIndexFileStepBase::doTestStepPreambleL() |
|
105 /** |
|
106 * @return - TVerdict |
|
107 */ |
|
108 { |
|
109 INFO_PRINTF1(_L("enter CTestCalIndexFileStepBase::doTestStepPreambleL()")); |
|
110 iActiveScheduler = new(ELeave)CActiveScheduler; |
|
111 CActiveScheduler::Install(iActiveScheduler); |
|
112 INFO_PRINTF1(_L("exit CTestCalIndexFileStepBase::doTestStepPreambleL()")); |
|
113 return (EPass); |
|
114 } |
|
115 |
|
116 TVerdict CTestCalIndexFileStepBase::doTestStepPostambleL() |
|
117 /** |
|
118 * @return - TVerdict |
|
119 */ |
|
120 { |
|
121 return (EPass); |
|
122 } |
|
123 |
|
124 |
|
125 void CTestCalIndexFileStepBase::SetUpCalDirL() |
|
126 { |
|
127 // determine calendar directory from ini |
|
128 // if not present use default |
|
129 |
|
130 TPtrC drive; |
|
131 TBool readRes = EFalse; |
|
132 TFileName driveName; |
|
133 readRes = GetStringFromConfig(ConfigSection(), KDrive, drive); |
|
134 if (readRes) |
|
135 { |
|
136 iDriveName = drive; |
|
137 } |
|
138 else |
|
139 { |
|
140 iDriveName = KDefaultTestDrive(); |
|
141 } |
|
142 |
|
143 iDir = iDriveName; |
|
144 iDir.Append(KDoubleBackslash()); |
|
145 iDir.Append(KDefaultDir()); |
|
146 iDir.Append(KDoubleBackslash()); |
|
147 |
|
148 // store the relevant file names for the calendar and |
|
149 // index and delete them from the directory if they already |
|
150 // exist |
|
151 if (!iFsSessionConnected) |
|
152 { |
|
153 iFsSession.Connect(); |
|
154 iFsSessionConnected = ETrue; |
|
155 } |
|
156 |
|
157 // calendar file |
|
158 TPtrC calendarName; |
|
159 |
|
160 readRes = GetStringFromConfig(ConfigSection(), KCalendarName, calendarName); |
|
161 if (readRes) |
|
162 { |
|
163 iCalendarName = calendarName; |
|
164 } |
|
165 else |
|
166 { |
|
167 iCalendarName = KDefaultFile(); |
|
168 } |
|
169 |
|
170 TFileName fName; |
|
171 fName = iDir; |
|
172 fName.Append(iCalendarName); |
|
173 if (BaflUtils::FileExists(iFsSession, fName)) |
|
174 { |
|
175 iFsSession.Delete(fName); |
|
176 } |
|
177 |
|
178 // index file |
|
179 TPtrC indexName; |
|
180 readRes = EFalse; |
|
181 readRes = GetStringFromConfig(ConfigSection(), KIndexName, indexName); |
|
182 if (readRes) |
|
183 { |
|
184 iIndexName = indexName; |
|
185 } |
|
186 else |
|
187 { |
|
188 iIndexName = KDefaultIdx(); |
|
189 } |
|
190 |
|
191 fName = iDir; |
|
192 fName.Append(iIndexName); |
|
193 if (BaflUtils::FileExists(iFsSession, fName)) |
|
194 { |
|
195 iFsSession.Delete(fName); |
|
196 } |
|
197 |
|
198 iFsSession.Close(); |
|
199 iFsSessionConnected = EFalse; |
|
200 INFO_PRINTF1(_L("exit CTestCalIndexFileStepBase::SetUpCalDirL()")); |
|
201 } |
|
202 |
|
203 void CTestCalIndexFileStepBase::MakeCalendarFileName(TFileName& aCalFile) |
|
204 { |
|
205 aCalFile = iDriveName; |
|
206 aCalFile.Append(iCalendarName); |
|
207 } |
|
208 |
|
209 void CTestCalIndexFileStepBase::AddCalendarFileL() |
|
210 { |
|
211 // copy file from stored data area to target directory |
|
212 TFileName trgtName; |
|
213 trgtName = iDir; |
|
214 trgtName.Append(iCalendarName); |
|
215 |
|
216 TFileName srcName = GetFullFileName(KIndexFileDataDir); |
|
217 srcName.Append(iCalendarName); |
|
218 |
|
219 if (!iFsSessionConnected) |
|
220 { |
|
221 iFsSession.Connect(); |
|
222 iFsSessionConnected = ETrue; |
|
223 } |
|
224 CFileMan* fileman = CFileMan::NewL(iFsSession); |
|
225 CleanupStack::PushL(fileman); |
|
226 fileman->Copy(srcName, trgtName); |
|
227 CleanupStack::PopAndDestroy(fileman); |
|
228 iFsSession.Close(); |
|
229 iFsSessionConnected = EFalse; |
|
230 } |
|
231 |
|
232 void CTestCalIndexFileStepBase::AddIndexFileL() |
|
233 { |
|
234 // copy file from stored data area to target directory |
|
235 TFileName trgtName; |
|
236 trgtName = iDir; |
|
237 trgtName.Append(iIndexName); |
|
238 |
|
239 TFileName srcName = GetFullFileName(KIndexFileDataDir); |
|
240 srcName.Append(iIndexName); |
|
241 |
|
242 if (!iFsSessionConnected) |
|
243 { |
|
244 iFsSession.Connect(); |
|
245 iFsSessionConnected = ETrue; |
|
246 } |
|
247 CFileMan* fileman = CFileMan::NewL(iFsSession); |
|
248 CleanupStack::PushL(fileman); |
|
249 fileman->Copy(srcName, trgtName); |
|
250 CleanupStack::PopAndDestroy(fileman); |
|
251 iFsSession.Close(); |
|
252 iFsSessionConnected = EFalse; |
|
253 } |
|
254 |
|
255 void CTestCalIndexFileStepBase::OpenAgendaL() |
|
256 { |
|
257 // create a calendar session using the filename & directory |
|
258 // retrieved earlier |
|
259 |
|
260 iSession = CCalSession::NewL(); |
|
261 |
|
262 TFileName calName; |
|
263 MakeCalendarFileName(calName); |
|
264 iSession->OpenL(calName); |
|
265 } |
|
266 |
|
267 void CTestCalIndexFileStepBase::CloseAgendaL() |
|
268 { |
|
269 // close the session to which we have a pointer |
|
270 delete iSession; |
|
271 iSession = NULL; |
|
272 |
|
273 // a little pause to let the index file get written |
|
274 TTimeIntervalMicroSeconds32 delay = 7000000; // 7 s - we need to wait more than 5s due to the delay introduced by CR0979. |
|
275 User::After(delay); |
|
276 } |
|
277 |
|
278 |
|
279 TBool CTestCalIndexFileStepBase::CheckIndexFilePresentL() |
|
280 { |
|
281 // check if indexfile is in directory |
|
282 TFileName idxName; |
|
283 idxName = iDir; |
|
284 idxName.Append(iIndexName); |
|
285 |
|
286 if (!iFsSessionConnected) |
|
287 { |
|
288 iFsSession.Connect(); |
|
289 iFsSessionConnected = ETrue; |
|
290 } |
|
291 RFile idxFile; |
|
292 |
|
293 TBool result = BaflUtils::FileExists(iFsSession, idxName); |
|
294 iFsSession.Close(); |
|
295 iFsSessionConnected = EFalse; |
|
296 return result; |
|
297 } |
|
298 |
|
299 |
|
300 TBool CTestCalIndexFileStepBase::CheckCalendarFilePresentL() |
|
301 { |
|
302 // check if calendar file is in directory |
|
303 TFileName calName; |
|
304 calName = iDir; |
|
305 calName.Append(iCalendarName); |
|
306 |
|
307 if (!iFsSessionConnected) |
|
308 { |
|
309 iFsSession.Connect(); |
|
310 iFsSessionConnected = ETrue; |
|
311 } |
|
312 RFile calFile; |
|
313 |
|
314 TBool result = BaflUtils::FileExists(iFsSession, calName); |
|
315 iFsSession.Close(); |
|
316 iFsSessionConnected = EFalse; |
|
317 return result; |
|
318 } |
|
319 |
|
320 void CTestCalIndexFileStepBase::GetEntryInfoFromConfigL(RPointerArray<CConfigTestEntryInfo>& aEntriesInfo, TInt& aNumEntries, TBool aPerformCrudOps) |
|
321 { |
|
322 // for the base class we don't care about CRUD operations |
|
323 aPerformCrudOps = aPerformCrudOps; |
|
324 |
|
325 for (TInt i = 0; i < aNumEntries; i++) |
|
326 { |
|
327 HBufC* entryBuf = HBufC::NewL(KTCIEntry().Length()+ 4); // add 4 to allow for 4 digits of entries |
|
328 CleanupStack::PushL(entryBuf); |
|
329 *entryBuf = KTCIEntry(); |
|
330 TPtr ptr(entryBuf->Des()); |
|
331 ptr.AppendNum(i+1); |
|
332 TPtrC entryString; |
|
333 TBool readRes = EFalse; |
|
334 readRes = GetStringFromConfig(ConfigSection(), ptr, entryString); |
|
335 if (!readRes) |
|
336 { |
|
337 INFO_PRINTF2(_L("Error in CTestCalIndexFileStepBase::GetEntryInfoFromConfigL - entry%d not found in config file"),(i+1)); |
|
338 User::Leave(KErrNotFound); |
|
339 } |
|
340 CConfigTestEntryInfo* inf = new(ELeave)CConfigTestEntryInfo(); |
|
341 CleanupStack::PushL(inf); |
|
342 ParseEntryStringL(*inf, entryString); |
|
343 aEntriesInfo.Append(inf); |
|
344 CleanupStack::Pop(inf); // now in array to be cleaned up |
|
345 CleanupStack::PopAndDestroy(entryBuf); |
|
346 } |
|
347 |
|
348 } |
|
349 |
|
350 |
|
351 TBool CTestCalIndexFileStepBase::ValidateDbContentsL(TBool aPerformCrudOps) |
|
352 { |
|
353 // for each entry in the database validate ALL relevant |
|
354 // fields against info for the entry in the ini file |
|
355 TInt numEntries; |
|
356 TBool readRes = EFalse; |
|
357 readRes = GetIntFromConfig(ConfigSection(),KTCINumEntries, numEntries); |
|
358 if (!readRes) |
|
359 { |
|
360 INFO_PRINTF1(_L("Error in CTestCalIndexFileStepBase::ValidateDbContentsL - numentriespresent not found in config file")); |
|
361 User::Leave(KErrNotFound); |
|
362 } |
|
363 |
|
364 if (numEntries == 0) |
|
365 { |
|
366 return ETrue; |
|
367 } |
|
368 |
|
369 RPointerArray<CConfigTestEntryInfo> entriesInfo; |
|
370 CleanupResetAndDestroyPushL(entriesInfo); |
|
371 |
|
372 GetEntryInfoFromConfigL(entriesInfo, numEntries, aPerformCrudOps); |
|
373 |
|
374 // for each entry in the list of entries, see if we can find a |
|
375 // match in the database using an instance view |
|
376 for (TInt j = 0; j < numEntries; j++) |
|
377 { |
|
378 INFO_PRINTF2(_L("Trying to validate entry info - %d"),(j+1)); |
|
379 CConfigTestEntryInfo* infoToUse = entriesInfo[j]; |
|
380 |
|
381 CCalProgress* progress = new(ELeave)CCalProgress; |
|
382 CleanupStack::PushL(progress); //1 |
|
383 |
|
384 CCalInstanceView* view = CCalInstanceView::NewL(*iSession, *progress); |
|
385 CleanupStack::PushL(view); //2 |
|
386 |
|
387 CActiveScheduler::Start(); |
|
388 |
|
389 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAppts; |
|
390 switch (infoToUse->iType) |
|
391 { |
|
392 case (CCalEntry::EAppt): |
|
393 filter = CalCommon::EIncludeAppts; |
|
394 break; |
|
395 case (CCalEntry::ETodo): |
|
396 filter = CalCommon::EIncludeCompletedTodos | CalCommon::EIncludeIncompletedTodos; |
|
397 break; |
|
398 case (CCalEntry::EEvent): |
|
399 filter = CalCommon::EIncludeEvents; |
|
400 break; |
|
401 case (CCalEntry::EReminder): |
|
402 filter = CalCommon::EIncludeReminder; |
|
403 break; |
|
404 case (CCalEntry::EAnniv): |
|
405 filter = CalCommon::EIncludeAnnivs; |
|
406 break; |
|
407 default: |
|
408 User::Leave(KErrCorrupt); |
|
409 break; |
|
410 } |
|
411 RPointerArray<CCalInstance> instances; |
|
412 CleanupResetAndDestroyPushL(instances); |
|
413 |
|
414 // look for instances between (startdate -1 day) and |
|
415 // (enddate + 1 day) |
|
416 TTimeIntervalDays oneDay(1); |
|
417 TTime beginTTime = (infoToUse->iStartTime) - oneDay; |
|
418 TTime endTTime = (infoToUse->iEndTime) + oneDay; |
|
419 TCalTime begin; |
|
420 begin.SetTimeUtcL(beginTTime); |
|
421 TCalTime end; |
|
422 end.SetTimeUtcL(endTTime); |
|
423 CalCommon::TCalTimeRange timerange(begin, end); |
|
424 |
|
425 view->FindInstanceL(instances, filter, timerange); |
|
426 |
|
427 TInt counter = 0; |
|
428 TInt max = instances.Count(); |
|
429 INFO_PRINTF2(_L("%d instances to compare against"),max); |
|
430 TBool found = EFalse; |
|
431 while ((found == EFalse) && (counter < max)) |
|
432 { |
|
433 INFO_PRINTF3(_L("compare info %d to entry %d"),(j+1), (counter+1)); |
|
434 if (infoToUse->CompareToEntryL((instances[counter])->Entry())) |
|
435 { |
|
436 INFO_PRINTF3(_L("Entry info %d matched instance %d"),(j+1), (counter+1)); |
|
437 found = ETrue; |
|
438 } |
|
439 else |
|
440 { |
|
441 counter++; |
|
442 } |
|
443 } |
|
444 CleanupStack::PopAndDestroy(&instances); |
|
445 CleanupStack::PopAndDestroy(view); |
|
446 CleanupStack::PopAndDestroy(progress); |
|
447 |
|
448 if (!found) |
|
449 { |
|
450 CleanupStack::PopAndDestroy(&entriesInfo); |
|
451 INFO_PRINTF2(_L("Could not validate entry info - %d"),(j+1)); |
|
452 return EFalse; |
|
453 } |
|
454 } |
|
455 CleanupStack::PopAndDestroy(&entriesInfo); |
|
456 return ETrue; |
|
457 } |
|
458 |
|
459 |
|
460 void CTestCalIndexFileStepBase::AddEntryL() |
|
461 { |
|
462 TPtrC entryString; |
|
463 TBool readRes = EFalse; |
|
464 readRes = GetStringFromConfig(ConfigSection(), KAddEntry, entryString); |
|
465 |
|
466 if (!readRes) |
|
467 { |
|
468 INFO_PRINTF1(_L("Error in CTestCalIndexFileStepBase::AddEntryL - section not found in config file")); |
|
469 User::Leave(KErrNotFound); |
|
470 } |
|
471 |
|
472 CConfigTestEntryInfo* entryInf = new(ELeave)CConfigTestEntryInfo(); |
|
473 CleanupStack::PushL(entryInf); |
|
474 ParseEntryStringL(*entryInf, entryString); |
|
475 CCalEntry* newEntry = CreateEntryL(*entryInf); |
|
476 CleanupStack::PushL(newEntry); |
|
477 |
|
478 CCalProgress* progress = new(ELeave)CCalProgress; |
|
479 CleanupStack::PushL(progress); |
|
480 |
|
481 CCalEntryView* view = CCalEntryView::NewL(*iSession, *progress); |
|
482 CleanupStack::PushL(view); |
|
483 |
|
484 CActiveScheduler::Start(); |
|
485 |
|
486 |
|
487 TInt cnt; |
|
488 RPointerArray<CCalEntry> entries; |
|
489 entries.Append(newEntry); |
|
490 view->StoreL(entries, cnt); |
|
491 |
|
492 CleanupStack::PopAndDestroy(4); //entryInf, newEntry, progress, view |
|
493 } |
|
494 |
|
495 CCalEntry* CTestCalIndexFileStepBase::CreateEntryL(CConfigTestEntryInfo& aInfo) |
|
496 { |
|
497 // build the uid from the constant we always use here |
|
498 TInt len = KTCIUid().Length(); |
|
499 |
|
500 HBufC8* uId = HBufC8::NewLC(len); |
|
501 *uId = KTCIUid; |
|
502 |
|
503 CCalEntry* retEntry = CCalEntry::NewL(aInfo.iType, uId, aInfo.iMethod, 0); |
|
504 CleanupStack::Pop(uId); // entry takes ownership |
|
505 CleanupStack::PushL(retEntry); |
|
506 |
|
507 |
|
508 TCalTime start; |
|
509 start.SetTimeUtcL(aInfo.iStartTime); |
|
510 TCalTime end; |
|
511 end.SetTimeUtcL(aInfo.iEndTime); |
|
512 retEntry->SetStartAndEndTimeL(start, end); |
|
513 |
|
514 retEntry->SetSummaryL(*(aInfo.iSummary)); |
|
515 retEntry->SetDescriptionL(*(aInfo.iDescription)); |
|
516 retEntry->SetLocationL(*(aInfo.iLocation)); |
|
517 |
|
518 if (aInfo.iRepeats) |
|
519 { |
|
520 TCalRRule rRule(aInfo.iRptType); |
|
521 rRule.SetCount(aInfo.iRptCount); |
|
522 rRule.SetDtStart(start); |
|
523 rRule.SetInterval(1); |
|
524 retEntry->SetRRuleL(rRule); |
|
525 } |
|
526 CleanupStack::Pop(retEntry); |
|
527 return (retEntry); |
|
528 } |
|
529 |
|
530 const TUint KMaxEntryStringLen = 250; // arbitrary size, can be chanegd to match needs |
|
531 // of format described below |
|
532 |
|
533 const TUint KMaxEntryPartStringLen = 50; // arbitrary size, can be chanegd to match needs |
|
534 // of format described below |
|
535 // The string in the config file for the entry has one of the following |
|
536 // formats: |
|
537 // (1) type;starttime;endtime;summary;description;location;method |
|
538 // (2) type;starttime;endtime;summary;description;location;method;repeating;rpttype;rptnum |
|
539 // where |
|
540 // type = string that fits with one of the entry types |
|
541 // starttime, endtime = TDateTime string |
|
542 // summary, description, location = any string |
|
543 // method = string that fits with one of the method types |
|
544 // repeating = bool string |
|
545 // rpttype = string that fits with one of the repeat types |
|
546 // rptnum = integer string for number of repeats |
|
547 // |
|
548 // example1: appt;20050622:122500;20050623:154500;a summary;a description;a location;none;true;weekly;5; |
|
549 // example2: appt;20050622:122500;20050623:154500;a summary;a description;a location;none;false; |
|
550 // |
|
551 // Refer to TestCalIndexFileDefs.h for the constants for type, method, and rpttype |
|
552 |
|
553 void CTestCalIndexFileStepBase::ParseEntryStringL(CConfigTestEntryInfo& aInfo, TPtrC& aString) |
|
554 { |
|
555 TBuf<KMaxEntryStringLen> data(aString); |
|
556 |
|
557 TBuf<KMaxEntryPartStringLen> item; |
|
558 |
|
559 GoToNextEntryItem(data, item); |
|
560 |
|
561 // get the entry type |
|
562 if (0 == item.Compare(KTCIEntryTypeAppt)) |
|
563 { |
|
564 aInfo.iType = CCalEntry::EAppt; |
|
565 } |
|
566 else if (0 == item.Compare(KTCIEntryTypeToDo)) |
|
567 { |
|
568 aInfo.iType = CCalEntry::ETodo; |
|
569 } |
|
570 else if (0 == item.Compare(KTCIEntryTypeEvent)) |
|
571 { |
|
572 aInfo.iType = CCalEntry::EEvent; |
|
573 } |
|
574 else if (0 == item.Compare(KTCIEntryTypeRemind)) |
|
575 { |
|
576 aInfo.iType = CCalEntry::EReminder; |
|
577 } |
|
578 else if (0 == item.Compare(KTCIEntryTypeAnniv)) |
|
579 { |
|
580 aInfo.iType = CCalEntry::EAnniv; |
|
581 } |
|
582 else |
|
583 { |
|
584 User::Leave(KErrArgument); |
|
585 } |
|
586 |
|
587 // get the start time |
|
588 GoToNextEntryItem(data, item); |
|
589 TTime start(item); |
|
590 aInfo.iStartTime = start; |
|
591 |
|
592 // get the end time |
|
593 GoToNextEntryItem(data, item); |
|
594 TTime end(item); |
|
595 aInfo.iEndTime = end; |
|
596 |
|
597 |
|
598 // use this integer length for all pure strings to be stored |
|
599 TInt len = 0; |
|
600 |
|
601 // get the summary |
|
602 GoToNextEntryItem(data, item); |
|
603 len = item.Length(); |
|
604 if (aInfo.iSummary) |
|
605 { |
|
606 delete aInfo.iSummary; |
|
607 aInfo.iSummary = NULL; |
|
608 } |
|
609 aInfo.iSummary = HBufC::NewL(len); |
|
610 *(aInfo.iSummary) = item; |
|
611 |
|
612 // get the description |
|
613 GoToNextEntryItem(data, item); |
|
614 len = item.Length(); |
|
615 if (aInfo.iDescription) |
|
616 { |
|
617 delete aInfo.iDescription; |
|
618 aInfo.iDescription = NULL; |
|
619 } |
|
620 aInfo.iDescription = HBufC::NewL(len); |
|
621 *(aInfo.iDescription) = item; |
|
622 |
|
623 // get the location |
|
624 GoToNextEntryItem(data, item); |
|
625 len = item.Length(); |
|
626 if (aInfo.iLocation) |
|
627 { |
|
628 delete aInfo.iLocation; |
|
629 aInfo.iLocation = NULL; |
|
630 } |
|
631 aInfo.iLocation = HBufC::NewL(len); |
|
632 *(aInfo.iLocation) = item; |
|
633 |
|
634 // get the method |
|
635 GoToNextEntryItem(data, item); |
|
636 if (0 == item.Compare(KTCIEntryMethodNone)) |
|
637 { |
|
638 aInfo.iMethod = CCalEntry::EMethodNone; |
|
639 } |
|
640 else if (0 == item.Compare(KTCIEntryMethodPub)) |
|
641 { |
|
642 aInfo.iMethod = CCalEntry::EMethodPublish; |
|
643 } |
|
644 else if (0 == item.Compare(KTCIEntryMethodReq)) |
|
645 { |
|
646 aInfo.iMethod = CCalEntry::EMethodRequest; |
|
647 } |
|
648 else if (0 == item.Compare(KTCIEntryMethodReply)) |
|
649 { |
|
650 aInfo.iMethod = CCalEntry::EMethodReply; |
|
651 } |
|
652 else if (0 == item.Compare(KTCIEntryMethodAdd)) |
|
653 { |
|
654 aInfo.iMethod = CCalEntry::EMethodAdd; |
|
655 } |
|
656 else if (0 == item.Compare(KTCIEntryMethodCancel)) |
|
657 { |
|
658 aInfo.iMethod = CCalEntry::EMethodCancel; |
|
659 } |
|
660 else if (0 == item.Compare(KTCIEntryMethodRefresh)) |
|
661 { |
|
662 aInfo.iMethod = CCalEntry::EMethodRefresh; |
|
663 } |
|
664 else if (0 == item.Compare(KTCIEntryMethodCounter)) |
|
665 { |
|
666 aInfo.iMethod = CCalEntry::EMethodCounter; |
|
667 } |
|
668 else if (0 == item.Compare(KTCIEntryMethodDeclineCounter)) |
|
669 { |
|
670 aInfo.iMethod = CCalEntry::EMethodDeclineCounter; |
|
671 } |
|
672 else |
|
673 { |
|
674 User::Leave(KErrArgument); |
|
675 } |
|
676 |
|
677 // check if repeating |
|
678 GoToNextEntryItem(data, item); |
|
679 if (0 == item.Compare(KTCIEntryTrue)) |
|
680 { |
|
681 aInfo.iRepeats = ETrue; |
|
682 |
|
683 // get rpttype |
|
684 GoToNextEntryItem(data, item); |
|
685 if (0 == item.Compare(KTCIEntryRptDaily)) |
|
686 { |
|
687 aInfo.iRptType = TCalRRule::EDaily; |
|
688 } |
|
689 else if (0 == item.Compare(KTCIEntryRptWeekly)) |
|
690 { |
|
691 aInfo.iRptType = TCalRRule::EWeekly; |
|
692 } |
|
693 else if (0 == item.Compare(KTCIEntryRptMonthly)) |
|
694 { |
|
695 aInfo.iRptType = TCalRRule::EMonthly; |
|
696 } |
|
697 else if (0 == item.Compare(KTCIEntryRptYearly)) |
|
698 { |
|
699 aInfo.iRptType = TCalRRule::EYearly; |
|
700 } |
|
701 else |
|
702 { |
|
703 User::Leave(KErrArgument); |
|
704 } |
|
705 |
|
706 // get rptnum |
|
707 GoToNextEntryItem(data, item); |
|
708 TLex mylex(item); |
|
709 TInt lexErr = mylex.Val(aInfo.iRptCount); |
|
710 User::LeaveIfError(lexErr); |
|
711 } |
|
712 else |
|
713 { |
|
714 aInfo.iRepeats = EFalse; |
|
715 } |
|
716 } |
|
717 |
|
718 |
|
719 void CTestCalIndexFileStepBase::GoToNextEntryItem(TDes& aData, TDes& aItem) |
|
720 { |
|
721 TInt pos; |
|
722 pos = aData.Locate(';'); |
|
723 aItem = aData.Left(pos); |
|
724 aData.Delete(0, pos+1); |
|
725 } |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 // CConfigTestEntryInfo |
|
732 // |
|
733 CConfigTestEntryInfo::CConfigTestEntryInfo() |
|
734 { |
|
735 iSummary = NULL; |
|
736 iDescription = NULL; |
|
737 iLocation = NULL; |
|
738 } |
|
739 |
|
740 CConfigTestEntryInfo::~CConfigTestEntryInfo() |
|
741 { |
|
742 if (iSummary) |
|
743 { |
|
744 delete iSummary; |
|
745 iSummary = NULL; |
|
746 } |
|
747 if (iDescription) |
|
748 { |
|
749 delete iDescription; |
|
750 iDescription = NULL; |
|
751 } |
|
752 if (iLocation) |
|
753 { |
|
754 delete iLocation; |
|
755 iLocation = NULL; |
|
756 } |
|
757 } |
|
758 |
|
759 TBool CConfigTestEntryInfo::CompareToEntryL(CCalEntry& aEntry) |
|
760 { |
|
761 // This method assumes a pass. |
|
762 // If any check fails, it immediately returns EFalse since |
|
763 // there is no sense checking any further. |
|
764 |
|
765 // NB: Implementers of any future test checks should be sure |
|
766 // to include appropriate debug print information about |
|
767 // the failure within the check method itself. |
|
768 if (!CheckTypeL(aEntry)) |
|
769 { |
|
770 RDebug::Print(_L("Failed checking Entry type")); |
|
771 RDebug::Print(_L("Expected %d, Actual %d"),iType, aEntry.EntryTypeL()); |
|
772 return EFalse; |
|
773 } |
|
774 |
|
775 if (!CheckTimesL(aEntry)) |
|
776 { |
|
777 RDebug::Print(_L("Failed checking Entry times")); |
|
778 return EFalse; |
|
779 } |
|
780 |
|
781 if (!CheckSummaryL(aEntry)) |
|
782 { |
|
783 RDebug::Print(_L("Failed checking Entry summary")); |
|
784 return EFalse; |
|
785 } |
|
786 |
|
787 if (!CheckLocationL(aEntry)) |
|
788 { |
|
789 RDebug::Print(_L("Failed checking Entry location")); |
|
790 return EFalse; |
|
791 } |
|
792 |
|
793 if (!CheckMethodL(aEntry)) |
|
794 { |
|
795 RDebug::Print(_L("Failed checking Entry method")); |
|
796 return EFalse; |
|
797 } |
|
798 |
|
799 if (!CheckRRuleL(aEntry)) |
|
800 { |
|
801 RDebug::Print(_L("Failed checking Entry repeat rule")); |
|
802 return EFalse; |
|
803 } |
|
804 |
|
805 // all checks passed, return true |
|
806 return ETrue; |
|
807 } |
|
808 |
|
809 TBool CConfigTestEntryInfo::CheckTypeL(CCalEntry& aEntry) |
|
810 { |
|
811 return (iType == aEntry.EntryTypeL()); |
|
812 } |
|
813 |
|
814 TBool CConfigTestEntryInfo::CheckTimesL(CCalEntry& aEntry) |
|
815 { |
|
816 if (iType == CCalEntry::EReminder) |
|
817 { |
|
818 return (iStartTime == aEntry.StartTimeL().TimeUtcL()); |
|
819 } |
|
820 else |
|
821 { |
|
822 return ((iStartTime == aEntry.StartTimeL().TimeUtcL()) && |
|
823 (iEndTime == aEntry.EndTimeL().TimeUtcL())); |
|
824 } |
|
825 } |
|
826 |
|
827 TBool CConfigTestEntryInfo::CheckSummaryL(CCalEntry& aEntry) |
|
828 { |
|
829 return (*iSummary == aEntry.SummaryL()); |
|
830 } |
|
831 |
|
832 TBool CConfigTestEntryInfo::CheckDescriptionL(CCalEntry& aEntry) |
|
833 { |
|
834 return (*iDescription == aEntry.DescriptionL()); |
|
835 } |
|
836 |
|
837 TBool CConfigTestEntryInfo::CheckLocationL(CCalEntry& aEntry) |
|
838 { |
|
839 return (*iLocation == aEntry.LocationL()); |
|
840 } |
|
841 |
|
842 TBool CConfigTestEntryInfo::CheckMethodL(CCalEntry& aEntry) |
|
843 { |
|
844 return (iMethod == aEntry.MethodL()); |
|
845 } |
|
846 |
|
847 TBool CConfigTestEntryInfo::CheckRRuleL(CCalEntry& aEntry) |
|
848 { |
|
849 if (!iRepeats) |
|
850 { |
|
851 // no repeats, so check is superfluous |
|
852 // we keep the logic in here, therefore we don't |
|
853 // fail the check. |
|
854 return ETrue; |
|
855 } |
|
856 |
|
857 TCalRRule theRule; |
|
858 if (!aEntry.GetRRuleL(theRule)) |
|
859 { |
|
860 return EFalse; // no rule present, should not have got here |
|
861 } |
|
862 |
|
863 return ((iRptType == theRule.Type()) && (iRptCount == theRule.Count())); |
|
864 } |
|
865 |
|
866 |
|
867 |
|
868 CCalProgress::CCalProgress() |
|
869 :CActive(EPriorityStandard), iProgress(0),iCompleted(EFalse) |
|
870 { |
|
871 CActiveScheduler::Add(this); |
|
872 } |
|
873 |
|
874 CCalProgress::~CCalProgress() |
|
875 { |
|
876 Cancel(); |
|
877 } |
|
878 |
|
879 |
|
880 void CCalProgress::Progress(TInt aPercentageCompleted) |
|
881 { |
|
882 iProgress = aPercentageCompleted; |
|
883 if (aPercentageCompleted<100) |
|
884 iCompleted = EFalse; |
|
885 } |
|
886 |
|
887 void CCalProgress::Completed(TInt /* aError*/) |
|
888 { |
|
889 iCompleted = ETrue; |
|
890 Start(); |
|
891 } |
|
892 |
|
893 TBool CCalProgress::NotifyProgress() |
|
894 { |
|
895 return ETrue; |
|
896 } |
|
897 |
|
898 TBool CCalProgress::Completed() |
|
899 { |
|
900 return iCompleted; |
|
901 } |
|
902 |
|
903 TInt CCalProgress::Progress() |
|
904 { |
|
905 return iProgress; |
|
906 } |
|
907 |
|
908 void CCalProgress::Reset() |
|
909 { |
|
910 iCompleted=EFalse; |
|
911 } |
|
912 |
|
913 void CCalProgress::Start() |
|
914 { |
|
915 if (!IsActive()) |
|
916 { |
|
917 SetActive(); |
|
918 } |
|
919 TRequestStatus* status = &iStatus; |
|
920 User::RequestComplete(status, KErrNone); |
|
921 } |
|
922 |
|
923 void CCalProgress::DoCancel() |
|
924 { |
|
925 Close(); |
|
926 } |
|
927 |
|
928 void CCalProgress::RunL() |
|
929 { |
|
930 Close(); |
|
931 } |
|
932 |
|
933 void CCalProgress::Close() |
|
934 { |
|
935 CActiveScheduler::Stop(); |
|
936 } |
|
937 |