|
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 |
|
18 #include <calentry.h> |
|
19 #include <calentryview.h> |
|
20 #include <calinstance.h> |
|
21 #include <calinstanceview.h> |
|
22 #include <calrrule.h> |
|
23 #include <calsession.h> |
|
24 #include <e32test.h> |
|
25 #include <vtzrules.h> |
|
26 #include <calalarm.h> |
|
27 #include <s32file.h> |
|
28 #include <caliterator.h> |
|
29 #include <caldataexchange.h> |
|
30 #include <caldataformat.h> |
|
31 |
|
32 RTest test(_L("tcal_tz")); |
|
33 |
|
34 _LIT(KCalendarFile, "tcal_tz"); |
|
35 |
|
36 // Timezone constants |
|
37 |
|
38 _LIT8(KEuropeLondon, "Europe/London"); |
|
39 _LIT8(KAsiaTokyo, "Asia/Tokyo"); |
|
40 _LIT8(KAsiaTaiwan, "Asia/Taiwan"); |
|
41 _LIT8(KAsiaBangkok, "Asia/Bangkok"); |
|
42 _LIT8(KEuropeStockholm, "Europe/Stockholm"); |
|
43 _LIT8(KEuropeHelsinki, "Europe/Helsinki"); |
|
44 _LIT8(KUsNewYork, "America/New_York"); |
|
45 _LIT8(KUsCentral, "US/Central"); |
|
46 _LIT8(KUsLosAngeles, "US/LosAngeles"); |
|
47 _LIT8(KEuropeTirane, "Europe/Tirane"); |
|
48 _LIT8(KPacificHonolulu, "Pacific/Honolulu"); |
|
49 |
|
50 // Watch out for confusion between this and |
|
51 // the custom rule we create that matches this zone. |
|
52 _LIT8(KPacificAuckland, "Pacific/Auckland"); |
|
53 |
|
54 // Time constants |
|
55 |
|
56 const TDateTime KTokyoEntryTime(2005,EMarch,6,2,45,15,0); |
|
57 const TDateTime KExpectedTokyoEntryTime(2005,EMarch,7,2,45,15,0); |
|
58 |
|
59 |
|
60 class CTzTestManager : public CActive |
|
61 { |
|
62 public: |
|
63 static CTzTestManager* NewLC(); |
|
64 ~CTzTestManager(); |
|
65 |
|
66 void Start(); |
|
67 |
|
68 private: |
|
69 CTzTestManager(); |
|
70 void ConstructL(); |
|
71 |
|
72 void TestSetTimeZoneL(const TDesC8& aTimeZoneName); |
|
73 void TestSetAndGetTzRulesL(); |
|
74 void TestRemoteRepeatL(); |
|
75 void TestRepeatRuleTzSetupL(TBool aFloating, TBool aException = EFalse, TBool aRDate = EFalse); |
|
76 void TestRepeatRuleLocalTimeL(); |
|
77 void TestRepeatRuleTzStartEndTimeL(); |
|
78 void TestRepeatRuleTzStartEndTzRulesL(); |
|
79 void TestRepeatRuleTzRulesL(); |
|
80 void DefectTestL(); |
|
81 void TestRDatesTzSetupL(); |
|
82 void TestFloatingEntrySetupL(); // Create a floating entry in calendar |
|
83 void TestFloatingEntryCheckL(const TTime& aExpectedTime); // Check the previously stored floating entry |
|
84 void TestFloatingRepeatCheckL(); // Check the previously stored floating repeating entry |
|
85 void TestFloatingExceptionCheckL(); // Check the previously stored floating repeating entry with exception date |
|
86 void TestFloatingRDateCheckL(); // Check the previously stored floating repeating entry with RDate |
|
87 |
|
88 void TestForeignZoneRepeatRule1L(); |
|
89 void TestForeignZoneRepeatRule2L(); |
|
90 void TestLocalRepeatRuleL(); |
|
91 void TestLocalRepeatRule2L(); |
|
92 void TestLocalTimeZoneL(); |
|
93 |
|
94 void TestAlarmTzUpdateSetupL(); |
|
95 void TestAlarmTzUpdateCheckL(); |
|
96 void SetupEventCrossingMidnightL(); |
|
97 void CheckEventCrossingMidnightL(); |
|
98 void CheckDSTThresholdL(); |
|
99 |
|
100 void TestCopyRepeatRulesL(); |
|
101 void TestExportTzRulesInHemisphereL(TBool aSouthernHemisphere); |
|
102 void ImportFloatingEntryL(); |
|
103 void TestTimeModeL(); |
|
104 void TestAlarmOffsetL(); |
|
105 void CheckVcalImportFromS40L(); |
|
106 void CheckUtcOffsetL(TCalTime& aTestLocalTime, TInt aExpectedOffset); |
|
107 |
|
108 void CheckEntryInTimeZoneL(const TTime& aExpectedTime); |
|
109 |
|
110 void TestCreateEntryWithMidnightInHomeTimeL(TBool aFloating = EFalse); |
|
111 void TestCreateEntryWithDstChangeL(TBool aFloating = EFalse); |
|
112 |
|
113 // no copy constructor and assignment operator |
|
114 CTzTestManager(CTzTestManager& ); |
|
115 CTzTestManager& operator = (const CTzTestManager& ); |
|
116 |
|
117 void CheckIsAnInstanceInTimeModeL(const TTime& aLocalTime, TBool aFound = ETrue, TCalTime::TTimeMode aTimeMode = TCalTime::EFixedTimeZone); |
|
118 void CheckIsAnInstanceInSpecifiedZoneL(const TTime& aTime); |
|
119 void VerifyRulesL(const CTzRules& aRules,const TCalTime& aStartRange, const TCalTime& aEndRange); |
|
120 |
|
121 // from CActive |
|
122 void RunL(); |
|
123 void DoCancel(); |
|
124 |
|
125 private: |
|
126 CCalTestLibrary* iTestLibrary; // need a connection to a session to create a CCalEntry |
|
127 CCalEntry* iCalEntry; |
|
128 TBuf8<256> iCurrentTimeZone; |
|
129 TInt iTestStep; |
|
130 }; |
|
131 |
|
132 |
|
133 // Constructor/Destructor |
|
134 CTzTestManager::CTzTestManager() : CActive(EPriorityLow) |
|
135 { |
|
136 CActiveScheduler::Add(this); |
|
137 } |
|
138 |
|
139 CTzTestManager* CTzTestManager::NewLC() |
|
140 { |
|
141 CTzTestManager* self = new (ELeave) CTzTestManager; |
|
142 |
|
143 CleanupStack::PushL(self); |
|
144 self->ConstructL(); |
|
145 |
|
146 return (self); |
|
147 } |
|
148 |
|
149 |
|
150 void CTzTestManager::ConstructL() |
|
151 { |
|
152 iTestLibrary = CCalTestLibrary::NewL(); |
|
153 |
|
154 iTestLibrary->ReplaceFileL(KCalendarFile()); |
|
155 iTestLibrary->OpenFileL(KCalendarFile()); |
|
156 |
|
157 iTestLibrary->PIMTestServer().GetTimeZoneL(iCurrentTimeZone); |
|
158 } |
|
159 |
|
160 |
|
161 CTzTestManager::~CTzTestManager() |
|
162 { |
|
163 if (iTestLibrary && iCurrentTimeZone.Length()) |
|
164 { |
|
165 TRAP_IGNORE(TestSetTimeZoneL(iCurrentTimeZone)); |
|
166 } |
|
167 |
|
168 delete iCalEntry; |
|
169 delete iTestLibrary; |
|
170 } |
|
171 |
|
172 void CTzTestManager::Start() |
|
173 { |
|
174 TRequestStatus* status = &iStatus; |
|
175 User::RequestComplete(status, KErrNone); |
|
176 if ( ! IsActive()) |
|
177 { |
|
178 SetActive(); |
|
179 } |
|
180 } |
|
181 |
|
182 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
183 * Test cases forming the Time Zone test suite |
|
184 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
|
185 |
|
186 |
|
187 void CTzTestManager::TestSetTimeZoneL(const TDesC8& aTimeZoneName) |
|
188 { |
|
189 iTestLibrary->SetTimeZoneL(aTimeZoneName); |
|
190 } |
|
191 |
|
192 |
|
193 // TestRulesProvided: Creates a collection of TTzRule's and with it a CAgnTzZone. |
|
194 // Then it tests the time conversion methods in CAgnTzZone. |
|
195 /** @SYMTestCaseID PIM-TCAL-TZ-0002 */ |
|
196 void CTzTestManager::TestSetAndGetTzRulesL() |
|
197 { |
|
198 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0002 Running tcal_tz - TestSetAndGetTzRulesL")); |
|
199 HBufC8* dummy = NULL; |
|
200 |
|
201 delete iCalEntry; |
|
202 iCalEntry = NULL; |
|
203 iCalEntry = iTestLibrary->CreateCalEntryL(CCalEntry::EEvent, dummy); |
|
204 |
|
205 // Create arbitrary tz rule - add one hour between March 81 and October 96 |
|
206 TTzRule tRule1(1981,1996,0,60,EMarch,ETzDayInLastWeekOfMonth,0,ESunday,ETzUtcTimeReference,60); |
|
207 TTzRule tRule2(1981,1996,60,0,EOctober,ETzDayInLastWeekOfMonth,0,ESunday,ETzUtcTimeReference,60); |
|
208 TTzRule tRule3(0,KMaxTUint16,0,0,EJanuary,ETzFixedDate,0,0,ETzWallTimeReference,0); |
|
209 CTzRules* tzRules = CTzRules::NewL(2003,2007); |
|
210 CleanupStack::PushL(tzRules); // PUSH |
|
211 tzRules->AddRuleL(tRule1); |
|
212 tzRules->AddRuleL(tRule2); |
|
213 tzRules->AddRuleL(tRule3); |
|
214 |
|
215 // create weekly repeat rule every Tuesday from 1 May 05 to 1 Dec 05 |
|
216 TDateTime dtStart(2005,EMay,0,10,0,0,0); |
|
217 TDateTime dtEnd(2005,EDecember,0,10,0,0,0); |
|
218 TTime dtStart1(dtStart); |
|
219 TTime dtEnd1(dtEnd); |
|
220 TCalTime startCalTime; |
|
221 TCalTime endCalTime; |
|
222 tzRules->ConvertToUtcL(dtStart1); |
|
223 startCalTime.SetTimeUtcL(dtStart1); |
|
224 tzRules->ConvertToUtcL(dtEnd1); |
|
225 startCalTime.SetTimeUtcL(dtEnd1); |
|
226 |
|
227 iCalEntry->SetStartAndEndTimeL(startCalTime, startCalTime); |
|
228 |
|
229 TCalRRule calRule(TCalRRule::EWeekly); |
|
230 calRule.SetDtStart(startCalTime); |
|
231 calRule.SetUntil(endCalTime); |
|
232 calRule.SetInterval(1); |
|
233 RArray<TDay> days; |
|
234 days.AppendL(ETuesday); |
|
235 calRule.SetByDay(days); |
|
236 iCalEntry->SetRRuleL(calRule); |
|
237 days.Reset(); |
|
238 |
|
239 |
|
240 iCalEntry->SetTzRulesL(*tzRules); |
|
241 |
|
242 CTzRules* tzRules2 = iCalEntry->TzRulesL(); |
|
243 CleanupStack::PushL(tzRules2); |
|
244 |
|
245 test(tzRules->Count() == tzRules2->Count()); |
|
246 |
|
247 // Compare rules stored (tzRules) with rules retrieved (tzRules2) |
|
248 TInt count = tzRules->Count(); |
|
249 TTzRule oneRule; |
|
250 TTzRule anotherRule; |
|
251 for (TInt i = 0; i < count; i++) |
|
252 { |
|
253 oneRule = (*tzRules)[i]; |
|
254 anotherRule = (*tzRules2)[i]; |
|
255 |
|
256 test(oneRule.iFrom == anotherRule.iFrom); |
|
257 test(oneRule.iTo == anotherRule.iTo); |
|
258 test(oneRule.iOldLocalTimeOffset == anotherRule.iOldLocalTimeOffset); |
|
259 test(oneRule.iNewLocalTimeOffset == anotherRule.iNewLocalTimeOffset); |
|
260 test(oneRule.iMonth == anotherRule.iMonth); |
|
261 test(oneRule.iDayRule == anotherRule.iDayRule); |
|
262 test(oneRule.iDayOfMonth == anotherRule.iDayOfMonth); |
|
263 test(oneRule.iDayOfWeek == anotherRule.iDayOfWeek); |
|
264 test(oneRule.iTimeReference == anotherRule.iTimeReference); |
|
265 test(oneRule.iTimeOfChange == anotherRule.iTimeOfChange); |
|
266 } |
|
267 |
|
268 CleanupStack::PopAndDestroy(tzRules2); |
|
269 CleanupStack::PopAndDestroy(tzRules); |
|
270 delete iCalEntry; |
|
271 iCalEntry = NULL; |
|
272 } |
|
273 |
|
274 |
|
275 void CTzTestManager::CheckEntryInTimeZoneL(const TTime& aExpectedTime) |
|
276 { |
|
277 // Check that instance dates and times are properly converted to local times |
|
278 TTime newTime = iCalEntry->StartTimeL().TimeLocalL(); |
|
279 test(newTime == aExpectedTime); |
|
280 } |
|
281 |
|
282 |
|
283 // Tests that the start time of an entry changes correctly in different time zones |
|
284 // (using zone extracted from TZ server) |
|
285 /** @SYMTestCaseID PIM-TCAL-TZ-0003 */ |
|
286 void CTzTestManager::TestRemoteRepeatL() |
|
287 { |
|
288 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0003 Running tcal_tz - TestRemoteRepeatL")); |
|
289 HBufC8* dummy = NULL; |
|
290 |
|
291 delete iCalEntry; |
|
292 iCalEntry = NULL; |
|
293 iCalEntry = iTestLibrary->CreateCalEntryL(CCalEntry::EEvent, dummy); |
|
294 |
|
295 // create rule repeating every Monday from 7 Mar 05 to 7 Dec 05 |
|
296 TDateTime dtEnd(2005,EDecember,6,10,0,0,0); |
|
297 TCalTime startCalTime; |
|
298 TCalTime endCalTime; |
|
299 // OK to use SetTimeLocal, since we are using SetTzRulesL(); |
|
300 startCalTime.SetTimeLocalL(KTokyoEntryTime); |
|
301 endCalTime.SetTimeLocalL(dtEnd); |
|
302 |
|
303 iCalEntry->SetStartAndEndTimeL(startCalTime, startCalTime); |
|
304 |
|
305 TCalRRule calRule(TCalRRule::EWeekly); |
|
306 calRule.SetDtStart(startCalTime); |
|
307 calRule.SetUntil(endCalTime); |
|
308 calRule.SetInterval(1); |
|
309 RArray<TDay> days; |
|
310 days.AppendL(EMonday); |
|
311 calRule.SetByDay(days); |
|
312 days.Reset(); |
|
313 |
|
314 iCalEntry->SetRRuleL(calRule); |
|
315 iCalEntry->SetTzRulesL(); |
|
316 } |
|
317 |
|
318 |
|
319 /** @SYMTestCaseID PIM-TCAL-TZ-0004 */ |
|
320 void CTzTestManager::TestFloatingEntrySetupL() |
|
321 { |
|
322 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0004 Running tcal_tz - TestFloatingEntrySetupL")); |
|
323 iTestLibrary->CleanDatabaseL(); |
|
324 |
|
325 delete iCalEntry; |
|
326 iCalEntry = NULL; |
|
327 |
|
328 HBufC8* dummy = NULL; |
|
329 iCalEntry = iTestLibrary->CreateCalEntryL(CCalEntry::EEvent, dummy); |
|
330 |
|
331 // create rule repeating every Tuesday from 7 Mar 05 to 7 Dec 05 |
|
332 TDateTime dtEnd(2005,EDecember,6,10,0,0,0); |
|
333 TCalTime startCalTime; |
|
334 TCalTime endCalTime; |
|
335 startCalTime.SetTimeLocalFloatingL(KTokyoEntryTime); |
|
336 endCalTime.SetTimeLocalFloatingL(dtEnd); |
|
337 |
|
338 iCalEntry->SetStartAndEndTimeL(startCalTime, startCalTime); |
|
339 |
|
340 RPointerArray<CCalEntry> entryArray; |
|
341 CleanupClosePushL(entryArray); |
|
342 |
|
343 |
|
344 entryArray.AppendL(iCalEntry); |
|
345 TInt entriesAdded = 0; |
|
346 iTestLibrary->SynCGetEntryViewL().StoreL(entryArray, entriesAdded); |
|
347 |
|
348 |
|
349 CleanupStack::PopAndDestroy(&entryArray); |
|
350 } |
|
351 |
|
352 |
|
353 void CTzTestManager::TestFloatingEntryCheckL(const TTime& aExpectedTime) |
|
354 { |
|
355 RPointerArray<CCalEntry> entryArray; |
|
356 CleanupResetAndDestroyPushL(entryArray); |
|
357 |
|
358 |
|
359 iTestLibrary->SynCGetEntryViewL().FetchL(iCalEntry->UidL(), entryArray); |
|
360 |
|
361 // Check that entry dates and times are properly converted to local times |
|
362 test(entryArray.Count() == 1); |
|
363 TTime newTime = entryArray[0]->StartTimeL().TimeLocalL(); |
|
364 test(newTime == aExpectedTime); |
|
365 |
|
366 |
|
367 CleanupStack::PopAndDestroy(&entryArray); |
|
368 } |
|
369 |
|
370 |
|
371 /** @SYMTestCaseID PIM-TCAL-TZ-0005 */ |
|
372 void CTzTestManager::TestRepeatRuleTzSetupL(TBool aFloating, TBool aException, TBool aRDate) |
|
373 { |
|
374 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0005 Running tcal_tz - TestRepeatRuleTzL")); |
|
375 CCalEntryView& entryView = iTestLibrary->SynCGetEntryViewL(); |
|
376 if (aFloating) |
|
377 { |
|
378 entryView.DeleteL(*iCalEntry); |
|
379 } |
|
380 |
|
381 delete iCalEntry; |
|
382 iCalEntry = NULL; |
|
383 HBufC8* dummy = NULL; |
|
384 iCalEntry = iTestLibrary->CreateCalEntryL(CCalEntry::EEvent, dummy); |
|
385 |
|
386 TTime dtStart(TDateTime(2005, EJanuary, 0, 9, 0, 0, 0)); |
|
387 TTime dtEnd(TDateTime(2005, EDecember, 30, 9, 0, 0, 0)); |
|
388 TCalTime startCalTime; |
|
389 TCalTime endCalTime; |
|
390 |
|
391 if (aFloating) |
|
392 { |
|
393 // Create a floating repeat entry in Auckland timezone |
|
394 // create rule repeating every 2 days from 9am (local time) |
|
395 startCalTime.SetTimeLocalFloatingL(dtStart); |
|
396 endCalTime.SetTimeLocalFloatingL(dtEnd); |
|
397 |
|
398 TCalRRule rpt(TCalRRule::EDaily); |
|
399 rpt.SetDtStart(startCalTime); |
|
400 rpt.SetUntil(endCalTime); |
|
401 rpt.SetInterval(2); |
|
402 |
|
403 iCalEntry->SetStartAndEndTimeL(startCalTime, startCalTime); |
|
404 |
|
405 // add the repeat rule and the timezone rules to the entry |
|
406 iCalEntry->SetRRuleL(rpt); |
|
407 |
|
408 TRAPD(err, iCalEntry->SetTzRulesL()); |
|
409 test(err == KErrArgument); |
|
410 } |
|
411 else |
|
412 { |
|
413 // set time zone to Auckland, NZ |
|
414 // DST ends on Sunday, 20 March 2005, 03:00 local daylight time |
|
415 // DST starts on Sunday, 2 October 2005, 02:00 local standard time |
|
416 // create rule repeating every 2 days from 9am (NZ time) |
|
417 |
|
418 // fetch foreign rules from TZ server for Auckland |
|
419 RTz tz; |
|
420 User::LeaveIfError(tz.Connect()); |
|
421 CTzId* id = CTzId::NewL(KPacificAuckland); |
|
422 CleanupStack::PushL(id); |
|
423 |
|
424 CTzRules* rules = tz.GetTimeZoneRulesL(*id, TDateTime(2000, EJanuary, 0, 0, 0, 0, 0), TDateTime(2010, EJanuary, 0, 0, 0, 0, 0), ETzUtcTimeReference); |
|
425 CleanupStack::PopAndDestroy(id); |
|
426 CleanupStack::PushL(rules); |
|
427 |
|
428 tz.Close(); |
|
429 |
|
430 // convert to UTC for setting the calendar entry, because this is a foreign rule |
|
431 rules->ConvertToUtcL(dtStart); |
|
432 rules->ConvertToUtcL(dtEnd); |
|
433 startCalTime.SetTimeUtcL(dtStart); |
|
434 endCalTime.SetTimeUtcL(dtEnd); |
|
435 |
|
436 iCalEntry->SetStartAndEndTimeL(startCalTime, startCalTime); |
|
437 |
|
438 // create repeat rule |
|
439 TCalRRule rpt(TCalRRule::EDaily); |
|
440 rpt.SetDtStart(startCalTime); |
|
441 rpt.SetUntil(endCalTime); |
|
442 rpt.SetInterval(2); |
|
443 |
|
444 iCalEntry->SetRRuleL(rpt); |
|
445 |
|
446 iCalEntry->SetTzRulesL(*rules); // set tz rules to be local |
|
447 |
|
448 CleanupStack::PopAndDestroy(rules); |
|
449 } |
|
450 |
|
451 if (aException) |
|
452 { |
|
453 // Set 2 exceptions on the parent |
|
454 |
|
455 RArray<TCalTime> exArray; |
|
456 CleanupClosePushL(exArray); |
|
457 |
|
458 TCalTime exTime1; |
|
459 exTime1.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 23, 9, 0, 0, 0)); // March 24rd 9am |
|
460 exArray.Append(exTime1); |
|
461 |
|
462 TCalTime exTime2; |
|
463 exTime2.SetTimeLocalFloatingL(TDateTime(2005, ESeptember, 29, 9, 0, 0, 0)); // September 30th 9am |
|
464 exArray.Append(exTime2); |
|
465 |
|
466 iCalEntry->SetExceptionDatesL(exArray); |
|
467 |
|
468 RArray<TCalTime> exArray2; |
|
469 CleanupClosePushL(exArray2); |
|
470 |
|
471 iCalEntry->GetExceptionDatesL(exArray2); |
|
472 test(exArray.Count() == exArray2.Count()); |
|
473 for (TInt i = 0; i < exArray.Count(); i++) |
|
474 { |
|
475 test(exArray[i].TimeMode() == exArray2[i].TimeMode()); |
|
476 test(exArray[i].TimeLocalL() == exArray2[i].TimeLocalL()); |
|
477 } |
|
478 |
|
479 CleanupStack::PopAndDestroy(); // reset exArray2 |
|
480 |
|
481 CleanupStack::PopAndDestroy(); // reset exArray |
|
482 } |
|
483 |
|
484 if (aRDate) |
|
485 { |
|
486 // Set 2 sporadic dates on the parent |
|
487 |
|
488 RArray<TCalTime> rDateArray; |
|
489 CleanupClosePushL(rDateArray); |
|
490 |
|
491 TCalTime rDate1; |
|
492 rDate1.SetTimeLocalFloatingL(TDateTime(2004, EDecember, 2, 9, 0, 0, 0)); |
|
493 rDateArray.Append(rDate1); |
|
494 |
|
495 TCalTime rDate2; |
|
496 rDate2.SetTimeLocalFloatingL(TDateTime(2006, EMarch, 23, 9, 0, 0, 0)); |
|
497 rDateArray.Append(rDate2); |
|
498 |
|
499 iCalEntry->SetRDatesL(rDateArray); |
|
500 CleanupStack::PopAndDestroy(); // reset rDateArray |
|
501 } |
|
502 |
|
503 RPointerArray<CCalEntry> entryArray; |
|
504 CleanupClosePushL(entryArray); |
|
505 |
|
506 entryArray.AppendL(iCalEntry); |
|
507 TInt entriesAdded = 0; |
|
508 entryView.StoreL(entryArray, entriesAdded); |
|
509 |
|
510 CleanupStack::PopAndDestroy(&entryArray); |
|
511 } |
|
512 |
|
513 |
|
514 /** @SYMTestCaseID PIM-TCAL-TZ-0006 */ |
|
515 void CTzTestManager::TestRepeatRuleLocalTimeL() |
|
516 { |
|
517 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0006 Running tcal_tz - TestRepeatRuleLocalTimeL")); |
|
518 // |
|
519 // Check instances are correct in local London time |
|
520 // |
|
521 |
|
522 // Local time zone is London, Repeat Rule has TzRules |
|
523 // similar to Pacific/Auckland. |
|
524 // London DST starts on |
|
525 // Sunday, 27 March 2005, 01:00 local daylight time |
|
526 // London DST ends on |
|
527 // Sunday, 30 October 2005, 02:00 local standard time |
|
528 |
|
529 // Jan 1th 9am NZ time = Dec 31 8pm UK time |
|
530 // NZ = UK+13 (NZ DST on, UK DST off) |
|
531 |
|
532 TDateTime time1(2005, EMarch, 16, 20, 0, 0, 0); // March 18th 9am NZ time = March 17th 8pm UK time |
|
533 // NZ = UK+13 (NZ DST on, UK DST off) |
|
534 |
|
535 TDateTime time2(2005, EMarch, 22, 21, 0, 0, 0); // March 24rd 9am NZ time = March 23nd 9pm UK time |
|
536 // NZ = UK+12 (NZ DST off, UK DST off) |
|
537 |
|
538 TDateTime time3(2005, EMarch, 28, 22, 0, 0, 0); // March 30th 9am NZ time = March 29th 10pm UK time |
|
539 // NZ = UK+11 (NZ DST off, UK DST on) |
|
540 |
|
541 TDateTime time4(2005, ESeptember, 28, 22, 0, 0, 0); // September 30th 9am NZ time = September 29th 10pm UK time |
|
542 // NZ = UK+11 (NZ DST off, UK DST on) |
|
543 |
|
544 TDateTime time5(2005, EOctober, 12, 21, 0, 0, 0); // October 14th 9am NZ time = October 13th 9pm UK time |
|
545 // NZ = UK+12 (NZ DST on, UK DST on) |
|
546 |
|
547 TDateTime time6(2005, ENovember, 1, 20, 0, 0, 0); // November 3rd 9am NZ time = November 2nd 8pm UK time |
|
548 // NZ = UK+13 (NZ DST on, UK DST off) |
|
549 |
|
550 |
|
551 CheckIsAnInstanceInTimeModeL(time1); |
|
552 CheckIsAnInstanceInTimeModeL(time2); |
|
553 CheckIsAnInstanceInTimeModeL(time3); |
|
554 CheckIsAnInstanceInTimeModeL(time4); |
|
555 CheckIsAnInstanceInTimeModeL(time5); |
|
556 CheckIsAnInstanceInTimeModeL(time6); |
|
557 } |
|
558 |
|
559 |
|
560 /** @SYMTestCaseID PIM-TCAL-TZ-0007 */ |
|
561 void CTzTestManager::TestRepeatRuleTzRulesL() |
|
562 { |
|
563 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0007 Running tcal_tz - TestRepeatRuleTzRulesL")); |
|
564 // |
|
565 // Check instances are correct in entry's timezone |
|
566 // |
|
567 |
|
568 // Local time zone is Europe/London, Repeat Rule has TzRules |
|
569 // similar to Pacific/Auckland. |
|
570 |
|
571 TDateTime time1(2005, EMarch, 17, 9, 0, 0, 0); // March 18th 9am NZ time = March 17th 8pm UK time |
|
572 // NZ = UK+13 (NZ DST on, UK DST off) |
|
573 |
|
574 TDateTime time2(2005, EMarch, 23, 9, 0, 0, 0); // March 24rd 9am NZ time = March 23nd 9pm UK time |
|
575 // NZ = UK+12 (NZ DST off, UK DST off) |
|
576 |
|
577 TDateTime time3(2005, EMarch, 29, 9, 0, 0, 0); // March 30th 9am NZ time = March 29th 10pm UK time |
|
578 // NZ = UK+11 (NZ DST off, UK DST on) |
|
579 |
|
580 TDateTime time4(2005, ESeptember, 29, 9, 0, 0, 0); // September 30th 9am NZ time = September 29th 10pm UK time |
|
581 // NZ = UK+11 (NZ DST off, UK DST on) |
|
582 |
|
583 TDateTime time5(2005, EOctober, 13, 9, 0, 0, 0); // October 14th 9am NZ time = October 13th 9pm UK time |
|
584 // NZ = UK+12 (NZ DST on, UK DST on) |
|
585 |
|
586 TDateTime time6(2005, ENovember, 2, 9, 0, 0, 0); // November 3rd 9am NZ time = November 2nd 8pm UK time |
|
587 // NZ = UK+13 (NZ DST on, UK DST off) |
|
588 |
|
589 CheckIsAnInstanceInSpecifiedZoneL(time1); |
|
590 CheckIsAnInstanceInSpecifiedZoneL(time2); |
|
591 CheckIsAnInstanceInSpecifiedZoneL(time3); |
|
592 CheckIsAnInstanceInSpecifiedZoneL(time4); |
|
593 CheckIsAnInstanceInSpecifiedZoneL(time5); |
|
594 CheckIsAnInstanceInSpecifiedZoneL(time6); |
|
595 } |
|
596 |
|
597 |
|
598 /** @SYMTestCaseID PIM-TCAL-TZ-0008 */ |
|
599 void CTzTestManager::TestRepeatRuleTzStartEndTimeL() |
|
600 { |
|
601 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0008 Running tcal_tz - TestRepeatRuleTzStartEndTimeL")); |
|
602 // |
|
603 // Check start and end time |
|
604 // converted to local time (Asia/Tokyo). |
|
605 |
|
606 // The start and end times were set to this |
|
607 // in Pacific/Auckland summer time: |
|
608 TTime time(TDateTime(2005, EJanuary, 0, 9, 0, 0, 0)); |
|
609 |
|
610 // Local time is now Asia/Tokyo (no DST rule) |
|
611 time -= TTimeIntervalHours(13-9); |
|
612 |
|
613 TDateTime dbgStartTime = iCalEntry->StartTimeL().TimeUtcL().DateTime(); |
|
614 |
|
615 TTime start = iCalEntry->StartTimeL().TimeLocalL(); |
|
616 test(time == start); |
|
617 |
|
618 TTime end = iCalEntry->EndTimeL().TimeLocalL(); |
|
619 test(time == end); |
|
620 } |
|
621 |
|
622 |
|
623 /** @SYMTestCaseID PIM-TCAL-TZ-0009 */ |
|
624 void CTzTestManager::TestRepeatRuleTzStartEndTzRulesL() |
|
625 { |
|
626 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0009 Running tcal_tz - TestRepeatRuleTzStartEndTzRulesL")); |
|
627 // |
|
628 // Check start and end time |
|
629 // converted with entry's TzRules. |
|
630 |
|
631 // The start and end times were set to this |
|
632 TTime time(TDateTime(2005, EJanuary, 0, 9, 0, 0, 0)); |
|
633 |
|
634 CTzRules* rules = iCalEntry->TzRulesL(); |
|
635 CleanupStack::PushL(rules); |
|
636 |
|
637 TTime start = iCalEntry->StartTimeL().TimeUtcL(); |
|
638 rules->ConvertToLocalL(start); |
|
639 test(time == start); |
|
640 |
|
641 TTime end = iCalEntry->EndTimeL().TimeUtcL(); |
|
642 rules->ConvertToLocalL(end); |
|
643 test(time == end); |
|
644 |
|
645 CleanupStack::PopAndDestroy(rules); |
|
646 } |
|
647 |
|
648 |
|
649 /** @SYMTestCaseID PIM-TCAL-TZ-0010 */ |
|
650 void CTzTestManager::TestFloatingRepeatCheckL() |
|
651 { |
|
652 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0010 Running tcal_tz - TestFloatingRepeatCheckL")); |
|
653 // changed time zone to London |
|
654 // check instance are correct in local UK time, should be the same as Auckland time because entry time is floating |
|
655 TDateTime time1(2005, EMarch, 17, 9, 0, 0, 0); // March 18th 9am floating time |
|
656 |
|
657 TDateTime time2(2005, EMarch, 23, 9, 0, 0, 0); // March 24rd 9am floating time |
|
658 |
|
659 TDateTime time3(2005, EMarch, 29, 9, 0, 0, 0); // March 30th 9am floating time |
|
660 |
|
661 TDateTime time4(2005, ESeptember, 29, 9, 0, 0, 0); // September 30th 9am floating time |
|
662 |
|
663 TDateTime time5(2005, EOctober, 13, 9, 0, 0, 0); // October 14th 9am floating time |
|
664 |
|
665 TDateTime time6(2005, ENovember, 2, 9, 0, 0, 0); // November 3rd 9am floating time |
|
666 |
|
667 CheckIsAnInstanceInTimeModeL(time1, ETrue, TCalTime::EFloating); |
|
668 CheckIsAnInstanceInTimeModeL(time2, ETrue, TCalTime::EFloating); |
|
669 CheckIsAnInstanceInTimeModeL(time3, ETrue, TCalTime::EFloating); |
|
670 CheckIsAnInstanceInTimeModeL(time4, ETrue, TCalTime::EFloating); |
|
671 CheckIsAnInstanceInTimeModeL(time5, ETrue, TCalTime::EFloating); |
|
672 CheckIsAnInstanceInTimeModeL(time6, ETrue, TCalTime::EFloating); |
|
673 } |
|
674 |
|
675 |
|
676 /** @SYMTestCaseID PIM-TCAL-TZ-0011 */ |
|
677 void CTzTestManager::TestFloatingExceptionCheckL() |
|
678 { |
|
679 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0011 Running tcal_tz - TestFloatingExceptionCheckL")); |
|
680 // changed time zone to London |
|
681 // check instance are correct in local UK time, should be the same as Auckland time because entry time is floating |
|
682 TDateTime time1(2005, EMarch, 17, 9, 0, 0, 0); // March 18th 9am floating time |
|
683 |
|
684 TDateTime time2(2005, EMarch, 23, 9, 0, 0, 0); // March 24rd 9am floating time |
|
685 |
|
686 TDateTime time3(2005, EMarch, 29, 9, 0, 0, 0); // March 30th 9am floating time |
|
687 |
|
688 TDateTime time4(2005, ESeptember, 29, 9, 0, 0, 0); // September 30th 9am floating time |
|
689 |
|
690 TDateTime time5(2005, EOctober, 13, 9, 0, 0, 0); // October 14th 9am floating time |
|
691 |
|
692 TDateTime time6(2005, ENovember, 2, 9, 0, 0, 0); // November 3rd 9am floating time |
|
693 |
|
694 |
|
695 CheckIsAnInstanceInTimeModeL(time1, ETrue, TCalTime::EFloating); |
|
696 CheckIsAnInstanceInTimeModeL(time3, ETrue, TCalTime::EFloating); |
|
697 CheckIsAnInstanceInTimeModeL(time5, ETrue, TCalTime::EFloating); |
|
698 CheckIsAnInstanceInTimeModeL(time6, ETrue, TCalTime::EFloating); |
|
699 |
|
700 CheckIsAnInstanceInTimeModeL(time2, EFalse, TCalTime::EFloating); |
|
701 CheckIsAnInstanceInTimeModeL(time4, EFalse, TCalTime::EFloating); |
|
702 } |
|
703 |
|
704 |
|
705 /** @SYMTestCaseID PIM-TCAL-TZ-0012 */ |
|
706 void CTzTestManager::TestFloatingRDateCheckL() |
|
707 { |
|
708 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0012 Running tcal_tz - TestFloatingRDateCheckL")); |
|
709 // changed time zone to London |
|
710 // check instance are correct in local UK time, should be the same as Auckland time because entry time is floating |
|
711 TDateTime time1(2005, EMarch, 17, 9, 0, 0, 0); // March 18th 9am floating time |
|
712 |
|
713 TDateTime time2(2005, EMarch, 23, 9, 0, 0, 0); // March 24rd 9am floating time |
|
714 |
|
715 TDateTime time3(2005, EMarch, 29, 9, 0, 0, 0); // March 30th 9am floating time |
|
716 |
|
717 TDateTime time4(2005, ESeptember, 29, 9, 0, 0, 0); // September 30th 9am floating time |
|
718 |
|
719 TDateTime time5(2005, EOctober, 13, 9, 0, 0, 0); // October 14th 9am floating time |
|
720 |
|
721 TDateTime time6(2005, ENovember, 2, 9, 0, 0, 0); // November 3rd 9am floating time |
|
722 |
|
723 TDateTime time7(2004, EDecember, 2, 9, 0, 0, 0); // rDate1 |
|
724 |
|
725 TDateTime time8(2006, EMarch, 23, 9, 0, 0, 0); // rDate2 |
|
726 |
|
727 CheckIsAnInstanceInTimeModeL(time1, ETrue, TCalTime::EFloating); |
|
728 CheckIsAnInstanceInTimeModeL(time2, ETrue, TCalTime::EFloating); |
|
729 CheckIsAnInstanceInTimeModeL(time3, ETrue, TCalTime::EFloating); |
|
730 CheckIsAnInstanceInTimeModeL(time4, ETrue, TCalTime::EFloating); |
|
731 CheckIsAnInstanceInTimeModeL(time5, ETrue, TCalTime::EFloating); |
|
732 CheckIsAnInstanceInTimeModeL(time6, ETrue, TCalTime::EFloating); |
|
733 CheckIsAnInstanceInTimeModeL(time7, ETrue, TCalTime::EFloating); |
|
734 CheckIsAnInstanceInTimeModeL(time8, ETrue, TCalTime::EFloating); |
|
735 } |
|
736 |
|
737 |
|
738 /* |
|
739 This test is a variation of a repeat rule test. |
|
740 It was adapted from an unofficial version |
|
741 of tcal_tz.cpp written for reproducing a defect. |
|
742 */ |
|
743 /** @SYMTestCaseID PIM-TCAL-TZ-0013 */ |
|
744 void CTzTestManager::DefectTestL() |
|
745 { |
|
746 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0013 Running tcal_tz - DefectTestL")); |
|
747 HBufC8* uid = _L8("DUMMY_UID").AllocLC(); |
|
748 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, uid, CCalEntry::EMethodNone, 0); |
|
749 |
|
750 CleanupStack::Pop(uid); |
|
751 CleanupStack::PushL(entry); |
|
752 |
|
753 delete iCalEntry; |
|
754 iCalEntry = entry; |
|
755 |
|
756 CTzRules* tzRules = CTzRules::NewL(2000, 2010); |
|
757 CleanupStack::PushL(tzRules); |
|
758 |
|
759 // Specify start/end time |
|
760 TDateTime dtStart(2001,EJuly,5,20,30,0,0); //9:30pm in London 06 of July (Wednesday) 10:30 in Stockholm 07 of July (Thursday) |
|
761 TDateTime dtEnd(2001,EJuly,5,21,30,0,0); |
|
762 TCalTime startCalTime; |
|
763 TCalTime endCalTime; |
|
764 startCalTime.SetTimeUtcL(dtStart); |
|
765 endCalTime.SetTimeUtcL(dtEnd); |
|
766 entry->SetStartAndEndTimeL(startCalTime,endCalTime); |
|
767 entry->SetSummaryL(_L("QGsUtilsTest:: TestTzL")); |
|
768 entry->SetDescriptionL(_L("TZ test. ")); |
|
769 |
|
770 TCalRRule rule; |
|
771 TCalTime ruleStart; |
|
772 ruleStart.SetTimeUtcL(dtStart); |
|
773 // Create weekly repeat rule on Thursday and Saturday in Sweden |
|
774 rule.SetType(TCalRRule::EWeekly); |
|
775 rule.SetInterval(1); |
|
776 rule.SetCount(2); |
|
777 rule.SetDtStart(ruleStart); |
|
778 RArray<TDay> days; |
|
779 CleanupClosePushL(days); |
|
780 days.Append(EThursday); // 7th in Sweden is a Thursday |
|
781 days.Append(ESaturday); |
|
782 rule.SetByDay(days); |
|
783 days.Reset(); |
|
784 days.Close(); |
|
785 entry->SetRRuleL(rule); |
|
786 CleanupStack::PopAndDestroy(&days); |
|
787 |
|
788 tzRules->SetInitialStdTimeOffset(60); // Swedish rules |
|
789 TTzRule rule1(2000, 2010, 60, 120, EMarch, ETzDayInLastWeekOfMonth, 0, ESunday, ETzUtcTimeReference, 120); |
|
790 TTzRule rule2(2000, 2010, 120, 60, EOctober, ETzDayInLastWeekOfMonth, 0, ESunday, ETzUtcTimeReference, 180); |
|
791 tzRules->AddRuleL(rule1); |
|
792 tzRules->AddRuleL(rule2); |
|
793 entry->SetTzRulesL(*tzRules); // set tz rules to be Swedish |
|
794 |
|
795 |
|
796 // store entry |
|
797 |
|
798 CCalEntryView& entryView = iTestLibrary->SynCGetEntryViewL(); |
|
799 |
|
800 RPointerArray<CCalEntry> entryArray; |
|
801 CleanupClosePushL(entryArray); |
|
802 |
|
803 entryArray.AppendL(entry); |
|
804 TInt entriesAdded = 0; |
|
805 entryView.StoreL(entryArray, entriesAdded); |
|
806 |
|
807 CleanupStack::PopAndDestroy(&entryArray); |
|
808 CleanupStack::PopAndDestroy(tzRules); |
|
809 |
|
810 |
|
811 // fetch instances |
|
812 |
|
813 CCalInstanceView* instanceView = &iTestLibrary->SynCGetInstanceViewL(); |
|
814 |
|
815 RPointerArray<CCalInstance> instances; |
|
816 CleanupResetAndDestroyPushL(instances); |
|
817 |
|
818 TCalTime calTimeStart; |
|
819 calTimeStart.SetTimeUtcL(TDateTime(2001, EJuly, 0, 0, 0, 0, 0)); // 00:00 on 1 July 2005 |
|
820 TCalTime calTimeEnd; |
|
821 calTimeEnd.SetTimeUtcL(TDateTime(2001, EAugust, 0, 0, 0, 0, 0)); // 00:00 on 1 August 2005 |
|
822 |
|
823 CalCommon::TCalViewFilter filter(CalCommon::EIncludeAll); |
|
824 CalCommon::TCalTimeRange timeRange(calTimeStart, calTimeEnd); |
|
825 |
|
826 instanceView->FindInstanceL(instances, filter, timeRange); |
|
827 test(instances.Count() == 2); |
|
828 for (TInt i = 0; i < instances.Count(); i++) |
|
829 { |
|
830 TDateTime dt = instances[i]->Time().TimeUtcL().DateTime(); |
|
831 test.Printf(_L("found instance #%d: %d/%d/%d, %d:%d:%d UTC\n"), i, |
|
832 dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second()); |
|
833 } |
|
834 |
|
835 CleanupStack::PopAndDestroy(&instances); // instances.ResetAndDestroy(); |
|
836 |
|
837 |
|
838 // needed by CheckIsAnInstanceInSpecifiedZoneL |
|
839 iCalEntry = entry; |
|
840 // 7/7/2001, 21:30 London, 22:30 Stockholm |
|
841 TDateTime time1a(2001, EJuly, 6, 21, 30, 0, 0); |
|
842 TDateTime time1b(2001, EJuly, 6, 22, 30, 0, 0); |
|
843 CheckIsAnInstanceInTimeModeL(time1a, ETrue, TCalTime::EFloating); |
|
844 CheckIsAnInstanceInSpecifiedZoneL(time1b); |
|
845 |
|
846 // 7/12/2001, 21:30 London, 22:30 Stockholm |
|
847 TDateTime time2a(2001, EJuly, 11, 21, 30, 0, 0); |
|
848 TDateTime time2b(2001, EJuly, 11, 22, 30, 0, 0); |
|
849 CheckIsAnInstanceInTimeModeL(time2a, ETrue, TCalTime::EFloating); |
|
850 CheckIsAnInstanceInSpecifiedZoneL(time2b); |
|
851 |
|
852 iCalEntry = NULL; |
|
853 |
|
854 CleanupStack::PopAndDestroy(entry); |
|
855 } |
|
856 |
|
857 |
|
858 /** @SYMTestCaseID PIM-TCAL-TZ-0014 */ |
|
859 void CTzTestManager::TestRDatesTzSetupL() |
|
860 { |
|
861 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0014 Running tcal_tz - TestRDatesTzSetupL")); |
|
862 HBufC8* dummy = NULL; |
|
863 delete iCalEntry; |
|
864 iCalEntry = NULL; |
|
865 iCalEntry = iTestLibrary->CreateCalEntryL(CCalEntry::EEvent, dummy); |
|
866 |
|
867 TTime dtStart(TDateTime(2005, EJanuary, 0, 9, 0, 0, 0)); |
|
868 TTime dtEnd(TDateTime(2005, EJanuary, 0, 10, 0, 0, 0)); |
|
869 TCalTime startCalTime; |
|
870 TCalTime endCalTime; |
|
871 startCalTime.SetTimeLocalL(dtStart); |
|
872 endCalTime.SetTimeLocalL(dtEnd); |
|
873 iCalEntry->SetStartAndEndTimeL(startCalTime, startCalTime); |
|
874 |
|
875 RArray<TCalTime> dates; |
|
876 CleanupClosePushL(dates); |
|
877 TCalTime rdate; |
|
878 TDateTime date1(2005, EJanuary, 10, 9, 0, 0, 0); |
|
879 rdate.SetTimeLocalL(date1); |
|
880 dates.AppendL(rdate); |
|
881 TDateTime date2(2005, EJanuary, 20, 9, 0, 0, 0); |
|
882 rdate.SetTimeLocalL(date2); |
|
883 dates.AppendL(rdate); |
|
884 iCalEntry->SetRDatesL(dates); |
|
885 CleanupStack::PopAndDestroy(&dates); |
|
886 |
|
887 RTz tz; |
|
888 User::LeaveIfError(tz.Connect()); |
|
889 CTzId* id = CTzId::NewL(KPacificAuckland); |
|
890 CleanupStack::PushL(id); |
|
891 CTzRules* rules = tz.GetTimeZoneRulesL(*id, TDateTime(2000, EJanuary, 0, 0, 0, 0, 0), TDateTime(2010, EJanuary, 0, 0, 0, 0, 0), ETzUtcTimeReference); |
|
892 CleanupStack::PopAndDestroy(id); |
|
893 tz.Close(); |
|
894 |
|
895 CleanupStack::PushL(rules); |
|
896 |
|
897 iCalEntry->SetTzRulesL(*rules); // set tz rules to be local |
|
898 CleanupStack::PopAndDestroy(rules); |
|
899 |
|
900 CCalEntryView& entryView = iTestLibrary->SynCGetEntryViewL(); |
|
901 RPointerArray<CCalEntry> entryArray; |
|
902 CleanupClosePushL(entryArray); |
|
903 |
|
904 entryArray.AppendL(iCalEntry); |
|
905 TInt entriesAdded = 0; |
|
906 entryView.StoreL(entryArray, entriesAdded); |
|
907 |
|
908 CleanupStack::PopAndDestroy(&entryArray); |
|
909 |
|
910 // Now retrieve and test results |
|
911 |
|
912 CheckIsAnInstanceInSpecifiedZoneL(date1); |
|
913 CheckIsAnInstanceInSpecifiedZoneL(date2); |
|
914 } |
|
915 |
|
916 |
|
917 void CTzTestManager::CheckIsAnInstanceInTimeModeL(const TTime& aLocalTime, TBool aFound, TCalTime::TTimeMode aTimeMode) |
|
918 { |
|
919 CCalInstanceView& instanceView = iTestLibrary->SynCGetInstanceViewL(); |
|
920 |
|
921 RPointerArray<CCalInstance> instances; |
|
922 CleanupResetAndDestroyPushL(instances); |
|
923 |
|
924 // Set up filter to find instance at aTime: |
|
925 CalCommon::TCalViewFilter filter(CalCommon::EIncludeAll); |
|
926 TCalTime calTime; |
|
927 if(aTimeMode == TCalTime::EFloating) |
|
928 { |
|
929 calTime.SetTimeLocalFloatingL(aLocalTime); |
|
930 } |
|
931 else if(aTimeMode == TCalTime::EFixedTimeZone) |
|
932 { |
|
933 calTime.SetTimeLocalL(aLocalTime); |
|
934 } |
|
935 |
|
936 CalCommon::TCalTimeRange timeRange(calTime, calTime); |
|
937 |
|
938 instanceView.FindInstanceL(instances, filter, timeRange); |
|
939 |
|
940 TDateTime dt = aLocalTime.DateTime(); |
|
941 test.Printf(_L("expecting an instance at %d:%d:%d on %d/%d/%d"), |
|
942 dt.Hour(), dt.Minute(), dt.Second(), dt.Day()+1, dt.Month()+1, dt.Year()); |
|
943 |
|
944 for (TInt i = 0; i < instances.Count(); i++) |
|
945 { |
|
946 dt = instances[i]->Time().TimeLocalL().DateTime(); |
|
947 test.Printf(_L("found instance %d at %d:%d:%d on %d/%d/%d"), i, |
|
948 dt.Hour(), dt.Minute(), dt.Second(), dt.Day()+1, dt.Month()+1, dt.Year()); |
|
949 } |
|
950 |
|
951 if (aFound) |
|
952 { |
|
953 test(instances.Count() == 1); |
|
954 test(instances[0]->Time().TimeLocalL() == aLocalTime); |
|
955 } |
|
956 else |
|
957 { |
|
958 test(instances.Count() == 0); |
|
959 } |
|
960 |
|
961 CleanupStack::PopAndDestroy(&instances); // instances.ResetAndDestroy(); |
|
962 } |
|
963 |
|
964 |
|
965 // aTime should be relative to iCalEntry's own CTzRules. |
|
966 void CTzTestManager::CheckIsAnInstanceInSpecifiedZoneL(const TTime& aTime) |
|
967 { |
|
968 CCalInstanceView& instanceView = iTestLibrary->SynCGetInstanceViewL(); |
|
969 |
|
970 RPointerArray<CCalInstance> instances; |
|
971 CleanupResetAndDestroyPushL(instances); |
|
972 |
|
973 // Set up filter to find instance at aTime: |
|
974 CalCommon::TCalViewFilter filter(CalCommon::EIncludeAll); |
|
975 TCalTime calTime; |
|
976 CTzRules* rules = iCalEntry->TzRulesL(); |
|
977 CleanupStack::PushL(rules); |
|
978 TTime queryTime = aTime; |
|
979 rules->ConvertToUtcL(queryTime); |
|
980 calTime.SetTimeUtcL(queryTime); |
|
981 CalCommon::TCalTimeRange timeRange(calTime, calTime); |
|
982 |
|
983 instanceView.FindInstanceL(instances, filter, timeRange); |
|
984 test(instances.Count() == 1); |
|
985 |
|
986 TTime instanceTime = instances[0]->Time().TimeUtcL(); |
|
987 TDateTime dbgTime2 = instanceTime.DateTime(); |
|
988 rules->ConvertToLocalL(instanceTime); |
|
989 test(instanceTime == aTime); |
|
990 |
|
991 CleanupStack::PopAndDestroy(rules); |
|
992 CleanupStack::PopAndDestroy(&instances); // instances.ResetAndDestroy(); |
|
993 } |
|
994 |
|
995 |
|
996 void CTzTestManager::VerifyRulesL(const CTzRules& aRules,const TCalTime& aStartRange,const TCalTime& aEndRange) |
|
997 { |
|
998 CCalInstanceView* instanceView = &iTestLibrary->SynCGetInstanceViewL(); |
|
999 |
|
1000 RPointerArray<CCalInstance> instances; |
|
1001 CleanupResetAndDestroyPushL(instances); |
|
1002 |
|
1003 CalCommon::TCalViewFilter filter(CalCommon::EIncludeAll); |
|
1004 CalCommon::TCalTimeRange timeRange(aStartRange,aEndRange); |
|
1005 instanceView->FindInstanceL(instances, filter, timeRange); |
|
1006 for (TInt i = 0; i < instances.Count(); i++) |
|
1007 { |
|
1008 CCalEntry& entry = instances[i]->Entry(); |
|
1009 CTzRules* rules = entry.TzRulesL(); |
|
1010 CleanupStack::PushL(rules); |
|
1011 test(rules->IsEqualTo(aRules)); |
|
1012 CleanupStack::PopAndDestroy(rules); |
|
1013 } |
|
1014 |
|
1015 CleanupStack::PopAndDestroy(&instances); |
|
1016 } |
|
1017 |
|
1018 |
|
1019 // DEF074085 |
|
1020 // SetRRulesL() did not preserve the timezone rules of the CAgnEntry repeat def |
|
1021 // Any subsequent UpdateL would see a null timezone and reset to the local one |
|
1022 // Fix to SetRRulesL() preserves the CAgnRptDef tz rules |
|
1023 // This test case: |
|
1024 // Sets a repeat rule with SetRRulesL() |
|
1025 // Sets an arbitrary repeat timezone rule |
|
1026 // StoreL() to the database |
|
1027 // Verifies the retrieved tz rules are the original ones saved |
|
1028 // FetchL() the saved entry |
|
1029 // Modifies the summary with SetSummaryL() |
|
1030 // Calls SetRRulesL() again (Defect was here) |
|
1031 // Calls UpdateL() |
|
1032 // Verifies the retrieved tz rules are the original ones saved |
|
1033 void CTzTestManager::TestCopyRepeatRulesL() |
|
1034 { |
|
1035 iTestLibrary->CleanDatabaseL(); |
|
1036 |
|
1037 delete iCalEntry; |
|
1038 iCalEntry = NULL; |
|
1039 |
|
1040 _LIT8(KEntryUid,"DEF074805"); |
|
1041 HBufC8* uid = KEntryUid().AllocLC(); |
|
1042 |
|
1043 iCalEntry=CCalEntry::NewL(CCalEntry::EEvent,uid, CCalEntry::EMethodAdd, 0); |
|
1044 |
|
1045 CleanupStack::Pop(); |
|
1046 iCalEntry->SetSummaryL(_L("Original")); |
|
1047 TDateTime dtStart(2005,EMarch,0,8,0,0,0); |
|
1048 TCalTime startCalTime; |
|
1049 startCalTime.SetTimeLocalL(dtStart); |
|
1050 iCalEntry->SetStartAndEndTimeL(startCalTime,startCalTime); |
|
1051 TCalRRule calRule(TCalRRule::EWeekly); |
|
1052 calRule.SetDtStart(startCalTime); |
|
1053 calRule.SetCount(8); |
|
1054 calRule.SetInterval(1); |
|
1055 RArray<TDay> days; |
|
1056 days.AppendL(ESunday); |
|
1057 calRule.SetByDay(days); |
|
1058 // This call to SetRRuleL() has a null timezone |
|
1059 iCalEntry->SetRRuleL(calRule); |
|
1060 days.Reset(); |
|
1061 |
|
1062 // Arbitrary timezone (Not the same as local) |
|
1063 TTzRule tRule1(1981,1996,0,60,EMarch,ETzDayInLastWeekOfMonth,0,ESunday,ETzUtcTimeReference,60); |
|
1064 TTzRule tRule2(1981,1996,60,0,EOctober,ETzDayInLastWeekOfMonth,0,ESunday,ETzUtcTimeReference,60); |
|
1065 TTzRule tRule3(0,KMaxTUint16,0,0,EJanuary,ETzFixedDate,0,0,ETzWallTimeReference,0); |
|
1066 CTzRules* origRules = CTzRules::NewL(2003,2007); |
|
1067 CleanupStack::PushL(origRules); |
|
1068 origRules->AddRuleL(tRule1); |
|
1069 origRules->AddRuleL(tRule2); |
|
1070 origRules->AddRuleL(tRule3); |
|
1071 // Sets the timezone in the repeat def |
|
1072 iCalEntry->SetTzRulesL(*origRules); |
|
1073 { |
|
1074 CCalEntryView& entryView = iTestLibrary->SynCGetEntryViewL(); |
|
1075 RPointerArray<CCalEntry> entryArray; |
|
1076 CleanupClosePushL(entryArray); |
|
1077 |
|
1078 entryArray.AppendL(iCalEntry); |
|
1079 TInt entriesAdded = 0; |
|
1080 // Save to database |
|
1081 entryView.StoreL(entryArray, entriesAdded); |
|
1082 |
|
1083 CleanupStack::PopAndDestroy(&entryArray); |
|
1084 } |
|
1085 // Set up the range for entries to read |
|
1086 TCalTime startRange; |
|
1087 startRange.SetTimeLocalL(TDateTime(2005,EMarch,0,8,0,0,0)); |
|
1088 TCalTime endRange; |
|
1089 endRange.SetTimeLocalL(TDateTime(2005,EApril,15, 8, 0, 0, 0)); |
|
1090 // Verify the StoreL() preserved the original rules |
|
1091 VerifyRulesL(*origRules,startRange,endRange); |
|
1092 { |
|
1093 // Fetch the entry ready for update |
|
1094 CCalEntryView& entryView = iTestLibrary->SynCGetEntryViewL(); |
|
1095 RPointerArray<CCalEntry> entryArray; |
|
1096 CleanupResetAndDestroyPushL(entryArray); |
|
1097 |
|
1098 entryView.FetchL(KEntryUid, entryArray); |
|
1099 |
|
1100 // Update the rule (DEFECT was here) |
|
1101 entryArray[0]->SetRRuleL(calRule); |
|
1102 entryArray[0]->SetSummaryL(_L("Modified")); |
|
1103 TInt entriesAdded = 0; |
|
1104 // Updates the database |
|
1105 entryView.UpdateL(entryArray, entriesAdded); |
|
1106 |
|
1107 CleanupStack::PopAndDestroy(&entryArray); |
|
1108 } |
|
1109 // Verifies defect fix |
|
1110 VerifyRulesL(*origRules,startRange,endRange); |
|
1111 |
|
1112 CleanupStack::PopAndDestroy(origRules); |
|
1113 } |
|
1114 |
|
1115 |
|
1116 /** @SYMTestCaseID PIM-TCAL-TZ-0015 */ |
|
1117 void CTzTestManager::TestForeignZoneRepeatRule1L() |
|
1118 { |
|
1119 iTestLibrary->CleanDatabaseL(); |
|
1120 |
|
1121 HBufC8* uid = _L8("DUMMY_UID").AllocLC(); |
|
1122 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, uid, CCalEntry::EMethodNone, 0); |
|
1123 CleanupStack::Pop(uid); |
|
1124 CleanupStack::PushL(entry); |
|
1125 |
|
1126 CTzRules* tzRules = CTzRules::NewL(2000, 2010); |
|
1127 CleanupStack::PushL(tzRules); |
|
1128 |
|
1129 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0015 Creating repeating entry every Thursday and Saturday from 7 July at 00:30 Stockholm time (6 July 22:30 UTC)")); |
|
1130 TDateTime dtStart(2005,EJuly,5,22,30,0,0); //11:30pm in London 06 of Juli (Wednessday) 00:30 in Stockholm 07 of Juli (Thursday) |
|
1131 TDateTime dtEnd(2005,EJuly,5,23,20,0,0); |
|
1132 TCalTime startCalTime; |
|
1133 TCalTime endCalTime; |
|
1134 startCalTime.SetTimeUtcL(dtStart); |
|
1135 endCalTime.SetTimeUtcL(dtEnd); |
|
1136 entry->SetStartAndEndTimeL(startCalTime,endCalTime); |
|
1137 entry->SetSummaryL(_L("QGsUtilsTest:: TestTzL")); |
|
1138 entry->SetDescriptionL(_L("TZ test. ")); |
|
1139 |
|
1140 TCalRRule rule; |
|
1141 TCalTime ruleStart; |
|
1142 ruleStart.SetTimeUtcL(dtStart); |
|
1143 // Create weekly repeat rule on Thursday and Saturday in Sweden |
|
1144 rule.SetType(TCalRRule::EWeekly); |
|
1145 rule.SetInterval(1); |
|
1146 rule.SetCount(2); |
|
1147 rule.SetDtStart(ruleStart); |
|
1148 RArray<TDay> days; |
|
1149 days.Append(EThursday); // 7th is a Thursday |
|
1150 days.Append(ESaturday); |
|
1151 rule.SetByDay(days); |
|
1152 days.Reset(); |
|
1153 days.Close(); |
|
1154 entry->SetRRuleL(rule); |
|
1155 |
|
1156 tzRules->SetInitialStdTimeOffset(60); // Swedish rules |
|
1157 TTzRule rule1(2000, 2010, 60, 120, EMarch, ETzDayInLastWeekOfMonth, 0, ESunday, ETzUtcTimeReference, 120); |
|
1158 TTzRule rule2(2000, 2010, 120, 60, EOctober, ETzDayInLastWeekOfMonth, 0, ESunday, ETzUtcTimeReference, 180); |
|
1159 tzRules->AddRuleL(rule1); |
|
1160 tzRules->AddRuleL(rule2); |
|
1161 entry->SetTzRulesL(*tzRules); // set tz rules to be Swedish |
|
1162 |
|
1163 CCalEntryView* entryView = &iTestLibrary->SynCGetEntryViewL(); |
|
1164 TInt success = 0; |
|
1165 RPointerArray<CCalEntry> entries; |
|
1166 CleanupClosePushL(entries); |
|
1167 |
|
1168 entries.Append(entry); |
|
1169 entryView->StoreL(entries, success); // Store the CCalEntry |
|
1170 test(success == 1); |
|
1171 |
|
1172 CleanupStack::PopAndDestroy(&entries);//entries.Reset(); |
|
1173 CleanupStack::PopAndDestroy(tzRules); |
|
1174 CleanupStack::PopAndDestroy(entry); |
|
1175 } |
|
1176 |
|
1177 void CTzTestManager::TestForeignZoneRepeatRule2L() |
|
1178 { |
|
1179 CCalInstanceView* instanceView = &iTestLibrary->SynCGetInstanceViewL(); |
|
1180 |
|
1181 TCalTime calTimeStart; |
|
1182 calTimeStart.SetTimeUtcL(TDateTime(2005, EJuly, 0, 0, 0, 0, 0)); // 00:00 on 1 July 2005 |
|
1183 TCalTime calTimeEnd; |
|
1184 calTimeEnd.SetTimeUtcL(TDateTime(2005, EJuly, 30, 23, 59, 59, 0)); // 23:59 on 31 July 2005 |
|
1185 |
|
1186 RPointerArray<CCalInstance> instances; |
|
1187 CleanupResetAndDestroyPushL(instances); |
|
1188 |
|
1189 CalCommon::TCalViewFilter filter(CalCommon::EIncludeAll); |
|
1190 CalCommon::TCalTimeRange timeRange(calTimeStart, calTimeEnd); |
|
1191 |
|
1192 instanceView->FindInstanceL(instances, filter, timeRange); |
|
1193 test(instances.Count() == 2); |
|
1194 for (TInt i = 0; i < instances.Count(); i++) |
|
1195 { |
|
1196 TDateTime dt = instances[i]->Time().TimeLocalL().DateTime(); |
|
1197 test.Printf(_L("found instance on %d: %d/%d/%d, %d:%d:%d\n"), i, |
|
1198 dt.Day()+1, dt.Month()+1, dt.Year(), dt.Hour(), dt.Minute(), dt.Second()); |
|
1199 |
|
1200 //1-st instance is on July 06 at 23:30 - Wednesday (London timezone) |
|
1201 //2-nd instance is on July 08 at 23:30 - Friday (London time zone) |
|
1202 test((TTime(dt) == TTime(TDateTime(2005,EJuly,5,23,30,0,0))) || |
|
1203 (TTime(dt) == TTime(TDateTime(2005,EJuly,7,23,30,0,0)))); |
|
1204 } |
|
1205 |
|
1206 CleanupStack::PopAndDestroy(&instances); //instances.ResetAndDestroy(); |
|
1207 } |
|
1208 |
|
1209 |
|
1210 // DEF 066566 |
|
1211 // Test recurring entry has correctly updating instance time |
|
1212 /** @SYMTestCaseID PIM-TCAL-TZ-0016 */ |
|
1213 void CTzTestManager::TestLocalRepeatRuleL() |
|
1214 { |
|
1215 iTestLibrary->CleanDatabaseL(); |
|
1216 |
|
1217 TestSetTimeZoneL(KEuropeHelsinki); |
|
1218 |
|
1219 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0016 Create repeating entry every 4th day of the month, from 4 Sept 2005 at 11:30 Helsinki time (08:30 UTC)")); test.Printf(_L("Check that the UTC time changes between different months and the local time doesn't")); |
|
1220 |
|
1221 // ADD RECURRING ENTRY |
|
1222 HBufC8* uid = HBufC8::NewL( 10 ); |
|
1223 uid->Des().Copy( _L8("myuid") ); |
|
1224 CCalEntry* entry = CCalEntry::NewL( CCalEntry::EAppt, uid, CCalEntry::EMethodNone, 0 ); |
|
1225 |
|
1226 TCalTime startTime; |
|
1227 TCalTime endTime; |
|
1228 startTime.SetTimeUtcL(TTime(TDateTime(2005, ESeptember, 3, 8, 30, 0, 0))); |
|
1229 endTime.SetTimeUtcL(TTime(TDateTime(2005, ESeptember, 3, 9, 00, 0, 0))); |
|
1230 |
|
1231 entry->SetStartAndEndTimeL( startTime, endTime ); |
|
1232 |
|
1233 // recurrence rule |
|
1234 TCalRRule recurrenceRule; |
|
1235 recurrenceRule.SetType( TCalRRule::EMonthly ); |
|
1236 recurrenceRule.SetCount( 12 ); |
|
1237 recurrenceRule.SetDtStart( startTime ); |
|
1238 recurrenceRule.SetInterval( 1 ); |
|
1239 |
|
1240 RArray<TInt> monthDays; |
|
1241 monthDays.Append( 3 ); |
|
1242 recurrenceRule.SetByMonthDay( monthDays ); |
|
1243 monthDays.Close(); |
|
1244 |
|
1245 entry->SetRRuleL( recurrenceRule ); |
|
1246 |
|
1247 // time zone rules - use Helsinki time |
|
1248 entry->SetTzRulesL(); |
|
1249 |
|
1250 // write entry to database |
|
1251 RPointerArray<CCalEntry> entries; |
|
1252 CleanupResetAndDestroyPushL(entries); |
|
1253 |
|
1254 entries.Append( entry ); |
|
1255 TInt successCount = 0; |
|
1256 iTestLibrary->SynCGetEntryViewL().StoreL( entries, successCount ); |
|
1257 |
|
1258 CleanupStack::PopAndDestroy(&entries); //entries.ResetAndDestroy(); |
|
1259 |
|
1260 TCalTime calMinTimeRange; |
|
1261 calMinTimeRange.SetTimeUtcL(TCalTime::MinTime()); |
|
1262 TCalTime calMaxTimeRange; |
|
1263 calMaxTimeRange.SetTimeUtcL(TCalTime::MaxTime()); |
|
1264 |
|
1265 // find all instances |
|
1266 CalCommon::TCalTimeRange timeRange(calMinTimeRange, calMaxTimeRange); |
|
1267 RPointerArray<CCalInstance> instanceList; |
|
1268 CleanupResetAndDestroyPushL(instanceList); |
|
1269 |
|
1270 iTestLibrary->SynCGetInstanceViewL().FindInstanceL( instanceList, CalCommon::EIncludeAll, timeRange ); |
|
1271 |
|
1272 TInt count = instanceList.Count(); |
|
1273 |
|
1274 // Check that the UTC time of the zone varies |
|
1275 TInt utcHour = startTime.TimeUtcL().DateTime().Hour(); // 8 |
|
1276 TInt localHour = startTime.TimeLocalL().DateTime().Hour(); // 11 |
|
1277 |
|
1278 TBool utcTimeChanged = EFalse; |
|
1279 TBool localTimeChanged = EFalse; |
|
1280 |
|
1281 for( TInt i = 0; i < count; i++ ) |
|
1282 { |
|
1283 TDateTime dt = instanceList[i]->Time().TimeLocalL().DateTime(); |
|
1284 TInt startHourUtcInstance = instanceList[i]->Time().TimeUtcL().DateTime().Hour(); |
|
1285 |
|
1286 test.Printf(_L("local instance time: %d:%d:%d on %d/%d/%d, utc hour=%d \n"), |
|
1287 dt.Hour(), dt.Minute(), dt.Second(), dt.Day()+1, dt.Month()+1, dt.Year(), startHourUtcInstance); |
|
1288 |
|
1289 if (utcHour != startHourUtcInstance) |
|
1290 { |
|
1291 utcTimeChanged = ETrue; |
|
1292 } |
|
1293 if (dt.Hour() != localHour) |
|
1294 { |
|
1295 localTimeChanged = ETrue; |
|
1296 } |
|
1297 } |
|
1298 |
|
1299 CleanupStack::PopAndDestroy(&instanceList); //instanceList.ResetAndDestroy(); |
|
1300 |
|
1301 // check that the UTC times were not all the same over the course of the year |
|
1302 test(utcTimeChanged); |
|
1303 |
|
1304 // check that the local time did not change |
|
1305 test(!localTimeChanged); |
|
1306 } |
|
1307 |
|
1308 |
|
1309 // Defect 68010 - check that repeating instance times change w.r.t UTC |
|
1310 /** @SYMTestCaseID PIM-TCAL-TZ-0017 */ |
|
1311 void CTzTestManager::TestLocalRepeatRule2L() |
|
1312 { |
|
1313 iTestLibrary->CleanDatabaseL(); |
|
1314 |
|
1315 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0017 Create repeating entry every day from 6 January 2005 at 09:00 Central US time")); test.Printf(_L("Check that the UTC time changes between different months and the local time doesn't")); |
|
1316 |
|
1317 TTime startTime(TDateTime(2005, EJanuary, 5, 9, 0, 0, 0)); |
|
1318 HBufC8* uid = _L8("GUID1").AllocLC(); |
|
1319 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, uid, CCalEntry::EMethodNone, 0); |
|
1320 CleanupStack::Pop(uid); |
|
1321 CleanupStack::PushL(entry); |
|
1322 |
|
1323 TCalTime startTimeCal; |
|
1324 startTimeCal.SetTimeLocalL(startTime); |
|
1325 entry->SetStartAndEndTimeL(startTimeCal, startTimeCal); |
|
1326 |
|
1327 TCalRRule rule(TCalRRule::EDaily); |
|
1328 rule.SetDtStart(startTimeCal); |
|
1329 rule.SetCount(400); |
|
1330 |
|
1331 entry->SetRRuleL(rule); |
|
1332 |
|
1333 RPointerArray<CCalEntry> entries; |
|
1334 CleanupClosePushL(entries); |
|
1335 |
|
1336 entries.AppendL(entry); |
|
1337 TInt success = 0; |
|
1338 iTestLibrary->SynCGetEntryViewL().StoreL(entries, success); |
|
1339 |
|
1340 CleanupStack::PopAndDestroy(&entries); //entries.Reset(); |
|
1341 CleanupStack::PopAndDestroy(entry); |
|
1342 |
|
1343 RPointerArray<CCalInstance> instanceList; |
|
1344 CleanupResetAndDestroyPushL(instanceList); |
|
1345 |
|
1346 CalCommon::TCalViewFilter filter(CalCommon::EIncludeAll); |
|
1347 TTime searchTime1(TDateTime(2005, EApril, 0, 0, 0, 0, 0)); |
|
1348 TTime searchTime2(TDateTime(2005, EApril, 7, 0, 0, 0, 0)); |
|
1349 TCalTime searchCalTime1; |
|
1350 searchCalTime1.SetTimeUtcL(searchTime1); |
|
1351 TCalTime searchCalTime2; |
|
1352 searchCalTime2.SetTimeUtcL(searchTime2); |
|
1353 |
|
1354 CalCommon::TCalTimeRange searchRange(searchCalTime1, searchCalTime2); |
|
1355 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(instanceList, filter, searchRange); |
|
1356 |
|
1357 TInt localHour = startTime.DateTime().Hour(); |
|
1358 TInt utcHour = startTimeCal.TimeUtcL().DateTime().Hour(); |
|
1359 |
|
1360 TBool utcTimeChanged = EFalse; |
|
1361 TBool localTimeChanged = EFalse; |
|
1362 |
|
1363 TInt count = instanceList.Count(); |
|
1364 for( TInt i = 0; i < count; i++ ) |
|
1365 { |
|
1366 TDateTime dt = instanceList[i]->Time().TimeLocalL().DateTime(); |
|
1367 TInt startHourUtcInstance = instanceList[i]->Time().TimeUtcL().DateTime().Hour(); |
|
1368 |
|
1369 test.Printf(_L("local instance time: %d:%d:%d on %d/%d/%d, utc hour=%d \n"), |
|
1370 dt.Hour(), dt.Minute(), dt.Second(), dt.Day()+1, dt.Month()+1, dt.Year(), startHourUtcInstance); |
|
1371 |
|
1372 if (utcHour != startHourUtcInstance) |
|
1373 { |
|
1374 utcTimeChanged = ETrue; |
|
1375 } |
|
1376 if (dt.Hour() != localHour) |
|
1377 { |
|
1378 localTimeChanged = ETrue; |
|
1379 } |
|
1380 } |
|
1381 |
|
1382 CleanupStack::PopAndDestroy(&instanceList); //instanceList.ResetAndDestroy(); |
|
1383 |
|
1384 // check that the UTC times were not all the same over the course of the year |
|
1385 test(utcTimeChanged); |
|
1386 |
|
1387 // check that the local time did not change |
|
1388 test(!localTimeChanged); |
|
1389 } |
|
1390 |
|
1391 |
|
1392 // Defect 70132 - check that November in Helsinki is 2 hours from UTC |
|
1393 /** @SYMTestCaseID PIM-TCAL-TZ-0018 */ |
|
1394 void CTzTestManager::TestLocalTimeZoneL() |
|
1395 { |
|
1396 iTestLibrary->CleanDatabaseL(); |
|
1397 |
|
1398 TestSetTimeZoneL(KEuropeHelsinki); |
|
1399 |
|
1400 RTz tz; |
|
1401 User::LeaveIfError(tz.Connect()); |
|
1402 |
|
1403 TTime start(TDateTime(2005, ENovember, 0, 0, 0, 0, 0)); |
|
1404 TTime end(TDateTime(2005, EDecember, 0, 0, 0, 0, 0)); |
|
1405 |
|
1406 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0018 Fetch time zone rules for Helsinki for November and use them to convert a time (should be 2 hours difference)")); CTzRules* rules = tz.GetTimeZoneRulesL(start, end, ETzStdTimeReference); |
|
1407 CleanupStack::PushL(rules); |
|
1408 |
|
1409 TTime time(TDateTime(2005, ENovember, 6, 12, 0, 0, 0)); |
|
1410 |
|
1411 TDateTime dt1 = time.DateTime(); |
|
1412 rules->ConvertToUtcL(time); |
|
1413 TDateTime dt2 = time.DateTime(); |
|
1414 |
|
1415 test.Printf(_L("Local time %d:%d on %d/%d converts to %d:%d UTC"), |
|
1416 dt1.Hour(), dt1.Minute(), dt1.Day()+1, dt1.Month()+1, dt2.Hour(), dt2.Minute()); |
|
1417 |
|
1418 test(dt1.Hour() - dt2.Hour() == 2); |
|
1419 |
|
1420 CleanupStack::PopAndDestroy(rules); |
|
1421 } |
|
1422 |
|
1423 |
|
1424 // DEF076327 - check that alarm time for Todo and other entries is updated according to timezone change |
|
1425 /** @SYMTestCaseID PIM-TCAL-TZ-0019 */ |
|
1426 void CTzTestManager::TestAlarmTzUpdateSetupL() |
|
1427 { |
|
1428 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0019 Check that entry alarm time is updated according to timezone change")); iTestLibrary->CleanDatabaseL(); |
|
1429 |
|
1430 RPointerArray<CCalEntry> entries; |
|
1431 CleanupResetAndDestroyPushL(entries); |
|
1432 |
|
1433 HBufC8* uid = _L8("Todo_Test").AllocLC(); |
|
1434 CCalEntry* entry = CCalEntry::NewL(CCalEntry::ETodo, uid, CCalEntry::EMethodNone, 0); |
|
1435 CleanupStack::Pop(uid); |
|
1436 CleanupStack::PushL(entry); |
|
1437 entries.AppendL(entry); |
|
1438 CleanupStack::Pop(entry); |
|
1439 |
|
1440 uid = _L8("Appt_Test").AllocLC(); |
|
1441 entry = CCalEntry::NewL(CCalEntry::EAppt, uid, CCalEntry::EMethodNone, 0); |
|
1442 CleanupStack::Pop(uid); |
|
1443 CleanupStack::PushL(entry); |
|
1444 entries.AppendL(entry); |
|
1445 CleanupStack::Pop(entry); |
|
1446 |
|
1447 uid = _L8("Event_Test").AllocLC(); |
|
1448 entry = CCalEntry::NewL(CCalEntry::EEvent, uid, CCalEntry::EMethodNone, 0); |
|
1449 CleanupStack::Pop(uid); |
|
1450 CleanupStack::PushL(entry); |
|
1451 entries.AppendL(entry); |
|
1452 CleanupStack::Pop(entry); |
|
1453 |
|
1454 uid = _L8("Reminder_Test").AllocLC(); |
|
1455 entry = CCalEntry::NewL(CCalEntry::EReminder, uid, CCalEntry::EMethodNone, 0); |
|
1456 CleanupStack::Pop(uid); |
|
1457 CleanupStack::PushL(entry); |
|
1458 entries.AppendL(entry); |
|
1459 CleanupStack::Pop(entry); |
|
1460 |
|
1461 uid = _L8("Anniv_Test").AllocLC(); |
|
1462 entry = CCalEntry::NewL(CCalEntry::EAnniv, uid, CCalEntry::EMethodNone, 0); |
|
1463 CleanupStack::Pop(uid); |
|
1464 CleanupStack::PushL(entry); |
|
1465 entries.AppendL(entry); |
|
1466 CleanupStack::Pop(entry); |
|
1467 |
|
1468 TCalTime calTime; |
|
1469 TTime time(TDateTime(2005, ENovember, 0, 10, 0, 0, 0)); |
|
1470 TInt count = entries.Count(); |
|
1471 for (TInt i = 0; i < count; i++) |
|
1472 { |
|
1473 calTime.SetTimeLocalL(time); |
|
1474 entries[i]->SetStartAndEndTimeL(calTime, calTime); |
|
1475 |
|
1476 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
1477 CleanupStack::PushL(alarm); |
|
1478 alarm->SetTimeOffset(60); // set alarm to be 60 minutes before due time |
|
1479 entries[i]->SetAlarmL(alarm); |
|
1480 CleanupStack::PopAndDestroy(alarm); |
|
1481 } |
|
1482 |
|
1483 TInt success = 0; |
|
1484 iTestLibrary->SynCGetEntryViewL().StoreL(entries, success); |
|
1485 CleanupStack::PopAndDestroy(); // entries |
|
1486 } |
|
1487 |
|
1488 |
|
1489 void CTzTestManager::TestAlarmTzUpdateCheckL() |
|
1490 { |
|
1491 TCalTime calMinTimeRange; |
|
1492 calMinTimeRange.SetTimeUtcL(TCalTime::MinTime()); |
|
1493 TCalTime calMaxTimeRange; |
|
1494 calMaxTimeRange.SetTimeUtcL(TCalTime::MaxTime()); |
|
1495 |
|
1496 // find all instances |
|
1497 CalCommon::TCalTimeRange timeRange(calMinTimeRange, calMaxTimeRange); |
|
1498 |
|
1499 RPointerArray<CCalInstance> instanceList; |
|
1500 CleanupResetAndDestroyPushL(instanceList); |
|
1501 |
|
1502 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(instanceList, CalCommon::EIncludeAll, timeRange); |
|
1503 |
|
1504 TInt count = instanceList.Count(); |
|
1505 test(count == 5); // get the 5 entries saved above |
|
1506 |
|
1507 TTime expectedTime(TDateTime(2005, ENovember, 0, 9, 0, 0, 0)); // expected start and end time after timezone change |
|
1508 TTimeIntervalMinutes expectedAlarmOffset(60); // because start and end time are changed according to time zone already, |
|
1509 // we expect alarm offset to be same as before |
|
1510 for (TInt i = 0; i < count; i++) |
|
1511 { |
|
1512 CCalInstance* instance = instanceList[i]; |
|
1513 |
|
1514 TCalTime startCalTime = instance->StartTimeL(); |
|
1515 TCalTime endCalTime = instance->EndTimeL(); |
|
1516 test(startCalTime.TimeLocalL() == expectedTime); |
|
1517 test(endCalTime.TimeLocalL() == expectedTime); |
|
1518 |
|
1519 CCalEntry &insEntry = instance->Entry(); |
|
1520 startCalTime = insEntry.StartTimeL(); |
|
1521 endCalTime = insEntry.EndTimeL(); |
|
1522 test(startCalTime.TimeLocalL() == expectedTime); |
|
1523 if (insEntry.EntryTypeL() != CCalEntry::EReminder) // reminder entry have null end time |
|
1524 { |
|
1525 test(endCalTime.TimeLocalL() == expectedTime); |
|
1526 } |
|
1527 |
|
1528 CCalAlarm* alarm = insEntry.AlarmL(); |
|
1529 CleanupStack::PushL(alarm); |
|
1530 test(alarm->TimeOffset() == expectedAlarmOffset); |
|
1531 CleanupStack::PopAndDestroy(alarm); |
|
1532 } |
|
1533 |
|
1534 CleanupStack::PopAndDestroy(); // close instanceList |
|
1535 } |
|
1536 |
|
1537 //Test code for DEF080617 |
|
1538 //Timemode of instances should be floating |
|
1539 /** @SYMTestCaseID PIM-TCAL-TZ-0020 */ |
|
1540 void CTzTestManager::ImportFloatingEntryL() |
|
1541 { |
|
1542 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0020 Importing floating entry")); _LIT8(KFloatingEntry, "BEGIN:VCALENDAR\r\n" |
|
1543 "VERSION:1.0\r\n" |
|
1544 "BEGIN:VEVENT\r\n" |
|
1545 "UID:1\r\n" |
|
1546 "X-EPOCAGENDAENTRYTYPE:EVENT\r\n" |
|
1547 "DTSTART:19991101T100000\r\n" |
|
1548 "DTEND:19991101T113000\r\n" |
|
1549 "RRULE:D1 #3\r\n" |
|
1550 "AALARM:19991101T090000\r\n" |
|
1551 "RDATE:19991105T130000\r\n" |
|
1552 "LAST-MODIFIED:19991101T124400\r\n" |
|
1553 "END:VEVENT\r\n" |
|
1554 "END:VCALENDAR\r\n"); |
|
1555 |
|
1556 _LIT(KFileName, "c:\\floatingvcard.vcs"); |
|
1557 RFile outfile; |
|
1558 TInt err = outfile.Replace(iTestLibrary->FileSession(), KFileName(), EFileWrite); |
|
1559 |
|
1560 User::LeaveIfError(err); |
|
1561 |
|
1562 outfile.Write(KFloatingEntry()); |
|
1563 outfile.Close(); |
|
1564 |
|
1565 RFile infile; |
|
1566 User::LeaveIfError(infile.Open(iTestLibrary->FileSession(),KFileName,EFileRead)); |
|
1567 CleanupClosePushL(infile); |
|
1568 RFileReadStream readStream(infile); |
|
1569 CleanupClosePushL(readStream); |
|
1570 |
|
1571 RPointerArray<CCalEntry> entryArray; |
|
1572 CleanupResetAndDestroyPushL(entryArray); |
|
1573 |
|
1574 CCalDataExchange* sync = CCalDataExchange::NewL(iTestLibrary->GetSession()); |
|
1575 CleanupStack::PushL(sync); |
|
1576 TUid uidVCalendar(KUidVCalendar); |
|
1577 |
|
1578 sync->ImportL(uidVCalendar, readStream, entryArray); |
|
1579 CleanupStack::PopAndDestroy(sync); |
|
1580 |
|
1581 test(entryArray.Count() == 1); |
|
1582 |
|
1583 TInt entriesCompleted=0; |
|
1584 test.Printf(_L("Store entry\n")); |
|
1585 |
|
1586 iTestLibrary->SynCGetEntryViewL().StoreL(entryArray,entriesCompleted); |
|
1587 test(entriesCompleted==entryArray.Count()); |
|
1588 |
|
1589 CleanupStack::PopAndDestroy(3,&infile);//infile, readStream, entryArray |
|
1590 iTestLibrary->FileSession().Delete(KFileName); |
|
1591 } |
|
1592 |
|
1593 //Test code for DEF080617 |
|
1594 //Timemode of instances should be floating |
|
1595 void CTzTestManager::TestTimeModeL() |
|
1596 { |
|
1597 test.Printf(_L("Testing TimeMode")); |
|
1598 |
|
1599 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
1600 TCalTime startTime; |
|
1601 startTime.SetTimeUtcL(TTime(TDateTime(1999, ESeptember, 0, 0, 0, 0, 0))); |
|
1602 TCalTime endTime; |
|
1603 endTime.SetTimeUtcL(TTime(TDateTime(1999, ENovember, 6, 0, 0, 0, 0))); |
|
1604 CalCommon::TCalTimeRange timeRange(startTime, endTime); |
|
1605 |
|
1606 RPointerArray<CCalInstance> aInstances; |
|
1607 CleanupResetAndDestroyPushL(aInstances); |
|
1608 |
|
1609 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(aInstances, filter, timeRange); |
|
1610 |
|
1611 for (TInt i = 0; i < aInstances.Count(); i++) |
|
1612 { |
|
1613 TDateTime instanceTime = aInstances[i]->Time().TimeLocalL().DateTime(); |
|
1614 RDebug::Print(_L("instance time at %d:%d on %d/%d/%d"), instanceTime.Hour(), instanceTime.Minute(), |
|
1615 instanceTime.Day()+1, instanceTime.Month()+1, instanceTime.Year()); |
|
1616 TCalTime::TTimeMode instanceTimeMode = aInstances[i]->Time().TimeMode(); |
|
1617 test(instanceTimeMode == TCalTime::EFloating); |
|
1618 |
|
1619 TDateTime startTime = aInstances[i]->StartTimeL().TimeLocalL().DateTime(); |
|
1620 RDebug::Print(_L("instance start time at %d:%d on %d/%d/%d"), startTime.Hour(), startTime.Minute(), |
|
1621 startTime.Day()+1, startTime.Month()+1, startTime.Year()); |
|
1622 TCalTime::TTimeMode startTimeMode = aInstances[i]->StartTimeL().TimeMode(); |
|
1623 test(startTimeMode == TCalTime::EFloating); |
|
1624 |
|
1625 TDateTime endTime = aInstances[i]->EndTimeL().TimeLocalL().DateTime(); |
|
1626 RDebug::Print(_L("instance end time at %d:%d on %d/%d/%d"), endTime.Hour(), endTime.Minute(), |
|
1627 endTime.Day()+1, endTime.Month()+1, endTime.Year()); |
|
1628 TCalTime::TTimeMode endTimeMode = aInstances[i]->EndTimeL().TimeMode(); |
|
1629 test(endTimeMode == TCalTime::EFloating); |
|
1630 RDebug::Print(_L("\n")); |
|
1631 } |
|
1632 CleanupStack::PopAndDestroy(&aInstances); |
|
1633 } |
|
1634 |
|
1635 void CTzTestManager::TestExportTzRulesInHemisphereL(TBool aSouthernHemisphere) |
|
1636 { |
|
1637 _LIT(KTestExportFileSouth, "export_southern_hemisphere_tz.vcs"); |
|
1638 _LIT(KTestExportFileNorth, "export_northern_hemisphere_tz.vcs"); |
|
1639 _LIT8(KTestGuid, "guid123"); |
|
1640 |
|
1641 TBuf<64> fileName; |
|
1642 if (aSouthernHemisphere) |
|
1643 { |
|
1644 fileName.Copy(KTestExportFileSouth()); |
|
1645 } |
|
1646 else |
|
1647 { |
|
1648 fileName.Copy(KTestExportFileNorth()); |
|
1649 } |
|
1650 |
|
1651 |
|
1652 HBufC8* guid = KTestGuid().AllocLC(); |
|
1653 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0); |
|
1654 CleanupStack::Pop(guid); |
|
1655 CleanupStack::PushL(entry); |
|
1656 |
|
1657 TTime now; |
|
1658 now.HomeTime(); |
|
1659 TInt currYear = now.DateTime().Year(); |
|
1660 |
|
1661 TDateTime entryStart(currYear, EMarch, 19, 9, 0, 0, 0); // 0900 on 20 Mar This Year |
|
1662 TDateTime entryUntil(currYear+2, EJune, 9, 9, 0, 0, 0); // 0900 on 10 Jun Two Years Time |
|
1663 |
|
1664 TCalTime calStart; |
|
1665 calStart.SetTimeLocalL(entryStart); |
|
1666 TCalTime calUntil; |
|
1667 calUntil.SetTimeLocalL(entryUntil); |
|
1668 |
|
1669 entry->SetStartAndEndTimeL(calStart, calStart); |
|
1670 |
|
1671 TCalRRule rule(TCalRRule::EDaily); |
|
1672 rule.SetInterval(1); |
|
1673 rule.SetDtStart(calStart); |
|
1674 rule.SetUntil(calUntil); |
|
1675 entry->SetRRuleL(rule); |
|
1676 |
|
1677 iTestLibrary->StoreEntryL(*entry); |
|
1678 CleanupStack::PopAndDestroy(entry); |
|
1679 |
|
1680 // fetch the entry and export it |
|
1681 RPointerArray<CCalEntry> entries; |
|
1682 CleanupResetAndDestroyPushL(entries); |
|
1683 |
|
1684 iTestLibrary->SynCGetEntryViewL().FetchL(KTestGuid(), entries); |
|
1685 test(entries.Count() == 1); |
|
1686 |
|
1687 iTestLibrary->ExportL(fileName, entries); |
|
1688 entries.ResetAndDestroy(); |
|
1689 |
|
1690 iTestLibrary->ImportL(fileName, entries); |
|
1691 test(entries.Count() == 1); |
|
1692 CTzRules* fetchedTzRules = entries[0]->TzRulesL(); |
|
1693 CleanupStack::PushL(fetchedTzRules); |
|
1694 |
|
1695 test(fetchedTzRules != NULL); |
|
1696 TTzRule lastRule = (*fetchedTzRules)[fetchedTzRules->Count()-1]; |
|
1697 TDateTime lastRuleTime = lastRule.iFrom.iTime.DateTime(); |
|
1698 if (aSouthernHemisphere) |
|
1699 { |
|
1700 // check the last rule goes up to the first half of the year in Three Years Time |
|
1701 test(lastRuleTime.Year() == currYear + 3); |
|
1702 test(lastRuleTime.Month() < EJune); |
|
1703 } |
|
1704 else |
|
1705 { |
|
1706 // check the last rule goes up to the second half of the year in Two Years Time |
|
1707 test(lastRuleTime.Year() == currYear + 2); |
|
1708 test(lastRuleTime.Month() > EJuly); |
|
1709 } |
|
1710 |
|
1711 CleanupStack::PopAndDestroy(fetchedTzRules); |
|
1712 |
|
1713 CleanupStack::PopAndDestroy(&entries); // entries.ResetAndDestroy |
|
1714 } |
|
1715 |
|
1716 // new test cases |
|
1717 /** @SYMTestCaseID PIM-TCAL-TZ-0021 */ |
|
1718 void CTzTestManager::TestCreateEntryWithMidnightInHomeTimeL(TBool aFloating) |
|
1719 { |
|
1720 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0021 Running tcal_tz - TestCreateEntryWithMidnightInHomeTimeL")); |
|
1721 |
|
1722 // start the test case with a clean calendar database |
|
1723 |
|
1724 iTestLibrary->CleanDatabaseL(); |
|
1725 |
|
1726 |
|
1727 // this sets the number of iterations in the below for-loop of entries creation |
|
1728 |
|
1729 const TInt KNumberOfIterations = 4; |
|
1730 |
|
1731 |
|
1732 // array of entry types |
|
1733 |
|
1734 RArray<CCalEntry::TType> typeArray; |
|
1735 CleanupClosePushL(typeArray); |
|
1736 |
|
1737 typeArray.AppendL(CCalEntry::EAppt); |
|
1738 typeArray.AppendL(CCalEntry::ETodo); |
|
1739 typeArray.AppendL(CCalEntry::EEvent); |
|
1740 typeArray.AppendL(CCalEntry::EAnniv); |
|
1741 |
|
1742 |
|
1743 // array of time zones |
|
1744 |
|
1745 RPointerArray<TDesC8> lit8Array; |
|
1746 CleanupClosePushL(lit8Array); |
|
1747 |
|
1748 lit8Array.AppendL(&KAsiaTokyo); |
|
1749 lit8Array.AppendL(&KEuropeLondon); |
|
1750 lit8Array.AppendL(&KPacificAuckland); |
|
1751 lit8Array.AppendL(&KEuropeStockholm); |
|
1752 lit8Array.AppendL(&KUsCentral); |
|
1753 lit8Array.AppendL(&KEuropeHelsinki); |
|
1754 lit8Array.AppendL(&KUsNewYork); |
|
1755 lit8Array.AppendL(&KAsiaTaiwan); |
|
1756 lit8Array.AppendL(&KUsLosAngeles); |
|
1757 lit8Array.AppendL(&KAsiaBangkok); |
|
1758 |
|
1759 |
|
1760 for( TInt i = 0; i < typeArray.Count() * KNumberOfIterations; ++i ) |
|
1761 { |
|
1762 RPointerArray<CCalEntry> entryArray; |
|
1763 CleanupResetAndDestroyPushL(entryArray); |
|
1764 |
|
1765 |
|
1766 // create different types of entry |
|
1767 HBufC8* dummy = NULL; |
|
1768 // [i % typeArray.Count()] makes sure that even doing multiple iterations we don't exceed array boundaries |
|
1769 CCalEntry* entry = iTestLibrary->CreateCalEntryL(typeArray[i % typeArray.Count()], dummy); |
|
1770 entryArray.AppendL(entry); |
|
1771 |
|
1772 // set an entry using GMT0 time such it contains at least midnight in Tokyo time |
|
1773 // and insert an entry every other 2 days |
|
1774 TTime dtStart(TDateTime(2005, EJanuary, i * 2, 8, 0, 0, 0)); |
|
1775 TTime dtEnd(TDateTime(2005, EJanuary, i * 2, 20, 0, 0, 0)); |
|
1776 TCalTime startCalTime; |
|
1777 TCalTime endCalTime; |
|
1778 |
|
1779 |
|
1780 // the entry home time is London |
|
1781 TestSetTimeZoneL(KEuropeLondon); |
|
1782 |
|
1783 if ( aFloating ) |
|
1784 { |
|
1785 // Create a floating entry |
|
1786 startCalTime.SetTimeLocalFloatingL(dtStart); |
|
1787 endCalTime.SetTimeLocalFloatingL(dtEnd); |
|
1788 } |
|
1789 else |
|
1790 { |
|
1791 startCalTime.SetTimeLocalL(dtStart); |
|
1792 endCalTime.SetTimeLocalL(dtEnd); |
|
1793 } |
|
1794 |
|
1795 entry->SetStartAndEndTimeL(startCalTime, endCalTime); |
|
1796 |
|
1797 TInt entriesAdded = 0; |
|
1798 iTestLibrary->SynCGetEntryViewL().StoreL(entryArray, entriesAdded); |
|
1799 test(entryArray.Count() == entriesAdded); |
|
1800 |
|
1801 |
|
1802 CleanupStack::PopAndDestroy(&entryArray); |
|
1803 |
|
1804 |
|
1805 |
|
1806 // check the entry, changing the time zones (especially with midnight in) |
|
1807 |
|
1808 for( TInt j = 0; j < lit8Array.Count(); ++j ) |
|
1809 { |
|
1810 // we change the time zone such in local time the set event contains midnight |
|
1811 |
|
1812 TestSetTimeZoneL(*lit8Array[j]); |
|
1813 |
|
1814 |
|
1815 // fetch instances |
|
1816 |
|
1817 // create time filter |
|
1818 |
|
1819 TCalTime startTime, endTime; |
|
1820 if (aFloating) |
|
1821 { |
|
1822 startTime.SetTimeLocalL(dtStart); |
|
1823 endTime.SetTimeLocalL(dtStart + TTimeIntervalDays(1)); |
|
1824 } |
|
1825 else |
|
1826 { |
|
1827 startTime.SetTimeLocalFloatingL(dtStart); |
|
1828 endTime.SetTimeLocalFloatingL(dtStart + TTimeIntervalDays(1)); |
|
1829 } |
|
1830 CalCommon::TCalTimeRange timeRange(startTime, endTime); |
|
1831 |
|
1832 // array to store the loaded instances |
|
1833 |
|
1834 RPointerArray<CCalInstance> instances; |
|
1835 CleanupResetAndDestroyPushL(instances); |
|
1836 |
|
1837 |
|
1838 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(instances, CalCommon::EIncludeAll, timeRange); |
|
1839 // sanity check |
|
1840 test(instances.Count() != 0); |
|
1841 |
|
1842 CCalInstance& instance = *(instances[0]); |
|
1843 |
|
1844 TTime entryStartLocalT(instance.Entry().StartTimeL().TimeLocalL()); |
|
1845 TTime entryEndLocalT(instance.Entry().EndTimeL().TimeLocalL()); |
|
1846 |
|
1847 TTime instStartLocalT(instance.StartTimeL().TimeLocalL()); |
|
1848 TTime instEndLocalT(instance.EndTimeL().TimeLocalL()); |
|
1849 |
|
1850 test.Printf( _L("found instance: ") ); |
|
1851 TDateTime startDt = instStartLocalT.DateTime(); |
|
1852 test.Printf( _L("%d/%d/%d, %d:%d:%d - "), |
|
1853 startDt.Day()+1, startDt.Month()+1, startDt.Year(), |
|
1854 startDt.Hour(), startDt.Minute(), startDt.Second() ); |
|
1855 TDateTime endDt = instEndLocalT.DateTime(); |
|
1856 test.Printf( _L("%d/%d/%d, %d:%d:%d\n"), |
|
1857 endDt.Day()+1, endDt.Month()+1, endDt.Year(), |
|
1858 endDt.Hour(), endDt.Minute(), endDt.Second() ); |
|
1859 |
|
1860 // check the entry times |
|
1861 test( entryStartLocalT == startCalTime.TimeLocalL() ); |
|
1862 test( entryEndLocalT == endCalTime.TimeLocalL() ); |
|
1863 |
|
1864 /* TODO: instance time is not matching entry one in floating scenario. |
|
1865 To be fixed - raised defect DEF081789 - |
|
1866 and remove the if( ! aFloating ) to prove it */ |
|
1867 |
|
1868 if( ! aFloating ) |
|
1869 { |
|
1870 /***/ |
|
1871 // check the instance times |
|
1872 test( instStartLocalT == startCalTime.TimeLocalL() ); |
|
1873 test( instEndLocalT == endCalTime.TimeLocalL() ); |
|
1874 /***/ |
|
1875 } |
|
1876 /* ODOT */ |
|
1877 |
|
1878 CleanupStack::PopAndDestroy(&instances); |
|
1879 } |
|
1880 } |
|
1881 |
|
1882 |
|
1883 CleanupStack::PopAndDestroy(&lit8Array); |
|
1884 |
|
1885 |
|
1886 CleanupStack::PopAndDestroy(&typeArray); |
|
1887 } |
|
1888 |
|
1889 |
|
1890 /** @SYMTestCaseID PIM-TCAL-TZ-0022 */ |
|
1891 void CTzTestManager::TestCreateEntryWithDstChangeL(TBool aFloating) |
|
1892 { |
|
1893 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0022 Running tcal_tz - TestCreateEntryWithDstChangeL")); |
|
1894 |
|
1895 // array of entry types |
|
1896 |
|
1897 RArray<CCalEntry::TType> typeArray; |
|
1898 CleanupClosePushL(typeArray); |
|
1899 |
|
1900 typeArray.AppendL(CCalEntry::EAppt); |
|
1901 typeArray.AppendL(CCalEntry::ETodo); |
|
1902 typeArray.AppendL(CCalEntry::EEvent); |
|
1903 typeArray.AppendL(CCalEntry::EAnniv); |
|
1904 |
|
1905 |
|
1906 for( TInt i = 0; i < typeArray.Count(); ++i ) |
|
1907 { |
|
1908 // start with a clean calendar database |
|
1909 |
|
1910 iTestLibrary->CleanDatabaseL(); |
|
1911 |
|
1912 |
|
1913 RPointerArray<CCalEntry> entryArray; |
|
1914 CleanupResetAndDestroyPushL(entryArray); |
|
1915 |
|
1916 |
|
1917 // create different types of entry |
|
1918 HBufC8* dummy = NULL; |
|
1919 // [i % typeArray.Count()] makes sure that even doing multiple iterations we don't exceed array boundaries |
|
1920 CCalEntry* entry = iTestLibrary->CreateCalEntryL(typeArray[i % typeArray.Count()], dummy); |
|
1921 entryArray.AppendL(entry); |
|
1922 |
|
1923 // set an entry using GMT0 time such it contains at least DST time |
|
1924 TTime dtStart(TDateTime(2005, EMarch, 25, 20, 0, 0, 0)); |
|
1925 TTime dtEnd(TDateTime(2005, EMarch, 26, 8, 0, 0, 0)); |
|
1926 TCalTime startCalTime; |
|
1927 TCalTime endCalTime; |
|
1928 |
|
1929 |
|
1930 // the entry home time is London |
|
1931 TestSetTimeZoneL(KEuropeLondon); |
|
1932 |
|
1933 // change the time to start one to simulate a non DST |
|
1934 iTestLibrary->PIMTestServer().SetHomeTime(dtStart); |
|
1935 |
|
1936 |
|
1937 if ( aFloating ) |
|
1938 { |
|
1939 // Create a floating entry |
|
1940 startCalTime.SetTimeLocalFloatingL(dtStart); |
|
1941 endCalTime.SetTimeLocalFloatingL(dtEnd); |
|
1942 } |
|
1943 else |
|
1944 { |
|
1945 startCalTime.SetTimeLocalL(dtStart); |
|
1946 endCalTime.SetTimeLocalL(dtEnd); |
|
1947 } |
|
1948 |
|
1949 entry->SetStartAndEndTimeL(startCalTime, endCalTime); |
|
1950 |
|
1951 TInt entriesAdded = 0; |
|
1952 iTestLibrary->SynCGetEntryViewL().StoreL(entryArray, entriesAdded); |
|
1953 test(entryArray.Count() == entriesAdded); |
|
1954 |
|
1955 |
|
1956 CleanupStack::PopAndDestroy(&entryArray); |
|
1957 |
|
1958 |
|
1959 |
|
1960 // change the time to end one to simulate a DST |
|
1961 |
|
1962 iTestLibrary->PIMTestServer().SetHomeTime(dtEnd); |
|
1963 |
|
1964 |
|
1965 // check the entry |
|
1966 |
|
1967 |
|
1968 // fetch instances |
|
1969 |
|
1970 // create time filter |
|
1971 |
|
1972 TCalTime startTime, endTime; |
|
1973 if (aFloating) |
|
1974 { |
|
1975 startTime.SetTimeLocalL(dtStart); |
|
1976 endTime.SetTimeLocalL(dtStart + TTimeIntervalDays(1)); |
|
1977 } |
|
1978 else |
|
1979 { |
|
1980 startTime.SetTimeLocalFloatingL(dtStart); |
|
1981 endTime.SetTimeLocalFloatingL(dtStart + TTimeIntervalDays(1)); |
|
1982 } |
|
1983 CalCommon::TCalTimeRange timeRange(startTime, endTime); |
|
1984 |
|
1985 // array to store the loaded instances |
|
1986 |
|
1987 RPointerArray<CCalInstance> instances; |
|
1988 CleanupResetAndDestroyPushL(instances); |
|
1989 |
|
1990 |
|
1991 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(instances, CalCommon::EIncludeAll, timeRange); |
|
1992 // sanity check |
|
1993 test(instances.Count() != 0); |
|
1994 |
|
1995 CCalInstance& instance = *(instances[0]); |
|
1996 |
|
1997 TTime entryStartLocalT(instance.Entry().StartTimeL().TimeLocalL()); |
|
1998 TTime entryEndLocalT(instance.Entry().EndTimeL().TimeLocalL()); |
|
1999 |
|
2000 TTime instStartLocalT(instance.StartTimeL().TimeLocalL()); |
|
2001 TTime instEndLocalT(instance.EndTimeL().TimeLocalL()); |
|
2002 |
|
2003 test.Printf( _L("found instance: ") ); |
|
2004 TDateTime startDt = instStartLocalT.DateTime(); |
|
2005 test.Printf( _L("%d/%d/%d, %d:%d:%d - "), |
|
2006 startDt.Day()+1, startDt.Month()+1, startDt.Year(), |
|
2007 startDt.Hour(), startDt.Minute(), startDt.Second() ); |
|
2008 TDateTime endDt = instEndLocalT.DateTime(); |
|
2009 test.Printf( _L("%d/%d/%d, %d:%d:%d\n"), |
|
2010 endDt.Day()+1, endDt.Month()+1, endDt.Year(), |
|
2011 endDt.Hour(), endDt.Minute(), endDt.Second() ); |
|
2012 |
|
2013 // check the entry times |
|
2014 test( entryStartLocalT == startCalTime.TimeLocalL() ); |
|
2015 test( entryEndLocalT == endCalTime.TimeLocalL() ); |
|
2016 |
|
2017 // check the instance times |
|
2018 test( instStartLocalT == startCalTime.TimeLocalL() ); |
|
2019 test( instEndLocalT == endCalTime.TimeLocalL() ); |
|
2020 |
|
2021 |
|
2022 CleanupStack::PopAndDestroy(&instances); |
|
2023 } |
|
2024 |
|
2025 |
|
2026 CleanupStack::PopAndDestroy(&typeArray); |
|
2027 } |
|
2028 |
|
2029 /** @SYMTestCaseID PIM-TCAL-TZ-0023 */ |
|
2030 void CTzTestManager::CheckVcalImportFromS40L() |
|
2031 { |
|
2032 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0023 Check alarm time on vcard import...")); |
|
2033 _LIT8(KS40Entry, "BEGIN:VCALENDAR\r\n" |
|
2034 "VERSION:1.0\r\n" |
|
2035 "BEGIN:VEVENT\r\n" |
|
2036 "DTSTART:20060215T090000\r\n" |
|
2037 "DTEND:20060215T093000\r\n" |
|
2038 "AALARM:20060215T084500\r\n" |
|
2039 "DALARM:20060215T084500\r\n" |
|
2040 "RRULE:W1 20060510T090000\r\n" |
|
2041 "CATEGORIES:MEETING\r\n" |
|
2042 "SUMMARY:Meeting repeating weekly at 8 to 9\r\n" |
|
2043 "LOCATION:My location\r\n" |
|
2044 "X-NOK-CAT:icon_indi_cale_appointment\r\n" |
|
2045 "END:VEVENT\r\n" |
|
2046 "END:VCALENDAR\r\n"); |
|
2047 |
|
2048 _LIT(KFileName, "c:\\S40vcard.vcs"); |
|
2049 |
|
2050 RFile outfile; |
|
2051 TInt err = outfile.Replace(iTestLibrary->FileSession(), KFileName(), EFileWrite); |
|
2052 |
|
2053 User::LeaveIfError(err); |
|
2054 |
|
2055 outfile.Write(KS40Entry()); |
|
2056 outfile.Close(); |
|
2057 |
|
2058 RFile infile; |
|
2059 |
|
2060 User::LeaveIfError(infile.Open(iTestLibrary->FileSession(),KFileName,EFileRead)); |
|
2061 |
|
2062 CleanupClosePushL(infile); |
|
2063 |
|
2064 RFileReadStream readStream(infile); |
|
2065 CleanupClosePushL(readStream); |
|
2066 |
|
2067 RPointerArray<CCalEntry> entryArray; |
|
2068 CleanupResetAndDestroyPushL(entryArray); |
|
2069 |
|
2070 CCalDataExchange* sync = CCalDataExchange::NewL(iTestLibrary->GetSession()); |
|
2071 CleanupStack::PushL(sync); |
|
2072 |
|
2073 sync->ImportL(KUidVCalendar, readStream, entryArray); |
|
2074 |
|
2075 CleanupStack::PopAndDestroy(sync); |
|
2076 |
|
2077 test(entryArray.Count()==1); |
|
2078 |
|
2079 CCalEntry* entry = entryArray[0]; |
|
2080 CCalAlarm* alarm = entry->AlarmL(); |
|
2081 TTimeIntervalMinutes alarmOffset = alarm->TimeOffset(); |
|
2082 delete alarm; |
|
2083 |
|
2084 |
|
2085 TTime startTTime = entry->StartTimeL().TimeLocalL(); |
|
2086 TTime alarmTTime = startTTime - alarmOffset;//calculate actual alarm time |
|
2087 |
|
2088 TDateTime startTime = startTTime.DateTime(); |
|
2089 TDateTime alarmTime = alarmTTime.DateTime(); |
|
2090 |
|
2091 test.Printf(_L("Imported startdate from S40: %d.%d.%d at %d:%d\n"),startTime.Day()+1, startTime.Month()+1, startTime.Year(), startTime.Hour(), startTime.Minute()); |
|
2092 test(startTTime == TTime(TDateTime(2006, EFebruary, 14, 9, 0, 0, 0))); |
|
2093 test.Printf(_L("Imported alarm from S40: %d.%d.%d at %d:%d\n"),alarmTime.Day()+1, alarmTime.Month()+1, alarmTime.Year(), alarmTime.Hour(), alarmTime.Minute()); |
|
2094 test(alarmTTime == TTime(TDateTime(2006, EFebruary, 14, 8, 45, 0, 0))); |
|
2095 |
|
2096 CleanupStack::PopAndDestroy(3, &infile);//entryArray, readStream |
|
2097 iTestLibrary->FileSession().Delete(KFileName); |
|
2098 } |
|
2099 |
|
2100 void CTzTestManager::SetupEventCrossingMidnightL() |
|
2101 { |
|
2102 iTestLibrary->CleanDatabaseL(); |
|
2103 |
|
2104 HBufC8* guid = _L8("midnightcross").AllocLC(); |
|
2105 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0); |
|
2106 CleanupStack::Pop(guid); |
|
2107 CleanupStack::PushL(entry); |
|
2108 |
|
2109 // set event from 0300 to 2100 on 1 Jan 2006, local time Stockholm |
|
2110 TCalTime start, end; |
|
2111 start.SetTimeLocalL(TDateTime(2006, EJanuary, 0, 3, 0, 0, 0)); |
|
2112 end.SetTimeLocalL(TDateTime(2006, EJanuary, 0, 21, 0, 0, 0)); |
|
2113 entry->SetStartAndEndTimeL(start, end); |
|
2114 iTestLibrary->StoreEntryL(*entry); |
|
2115 CleanupStack::PopAndDestroy(entry); |
|
2116 } |
|
2117 |
|
2118 void CTzTestManager::CheckEventCrossingMidnightL() |
|
2119 { |
|
2120 // the event created in SetupEventCrossingMidnightL starts at |
|
2121 // 1500 on 1 Jan 2006 and finishes on 0900 on 2 Jan 2006 in Auckland time |
|
2122 RPointerArray<CCalInstance> instances; |
|
2123 CleanupResetAndDestroyPushL(instances); |
|
2124 |
|
2125 // check the event appears on the first day it appears |
|
2126 TCalTime start1, end1; |
|
2127 start1.SetTimeLocalL(TDateTime(2006, EJanuary, 0, 0, 0, 0, 0)); |
|
2128 end1.SetTimeLocalL(TDateTime(2006, EJanuary, 0, 23, 59, 59, 999)); |
|
2129 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(instances, CalCommon::EIncludeAll, CalCommon::TCalTimeRange(start1, end1)); |
|
2130 test(instances.Count() == 1); |
|
2131 TCalTime instanceDate = instances[0]->Time(); |
|
2132 instances.ResetAndDestroy(); |
|
2133 |
|
2134 // check the event appears on the second day it appears |
|
2135 TCalTime start2, end2; |
|
2136 start2.SetTimeLocalL(TDateTime(2006, EJanuary, 1, 0, 0, 0, 0)); |
|
2137 end2.SetTimeLocalL(TDateTime(2006, EJanuary, 1, 23, 59, 59, 999)); |
|
2138 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(instances, CalCommon::EIncludeAll, CalCommon::TCalTimeRange(start2, end2)); |
|
2139 test(instances.Count() == 1); |
|
2140 TCalTime instanceDate2 = instances[0]->Time(); |
|
2141 test(instanceDate.TimeUtcL() == instanceDate2.TimeUtcL()); |
|
2142 |
|
2143 CleanupStack::PopAndDestroy(&instances); |
|
2144 } |
|
2145 |
|
2146 |
|
2147 |
|
2148 void CTzTestManager::CheckDSTThresholdL() |
|
2149 { |
|
2150 test.Printf(_L("Start - CTestHarness::CheckDSTThresholdL\n")); |
|
2151 iTestLibrary->CleanDatabaseL(); |
|
2152 |
|
2153 _LIT8(KGuid1, "guid-1"); |
|
2154 _LIT(KTime1, "20030227:010000.000000"); |
|
2155 _LIT(KTime2, "20030227:030000.000000"); |
|
2156 _LIT(KTimeUntil, "20041116:000000.000000"); |
|
2157 |
|
2158 HBufC8* guid8 = KGuid1().AllocLC(); |
|
2159 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EEvent, guid8, CCalEntry::EMethodAdd, 0); |
|
2160 CleanupStack::Pop(guid8); |
|
2161 CleanupStack::PushL(entry); |
|
2162 |
|
2163 TTime time1(KTime1()); |
|
2164 TTime time2(KTime2()); |
|
2165 TCalTime st; |
|
2166 st.SetTimeUtcL(time1); |
|
2167 TCalTime end; |
|
2168 end.SetTimeUtcL(time2); |
|
2169 entry->SetStartAndEndTimeL(st, end); |
|
2170 |
|
2171 TCalRRule rrule(TCalRRule::EDaily); |
|
2172 TCalTime calTime = entry->StartTimeL(); |
|
2173 rrule.SetDtStart(calTime); |
|
2174 rrule.SetInterval(1); |
|
2175 TTime until(KTimeUntil()); |
|
2176 TCalTime untilTime; |
|
2177 untilTime.SetTimeUtcL(until); |
|
2178 rrule.SetUntil(untilTime); // where untilTime is 20041116:000000.000000 |
|
2179 entry->SetRRuleL(rrule); |
|
2180 entry->SetTzRulesL(); |
|
2181 |
|
2182 CCalAlarm* alarm=CCalAlarm::NewL(); |
|
2183 CleanupStack::PushL(alarm); |
|
2184 alarm->SetTimeOffset(0); |
|
2185 entry->SetAlarmL(alarm); |
|
2186 CleanupStack::PopAndDestroy(alarm); |
|
2187 |
|
2188 iTestLibrary->StoreEntryL(*entry); |
|
2189 CleanupStack::PopAndDestroy(entry); |
|
2190 |
|
2191 // check for instances |
|
2192 RPointerArray<CCalInstance> instances; |
|
2193 CleanupResetAndDestroyPushL(instances); |
|
2194 TCalTime start1, end1; |
|
2195 start1.SetTimeLocalL(TDateTime(2004, EMarch, 27, 0, 0, 0, 0)); |
|
2196 end1.SetTimeLocalL(TDateTime(2004, EMarch, 27, 23, 59, 59, 999)); |
|
2197 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(instances, CalCommon::EIncludeAll, CalCommon::TCalTimeRange(start1, end1)); |
|
2198 |
|
2199 for(TInt i=0; i < instances.Count(); i++) |
|
2200 { |
|
2201 CCalInstance* instance = instances[i]; |
|
2202 TCalTime insCalTime = instance->Time(); |
|
2203 TTime insTime = insCalTime.TimeLocalL(); |
|
2204 TDateTime dateTime = insTime.DateTime(); |
|
2205 test.Printf(_L("Local DateTime %d/%d/%d %d:%d\n"), dateTime.Day()+1, dateTime.Month()+1, dateTime.Year(), |
|
2206 dateTime.Hour(), dateTime.Minute()); |
|
2207 insTime = insCalTime.TimeUtcL(); |
|
2208 dateTime = insTime.DateTime(); |
|
2209 test.Printf(_L("Utc DateTime %d/%d/%d %d:%d\n"), dateTime.Day()+1, dateTime.Month()+1, dateTime.Year(), |
|
2210 dateTime.Hour(), dateTime.Minute()); |
|
2211 } |
|
2212 |
|
2213 // expect the instance in Mar 28 will be adjusted to 2am because 1am is non-existance local time |
|
2214 test(instances.Count() == 1); |
|
2215 TCalTime instanceDate = instances[0]->Time(); |
|
2216 TTime expectedTime(TDateTime(2004, EMarch, 27, 2, 0, 0, 0)); |
|
2217 test(instanceDate.TimeLocalL() == expectedTime); |
|
2218 |
|
2219 // test deleting instance in DST threshold |
|
2220 iTestLibrary->SynCGetInstanceViewL().DeleteL(instances[0], CalCommon::EThisOnly); |
|
2221 instances.Reset(); |
|
2222 iTestLibrary->SynCGetInstanceViewL().FindInstanceL(instances, CalCommon::EIncludeAll, CalCommon::TCalTimeRange(start1, end1)); |
|
2223 |
|
2224 test(instances.Count() == 0); |
|
2225 |
|
2226 CleanupStack::PopAndDestroy(&instances); |
|
2227 } |
|
2228 |
|
2229 void CTzTestManager::TestAlarmOffsetL() |
|
2230 { |
|
2231 test.Printf(_L("Start - CTestHarness::TestAlarmOffsetL\n")); |
|
2232 |
|
2233 _LIT8(KGuid1, "guid-1"); |
|
2234 _LIT(KSummary1, "Test Entry 1"); |
|
2235 |
|
2236 _LIT(KTime1, "20030227:010000.000000"); |
|
2237 _LIT(KTime2, "20030227:023000.000000"); |
|
2238 _LIT(KTimeUntil, "20041116:000000.000000"); |
|
2239 |
|
2240 |
|
2241 //entry 1 |
|
2242 HBufC8* guid8 = HBufC8::NewL(KGuid1().Length()); |
|
2243 guid8->Des().Copy(KGuid1); |
|
2244 CleanupStack::PushL(guid8); |
|
2245 CCalEntry* iEntry = CCalEntry::NewL(CCalEntry::EAppt, guid8, CCalEntry::EMethodAdd, (TUint)0); |
|
2246 CleanupStack::Pop(guid8); |
|
2247 TTime time1(KTime1()); |
|
2248 TTime time2(KTime2()); |
|
2249 |
|
2250 TCalTime st; |
|
2251 st.SetTimeUtcL(time1); |
|
2252 |
|
2253 TCalTime end; |
|
2254 end.SetTimeUtcL(time2); |
|
2255 iEntry->SetStartAndEndTimeL(st, end); |
|
2256 |
|
2257 iEntry->SetSummaryL(KSummary1); |
|
2258 |
|
2259 |
|
2260 TCalRRule* iRRule=new (ELeave) TCalRRule(TCalRRule::EMonthly); |
|
2261 TCalTime calTime = iEntry->StartTimeL(); |
|
2262 iRRule->SetDtStart(calTime); |
|
2263 iRRule->SetInterval(2); |
|
2264 |
|
2265 RArray<TCalRRule::TDayOfMonth> arrayWeekInMonth; |
|
2266 arrayWeekInMonth.Append(TCalRRule::TDayOfMonth(ESunday, -1)); |
|
2267 iRRule->SetByDay(arrayWeekInMonth); |
|
2268 |
|
2269 TTime until(KTimeUntil()); |
|
2270 TCalTime untilTime; |
|
2271 untilTime.SetTimeUtcL(until); |
|
2272 |
|
2273 iRRule->SetUntil(untilTime); |
|
2274 iEntry->SetRRuleL(*iRRule); |
|
2275 |
|
2276 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
2277 alarm->SetTimeOffset(0); |
|
2278 iEntry->SetAlarmL(alarm); |
|
2279 |
|
2280 TInt entriesStored(0); |
|
2281 RPointerArray<CCalEntry> entries; |
|
2282 CleanupResetAndDestroyPushL(entries); |
|
2283 entries.AppendL(iEntry); |
|
2284 iTestLibrary->SynCGetEntryViewL().StoreL(entries, entriesStored); |
|
2285 arrayWeekInMonth.Close(); |
|
2286 delete iRRule; |
|
2287 entries.ResetAndDestroy(); |
|
2288 |
|
2289 iTestLibrary->SynCGetEntryViewL().FetchL(KGuid1(), entries); |
|
2290 |
|
2291 test(entries.Count() == 1); |
|
2292 |
|
2293 CCalAlarm* alarm2 = entries[0]->AlarmL(); |
|
2294 |
|
2295 _LIT(KTimeFmt, "%F%Y%M%D-%H:%T:%S"); |
|
2296 TBuf<32> buf; |
|
2297 entries[0]->StartTimeL().TimeUtcL().FormatL(buf, KTimeFmt); |
|
2298 test.Printf(_L("Entry start time: %S"), &buf); |
|
2299 |
|
2300 test.Printf(_L("alarm offset before StoreL: %d"), alarm->TimeOffset().Int()); |
|
2301 test.Printf(_L("alarm offset after StoreL: %d"), alarm2->TimeOffset().Int()); |
|
2302 |
|
2303 test(alarm->TimeOffset() == alarm2->TimeOffset()); |
|
2304 |
|
2305 CleanupStack::PopAndDestroy(&entries); |
|
2306 |
|
2307 |
|
2308 delete alarm; |
|
2309 delete alarm2; |
|
2310 } |
|
2311 |
|
2312 void CTzTestManager::DoCancel() |
|
2313 { |
|
2314 } |
|
2315 |
|
2316 void CTzTestManager::RunL() |
|
2317 { |
|
2318 test.Printf(_L("CTzTestManager::RunL - test step %d\n"), iTestStep); |
|
2319 TBool completed = EFalse; |
|
2320 |
|
2321 switch (iTestStep++) |
|
2322 { |
|
2323 case 0: |
|
2324 test.Printf(_L("Start no floating entry test\n")); |
|
2325 TestSetAndGetTzRulesL(); |
|
2326 break; |
|
2327 case 1: |
|
2328 TestSetTimeZoneL(KAsiaTokyo); |
|
2329 break; |
|
2330 case 2: |
|
2331 TestRemoteRepeatL(); |
|
2332 break; |
|
2333 case 3: |
|
2334 TestSetTimeZoneL(KEuropeLondon); |
|
2335 break; |
|
2336 case 4: |
|
2337 CheckEntryInTimeZoneL(TTime(KTokyoEntryTime) - (TTimeIntervalHours)9); |
|
2338 break; |
|
2339 case 5: |
|
2340 TestSetTimeZoneL(KPacificAuckland); |
|
2341 break; |
|
2342 case 6: |
|
2343 CheckEntryInTimeZoneL(TTime(KTokyoEntryTime) + (TTimeIntervalHours)4); |
|
2344 break; |
|
2345 case 7: |
|
2346 TestSetTimeZoneL(KAsiaTokyo); |
|
2347 break; |
|
2348 case 8: |
|
2349 TestRepeatRuleTzSetupL(EFalse); |
|
2350 break; |
|
2351 case 9: |
|
2352 TestSetTimeZoneL(KEuropeLondon); |
|
2353 break; |
|
2354 case 10: |
|
2355 TestRepeatRuleLocalTimeL(); |
|
2356 break; |
|
2357 case 11: |
|
2358 TestRepeatRuleTzRulesL(); |
|
2359 break; |
|
2360 case 12: |
|
2361 TestSetTimeZoneL(KAsiaTokyo); |
|
2362 break; |
|
2363 case 13: |
|
2364 TestRepeatRuleTzStartEndTimeL(); |
|
2365 TestRepeatRuleTzStartEndTzRulesL(); |
|
2366 break; |
|
2367 case 14: |
|
2368 TestSetTimeZoneL(KEuropeLondon); |
|
2369 break; |
|
2370 case 15: |
|
2371 DefectTestL(); |
|
2372 TestRDatesTzSetupL(); |
|
2373 TestSetTimeZoneL(KEuropeStockholm); // Set device timezone |
|
2374 break; |
|
2375 case 16: |
|
2376 TestForeignZoneRepeatRule1L(); |
|
2377 TestSetTimeZoneL(KEuropeLondon); |
|
2378 break; |
|
2379 case 17: |
|
2380 TestForeignZoneRepeatRule2L(); |
|
2381 TestLocalRepeatRuleL(); |
|
2382 break; |
|
2383 case 18: |
|
2384 TestSetTimeZoneL(KUsCentral); |
|
2385 break; |
|
2386 case 19: |
|
2387 TestLocalRepeatRule2L(); |
|
2388 TestLocalTimeZoneL(); |
|
2389 break; |
|
2390 case 20: |
|
2391 /* @SYMTestCaseID PIM-TCAL-TZ-Floating_Entry_UTC_Change |
|
2392 @SYMTestCaseDesc Set and get time for floating entries with utc change |
|
2393 @SYMFssID App-Engines/CalInterimAPI/Data.007 |
|
2394 @SYMTestStatus Implemented |
|
2395 @SYMTestPriority Medium |
|
2396 @SYMTestActions 1) Create floating entry, change timezone, check that new time values are as expected |
|
2397 2) Create floating repeating entry, check time stored, change timezone, check that new time values are as expected |
|
2398 3) Create floating repeating entry with exception, check time stored, change timezone, check that new time values are as expected |
|
2399 4) Create floating repeating entry with RDate, check time stored, change timezone, check that new time values are as expected |
|
2400 @SYMTestExpectedResults The check shows that the expected time values are found |
|
2401 @SYMTestType CT |
|
2402 */ |
|
2403 |
|
2404 test.Printf(_L("Start floating entry test\n")); |
|
2405 TestFloatingEntrySetupL(); |
|
2406 break; |
|
2407 case 21: |
|
2408 TestSetTimeZoneL(KPacificAuckland); |
|
2409 break; |
|
2410 case 22: |
|
2411 TestFloatingEntryCheckL(TTime(KTokyoEntryTime)); |
|
2412 TestRepeatRuleTzSetupL(ETrue); |
|
2413 TestFloatingRepeatCheckL(); // check floating entry without timezone change |
|
2414 break; |
|
2415 case 23: |
|
2416 TestSetTimeZoneL(KEuropeLondon); |
|
2417 break; |
|
2418 case 24: |
|
2419 TestFloatingRepeatCheckL(); // check floating entry after timezone change |
|
2420 TestRepeatRuleTzSetupL(ETrue, ETrue); |
|
2421 TestFloatingExceptionCheckL(); // check floating entry without timezone change |
|
2422 break; |
|
2423 case 25: |
|
2424 TestSetTimeZoneL(KPacificAuckland); |
|
2425 break; |
|
2426 case 26: |
|
2427 TestFloatingExceptionCheckL(); // check floating entry after timezone change |
|
2428 TestRepeatRuleTzSetupL(ETrue, EFalse, ETrue); |
|
2429 TestFloatingRDateCheckL(); // check floating entry without timezone change |
|
2430 break; |
|
2431 case 27: |
|
2432 TestSetTimeZoneL(KEuropeLondon); |
|
2433 break; |
|
2434 case 28: |
|
2435 TestFloatingRDateCheckL(); // check floating entry after timezone change |
|
2436 break; |
|
2437 case 29: |
|
2438 TestSetTimeZoneL(KEuropeStockholm); |
|
2439 break; |
|
2440 case 30: |
|
2441 TestAlarmTzUpdateSetupL(); |
|
2442 break; |
|
2443 case 31: |
|
2444 TestSetTimeZoneL(KEuropeLondon); |
|
2445 break; |
|
2446 case 32: |
|
2447 TestAlarmTzUpdateCheckL(); |
|
2448 TestCopyRepeatRulesL(); |
|
2449 TestCreateEntryWithMidnightInHomeTimeL(); |
|
2450 TestCreateEntryWithMidnightInHomeTimeL(ETrue); |
|
2451 TestCreateEntryWithDstChangeL(); |
|
2452 TestCreateEntryWithDstChangeL(ETrue); |
|
2453 break; |
|
2454 case 33: |
|
2455 TestSetTimeZoneL(KEuropeLondon); |
|
2456 break; |
|
2457 case 34: |
|
2458 ImportFloatingEntryL(); |
|
2459 break; |
|
2460 case 35: |
|
2461 TestSetTimeZoneL(KEuropeTirane); |
|
2462 break; |
|
2463 case 36: |
|
2464 TestTimeModeL(); |
|
2465 break; |
|
2466 case 37: |
|
2467 // southern hemisphere |
|
2468 TestSetTimeZoneL(KPacificAuckland); |
|
2469 break; |
|
2470 case 38: |
|
2471 TestExportTzRulesInHemisphereL(ETrue); |
|
2472 break; |
|
2473 case 39: |
|
2474 TestSetTimeZoneL(KEuropeStockholm); |
|
2475 break; |
|
2476 case 40: |
|
2477 TestExportTzRulesInHemisphereL(EFalse); |
|
2478 CheckVcalImportFromS40L(); |
|
2479 // northern hemisphere |
|
2480 SetupEventCrossingMidnightL(); |
|
2481 break; |
|
2482 case 41: |
|
2483 // southern hemisphere |
|
2484 TestSetTimeZoneL(KPacificAuckland); |
|
2485 break; |
|
2486 case 42: |
|
2487 // southern hemisphere |
|
2488 SetupEventCrossingMidnightL(); |
|
2489 break; |
|
2490 case 43: |
|
2491 TestSetTimeZoneL(KEuropeLondon); |
|
2492 break; |
|
2493 case 44: |
|
2494 CheckDSTThresholdL(); |
|
2495 TestAlarmOffsetL(); |
|
2496 break; |
|
2497 case 45: |
|
2498 TestSetTimeZoneL(KPacificHonolulu); |
|
2499 break; |
|
2500 case 46: |
|
2501 { |
|
2502 TInt aExpectedOffset = -600; //utc offset for hawaii time zone is -600mins |
|
2503 TDateTime dtStart(2006,ESeptember,1,10,0,0,0); |
|
2504 TCalTime startCalTime; |
|
2505 startCalTime.SetTimeLocalL(dtStart); |
|
2506 CheckUtcOffsetL(startCalTime, aExpectedOffset); |
|
2507 } |
|
2508 break; |
|
2509 case 47: |
|
2510 completed = ETrue; |
|
2511 break; |
|
2512 } |
|
2513 |
|
2514 if (completed) |
|
2515 { |
|
2516 CActiveScheduler::Stop(); |
|
2517 } |
|
2518 else |
|
2519 { |
|
2520 Start(); |
|
2521 } |
|
2522 } |
|
2523 |
|
2524 /** @SYMTestCaseID PIM-TCAL-TZ-0024 */ |
|
2525 void CTzTestManager::CheckUtcOffsetL(TCalTime& aTestLocalTime, TInt aExpectedOffset) |
|
2526 { |
|
2527 test.Next(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0024 Check for Utc offset")); |
|
2528 TTime localTime = aTestLocalTime.TimeLocalL(); |
|
2529 TTime utcTime = aTestLocalTime.TimeUtcL(); |
|
2530 TTimeIntervalMinutes utcOffset; |
|
2531 test(localTime.MinutesFrom(utcTime, utcOffset) == KErrNone); |
|
2532 test(utcOffset.Int() == aExpectedOffset); |
|
2533 } |
|
2534 |
|
2535 |
|
2536 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
2537 * DoTestL() |
|
2538 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
|
2539 |
|
2540 static void DoTestL() |
|
2541 { |
|
2542 CTzTestManager* testManager = CTzTestManager::NewLC(); |
|
2543 |
|
2544 TPerformanceTimer timer(test); |
|
2545 timer.Start(); |
|
2546 |
|
2547 // Run the test suite |
|
2548 testManager->Start(); |
|
2549 CActiveScheduler::Start(); |
|
2550 |
|
2551 timer.Stop(); |
|
2552 test.Printf(_L("Done\n")); |
|
2553 // printout performance time |
|
2554 timer.PrintOut(); |
|
2555 |
|
2556 CleanupStack::PopAndDestroy(testManager); |
|
2557 } |
|
2558 |
|
2559 |
|
2560 /** @SYMTestCaseID PIM-TCAL-TZ-0001 */ |
|
2561 TInt E32Main() |
|
2562 { |
|
2563 __UHEAP_MARK; |
|
2564 |
|
2565 test.Start(_L("@SYMTESTCaseID:PIM-TCAL-TZ-0001 Calendar Interim API Time Zone test suite")); test.Title(); |
|
2566 |
|
2567 CTrapCleanup* trapCleanup = CTrapCleanup::New(); |
|
2568 if (!trapCleanup) |
|
2569 { |
|
2570 return KErrNoMemory; |
|
2571 } |
|
2572 |
|
2573 CActiveScheduler* scheduler = new CActiveScheduler(); |
|
2574 if (!scheduler) |
|
2575 { |
|
2576 delete trapCleanup; |
|
2577 return KErrNoMemory; |
|
2578 } |
|
2579 CActiveScheduler::Install(scheduler); |
|
2580 |
|
2581 TRAPD(ret, DoTestL()); |
|
2582 test(ret == KErrNone); |
|
2583 |
|
2584 delete scheduler; |
|
2585 delete trapCleanup; |
|
2586 |
|
2587 test.End(); |
|
2588 test.Close(); |
|
2589 |
|
2590 __UHEAP_MARKEND; |
|
2591 |
|
2592 return (KErrNone); |
|
2593 } |