|
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 "tcal_instance_testdata.h" |
|
17 #include "caltestlib.h" |
|
18 |
|
19 #include <calalarm.h> |
|
20 #include <calentry.h> |
|
21 #include <calentryview.h> |
|
22 #include <calinstance.h> |
|
23 #include <calinstanceview.h> |
|
24 #include <calrrule.h> |
|
25 #include <caluser.h> |
|
26 #include "caltestlib.h" |
|
27 #include <e32debug.h> |
|
28 #include <e32test.h> |
|
29 |
|
30 |
|
31 CTestDataStruct::CTestDataStruct() |
|
32 { |
|
33 iFilter = CalCommon::EIncludeAll; |
|
34 iSearchBehaviour = CalCommon::EExactTextSearch; |
|
35 } |
|
36 |
|
37 |
|
38 CTestDataStruct::~CTestDataStruct() |
|
39 { |
|
40 iTimes.Reset(); |
|
41 |
|
42 if(iFunction) |
|
43 { |
|
44 iFunction->CallBack(); |
|
45 } |
|
46 |
|
47 delete iFunction; |
|
48 delete iSearchString; |
|
49 } |
|
50 |
|
51 |
|
52 CTestDataStruct* CTestData::GenerateTestDataLC(TTestNumber aTestNumber, CCalInstanceView* aInstanceView, CCalEntryView* aEntryView) |
|
53 { |
|
54 CTestDataStruct* testData = new (ELeave) CTestDataStruct(); |
|
55 CleanupStack::PushL(testData); |
|
56 |
|
57 switch (aTestNumber) |
|
58 { |
|
59 case EDailyTest1: CreateDailyTest1L(*testData, aEntryView); break; |
|
60 case EDailyTest2: CreateDailyTest2L(*testData, aEntryView); break; |
|
61 case EDailyTest3: CreateDailyTest3L(*testData, aEntryView); break; |
|
62 case EDailyTest4: CreateDailyTest4L(*testData, aEntryView); break; |
|
63 case EDailyTest5: CreateDailyTest5L(*testData, aEntryView); break; |
|
64 case EDailyTest6: CreateDailyTest6L(*testData, aEntryView); break; |
|
65 case EDailyTest7: CreateDailyTest7L(*testData, aEntryView); break; |
|
66 case EWeeklyTest1: CreateWeeklyTest1L(*testData, aEntryView); break; |
|
67 case EWeeklyTest2: CreateWeeklyTest2L(*testData, aEntryView); break; |
|
68 case EWeeklyTest3: CreateWeeklyTest3L(*testData, aEntryView); break; |
|
69 case EWeeklyTest4: CreateWeeklyTest4L(*testData, aEntryView); break; |
|
70 case EWeeklyTest1980_5: CreateWeeklyTest1980_5L(*testData, aEntryView); break; |
|
71 case EMonthlyTest1: CreateMonthlyTest1L(*testData, aEntryView); break; |
|
72 case EMonthlyTest2: CreateMonthlyTest2L(*testData, aEntryView); break; |
|
73 case EMonthlyTest3: CreateMonthlyTest3L(*testData, aEntryView); break; |
|
74 case EMonthlyTest4: CreateMonthlyTest4L(*testData, aEntryView); break; |
|
75 case EYearlyTest1: CreateYearlyTest1L(*testData, aEntryView); break; |
|
76 case EYearlyTest2: CreateYearlyTest2L(*testData, aEntryView); break; |
|
77 case EYearlyTest3: CreateYearlyTest3L(*testData, aEntryView); break; |
|
78 case EYearlyTest4: CreateYearlyTest4L(*testData, ETrue, aEntryView); break; |
|
79 case EYearlyTest5: CreateYearlyTest4L(*testData, EFalse, aEntryView); break; |
|
80 case EYearlyTest1980_6: CreateYearlyTest1980_6L(*testData, aEntryView); break; |
|
81 case EMultipleTest1:CreateMultipleRuleTest1L(*testData, aEntryView); break; |
|
82 case EMultipleTest2:CreateMultipleRuleTest2L(*testData, aEntryView); break; |
|
83 case EFilterTest1: CreateFilterTest1L(*testData, aEntryView); break; |
|
84 case EFilterTest2: CreateFilterTest2L(*testData, aEntryView); break; |
|
85 case EFilterTest3: CreateFilterTest3L(*testData, aEntryView); break; |
|
86 case EFilterTest4: CreateFilterTest4L(*testData, aEntryView); break; |
|
87 case EFilterTest5: CreateFilterTest5L(*testData, aEntryView); break; |
|
88 case EFilterTest6: CreateFilterTest6L(*testData, aEntryView); break; |
|
89 case EFilterTest7: CreateFilterTest7L(*testData, aEntryView); break; |
|
90 case EDeleteTest1: CreateDeleteTest1L(*testData, aEntryView, aInstanceView); break; |
|
91 case EDeleteTest2: CreateDeleteTest2L(*testData, aEntryView, aInstanceView); break; |
|
92 case EDeleteTest3: CreateDeleteTest3L(*testData, aEntryView, aInstanceView); break; |
|
93 case EDeleteTest4: CreateDeleteTest4L(*testData, aEntryView, aInstanceView); break; |
|
94 case EFindStringTest1: CreateStringTest1L(*testData, aEntryView); break; |
|
95 case EFindStringTest2: CreateStringTest2L(*testData, aEntryView); break; |
|
96 case EFindStringTest3: CreateStringTest3L(*testData, aEntryView); break; |
|
97 case EFindStringTest4: CreateStringTest4L(*testData, aEntryView); break; |
|
98 case EFindStringInFieldTest1: CreateStringInFieldTest1L(*testData, aEntryView); break; |
|
99 case EFindStringInFieldTest2: CreateStringInFieldTest2L(*testData, aEntryView); break; |
|
100 case EFindStringInFieldTest3: CreateStringInFieldTest3L(*testData, aEntryView); break; |
|
101 case EFindStringInFieldTest4: CreateStringInFieldTest4L(*testData, aEntryView); break; |
|
102 case EFindStringInFieldTest5: CreateStringInFieldTest5L(*testData, aEntryView); break; |
|
103 case EFindStringInFieldTest6: CreateStringInFieldTest6L(*testData, aEntryView); break; |
|
104 case EStartEndTimesTest1: CreateStartEndTimesTest1L(*testData, aEntryView); break; |
|
105 case EStartEndTimesTest2: CreateStartEndTimesTest2L(*testData, aEntryView); break; |
|
106 case EStartEndTimesTest3: CreateStartEndTimesTest3L(*testData, aEntryView); break; |
|
107 case EStartEndTimesTest4: CreateStartEndTimesTest4L(*testData, aEntryView); break; |
|
108 case EStartEndTimesTest5: CreateStartEndTimesTest5L(*testData, aEntryView); break; |
|
109 case EStartEndTimesTest6: CreateStartEndTimesTest6L(*testData, aEntryView); break; |
|
110 case EStartEndTimesTest7: CreateStartEndTimesTest7L(*testData, aEntryView); break; |
|
111 case EManyInstancesTest: CreateManyInstancesTestL(*testData, aEntryView); break; |
|
112 case EManyInstancesTest2: CreateManyInstancesTest2L(*testData, aEntryView); break; |
|
113 case EManyInstancesTest3: CreateManyInstancesTest3L(*testData, aEntryView); break; |
|
114 case EMaxRangeTest: CreateMaxRangeTestL(*testData, aEntryView); break; |
|
115 case EMaxRangeTest2: CreateMaxRangeTest2L(*testData, aEntryView); break; |
|
116 case EMaxRangeTest3: CreateMaxRangeTest3L(*testData, aEntryView); break; |
|
117 case EMaxRangeTest4: CreateMaxRangeTest4L(*testData, aEntryView); break; |
|
118 case EMaxRangeTest5: CreateMaxRangeTest5L(*testData, aEntryView); break; |
|
119 case EMaxRangeTest6: CreateMaxRangeTest6L(*testData, aEntryView); break; |
|
120 case EMaxRangeTest7: CreateMaxRangeTest7L(*testData, aEntryView); break; |
|
121 case EMaxRangeTest8: CreateMaxRangeTest8L(*testData, aEntryView); break; |
|
122 case EEmptyDatabase1: EmptyDatabase1L(*testData, aEntryView); break; |
|
123 case EEmptyDatabase2: EmptyDatabase2L(*testData, aEntryView); break; |
|
124 case ESecondGranularityTest: CreateRepeatingWithSecondGranularityL(*testData, aEntryView); break; |
|
125 case EMSecondGranularityTest: CreateRepeatingWithMSecondGranularityL(*testData, aEntryView); break; |
|
126 case ERuleAndDateTest: CreateRepeatingWithRuleAndDatesL(*testData, aEntryView); break; |
|
127 case ENextInstanceOnlyTest: CreateNextInstanceOnlyTestL(*testData, aEntryView); break; |
|
128 case EDeleteInstanceTest:DeleteEntryLastInstanceL(*testData, aEntryView, aInstanceView); break; |
|
129 case EUpdateInstanceTest : TestUpdateInstanceL(*testData, aEntryView); break; |
|
130 case EFindInstanceWithTimeTest: TestFindInstanceWithTimeL( *testData, aEntryView ); break; |
|
131 case ERDateBeforeDtStartTest: CreateRDateBeforeDtStartTestL(*testData, aEntryView); break; |
|
132 case EDstBoundaryTest1: CreateDstBoundaryTest1L(*testData, aEntryView); break; |
|
133 case EDstBoundaryTest2: CreateDstBoundaryTest2L(*testData, aEntryView); break; |
|
134 case EDstBoundaryTest3: CreateDstBoundaryTest3L(*testData, aEntryView); break; |
|
135 case EDstBoundaryTest4: CreateDstBoundaryTest4L(*testData, aEntryView); break; |
|
136 case EDstBoundaryTest5: CreateDstBoundaryTest5L(*testData, aEntryView); break; |
|
137 case EExcludeInstanceAdjoiningRangeTestNonRepeat: ExcludeInstanceAdjoiningRangeTestNonRepeatL(*testData, aEntryView); break; |
|
138 case EExcludeInstanceAdjoiningRangeTestRepeat: ExcludeInstanceAdjoiningRangeTestRepeatL(*testData, aEntryView); break; |
|
139 case ETestTodoOnMaxDate: TestTodoOnMaxDateL(*testData, aEntryView); break; |
|
140 // shouldn't get here |
|
141 default: User::Leave(KErrCorrupt); break; |
|
142 } |
|
143 |
|
144 return testData; |
|
145 } |
|
146 |
|
147 |
|
148 // Add an entry to the calendar file with the given repeat rule |
|
149 void CTestData::AddRuleL(const TCalRRule& aRpt, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType, TTimeIntervalHours aDuration) |
|
150 { |
|
151 CCalEntry* entry = CreateEntryLC(aType, aGuid, aRpt.DtStart().TimeLocalL(), aRpt.DtStart().TimeLocalL() + aDuration); |
|
152 entry->SetRRuleL(aRpt); // doesn't take ownership |
|
153 |
|
154 RPointerArray<CCalEntry> array; |
|
155 CleanupClosePushL(array); |
|
156 array.AppendL(entry); |
|
157 TInt success(0); |
|
158 aEntryView->StoreL(array, success); |
|
159 CleanupStack::PopAndDestroy(&array); |
|
160 |
|
161 CleanupStack::PopAndDestroy(entry); |
|
162 } |
|
163 |
|
164 |
|
165 CCalEntry* CTestData::CreateEntryLC(CCalEntry::TType aType, const TDesC8& aGuid, const TTime& aStartTimeLocal, const TTime& aEndTimeLocal) |
|
166 { |
|
167 HBufC8* guid = aGuid.AllocLC(); |
|
168 CCalEntry* entry = CCalEntry::NewL(aType, guid, CCalEntry::EMethodNone, 0); |
|
169 CleanupStack::Pop(guid); |
|
170 CleanupStack::PushL(entry); |
|
171 |
|
172 TCalTime calTime; |
|
173 calTime.SetTimeLocalL(aStartTimeLocal); |
|
174 TCalTime calEndTime; |
|
175 calEndTime.SetTimeLocalL(aEndTimeLocal); |
|
176 entry->SetStartAndEndTimeL(calTime, calEndTime); |
|
177 |
|
178 return entry; |
|
179 } |
|
180 |
|
181 |
|
182 void CTestData::StoreEntryWithTextL(CCalEntryView* aEntryView, CCalEntry::TType aType, const TDesC8& aGuid, const TTime& aStartTimeLocal, const TDesC& aSummaryText) |
|
183 { |
|
184 CCalEntry* entry = CreateEntryLC(aType, aGuid, aStartTimeLocal, aStartTimeLocal + TTimeIntervalHours(1)); |
|
185 entry->SetSummaryL(aSummaryText); |
|
186 RPointerArray<CCalEntry> array; |
|
187 CleanupClosePushL(array); |
|
188 array.AppendL(entry); |
|
189 TInt success(0); |
|
190 aEntryView->StoreL(array, success); |
|
191 CleanupStack::PopAndDestroy(&array); |
|
192 CleanupStack::PopAndDestroy(entry); |
|
193 } |
|
194 |
|
195 |
|
196 void CTestData::CreateDailyTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
197 { |
|
198 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05. Get instances between 28 Feb 05 and 5 Mar 05.")); |
|
199 |
|
200 TCalRRule rpt(TCalRRule::EDaily); |
|
201 rpt.SetInterval(3); |
|
202 TCalTime startTime; |
|
203 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
204 rpt.SetDtStart(startTime); // 24 Feb |
|
205 TCalTime endTime; |
|
206 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 14, 0, 0, 0)); |
|
207 rpt.SetUntil(endTime); // 2008 |
|
208 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
209 |
|
210 aData.iStartDate = TDateTime(2005, EFebruary, 27, 0, 0, 0, 0); // 28 Feb |
|
211 aData.iEndDate = TDateTime(2005, EMarch, 4, 0, 0, 0, 0); // 5 Mar |
|
212 |
|
213 // expected times: |
|
214 aData.iTimes.AppendL(TTime(TDateTime(2005, EMarch, 1, 0, 0, 0, 0))); // 2 Mar |
|
215 aData.iTimes.AppendL(TTime(TDateTime(2005, EMarch, 4, 0, 0, 0, 0))); // 5 Mar |
|
216 } |
|
217 |
|
218 |
|
219 void CTestData::CreateDailyTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
220 { |
|
221 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05. Get instances between 20 Feb 05 and 24 Feb 05.")); |
|
222 // check instance can be found when it starts at end search time |
|
223 |
|
224 TCalRRule rpt(TCalRRule::EDaily); |
|
225 rpt.SetInterval(3); |
|
226 TCalTime startTime; |
|
227 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
228 rpt.SetDtStart(startTime); |
|
229 TCalTime endTime; |
|
230 endTime.SetTimeLocalL(TDateTime(2005, EMarch, 30, 0, 0, 0, 0)); |
|
231 rpt.SetUntil(endTime); // 31 Mar |
|
232 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
233 |
|
234 aData.iStartDate = TDateTime(2005, EFebruary, 19, 0, 0, 0, 0); // 20 Feb |
|
235 aData.iEndDate = TDateTime(2005, EFebruary, 23, 0, 0, 0, 0); // 24 Feb |
|
236 |
|
237 // expected times: |
|
238 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0))); // 24 Feb |
|
239 } |
|
240 |
|
241 |
|
242 void CTestData::CreateDailyTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
243 { |
|
244 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05 until 29 Mar. Get instances between 29 Mar 05 and 6 Apr 05.")); |
|
245 // check instance can be found when it finishes at start search time |
|
246 |
|
247 TCalRRule rpt(TCalRRule::EDaily); |
|
248 rpt.SetInterval(3); |
|
249 TCalTime startTime; |
|
250 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); // 24 Feb |
|
251 rpt.SetDtStart(startTime); |
|
252 TCalTime endTime; |
|
253 endTime.SetTimeLocalL(TDateTime(2005, EMarch, 28, 0, 0, 0, 0)); // 29 Mar |
|
254 rpt.SetUntil(endTime); |
|
255 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
256 |
|
257 aData.iStartDate = TDateTime(2005, EMarch, 28, 0, 0, 0, 0); // 29 Mar |
|
258 aData.iEndDate = TDateTime(2005, EApril, 5, 0, 0, 0, 0); // 6 Apr |
|
259 |
|
260 // expected times: |
|
261 aData.iTimes.AppendL(TTime(TDateTime(2005, EMarch, 28, 0, 0, 0, 0))); // 29 Mar |
|
262 } |
|
263 |
|
264 |
|
265 void CTestData::CreateDailyTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
266 { |
|
267 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05 until 27 Feb. Get instances between 24 Feb 05 and 27 Feb 05.")); |
|
268 // check instance can be found when it starts at start search time and ends at end search time |
|
269 |
|
270 TCalRRule rpt(TCalRRule::EDaily); |
|
271 rpt.SetInterval(3); |
|
272 TCalTime startTime; |
|
273 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); // 24 Feb |
|
274 rpt.SetDtStart(startTime); |
|
275 TCalTime endTime; |
|
276 endTime.SetTimeLocalL(TDateTime(2005, EFebruary, 26, 0, 0, 0, 0)); |
|
277 rpt.SetUntil(endTime); |
|
278 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
279 |
|
280 aData.iStartDate = TDateTime(2005, EFebruary, 23, 0, 0, 0, 0); // 24 Feb |
|
281 aData.iEndDate = TDateTime(2005, EFebruary, 26, 0, 0, 0, 0); // 27 Feb |
|
282 |
|
283 // expected times: |
|
284 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0))); // 24 Feb |
|
285 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 26, 0, 0, 0, 0))); // 27 Feb |
|
286 } |
|
287 |
|
288 |
|
289 void CTestData::CreateDailyTest5L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
290 { |
|
291 aData.iDescription.Copy(_L("Every 10 days from 28 Jan 05. Get instances between 28 Jan 05 and 28 Jan 05.")); |
|
292 // check instance can be found when the search time range is 0 |
|
293 |
|
294 TCalRRule rpt(TCalRRule::EDaily); |
|
295 rpt.SetInterval(10); |
|
296 TCalTime startTime; |
|
297 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 27, 0, 0, 0, 0)); // 28 Jan |
|
298 rpt.SetDtStart(startTime); |
|
299 TCalTime endTime; |
|
300 endTime.SetTimeLocalL(TDateTime(2008, EApril, 1, 0, 0, 0, 0)); // 2008 |
|
301 rpt.SetUntil(endTime); |
|
302 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
303 |
|
304 aData.iStartDate = TDateTime(2005, EJanuary, 27, 0, 0, 0, 0); // 28 Jan |
|
305 aData.iEndDate = TDateTime(2005, EJanuary, 27, 0, 0, 0, 0); // 28 Jan |
|
306 |
|
307 // expected times: |
|
308 aData.iTimes.AppendL(TTime(TDateTime(2005, EJanuary, 27, 0, 0, 0, 0))); // 28 Jan |
|
309 } |
|
310 |
|
311 |
|
312 void CTestData::CreateDailyTest6L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
313 { |
|
314 aData.iDescription.Copy(_L("Every day from 26 Jan 05. Get instances between 28 Jan 05 and 27 Jan 05 (end date earlier than start).")); |
|
315 // check instance isn't found when the search time range is invalid |
|
316 |
|
317 TCalRRule rpt(TCalRRule::EDaily); |
|
318 rpt.SetInterval(1); |
|
319 TCalTime startTime; |
|
320 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 25, 0, 0, 0, 0)); // 26 Jan |
|
321 rpt.SetDtStart(startTime); |
|
322 TCalTime endTime; |
|
323 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 0, 0, 0, 0)); // 2008 |
|
324 rpt.SetUntil(endTime); |
|
325 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
326 |
|
327 aData.iStartDate = TDateTime(2005, EJanuary, 27, 0, 0, 0, 0); // 28 Jan |
|
328 aData.iEndDate = TDateTime(2005, EJanuary, 26, 0, 0, 0, 0); // 27 Jan |
|
329 |
|
330 // expected times: |
|
331 // NONE |
|
332 } |
|
333 |
|
334 |
|
335 //Test code added for DEF063984 |
|
336 void CTestData::CreateDailyTest7L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
337 { |
|
338 aData.iDescription.Copy(_L("Set Until date equal to Start date which is 24 Feb 05 and check whether CCalEntry::SetRRuleL leaves with EAgmErrBadEntry")); |
|
339 |
|
340 RTest test(_L("CreateDailyTest7L")); |
|
341 TCalRRule rpt(TCalRRule::EDaily); |
|
342 rpt.SetInterval(1); |
|
343 TCalTime startTime; |
|
344 TCalTime endTime; |
|
345 |
|
346 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
347 rpt.SetDtStart(startTime); // 24 Feb 2005 |
|
348 endTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
349 rpt.SetUntil(endTime); // 24 Feb 2005 |
|
350 TRAPD(ret,AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt)); |
|
351 test(ret==KErrArgument); |
|
352 |
|
353 aData.iStartDate = TDateTime(2005, EFebruary, 23, 0, 0, 0, 0); |
|
354 aData.iEndDate = TDateTime(2005, EFebruary, 23, 0, 0, 0, 0); |
|
355 } |
|
356 |
|
357 |
|
358 void CTestData::CreateWeeklyTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
359 { |
|
360 aData.iDescription.Copy(_L("Every Wed/Thur from 6 Apr 05 until 21 Apr 05. Get instances between Sun 27 Mar 05 and Sun 24 Apr 05.")); |
|
361 |
|
362 TCalRRule rpt(TCalRRule::EWeekly); |
|
363 rpt.SetInterval(1); |
|
364 RArray<TDay> days; |
|
365 CleanupClosePushL(days); |
|
366 days.AppendL(EWednesday); |
|
367 days.AppendL(EThursday); |
|
368 rpt.SetByDay(days); |
|
369 CleanupStack::PopAndDestroy(&days); |
|
370 TCalTime startTime; |
|
371 startTime.SetTimeLocalL(TDateTime(2005, EApril, 5, 0, 0, 0, 0)); // 6 Apr |
|
372 rpt.SetDtStart(startTime); |
|
373 TCalTime endTime; |
|
374 endTime.SetTimeLocalL(TDateTime(2005, EApril, 20, 0, 0, 0, 0)); // 21 Apr |
|
375 rpt.SetUntil(endTime); |
|
376 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
377 |
|
378 aData.iStartDate = TDateTime(2005, EMarch, 26, 0, 0, 0, 0); // 27 Mar |
|
379 aData.iEndDate = TDateTime(2005, EApril, 23, 0, 0, 0, 0); // 24 Apr |
|
380 |
|
381 // expected times: |
|
382 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 5, 0, 0, 0, 0))); // Wed 6 Apr |
|
383 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 6, 0, 0, 0, 0))); // Thur 7 Apr |
|
384 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // Wed 13 Apr |
|
385 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 13, 0, 0, 0, 0))); // Thur 14 Apr |
|
386 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 19, 0, 0, 0, 0))); // Wed 20 Apr |
|
387 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 20, 0, 0, 0, 0))); // Thur 21 Apr |
|
388 } |
|
389 |
|
390 |
|
391 void CTestData::CreateWeeklyTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
392 { |
|
393 aData.iDescription.Copy(_L("Every Wed/Thur from 3 Apr 05. Get instances between Thur 14 Apr 05 and Wed 27 Apr 05.")); |
|
394 |
|
395 TCalRRule rpt(TCalRRule::EWeekly); |
|
396 rpt.SetInterval(1); |
|
397 RArray<TDay> days; |
|
398 CleanupClosePushL(days); |
|
399 days.AppendL(EWednesday); |
|
400 days.AppendL(EThursday); |
|
401 rpt.SetByDay(days); |
|
402 CleanupStack::PopAndDestroy(&days); |
|
403 TCalTime startTime; |
|
404 startTime.SetTimeLocalL(TDateTime(2005, EApril, 2, 0, 0, 0, 0)); // 3 Apr |
|
405 rpt.SetDtStart(startTime); |
|
406 TCalTime endTime; |
|
407 endTime.SetTimeLocalL(TDateTime(2005, EApril, 26, 0, 0, 0, 0)); // 2008 |
|
408 rpt.SetUntil(endTime); |
|
409 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
410 |
|
411 aData.iStartDate = TDateTime(2005, EApril, 13, 0, 0, 0, 0); // 14 Apr |
|
412 aData.iEndDate = TDateTime(2005, EApril, 26, 0, 0, 0, 0); // 27 Apr |
|
413 |
|
414 // expected times: |
|
415 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 13, 0, 0, 0, 0))); // Thur 14 Apr |
|
416 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 19, 0, 0, 0, 0))); // Wed 20 Apr |
|
417 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 20, 0, 0, 0, 0))); // Thur 21 Apr |
|
418 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 26, 0, 0, 0, 0))); // Wed 27 Apr |
|
419 } |
|
420 |
|
421 |
|
422 void CTestData::CreateWeeklyTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
423 { |
|
424 aData.iDescription.Copy(_L("Every day from 3 Apr 05. Get instances between 2 Apr 05 and 15 Apr 05.")); |
|
425 |
|
426 TCalRRule rpt(TCalRRule::EWeekly); |
|
427 rpt.SetInterval(1); |
|
428 RArray<TDay> days; |
|
429 CleanupClosePushL(days); |
|
430 days.AppendL(EMonday); |
|
431 days.AppendL(ETuesday); |
|
432 days.AppendL(EWednesday); |
|
433 days.AppendL(EThursday); |
|
434 days.AppendL(EFriday); |
|
435 days.AppendL(ESaturday); |
|
436 days.AppendL(ESunday); |
|
437 rpt.SetByDay(days); |
|
438 CleanupStack::PopAndDestroy(&days); |
|
439 TCalTime startTime; |
|
440 startTime.SetTimeLocalL(TDateTime(2005, EApril, 2, 0, 0, 0, 0)); // 3 Apr |
|
441 rpt.SetDtStart(startTime); |
|
442 TCalTime endTime; |
|
443 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 0, 0, 0, 0)); // 2008 |
|
444 rpt.SetUntil(endTime); |
|
445 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
446 |
|
447 aData.iStartDate = TDateTime(2005, EApril, 1, 0, 0, 0, 0); // 2 Apr |
|
448 aData.iEndDate = TDateTime(2005, EApril, 14, 0, 0, 0, 0); // 15 Apr |
|
449 |
|
450 // expected times: |
|
451 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 2, 0, 0, 0, 0))); // 3 Apr |
|
452 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 3, 0, 0, 0, 0))); // 4 Apr |
|
453 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 4, 0, 0, 0, 0))); // 5 Apr |
|
454 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 5, 0, 0, 0, 0))); // 6 Apr |
|
455 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 6, 0, 0, 0, 0))); // 7 Apr |
|
456 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 Apr |
|
457 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 8, 0, 0, 0, 0))); // 9 Apr |
|
458 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 9, 0, 0, 0, 0))); // 10 Apr |
|
459 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 10, 0, 0, 0, 0)));// 11 Apr |
|
460 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 11, 0, 0, 0, 0)));// 12 Apr |
|
461 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0)));// 13 Apr |
|
462 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 13, 0, 0, 0, 0)));// 14 Apr |
|
463 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0)));// 15 Apr |
|
464 } |
|
465 |
|
466 |
|
467 void CTestData::CreateWeeklyTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
468 { |
|
469 aData.iDescription.Copy(_L("Every 10th Sunday from 3 Apr 05. Get instances between 3 Apr 05 and 1 Dec 05.")); |
|
470 |
|
471 TCalRRule rpt(TCalRRule::EWeekly); |
|
472 rpt.SetInterval(10); |
|
473 RArray<TDay> days; |
|
474 CleanupClosePushL(days); |
|
475 days.AppendL(ESunday); |
|
476 rpt.SetByDay(days); |
|
477 CleanupStack::PopAndDestroy(&days); |
|
478 TCalTime startTime; |
|
479 startTime.SetTimeLocalL(TDateTime(2005, EApril, 2, 0, 0, 0, 0)); // 3 Apr |
|
480 rpt.SetDtStart(startTime); |
|
481 TCalTime endTime; |
|
482 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 0, 0, 0, 0)); // 2008 |
|
483 rpt.SetUntil(endTime); |
|
484 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
485 |
|
486 aData.iStartDate = TDateTime(2005, EApril, 2, 0, 0, 0, 0); // 3 Apr |
|
487 aData.iEndDate = TDateTime(2005, EDecember, 0, 0, 0, 0, 0); // 1 Dec |
|
488 |
|
489 // expected times: |
|
490 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 2, 0, 0, 0, 0))); // 3 Apr |
|
491 aData.iTimes.AppendL(TTime(TDateTime(2005, EJune, 11, 0, 0, 0, 0))); // 12 Jun |
|
492 aData.iTimes.AppendL(TTime(TDateTime(2005, EAugust, 20, 0, 0, 0, 0))); // 21 Aug |
|
493 aData.iTimes.AppendL(TTime(TDateTime(2005, EOctober, 29, 0, 0, 0, 0))); // 30 Oct |
|
494 } |
|
495 |
|
496 |
|
497 void CTestData::CreateMonthlyTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
498 { |
|
499 aData.iDescription.Copy(_L("Every month on the 1st and 31st from 1 Apr 05. Get instances between 1 Nov 05 and 1 Mar 06.")); |
|
500 |
|
501 TCalRRule rpt(TCalRRule::EMonthly); |
|
502 rpt.SetInterval(1); |
|
503 RArray<TInt> days; |
|
504 CleanupClosePushL(days); |
|
505 days.AppendL(0); |
|
506 days.AppendL(30); |
|
507 rpt.SetByMonthDay(days); |
|
508 CleanupStack::PopAndDestroy(&days); |
|
509 TCalTime startTime; |
|
510 startTime.SetTimeLocalL(TDateTime(2005, EApril, 0, 0, 0, 0, 0)); // 1 Apr |
|
511 rpt.SetDtStart(startTime); |
|
512 TCalTime endTime; |
|
513 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 0, 0, 0, 0)); // 2008 |
|
514 rpt.SetUntil(endTime); |
|
515 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
516 |
|
517 aData.iStartDate = TDateTime(2005, ENovember, 0, 0, 0, 0, 0); // 1 Nov 05 |
|
518 aData.iEndDate = TDateTime(2006, EMarch, 0, 0, 0, 0, 0); // 1 Mar 06 |
|
519 |
|
520 // expected times: |
|
521 aData.iTimes.AppendL(TTime(TDateTime(2005, ENovember, 0, 0, 0, 0, 0))); // 1 Nov 05 |
|
522 aData.iTimes.AppendL(TTime(TDateTime(2005, ENovember, 29, 0, 0, 0, 0))); // 30 Nov 05 |
|
523 aData.iTimes.AppendL(TTime(TDateTime(2005, EDecember, 0, 0, 0, 0, 0))); // 1 Dec 05 |
|
524 aData.iTimes.AppendL(TTime(TDateTime(2005, EDecember, 30, 0, 0, 0, 0))); // 31 Dec 05 |
|
525 aData.iTimes.AppendL(TTime(TDateTime(2006, EJanuary, 0, 0, 0, 0, 0))); // 1 Jan 06 |
|
526 aData.iTimes.AppendL(TTime(TDateTime(2006, EJanuary, 30, 0, 0, 0, 0))); // 31 Jan 06 |
|
527 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 0, 0, 0, 0, 0))); // 1 Feb 06 |
|
528 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 27, 0, 0, 0, 0))); // 28 Feb 06 |
|
529 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 0, 0, 0, 0, 0))); // 1 Mar 06 |
|
530 } |
|
531 |
|
532 |
|
533 void CTestData::CreateMonthlyTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
534 { |
|
535 aData.iDescription.Copy(_L("Every 5 months on the 10th from 11 Apr 05. Get instances between 1 Jan 05 and 1 Jan 07.")); |
|
536 |
|
537 TCalRRule rpt(TCalRRule::EMonthly); |
|
538 rpt.SetInterval(5); |
|
539 RArray<TInt> days; |
|
540 CleanupClosePushL(days); |
|
541 days.AppendL(9); |
|
542 rpt.SetByMonthDay(days); |
|
543 CleanupStack::PopAndDestroy(&days); |
|
544 TCalTime startTime; |
|
545 startTime.SetTimeLocalL(TDateTime(2005, EApril, 10, 0, 0, 0, 0)); // 11 Apr |
|
546 rpt.SetDtStart(startTime); |
|
547 TCalTime endTime; |
|
548 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 0, 0, 0, 0)); // 2008 |
|
549 rpt.SetUntil(endTime); |
|
550 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
551 |
|
552 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 05 |
|
553 aData.iEndDate = TDateTime(2007, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 07 |
|
554 |
|
555 // expected times: |
|
556 aData.iTimes.AppendL(TTime(TDateTime(2005, ESeptember, 9, 0, 0, 0, 0)));// 10 Sep 05 |
|
557 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 9, 0, 0, 0, 0))); // 10 Feb 06 |
|
558 aData.iTimes.AppendL(TTime(TDateTime(2006, EJuly, 9, 0, 0, 0, 0))); // 10 Jul 06 |
|
559 aData.iTimes.AppendL(TTime(TDateTime(2006, EDecember, 9, 0, 0, 0, 0))); // 10 Dec 06 |
|
560 } |
|
561 |
|
562 |
|
563 void CTestData::CreateMonthlyTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
564 { |
|
565 aData.iDescription.Copy(_L("Every 4th + last Mon in the month from 11 Jun 05. Get instances between 1 Jul 05 and 31 Oct 05.")); |
|
566 |
|
567 TCalRRule rpt(TCalRRule::EMonthly); |
|
568 rpt.SetInterval(1); |
|
569 |
|
570 RArray<TCalRRule::TDayOfMonth> dayArray; |
|
571 CleanupClosePushL(dayArray); |
|
572 TCalRRule::TDayOfMonth day1(EMonday, - 1); |
|
573 dayArray.AppendL(day1); |
|
574 TCalRRule::TDayOfMonth day2(EMonday, 4); |
|
575 dayArray.AppendL(day2); |
|
576 rpt.SetByDay(dayArray); |
|
577 CleanupStack::PopAndDestroy(&dayArray); |
|
578 |
|
579 TCalTime startTime; |
|
580 startTime.SetTimeLocalL(TDateTime(2005, EJune, 10, 10, 0, 0, 0)); // 11 Jun |
|
581 rpt.SetDtStart(startTime); |
|
582 TCalTime endTime; |
|
583 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 0, 0, 0, 0)); // 2008 |
|
584 rpt.SetUntil(endTime); |
|
585 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
586 |
|
587 aData.iStartDate = TDateTime(2005, EJuly, 0, 0, 0, 0, 0); // 1 Jul 05 |
|
588 aData.iEndDate = TDateTime(2005, EOctober, 30, 10, 0, 0, 0); // 31 Oct 05 |
|
589 |
|
590 // expected times: |
|
591 aData.iTimes.AppendL(TTime(TDateTime(2005, EJuly, 24, 10, 0, 0, 0))); // 25 Jul 05 |
|
592 aData.iTimes.AppendL(TTime(TDateTime(2005, EAugust, 21, 10, 0, 0, 0))); // 22 Aug 05 |
|
593 aData.iTimes.AppendL(TTime(TDateTime(2005, EAugust, 28, 10, 0, 0, 0))); // 29 Aug 05 |
|
594 aData.iTimes.AppendL(TTime(TDateTime(2005, ESeptember, 25, 10, 0, 0, 0)));// 26 Sep 05 |
|
595 aData.iTimes.AppendL(TTime(TDateTime(2005, EOctober, 23, 10, 0, 0, 0))); // 24 Oct 05 |
|
596 aData.iTimes.AppendL(TTime(TDateTime(2005, EOctober, 30, 10, 0, 0, 0))); // 31 Oct 05 |
|
597 } |
|
598 |
|
599 |
|
600 void CTestData::CreateMonthlyTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
601 { |
|
602 aData.iDescription.Copy(_L("Every second Wed every 3 months from 11 Jun 05. Get instances between 1 Jun 05 and 1 Mar 06.")); |
|
603 |
|
604 TCalRRule rpt(TCalRRule::EMonthly); |
|
605 rpt.SetInterval(3); |
|
606 |
|
607 RArray<TCalRRule::TDayOfMonth> dayArray; |
|
608 CleanupClosePushL(dayArray); |
|
609 TCalRRule::TDayOfMonth day(EWednesday, 2); |
|
610 dayArray.AppendL(day); |
|
611 rpt.SetByDay(dayArray); |
|
612 CleanupStack::PopAndDestroy(&dayArray); |
|
613 |
|
614 TCalTime startTime; |
|
615 startTime.SetTimeLocalL(TDateTime(2005, EJune, 10, 10, 0, 0, 0)); // 11 Jun |
|
616 rpt.SetDtStart(startTime); |
|
617 TCalTime endTime; |
|
618 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 0, 0, 0, 0)); // 2008 |
|
619 rpt.SetUntil(endTime); |
|
620 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
621 |
|
622 aData.iStartDate = TDateTime(2005, EJune, 0, 0, 0, 0, 0); // 1 Jun 05 |
|
623 aData.iEndDate = TDateTime(2006, EMarch, 0, 0, 0, 0, 0); // 1 Mar 06 |
|
624 |
|
625 // expected times: |
|
626 aData.iTimes.AppendL(TTime(TDateTime(2005, ESeptember, 13, 10, 0, 0, 0)));// 14 Sep 05 |
|
627 aData.iTimes.AppendL(TTime(TDateTime(2005, EDecember, 13, 10, 0, 0, 0))); // 14 Dec 05 |
|
628 } |
|
629 |
|
630 |
|
631 void CTestData::CreateWeeklyTest1980_5L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
632 { |
|
633 aData.iDescription.Copy(_L("Three consecutive Mondays from 8 March 1920.")); |
|
634 |
|
635 TCalRRule rpt(TCalRRule::EWeekly); |
|
636 rpt.SetInterval(1); |
|
637 RArray<TDay> days; |
|
638 CleanupClosePushL(days); |
|
639 days.AppendL(EMonday); |
|
640 rpt.SetByDay(days); |
|
641 CleanupStack::PopAndDestroy(&days); |
|
642 |
|
643 TCalTime startTime; |
|
644 startTime.SetTimeLocalL(TDateTime (1920,EMarch,1,21,30,0,0)); |
|
645 rpt.SetDtStart(startTime); |
|
646 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
647 |
|
648 aData.iStartDate = TDateTime(1920,EMarch,1,21,30,0,0); |
|
649 aData.iEndDate = TDateTime(1920,EMarch,24,22,30,0,0); |
|
650 |
|
651 // expected times: |
|
652 aData.iTimes.AppendL(TTime(TDateTime(1920, EMarch, 7, 21,30, 0, 0))); // 8 Mar |
|
653 aData.iTimes.AppendL(TTime(TDateTime(1920, EMarch, 14, 21,30, 0, 0))); // 15 Mar |
|
654 aData.iTimes.AppendL(TTime(TDateTime(1920, EMarch, 21, 21,30, 0, 0))); // 22 Mar |
|
655 } |
|
656 |
|
657 |
|
658 void CTestData::CreateYearlyTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
659 { |
|
660 aData.iDescription.Copy(_L("Every year from 29 Feb 04. Get instances between 28 Feb 06 and 1 Jun 08.")); |
|
661 |
|
662 TCalRRule rpt(TCalRRule::EYearly); |
|
663 rpt.SetInterval(1); |
|
664 TCalTime startTime; |
|
665 startTime.SetTimeLocalL(TDateTime(2004, EFebruary, 28, 0, 0, 0, 0)); // 29 Feb 2004 |
|
666 rpt.SetDtStart(startTime); |
|
667 TCalTime endTime; |
|
668 endTime.SetTimeLocalL(TDateTime(2009, EMarch, 30, 0, 0, 0, 0)); // 2009 |
|
669 rpt.SetUntil(endTime); |
|
670 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
671 |
|
672 aData.iStartDate = TDateTime(2006, EFebruary, 27, 0, 0, 0, 0); // 28 Feb 06 |
|
673 aData.iEndDate = TDateTime(2008, EJune, 0, 0, 0, 0, 0); // 1 Jun 08 |
|
674 |
|
675 // expected times: |
|
676 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 27, 0, 0, 0, 0))); // 28 Feb 06 |
|
677 aData.iTimes.AppendL(TTime(TDateTime(2007, EFebruary, 27, 0, 0, 0, 0))); // 28 Feb 07 |
|
678 aData.iTimes.AppendL(TTime(TDateTime(2008, EFebruary, 28, 0, 0, 0, 0))); // 29 Feb 08 |
|
679 } |
|
680 |
|
681 |
|
682 void CTestData::CreateYearlyTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
683 { |
|
684 aData.iDescription.Copy(_L("Every 2 years from 15 Jun 05. Get instances between 1 Jan 05 and 1 Jan 10.")); |
|
685 |
|
686 TCalRRule rpt(TCalRRule::EYearly); |
|
687 rpt.SetInterval(2); |
|
688 TCalTime startTime; |
|
689 startTime.SetTimeLocalL(TDateTime(2005, EJune, 14, 0, 0, 0, 0)); // 15 Wed Jun |
|
690 rpt.SetDtStart(startTime); |
|
691 TCalTime endTime; |
|
692 endTime.SetTimeLocalL(TDateTime(2012, EMarch, 26, 0, 0, 0, 0)); // 2012 |
|
693 rpt.SetUntil(endTime); |
|
694 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
695 |
|
696 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 05 |
|
697 aData.iEndDate = TDateTime(2010, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 10 |
|
698 |
|
699 // expected times: |
|
700 aData.iTimes.AppendL(TTime(TDateTime(2005, EJune, 14, 0, 0, 0, 0))); // 15 Jun 05 |
|
701 aData.iTimes.AppendL(TTime(TDateTime(2007, EJune, 14, 0, 0, 0, 0))); // 15 Jun 07 |
|
702 aData.iTimes.AppendL(TTime(TDateTime(2009, EJune, 14, 0, 0, 0, 0))); // 15 Jun 09 |
|
703 } |
|
704 |
|
705 |
|
706 void CTestData::CreateYearlyTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
707 { |
|
708 aData.iDescription.Copy(_L("Every year on last Sun in Feb from 1 Jan 05. Get instances between 1 Jan 05 and 1 Jan 07.")); |
|
709 |
|
710 TCalRRule rpt(TCalRRule::EYearly); |
|
711 rpt.SetInterval(1); |
|
712 |
|
713 TCalTime startTime; |
|
714 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 0, 0, 0, 0, 0)); // 1 Jan |
|
715 rpt.SetDtStart(startTime); |
|
716 |
|
717 TCalTime endTime; |
|
718 endTime.SetTimeLocalL(TDateTime(2012, EMarch, 30, 14, 0, 0, 0)); // 2012 |
|
719 rpt.SetUntil(endTime); |
|
720 |
|
721 TCalRRule::TDayOfMonth dayOfMonth(ESunday, - 1); |
|
722 RArray<TCalRRule::TDayOfMonth> dayArray; |
|
723 CleanupClosePushL(dayArray); |
|
724 dayArray.AppendL(dayOfMonth); |
|
725 rpt.SetByDay(dayArray); |
|
726 CleanupStack::PopAndDestroy(&dayArray); |
|
727 |
|
728 RArray<TMonth> monthArray; |
|
729 CleanupClosePushL(monthArray); |
|
730 monthArray.AppendL(EFebruary); |
|
731 rpt.SetByMonth(monthArray); |
|
732 CleanupStack::PopAndDestroy(&monthArray); |
|
733 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
734 |
|
735 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 05 |
|
736 aData.iEndDate = TDateTime(2007, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 07 |
|
737 |
|
738 // expected times: |
|
739 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 26, 0, 0, 0, 0))); // 27 Feb 05 |
|
740 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 25, 0, 0, 0, 0))); // 26 Feb 06 |
|
741 } |
|
742 |
|
743 |
|
744 void CTestData::CreateYearlyTest4L(CTestDataStruct& aData, TBool aRepeatForever, CCalEntryView* aEntryView) |
|
745 { |
|
746 if (!aRepeatForever) |
|
747 { |
|
748 aData.iDescription.Copy(_L("Every 2 years on 2nd Thu in Nov, from 1 Jan 05. Get instances between 1 Jan 05 and 1 Jan 10.")); |
|
749 } |
|
750 else |
|
751 { |
|
752 aData.iDescription.Copy(_L("Every 2 years on 2nd Thu in Nov, from 1 Jan 05. Get instances between 1 Jan 05 and 1 Jan 10. (No repeat end date)")); |
|
753 } |
|
754 |
|
755 TCalRRule rpt(TCalRRule::EYearly); |
|
756 rpt.SetInterval(2); |
|
757 |
|
758 TCalTime startTime; |
|
759 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 0, 0, 0, 0, 0)); // 1 Jan |
|
760 rpt.SetDtStart(startTime); |
|
761 |
|
762 if (!aRepeatForever) |
|
763 { |
|
764 TCalTime endTime; |
|
765 endTime.SetTimeLocalL(TDateTime(2012, EMarch, 30, 14, 0, 0, 0)); // 2012 |
|
766 rpt.SetUntil(endTime); |
|
767 } |
|
768 |
|
769 TCalRRule::TDayOfMonth dayOfMonth(EThursday, 2); |
|
770 RArray<TCalRRule::TDayOfMonth> dayArray; |
|
771 CleanupClosePushL(dayArray); |
|
772 dayArray.AppendL(dayOfMonth); |
|
773 rpt.SetByDay(dayArray); |
|
774 CleanupStack::PopAndDestroy(&dayArray); |
|
775 |
|
776 RArray<TMonth> monthArray; |
|
777 CleanupClosePushL(monthArray); |
|
778 monthArray.AppendL(ENovember); |
|
779 rpt.SetByMonth(monthArray); |
|
780 CleanupStack::PopAndDestroy(&monthArray); |
|
781 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
782 |
|
783 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 05 |
|
784 aData.iEndDate = TDateTime(2010, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 10 |
|
785 |
|
786 // expected times: |
|
787 aData.iTimes.AppendL(TTime(TDateTime(2005, ENovember, 9, 0, 0, 0, 0))); // 10 Nov 05 |
|
788 aData.iTimes.AppendL(TTime(TDateTime(2007, ENovember, 7, 0, 0, 0, 0))); // 8 Nov 07 |
|
789 aData.iTimes.AppendL(TTime(TDateTime(2009, ENovember, 11, 0, 0, 0, 0))); // 12 Nov 09 |
|
790 } |
|
791 |
|
792 |
|
793 void CTestData::CreateYearlyTest1980_6L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
794 { |
|
795 aData.iDescription.Copy(_L("Three Repeats of 3 year each of Appt,Event,Todo from 1901 to 1917")); |
|
796 |
|
797 TCalRRule rpt(TCalRRule::EYearly); |
|
798 rpt.SetInterval(1); |
|
799 rpt.SetCount(3); |
|
800 TCalTime startTime; |
|
801 startTime.SetTimeLocalL((TDateTime (1901,EJanuary,24,21,30,0,0))); |
|
802 rpt.SetDtStart(startTime); |
|
803 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
804 |
|
805 startTime.SetTimeLocalL((TDateTime (1910,EAugust,15,21,30,0,0))); |
|
806 rpt.SetDtStart(startTime); |
|
807 AddRuleL(rpt, aEntryView, KGUID2(), CCalEntry::EEvent); |
|
808 |
|
809 startTime.SetTimeLocalL((TDateTime (1915,EMarch,5,21,30,0,0))); |
|
810 rpt.SetDtStart(startTime); |
|
811 AddRuleL(rpt, aEntryView, KGUID3(), CCalEntry::ETodo); |
|
812 |
|
813 |
|
814 aData.iStartDate = TDateTime(1900,EJanuary,24,21,30,0,0); |
|
815 aData.iEndDate = TDateTime(1919,EJanuary,0,0,0,0,0); |
|
816 |
|
817 // expected times: |
|
818 aData.iTimes.AppendL(TTime(TDateTime(1901,EJanuary,24,21,30,0,0))); |
|
819 aData.iTimes.AppendL(TTime(TDateTime(1902,EJanuary,24,21,30,0,0))); |
|
820 aData.iTimes.AppendL(TTime(TDateTime(1903,EJanuary,24,21,30,0,0))); |
|
821 |
|
822 aData.iTimes.AppendL(TTime(TDateTime(1910,EAugust,15,21,30,0,0))); |
|
823 aData.iTimes.AppendL(TTime(TDateTime(1911,EAugust,15,21,30,0,0))); |
|
824 aData.iTimes.AppendL(TTime(TDateTime(1912,EAugust,15,21,30,0,0))); |
|
825 |
|
826 aData.iTimes.AppendL(TTime(TDateTime(1915,EMarch,5,22,30,0,0))); |
|
827 aData.iTimes.AppendL(TTime(TDateTime(1916,EMarch,5,22,30,0,0))); |
|
828 aData.iTimes.AppendL(TTime(TDateTime(1917,EMarch,5,22,30,0,0))); |
|
829 } |
|
830 |
|
831 |
|
832 void CTestData::CreateMultipleRuleTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
833 { |
|
834 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05 and every Wed/Thur from 3 Apr 05 until 17 Apr 05. Get instances between 1 Apr and 30 Apr 05.")); |
|
835 |
|
836 // create two entries with repeat rules at overlapping dates |
|
837 // Every 3 days from 24 Feb 05 |
|
838 TCalRRule rpt(TCalRRule::EDaily); |
|
839 rpt.SetInterval(3); |
|
840 TCalTime startTime; |
|
841 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
842 rpt.SetDtStart(startTime); // 24 Feb |
|
843 TCalTime endTime; |
|
844 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 14, 0, 0, 0)); |
|
845 rpt.SetUntil(endTime); // 2008 |
|
846 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
847 |
|
848 // Every Wed/Thur from 6 Apr 05 until 17 Apr 05 |
|
849 TCalRRule rpt2(TCalRRule::EWeekly); |
|
850 rpt2.SetInterval(1); |
|
851 RArray<TDay> days; |
|
852 CleanupClosePushL(days); |
|
853 days.AppendL(EWednesday); |
|
854 days.AppendL(EThursday); |
|
855 rpt2.SetByDay(days); |
|
856 CleanupStack::PopAndDestroy(&days); |
|
857 startTime.SetTimeLocalL(TDateTime(2005, EApril, 2, 0, 0, 0, 0)); // 3 Apr |
|
858 rpt2.SetDtStart(startTime); |
|
859 endTime.SetTimeLocalL(TDateTime(2005, EApril, 16, 0, 0, 0, 0)); // 17 Apr |
|
860 rpt2.SetUntil(endTime); |
|
861 AddRuleL(rpt2, aEntryView, KGUID2(), CCalEntry::EAppt); |
|
862 |
|
863 aData.iStartDate = TDateTime(2005, EApril, 0, 0, 0, 0, 0); // 1 Apr 05 |
|
864 aData.iEndDate = TDateTime(2005, EApril, 29, 0, 0, 0, 0); // 30 Apr 05 |
|
865 |
|
866 aData.iTimes.Reset(); |
|
867 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 0, 0, 0, 0, 0))); // 1 Apr 05 |
|
868 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 3, 0, 0, 0, 0))); // 4 Apr 05 |
|
869 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 5, 0, 0, 0, 0))); // 6 Apr 05 - Wed |
|
870 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 6, 0, 0, 0, 0))); // 7 Apr 05 - Thur |
|
871 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 6, 0, 0, 0, 0))); // 7 Apr 05 - 3-daily (must mention both instances) |
|
872 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 9, 0, 0, 0, 0))); // 10 Apr 05 |
|
873 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // 13 Apr 05 - Wed |
|
874 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // 13 Apr 05 - 3-daily |
|
875 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 13, 0, 0, 0, 0))); // 14 Apr 05 - Thur |
|
876 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 15, 0, 0, 0, 0))); // 16 Apr 05 |
|
877 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 18, 0, 0, 0, 0))); // 19 Apr 05 |
|
878 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 Apr 05 |
|
879 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 24, 0, 0, 0, 0))); // 25 Apr 05 |
|
880 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 27, 0, 0, 0, 0))); // 28 Apr 05 |
|
881 } |
|
882 |
|
883 |
|
884 void CTestData::CreateMultipleRuleTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
885 { |
|
886 aData.iDescription.Copy(_L("Every month on the 1st and 31st and every Wed/Thur from 3 Apr 05. Get instances between 20 Apr and 10 Jun 05.")); |
|
887 |
|
888 // create two entries with repeat rules at overlapping dates |
|
889 // Every Wed/Thur from 3 Apr 05 |
|
890 TCalRRule rpt(TCalRRule::EWeekly); |
|
891 rpt.SetInterval(1); |
|
892 RArray<TDay> days; |
|
893 CleanupClosePushL(days); |
|
894 days.AppendL(EWednesday); |
|
895 days.AppendL(EThursday); |
|
896 rpt.SetByDay(days); |
|
897 CleanupStack::PopAndDestroy(&days); |
|
898 TCalTime startTime; |
|
899 startTime.SetTimeLocalL(TDateTime(2005, EApril, 2, 0, 0, 0, 0)); // 3 Apr |
|
900 rpt.SetDtStart(startTime); |
|
901 TCalTime endTime; |
|
902 endTime.SetTimeLocalL(TDateTime(2008, EApril, 26, 0, 0, 0, 0)); // 2008 |
|
903 rpt.SetUntil(endTime); |
|
904 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
905 |
|
906 // Every month on the 1st and 31st from 1 Apr 05 |
|
907 TCalRRule rpt2(TCalRRule::EMonthly); |
|
908 rpt2.SetInterval(1); |
|
909 RArray<TInt> days2; |
|
910 CleanupClosePushL(days2); |
|
911 days2.AppendL(0); |
|
912 days2.AppendL(30); |
|
913 rpt2.SetByMonthDay(days2); |
|
914 CleanupStack::PopAndDestroy(&days2); |
|
915 startTime.SetTimeLocalL(TDateTime(2005, EApril, 0, 0, 0, 0, 0)); // 1 Apr |
|
916 rpt2.SetDtStart(startTime); |
|
917 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 0, 0, 0, 0)); // 2008 |
|
918 rpt2.SetUntil(endTime); |
|
919 AddRuleL(rpt2, aEntryView, KGUID2(), CCalEntry::EAppt); |
|
920 |
|
921 aData.iStartDate = TDateTime(2005, EApril, 19, 0, 0, 0, 0); // 20 Apr 05 |
|
922 aData.iEndDate = TDateTime(2005, EJune, 9, 0, 0, 0, 0); // 10 Jun 05 |
|
923 |
|
924 aData.iTimes.Reset(); |
|
925 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 19, 0, 0, 0, 0))); // 20 Apr 05 - Wed |
|
926 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 20, 0, 0, 0, 0))); // 21 Apr 05 - Thur |
|
927 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 26, 0, 0, 0, 0))); // 27 Apr 05 - Wed |
|
928 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 27, 0, 0, 0, 0))); // 28 Apr 05 - Thur |
|
929 aData.iTimes.AppendL(TTime(TDateTime(2005, EApril, 29, 0, 0, 0, 0))); // 30 Apr 05 |
|
930 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 0, 0, 0, 0, 0))); // 1 May 05 |
|
931 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 3, 0, 0, 0, 0))); // 4 May 05 - Wed |
|
932 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 4, 0, 0, 0, 0))); // 5 May 05 - Thur |
|
933 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 10, 0, 0, 0, 0))); // 11 May 05 - Wed |
|
934 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 11, 0, 0, 0, 0))); // 12 May 05 - Thur |
|
935 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 17, 0, 0, 0, 0))); // 18 May 05 - Wed |
|
936 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 18, 0, 0, 0, 0))); // 19 May 05 - Thur |
|
937 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 24, 0, 0, 0, 0))); // 25 May 05 - Wed |
|
938 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 25, 0, 0, 0, 0))); // 26 May 05 - Thur |
|
939 aData.iTimes.AppendL(TTime(TDateTime(2005, EMay, 30, 0, 0, 0, 0))); // 31 May 05 |
|
940 aData.iTimes.AppendL(TTime(TDateTime(2005, EJune, 0, 0, 0, 0, 0))); // 1 Jun 05 |
|
941 aData.iTimes.AppendL(TTime(TDateTime(2005, EJune, 0, 0, 0, 0, 0))); // 1 Jun 05 - Wed |
|
942 aData.iTimes.AppendL(TTime(TDateTime(2005, EJune, 1, 0, 0, 0, 0))); // 2 Jun 05 - Thur |
|
943 aData.iTimes.AppendL(TTime(TDateTime(2005, EJune, 7, 0, 0, 0, 0))); // 8 Jun 05 - Wed |
|
944 aData.iTimes.AppendL(TTime(TDateTime(2005, EJune, 8, 0, 0, 0, 0))); // 9 Jun 05 - Thur |
|
945 } |
|
946 |
|
947 |
|
948 // create a weekly repeating rule for the specified day of the week |
|
949 void CTestData::AddWeeklyRuleL(TDay aDay, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType) |
|
950 { |
|
951 TCalRRule rpt(TCalRRule::EWeekly); |
|
952 rpt.SetInterval(1); |
|
953 |
|
954 TCalTime startTime; |
|
955 TCalTime endTime; |
|
956 |
|
957 if (aDay == EMonday) |
|
958 { |
|
959 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 2, 0, 0, 0, 0)); // 3 Jan 05 |
|
960 endTime.SetTimeLocalL(TDateTime(2012, EMarch, 25, 0, 0, 0, 0)); // 26 Mar 2012 |
|
961 } |
|
962 else if (aDay == ETuesday) |
|
963 { |
|
964 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 3, 0, 0, 0, 0)); // 4 Jan 05 |
|
965 endTime.SetTimeLocalL(TDateTime(2012, EMarch, 26, 0, 0, 0, 0)); // 27 Mar 2012 |
|
966 } |
|
967 else if (aDay == EWednesday) |
|
968 { |
|
969 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 4, 0, 0, 0, 0)); // 5 Jan 05 |
|
970 endTime.SetTimeLocalL(TDateTime(2012, EMarch, 27, 0, 0, 0, 0)); // 28 Mar 2012 |
|
971 } |
|
972 else if (aDay == EThursday) |
|
973 { |
|
974 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 5, 0, 0, 0, 0)); // 6 Jan 05 |
|
975 endTime.SetTimeLocalL(TDateTime(2012, EMarch, 28, 0, 0, 0, 0)); // 29 Mar 2012 |
|
976 } |
|
977 else if (aDay == EFriday) |
|
978 { |
|
979 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 6, 0, 0, 0, 0)); // 7 Jan 05 |
|
980 endTime.SetTimeLocalL(TDateTime(2012, EMarch, 29, 0, 0, 0, 0)); // 30 Mar 2012 |
|
981 } |
|
982 |
|
983 rpt.SetDtStart(startTime); |
|
984 rpt.SetUntil(endTime); |
|
985 RArray<TDay> days; |
|
986 CleanupClosePushL(days); |
|
987 days.AppendL(aDay); |
|
988 rpt.SetByDay(days); |
|
989 CleanupStack::PopAndDestroy(&days); |
|
990 |
|
991 AddRuleL(rpt, aEntryView, aGuid, aType); |
|
992 } |
|
993 |
|
994 |
|
995 // Create 5 weekly repeating rules - Appts every Monday, Todos every Tuesday, etc. |
|
996 // This is used for the filter tests. |
|
997 void CTestData::CreateFilterTestDataL(CCalEntryView* aEntryView) |
|
998 { |
|
999 AddWeeklyRuleL(EMonday, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
1000 AddWeeklyRuleL(ETuesday, aEntryView, KGUID2(), CCalEntry::ETodo); |
|
1001 AddWeeklyRuleL(EWednesday, aEntryView, KGUID3(), CCalEntry::EEvent); |
|
1002 AddWeeklyRuleL(EThursday, aEntryView, KGUID4(), CCalEntry::EReminder); |
|
1003 AddWeeklyRuleL(EFriday, aEntryView, KGUID5(),CCalEntry::EAnniv); |
|
1004 } |
|
1005 |
|
1006 |
|
1007 void CTestData::CreateFilterTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1008 { |
|
1009 aData.iDescription.Copy(_L("Filter out annivs (Fri) and appts (Mon) only. Get all instances between 1 Feb 05 and 12 Feb 05.")); |
|
1010 |
|
1011 CreateFilterTestDataL(aEntryView); |
|
1012 aData.iFilter = CalCommon::EIncludeAppts|CalCommon::EIncludeAnnivs; |
|
1013 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); // 1 Feb 05 |
|
1014 aData.iEndDate = TDateTime(2005, EFebruary, 11, 0, 0, 0, 0); // 12 Feb 05 |
|
1015 |
|
1016 // expected times: |
|
1017 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 3, 0, 0, 0, 0))); // Anniv |
|
1018 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 6, 0, 0, 0, 0))); // Appt |
|
1019 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 10, 0, 0, 0, 0))); // Anniv |
|
1020 } |
|
1021 |
|
1022 |
|
1023 void CTestData::CreateFilterTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1024 { |
|
1025 aData.iDescription.Copy(_L("Filter out events (Wed) only. Get all instances between 1 Feb 05 and 28 Feb 05.")); |
|
1026 |
|
1027 CreateFilterTestDataL(aEntryView); |
|
1028 aData.iFilter = CalCommon::EIncludeEvents; |
|
1029 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); // 1 Feb 05 |
|
1030 aData.iEndDate = TDateTime(2005, EFebruary, 27, 0, 0, 0, 0); // 28 Feb 05 |
|
1031 |
|
1032 // expected times: |
|
1033 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 1, 0, 0, 0, 0))); // 2 Feb 05 - Wed (Event) |
|
1034 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 8, 0, 0, 0, 0))); // 9 Feb 05 - Wed (Event) |
|
1035 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 15, 0, 0, 0, 0))); // 16 Feb 05 - Wed (Event) |
|
1036 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 22, 0, 0, 0, 0))); // 23 Feb 05 - Wed (Event) |
|
1037 } |
|
1038 |
|
1039 |
|
1040 void CTestData::CreateFilterTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1041 { |
|
1042 aData.iDescription.Copy(_L("Filter out Todos (Tue) and Reminders (Thu). Get all instances between 1 Feb 05 and 28 Feb 05.")); |
|
1043 |
|
1044 CreateFilterTestDataL(aEntryView); |
|
1045 aData.iFilter = CalCommon::EIncludeCompletedTodos|CalCommon::EIncludeIncompletedTodos|CalCommon::EIncludeReminder; |
|
1046 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); // 1 Feb 05 |
|
1047 aData.iEndDate = TDateTime(2005, EFebruary, 27, 0, 0, 0, 0); // 28 Feb 05 |
|
1048 |
|
1049 // expected times: |
|
1050 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 0, 1, 0, 0, 0))); // 1 Feb 05 - Tue (Todo) |
|
1051 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 2, 0, 0, 0, 0))); // 3 Feb 05 - Thu (Reminder) |
|
1052 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 7, 1, 0, 0, 0))); // 8 Feb 05 - Tue (Todo) |
|
1053 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 9, 0, 0, 0, 0))); // 10 Feb 05 - Thu (Reminder) |
|
1054 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 14, 1, 0, 0, 0))); // 15 Feb 05 - Tue (Todo) |
|
1055 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 16, 0, 0, 0, 0))); // 17 Feb 05 - Thu (Reminder) |
|
1056 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 21, 1, 0, 0, 0))); // 22 Feb 05 - Tue (Todo) |
|
1057 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0))); // 24 Feb 05 - Thu (Reminder) |
|
1058 } |
|
1059 |
|
1060 |
|
1061 void CTestData::CreateFilterTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1062 { |
|
1063 aData.iDescription.Copy(_L("Filter test for weekly events: No events included.")); |
|
1064 |
|
1065 CreateFilterTestDataL(aEntryView); |
|
1066 aData.iFilter = 0; // empty filter! |
|
1067 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); // 1 Feb 05 |
|
1068 aData.iEndDate = TDateTime(2005, EFebruary, 27, 0, 0, 0, 0); // 28 Feb 05 |
|
1069 |
|
1070 // expected times: |
|
1071 // NONE |
|
1072 } |
|
1073 |
|
1074 |
|
1075 CCalEntry* CTestData::CreateTodoLC(const TDesC8& aGuid, const TTime& aTimeLocal, const TTime& aCompletedTimeLocal) |
|
1076 { |
|
1077 CCalEntry* entry = CreateEntryLC(CCalEntry::ETodo, aGuid, aTimeLocal, aTimeLocal); |
|
1078 |
|
1079 TCalTime calTime; |
|
1080 if (aCompletedTimeLocal == Time::NullTTime()) |
|
1081 { |
|
1082 entry->SetCompletedL(EFalse, calTime); |
|
1083 } |
|
1084 else |
|
1085 { |
|
1086 calTime.SetTimeLocalL(aCompletedTimeLocal); |
|
1087 entry->SetCompletedL(ETrue, calTime); |
|
1088 } |
|
1089 |
|
1090 return entry; |
|
1091 } |
|
1092 |
|
1093 |
|
1094 void CTestData::CreateFilterTest5L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1095 { |
|
1096 aData.iDescription.Copy(_L("Filter test for incompleted todos only.")); |
|
1097 |
|
1098 // create one completed todo and one incomplete todo |
|
1099 TTime todoTime1(TDateTime(2005, EJanuary, 25, 0, 0, 0, 0)); |
|
1100 CCalEntry* entry = CreateTodoLC(KGUID1(), todoTime1, todoTime1); // 26 Jan - completed entry |
|
1101 |
|
1102 TTime todoTime2(TDateTime(2005, EJanuary, 15, 0, 0, 0, 0)); |
|
1103 CCalEntry* entry2 = CreateTodoLC(KGUID1(), todoTime2, Time::NullTTime()); // 16 Jan - incomplete entry |
|
1104 |
|
1105 RPointerArray<CCalEntry> array; |
|
1106 CleanupClosePushL(array); |
|
1107 array.AppendL(entry); |
|
1108 array.AppendL(entry2); |
|
1109 TInt success(0); |
|
1110 aEntryView->StoreL(array, success); |
|
1111 CleanupStack::PopAndDestroy(&array); |
|
1112 |
|
1113 CleanupStack::PopAndDestroy(entry2); |
|
1114 CleanupStack::PopAndDestroy(entry); |
|
1115 |
|
1116 aData.iFilter = CalCommon::EIncludeIncompletedTodos; |
|
1117 |
|
1118 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 05 |
|
1119 aData.iEndDate = TDateTime(2005, EJanuary, 30, 0, 0, 0, 0); // 31 Jan 05 |
|
1120 |
|
1121 // expected times: |
|
1122 aData.iTimes.AppendL(TTime(TDateTime(2005, EJanuary, 15, 0, 0, 0, 0))); // 16 Jan 05 |
|
1123 } |
|
1124 |
|
1125 |
|
1126 void CTestData::CreateFilterTest6L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1127 { |
|
1128 aData.iDescription.Copy(_L("Filter test for completed todos only.")); |
|
1129 |
|
1130 // create one completed todo and one incomplete todo |
|
1131 TTime todoTime1(TDateTime(2005, EJanuary, 25, 0, 0, 0, 0)); |
|
1132 CCalEntry* entry = CreateTodoLC(KGUID1(), todoTime1, todoTime1); // 26 Jan - completed entry |
|
1133 |
|
1134 TTime todoTime2(TDateTime(2005, EJanuary, 15, 0, 0, 0, 0)); |
|
1135 CCalEntry* entry2 = CreateTodoLC(KGUID2(), todoTime2, Time::NullTTime()); // 16 Jan - incomplete entry |
|
1136 |
|
1137 RPointerArray<CCalEntry> array; |
|
1138 CleanupClosePushL(array); |
|
1139 array.AppendL(entry); |
|
1140 array.AppendL(entry2); |
|
1141 TInt success(0); |
|
1142 aEntryView->StoreL(array, success); |
|
1143 CleanupStack::PopAndDestroy(&array); |
|
1144 |
|
1145 CleanupStack::PopAndDestroy(entry2); |
|
1146 CleanupStack::PopAndDestroy(entry); |
|
1147 |
|
1148 aData.iFilter = CalCommon::EIncludeCompletedTodos; |
|
1149 |
|
1150 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 05 |
|
1151 aData.iEndDate = TDateTime(2005, EJanuary, 30, 0, 0, 0, 0); // 31 Jan 05 |
|
1152 |
|
1153 // expected times: |
|
1154 aData.iTimes.AppendL(TTime(TDateTime(2005, EJanuary, 25, 0, 0, 0, 0))); // 26 Jan 05 |
|
1155 } |
|
1156 |
|
1157 |
|
1158 void CTestData::CreateFilterTest7L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1159 { |
|
1160 aData.iDescription.Copy(_L("Weekly alarmed entry every Monday, non-alarmed entry every Tuesday. Get alarmed instances between 1 Feb 05 and 28 Feb 05.")); |
|
1161 |
|
1162 TTime startTime(TDateTime(2005, EFebruary, 0, 0, 0, 0, 0)); // 1 Feb 05 |
|
1163 TCalTime calStartTime; |
|
1164 calStartTime.SetTimeLocalL(startTime); |
|
1165 |
|
1166 // create alarmed entry |
|
1167 CCalEntry* entry = CreateEntryLC(CCalEntry::EAppt, KGUID1(), startTime, startTime + TTimeIntervalHours(1)); |
|
1168 |
|
1169 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
1170 CleanupStack::PushL(alarm); |
|
1171 alarm->SetTimeOffset(30); |
|
1172 entry->SetAlarmL(alarm); |
|
1173 CleanupStack::PopAndDestroy(alarm); |
|
1174 |
|
1175 // make this entry repeat every monday |
|
1176 TCalRRule rpt(TCalRRule::EWeekly); |
|
1177 rpt.SetInterval(1); |
|
1178 rpt.SetDtStart(calStartTime); |
|
1179 RArray<TDay> dayArray; |
|
1180 CleanupClosePushL(dayArray); |
|
1181 dayArray.AppendL(EMonday); |
|
1182 rpt.SetByDay(dayArray); |
|
1183 CleanupStack::PopAndDestroy(&dayArray); |
|
1184 |
|
1185 entry->SetRRuleL(rpt); |
|
1186 |
|
1187 // create non-alarmed entry |
|
1188 CCalEntry* entry2 = CreateEntryLC(CCalEntry::EAppt, KGUID2(), startTime, startTime + TTimeIntervalHours(1)); |
|
1189 |
|
1190 // make this entry repeat every tuesday |
|
1191 TCalRRule rpt2(TCalRRule::EWeekly); |
|
1192 rpt2.SetInterval(1); |
|
1193 rpt2.SetDtStart(calStartTime); |
|
1194 dayArray.AppendL(ETuesday); |
|
1195 rpt2.SetByDay(dayArray); |
|
1196 dayArray.Reset(); |
|
1197 |
|
1198 entry2->SetRRuleL(rpt2); |
|
1199 |
|
1200 RPointerArray<CCalEntry> array; |
|
1201 CleanupClosePushL(array); |
|
1202 array.AppendL(entry); |
|
1203 array.AppendL(entry2); |
|
1204 TInt success(0); |
|
1205 aEntryView->StoreL(array, success); |
|
1206 CleanupStack::PopAndDestroy(&array); |
|
1207 |
|
1208 CleanupStack::PopAndDestroy(entry2); |
|
1209 CleanupStack::PopAndDestroy(entry); |
|
1210 |
|
1211 aData.iFilter = CalCommon::EIncludeAlarmedOnly|CalCommon::EIncludeAppts; |
|
1212 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); // 1 Feb 05 |
|
1213 aData.iEndDate = TDateTime(2005, EFebruary, 27, 0, 0, 0, 0); // 28 Feb 05 |
|
1214 |
|
1215 aData.iTimes.Reset(); |
|
1216 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 6, 0, 0, 0, 0))); // 7 Feb 05 - Mon (alarmed) |
|
1217 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 13, 0, 0, 0, 0))); // 14 Feb 05 - Mon (alarmed) |
|
1218 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 20, 0, 0, 0, 0))); // 21 Feb 05 - Mon (alarmed) |
|
1219 aData.iTimes.AppendL(TTime(TDateTime(2005, EFebruary, 27, 0, 0, 0, 0))); // 28 Feb 05 - Mon (alarmed) |
|
1220 } |
|
1221 |
|
1222 |
|
1223 void CTestData::CreateDeleteTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView, CCalInstanceView* aInstanceView) |
|
1224 { |
|
1225 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05, with 2 Mar only deleted. Get instances from 24 Feb to 8 Mar.")); |
|
1226 |
|
1227 // set up rule: Every 3 days from 24 Feb 05 |
|
1228 TCalRRule rpt(TCalRRule::EDaily); |
|
1229 rpt.SetInterval(3); |
|
1230 TCalTime startTime; |
|
1231 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
1232 rpt.SetDtStart(startTime); // 24 Feb |
|
1233 TCalTime endTime; |
|
1234 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 14, 0, 0, 0)); |
|
1235 rpt.SetUntil(endTime); // 2008 |
|
1236 |
|
1237 AddRuleL(rpt, aEntryView, KGUID1()); |
|
1238 |
|
1239 // get instance on 2 Mar |
|
1240 RPointerArray<CCalInstance> instanceList; |
|
1241 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
1242 TCalTime instDate; |
|
1243 instDate.SetTimeLocalL(TDateTime(2005, EMarch, 1, 0, 0, 0, 0)); // 2 Mar |
|
1244 CalCommon::TCalTimeRange timeRange(instDate, instDate); |
|
1245 aInstanceView->FindInstanceL(instanceList, filter, timeRange); |
|
1246 ASSERT(instanceList.Count() == 1); // check instance has been found |
|
1247 |
|
1248 // delete 2 Mar instance only |
|
1249 CCalInstance* instToDelete = instanceList[0]; |
|
1250 aInstanceView->DeleteL(instToDelete, CalCommon::EThisOnly); |
|
1251 instanceList.Remove(0); // remove first item |
|
1252 instanceList.ResetAndDestroy(); |
|
1253 |
|
1254 aData.iStartDate = TDateTime(2005, EFebruary, 23, 0, 0, 0, 0); // 24 Feb |
|
1255 aData.iEndDate = TDateTime(2005, EMarch, 7, 0, 0, 0, 0); // 8 Mar |
|
1256 |
|
1257 // expected times: |
|
1258 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); // 24 Feb |
|
1259 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 26, 0, 0, 0, 0)); // 27 Feb |
|
1260 aData.iTimes.AppendL(TDateTime(2005, EMarch, 4, 0, 0, 0, 0)); // 5 Mar |
|
1261 aData.iTimes.AppendL(TDateTime(2005, EMarch, 7, 0, 0, 0, 0)); // 8 Mar |
|
1262 } |
|
1263 |
|
1264 |
|
1265 void CTestData::CreateDeleteTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView, CCalInstanceView* aInstanceView) |
|
1266 { |
|
1267 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05, then delete all up to 2 Mar. Get instances from 24 Feb to 8 Mar.")); |
|
1268 |
|
1269 // set up rule: Every 3 days from 24 Feb 05 |
|
1270 TCalRRule rpt(TCalRRule::EDaily); |
|
1271 rpt.SetInterval(3); |
|
1272 TCalTime startTime; |
|
1273 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
1274 rpt.SetDtStart(startTime); // 24 Feb |
|
1275 TCalTime endTime; |
|
1276 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 14, 0, 0, 0)); |
|
1277 rpt.SetUntil(endTime); // 2008 |
|
1278 |
|
1279 AddRuleL(rpt, aEntryView, KGUID1()); |
|
1280 |
|
1281 // get instance on 2 Mar |
|
1282 RPointerArray<CCalInstance> instanceList; |
|
1283 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
1284 TCalTime instDate; |
|
1285 instDate.SetTimeLocalL(TDateTime(2005, EMarch, 1, 0, 0, 0, 0)); // 2 Mar |
|
1286 CalCommon::TCalTimeRange timeRange(instDate, instDate); |
|
1287 aInstanceView->FindInstanceL(instanceList, filter, timeRange); |
|
1288 ASSERT(instanceList.Count() == 1); // check instance has been found |
|
1289 |
|
1290 // delete 2 Mar instance and all instances before |
|
1291 CCalInstance* instToDelete = instanceList[0]; |
|
1292 aInstanceView->DeleteL(instToDelete, CalCommon::EThisAndPrior); |
|
1293 instanceList.Remove(0); // remove first item |
|
1294 instanceList.ResetAndDestroy(); |
|
1295 |
|
1296 aData.iStartDate = TDateTime(2005, EFebruary, 23, 0, 0, 0, 0); // 24 Feb |
|
1297 aData.iEndDate = TDateTime(2005, EMarch, 7, 0, 0, 0, 0); // 8 Mar |
|
1298 |
|
1299 // expected times: |
|
1300 aData.iTimes.AppendL(TDateTime(2005, EMarch, 4, 0, 0, 0, 0)); // 5 Mar |
|
1301 aData.iTimes.AppendL(TDateTime(2005, EMarch, 7, 0, 0, 0, 0)); // 8 Mar |
|
1302 } |
|
1303 |
|
1304 |
|
1305 void CTestData::CreateDeleteTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView, CCalInstanceView* aInstanceView) |
|
1306 { |
|
1307 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05, then delete all after 2 Mar. Get instances from 24 Feb to 8 Mar.")); |
|
1308 |
|
1309 // set up rule: Every 3 days from 24 Feb 05 |
|
1310 TCalRRule rpt(TCalRRule::EDaily); |
|
1311 rpt.SetInterval(3); |
|
1312 TCalTime startTime; |
|
1313 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
1314 rpt.SetDtStart(startTime); // 24 Feb |
|
1315 TCalTime endTime; |
|
1316 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 14, 0, 0, 0)); |
|
1317 rpt.SetUntil(endTime); // 2008 |
|
1318 |
|
1319 AddRuleL(rpt, aEntryView, KGUID1()); |
|
1320 |
|
1321 // get instance on 2 Mar |
|
1322 RPointerArray<CCalInstance> instanceList; |
|
1323 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
1324 TCalTime instDate; |
|
1325 instDate.SetTimeLocalL(TDateTime(2005, EMarch, 1, 0, 0, 0, 0)); // 2 Mar |
|
1326 CalCommon::TCalTimeRange timeRange(instDate, instDate); |
|
1327 aInstanceView->FindInstanceL(instanceList, filter, timeRange); |
|
1328 ASSERT(instanceList.Count() == 1); // check instance has been found |
|
1329 |
|
1330 // delete 2 Mar instance and all instances after |
|
1331 CCalInstance* instToDelete = instanceList[0]; |
|
1332 aInstanceView->DeleteL(instToDelete, CalCommon::EThisAndFuture); |
|
1333 instanceList.Remove(0); // remove first item |
|
1334 instanceList.ResetAndDestroy(); |
|
1335 |
|
1336 aData.iStartDate = TDateTime(2005, EFebruary, 23, 0, 0, 0, 0); // 24 Feb |
|
1337 aData.iEndDate = TDateTime(2005, EMarch, 7, 0, 0, 0, 0); // 8 Mar |
|
1338 |
|
1339 // expected times: |
|
1340 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); // 24 Feb |
|
1341 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 26, 0, 0, 0, 0)); // 27 Feb |
|
1342 } |
|
1343 |
|
1344 |
|
1345 void CTestData::CreateDeleteTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView, CCalInstanceView* aInstanceView) |
|
1346 { |
|
1347 aData.iDescription.Copy(_L("Every 3 days from 24 Feb 05, then delete all instances. Get instances from 1 Jan 05 to 1 Jan 06.")); |
|
1348 |
|
1349 // set up rule: Every 3 days from 24 Feb 05 |
|
1350 TCalRRule rpt(TCalRRule::EDaily); |
|
1351 rpt.SetInterval(3); |
|
1352 TCalTime startTime; |
|
1353 startTime.SetTimeLocalL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0)); |
|
1354 rpt.SetDtStart(startTime); // 24 Feb |
|
1355 TCalTime endTime; |
|
1356 endTime.SetTimeLocalL(TDateTime(2008, EMarch, 30, 14, 0, 0, 0)); |
|
1357 rpt.SetUntil(endTime); // 2008 |
|
1358 |
|
1359 AddRuleL(rpt, aEntryView, KGUID1()); |
|
1360 |
|
1361 // get instance on 2 Mar |
|
1362 RPointerArray<CCalInstance> instanceList; |
|
1363 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; |
|
1364 TCalTime instDate; |
|
1365 instDate.SetTimeLocalL(TDateTime(2005, EMarch, 1, 0, 0, 0, 0)); // 2 Mar |
|
1366 CalCommon::TCalTimeRange timeRange(instDate, instDate); |
|
1367 aInstanceView->FindInstanceL(instanceList, filter, timeRange); |
|
1368 ASSERT(instanceList.Count() == 1); // check instance has been found |
|
1369 |
|
1370 // delete all instances |
|
1371 CCalInstance* instToDelete = instanceList[0]; |
|
1372 aInstanceView->DeleteL(instToDelete, CalCommon::EThisAndAll); |
|
1373 instanceList.Remove(0); // remove first item |
|
1374 instanceList.ResetAndDestroy(); |
|
1375 |
|
1376 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 05 |
|
1377 aData.iEndDate = TDateTime(2006, EJanuary, 0, 0, 0, 0, 0); // 1 Jan 06 |
|
1378 |
|
1379 // expected times: |
|
1380 // NONE |
|
1381 } |
|
1382 |
|
1383 |
|
1384 // creates a weekly entry repeating on a certain weekday with the given summary string and UID |
|
1385 void CTestData::CreateWeeklyEntryWithThisStringL(TDay aDay, const TDesC& aString, CCalEntryView* aEntryView, const TDesC8& aGuid) |
|
1386 { |
|
1387 TCalRRule rpt1(TCalRRule::EWeekly); |
|
1388 rpt1.SetInterval(1); |
|
1389 RArray<TDay> days; |
|
1390 CleanupClosePushL(days); |
|
1391 days.AppendL(aDay); |
|
1392 rpt1.SetByDay(days); |
|
1393 CleanupStack::PopAndDestroy(&days); |
|
1394 TCalTime startTime; |
|
1395 startTime.SetTimeLocalL(TDateTime(2005, EJanuary, 0, 0, 0, 0, 0)); // 1 Jan 05 |
|
1396 rpt1.SetDtStart(startTime); |
|
1397 TCalTime endTime; |
|
1398 endTime.SetTimeLocalL(TDateTime(2008, EJanuary, 0, 0, 0, 0, 0)); // 1 Jan 08 |
|
1399 rpt1.SetUntil(endTime); |
|
1400 |
|
1401 TTime entryStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // on 1 Jan 05 |
|
1402 CCalEntry* entry = CreateEntryLC(CCalEntry::EAppt, aGuid, entryStartDate, entryStartDate + TTimeIntervalHours(1)); |
|
1403 |
|
1404 entry->SetRRuleL(rpt1); // doesn't take ownership |
|
1405 entry->SetSummaryL(aString); |
|
1406 |
|
1407 RPointerArray<CCalEntry> entryList; |
|
1408 CleanupClosePushL(entryList); |
|
1409 entryList.AppendL(entry); |
|
1410 TInt success(0); |
|
1411 aEntryView->StoreL(entryList, success); // takes ownership |
|
1412 CleanupStack::PopAndDestroy(&entryList); |
|
1413 |
|
1414 CleanupStack::PopAndDestroy(entry); |
|
1415 } |
|
1416 |
|
1417 |
|
1418 void CTestData::CreateStringTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1419 { |
|
1420 aData.iDescription.Copy(_L("Every Wed, summary 'This is search text'. Every Thu, 'Do not find this téxt'. Get instances in Feb 05 matching exactly 'text'.")); |
|
1421 |
|
1422 _LIT(KSummary1, "This is search text"); |
|
1423 _LIT(KSummary2, "Do not find this téxt"); |
|
1424 _LIT(KSearchString1, "text"); |
|
1425 // weekly entry every Wed from 1 Jan 05, summary = "This is search text" |
|
1426 CreateWeeklyEntryWithThisStringL(EWednesday, KSummary1(), aEntryView, KGUID1()); |
|
1427 CreateWeeklyEntryWithThisStringL(EThursday, KSummary2(), aEntryView, KGUID2()); |
|
1428 |
|
1429 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); // 1 Feb 05 |
|
1430 aData.iEndDate = TDateTime(2005, EFebruary, 27, 0, 0, 0, 0); // 28 Feb 05 |
|
1431 aData.iSearchString = KSearchString1().AllocL(); |
|
1432 aData.iSearchBehaviour = CalCommon::EExactTextSearch; |
|
1433 |
|
1434 // expected times: |
|
1435 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 1, 0, 0, 0, 0)); // 2 Feb |
|
1436 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 8, 0, 0, 0, 0)); // 9 Feb |
|
1437 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 15, 0, 0, 0, 0));// 16 Feb |
|
1438 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 22, 0, 0, 0, 0));// 23 Feb |
|
1439 } |
|
1440 |
|
1441 |
|
1442 void CTestData::CreateStringTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1443 { |
|
1444 aData.iDescription.Copy(_L("Every Wed, summary 'This is search text'. Every Thu, 'Also find this téxt'. Get instances in Feb 05 matching 'text'.")); |
|
1445 |
|
1446 _LIT(KSummary1, "This is search text"); |
|
1447 _LIT(KSummary2, "Also find this téxt"); |
|
1448 _LIT(KSearchString1, "text"); |
|
1449 // weekly entry every Wed from 1 Jan 05, summary = "This is search text" |
|
1450 CreateWeeklyEntryWithThisStringL(EWednesday, KSummary1(), aEntryView, KGUID1()); |
|
1451 CreateWeeklyEntryWithThisStringL(EThursday, KSummary2(), aEntryView, KGUID2()); |
|
1452 |
|
1453 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); // 1 Feb 05 |
|
1454 aData.iEndDate = TDateTime(2005, EFebruary, 27, 0, 0, 0, 0); // 28 Feb 05 |
|
1455 aData.iSearchString = KSearchString1().AllocL(); |
|
1456 aData.iSearchBehaviour = CalCommon::EFoldedTextSearch; |
|
1457 |
|
1458 // expected times: |
|
1459 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 1, 0, 0, 0, 0)); // 2 Feb |
|
1460 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 2, 0, 0, 0, 0)); // 3 Feb |
|
1461 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 8, 0, 0, 0, 0)); // 9 Feb |
|
1462 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 9, 0, 0, 0, 0)); // 10 Feb |
|
1463 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 15, 0, 0, 0, 0));// 16 Feb |
|
1464 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 16, 0, 0, 0, 0));// 17 Feb |
|
1465 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 22, 0, 0, 0, 0));// 23 Feb |
|
1466 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 23, 0, 0, 0, 0));// 24 Feb |
|
1467 } |
|
1468 |
|
1469 |
|
1470 void CTestData::CreateStringTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1471 { |
|
1472 aData.iDescription.Copy(_L("Test entries crossing start/end of search range. Search for 'text', find entry with summary 'This is search text' but not 'Do not find this téxt'.")); |
|
1473 |
|
1474 _LIT(KSummary1, "This is search text"); |
|
1475 _LIT(KSummary2, "Do not find this téxt"); |
|
1476 _LIT(KSearchString1, "text"); |
|
1477 |
|
1478 // weekly entry every Wed from 1 Jan 05, summary = "This is search text" |
|
1479 TTime entryStartDate1 = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 00:00 on 1 Jan 05 until 00:00 on 4 Jan 05 |
|
1480 CCalEntry* entry1 = CreateEntryLC(CCalEntry::EAppt, KGUID1(), entryStartDate1, entryStartDate1 + TTimeIntervalDays(3)); |
|
1481 entry1->SetSummaryL(KSummary1()); |
|
1482 |
|
1483 TTime entryStartDate2 = TDateTime(2005, EJanuary, 10, 0, 0, 0, 0); // 00:00 on 11 Jan 05 until 00:00 on 14 Jan 05 |
|
1484 CCalEntry* entry2 = CreateEntryLC(CCalEntry::EAppt, KGUID2(), entryStartDate2, entryStartDate2 + TTimeIntervalDays(3)); |
|
1485 entry2->SetSummaryL(KSummary2()); |
|
1486 |
|
1487 RPointerArray<CCalEntry> entries; |
|
1488 CleanupClosePushL(entries); |
|
1489 entries.AppendL(entry1); |
|
1490 entries.AppendL(entry2); |
|
1491 TInt success(0); |
|
1492 aEntryView->StoreL(entries, success); |
|
1493 CleanupStack::PopAndDestroy(&entries); |
|
1494 CleanupStack::PopAndDestroy(entry2); |
|
1495 CleanupStack::PopAndDestroy(entry1); |
|
1496 |
|
1497 aData.iStartDate = TDateTime(2005, EJanuary, 1, 0, 0, 0, 0); // 00:00 on 2 Jan 05 |
|
1498 aData.iEndDate = TDateTime(2005, EJanuary, 11, 0, 0, 0, 0); // 00:00 on 12 Jan 05 |
|
1499 aData.iSearchString = KSearchString1().AllocL(); |
|
1500 aData.iSearchBehaviour = CalCommon::EExactTextSearch; |
|
1501 |
|
1502 // expected times: |
|
1503 aData.iTimes.AppendL(entryStartDate1); // 1st entry, 1 Jan 05 |
|
1504 } |
|
1505 |
|
1506 |
|
1507 void CTestData::CreateStringTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1508 { |
|
1509 aData.iDescription.Copy(_L("Test entries crossing start/end of search range. Search for 'text' with filter, find entry with summary 'This is search text' and 'Also find this téxt'.")); |
|
1510 |
|
1511 _LIT(KSummary1, "This is search text"); |
|
1512 _LIT(KSummary2, "Also find this téxt"); |
|
1513 _LIT(KSearchString1, "text"); |
|
1514 |
|
1515 // weekly entry every Wed from 1 Jan 05, summary = "This is search text" |
|
1516 TTime entryStartDate1 = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); // 00:00 on 1 Jan 05 until 00:00 on 4 Jan 05 |
|
1517 CCalEntry* entry1 = CreateEntryLC(CCalEntry::EAppt, KGUID1(), entryStartDate1, entryStartDate1 + TTimeIntervalDays(3)); |
|
1518 entry1->SetSummaryL(KSummary1()); |
|
1519 |
|
1520 TTime entryStartDate2 = TDateTime(2005, EJanuary, 10, 0, 0, 0, 0); // 00:00 on 11 Jan 05 until 00:00 on 14 Jan 05 |
|
1521 CCalEntry* entry2 = CreateEntryLC(CCalEntry::EAppt, KGUID2(), entryStartDate2, entryStartDate2 + TTimeIntervalDays(3)); |
|
1522 entry2->SetSummaryL(KSummary2()); |
|
1523 |
|
1524 RPointerArray<CCalEntry> entries; |
|
1525 CleanupClosePushL(entries); |
|
1526 entries.AppendL(entry1); |
|
1527 entries.AppendL(entry2); |
|
1528 TInt success(0); |
|
1529 aEntryView->StoreL(entries, success); |
|
1530 CleanupStack::PopAndDestroy(&entries); |
|
1531 CleanupStack::PopAndDestroy(entry2); |
|
1532 CleanupStack::PopAndDestroy(entry1); |
|
1533 |
|
1534 aData.iStartDate = TDateTime(2005, EJanuary, 1, 0, 0, 0, 0); // 00:00 on 2 Jan 05 |
|
1535 aData.iEndDate = TDateTime(2005, EJanuary, 11, 0, 0, 0, 0); // 00:00 on 12 Jan 05 |
|
1536 aData.iSearchString = KSearchString1().AllocL(); |
|
1537 aData.iSearchBehaviour = CalCommon::EFoldedTextSearch; |
|
1538 |
|
1539 // expected times: |
|
1540 aData.iTimes.AppendL(entryStartDate1); // 1st entry, 1 Jan 05 |
|
1541 aData.iTimes.AppendL(entryStartDate2); // 2nd entry, 11 Jan 05 |
|
1542 } |
|
1543 |
|
1544 |
|
1545 void CTestData::SetupStartEndTimesTestL(CCalEntryView* aEntryView) |
|
1546 { |
|
1547 // create single todo entry which crosses start of search time range |
|
1548 TTime startTime1(TDateTime(2005, EJanuary, 25, 0, 0, 0, 0)); |
|
1549 TTime endTime1(TDateTime(2005, EFebruary, 4, 0, 0, 0, 0)); |
|
1550 CCalEntry* entry1 = CreateEntryLC(CCalEntry::ETodo, KGUID1(), startTime1, endTime1); |
|
1551 // |
|
1552 // create single appt entry which crosses start of search time range |
|
1553 TTime startTime2(TDateTime(2005, EJanuary, 26, 1, 0, 0, 0)); |
|
1554 TTime endTime2(TDateTime(2005, EFebruary, 5, 1, 0, 0, 0)); |
|
1555 CCalEntry* entry2 = CreateEntryLC(CCalEntry::EAppt, KGUID2(), startTime2, endTime2); |
|
1556 // |
|
1557 // create single todo entry which crosses end of search time range |
|
1558 TTime startTime3(TDateTime(2005, EFebruary, 7, 2, 0, 0, 0)); |
|
1559 TTime endTime3(TDateTime(2005, EFebruary, 17, 2, 0, 0, 0)); |
|
1560 CCalEntry* entry3 = CreateEntryLC(CCalEntry::ETodo, KGUID3(), startTime3, endTime3); |
|
1561 // |
|
1562 // create single appt entry which crosses end of search time range |
|
1563 TTime startTime4(TDateTime(2005, EFebruary, 6, 3, 0, 0, 0)); |
|
1564 TTime endTime4(TDateTime(2005, EFebruary, 16, 3, 0, 0, 0)); |
|
1565 CCalEntry* entry4 = CreateEntryLC(CCalEntry::EAppt, KGUID4(), startTime4, endTime4); |
|
1566 // |
|
1567 |
|
1568 RPointerArray<CCalEntry> array; |
|
1569 CleanupClosePushL(array); |
|
1570 array.AppendL(entry1); |
|
1571 array.AppendL(entry2); |
|
1572 array.AppendL(entry3); |
|
1573 array.AppendL(entry4); |
|
1574 TInt success(0); |
|
1575 aEntryView->StoreL(array, success); |
|
1576 CleanupStack::PopAndDestroy(&array); |
|
1577 |
|
1578 CleanupStack::PopAndDestroy(entry4); |
|
1579 CleanupStack::PopAndDestroy(entry3); |
|
1580 CleanupStack::PopAndDestroy(entry2); |
|
1581 CleanupStack::PopAndDestroy(entry1); |
|
1582 } |
|
1583 |
|
1584 |
|
1585 void CTestData::CreateStartEndTimesTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1586 { |
|
1587 aData.iDescription.Copy(_L("Filter test for appt/todo with only start/end date in time range.")); |
|
1588 |
|
1589 // search time range is 1 - 11 February |
|
1590 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); |
|
1591 aData.iEndDate = TDateTime(2005, EFebruary, 10, 0, 0, 0, 0); |
|
1592 |
|
1593 SetupStartEndTimesTestL(aEntryView); |
|
1594 |
|
1595 // expected times: |
|
1596 aData.iTimes.AppendL(TDateTime(2005, EJanuary, 26, 1, 0, 0, 0)); |
|
1597 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 4, 0, 0, 0, 0)); |
|
1598 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 6, 3, 0, 0, 0)); |
|
1599 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 17, 2, 0, 0, 0)); |
|
1600 } |
|
1601 |
|
1602 |
|
1603 void CTestData::CreateStartEndTimesTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1604 { |
|
1605 aData.iDescription.Copy(_L("Filter test for appt with only end date in time range.")); |
|
1606 |
|
1607 // create single appt entry which crosses start of search time range |
|
1608 TTime startTime2(TDateTime(2005, EJanuary, 26, 1, 0, 0, 0)); |
|
1609 TTime endTime2(TDateTime(2005, EFebruary, 5, 1, 0, 0, 0)); |
|
1610 CCalEntry* entry2 = CreateEntryLC(CCalEntry::EAppt, KGUID2(), startTime2, endTime2); |
|
1611 |
|
1612 RPointerArray<CCalEntry> array; |
|
1613 CleanupClosePushL(array); |
|
1614 array.AppendL(entry2); |
|
1615 TInt success(0); |
|
1616 aEntryView->StoreL(array, success); |
|
1617 CleanupStack::PopAndDestroy(&array); |
|
1618 |
|
1619 CleanupStack::PopAndDestroy(entry2); |
|
1620 |
|
1621 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); |
|
1622 aData.iEndDate = TDateTime(2005, EFebruary, 10, 0, 0, 0, 0); |
|
1623 |
|
1624 // expected times: |
|
1625 aData.iTimes.AppendL(TDateTime(2005, EJanuary, 26, 1, 0, 0, 0)); |
|
1626 } |
|
1627 |
|
1628 |
|
1629 void CTestData::CreateStartEndTimesTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1630 { |
|
1631 aData.iDescription.Copy(_L("Filter test for appt/todo with only start date in time range.")); |
|
1632 |
|
1633 // search time range is 1 - 11 February |
|
1634 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); |
|
1635 aData.iEndDate = TDateTime(2005, EFebruary, 10, 0, 0, 0, 0); |
|
1636 |
|
1637 aData.iFilter = CalCommon::EIncludeAll | CalCommon::EInstanceStartTimeWithinRange; |
|
1638 SetupStartEndTimesTestL(aEntryView); |
|
1639 |
|
1640 // expected times: |
|
1641 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 6, 3, 0, 0, 0)); |
|
1642 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 17, 2, 0, 0, 0)); |
|
1643 } |
|
1644 |
|
1645 |
|
1646 void CTestData::CreateStartEndTimesTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1647 { |
|
1648 aData.iDescription.Copy(_L("Filter test for appt/todo with only end date in time range.")); |
|
1649 |
|
1650 // search time range is 1 - 11 February |
|
1651 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); |
|
1652 aData.iEndDate = TDateTime(2005, EFebruary, 10, 0, 0, 0, 0); |
|
1653 |
|
1654 aData.iFilter = CalCommon::EIncludeAll | CalCommon::EInstanceEndTimeWithinRange; |
|
1655 SetupStartEndTimesTestL(aEntryView); |
|
1656 |
|
1657 // expected times: |
|
1658 aData.iTimes.AppendL(TDateTime(2005, EJanuary, 26, 1, 0, 0, 0)); |
|
1659 aData.iTimes.AppendL(TDateTime(2005, EFebruary, 4, 0, 0, 0, 0)); |
|
1660 } |
|
1661 |
|
1662 |
|
1663 void CTestData::CreateStartEndTimesTest5L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1664 { |
|
1665 aData.iDescription.Copy(_L("Filter test for appt/todo with both start and end date in time range.")); |
|
1666 |
|
1667 // search time range is 1 - 11 February |
|
1668 aData.iStartDate = TDateTime(2005, EFebruary, 0, 0, 0, 0, 0); |
|
1669 aData.iEndDate = TDateTime(2005, EFebruary, 10, 0, 0, 0, 0); |
|
1670 |
|
1671 aData.iFilter = CalCommon::EIncludeAll | CalCommon::EInstanceStartTimeWithinRange | CalCommon::EInstanceEndTimeWithinRange; |
|
1672 SetupStartEndTimesTestL(aEntryView); |
|
1673 |
|
1674 // expected times: |
|
1675 // NONE |
|
1676 } |
|
1677 |
|
1678 |
|
1679 void CTestData::CreateStartEndTimesTest6L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1680 { |
|
1681 aData.iDescription.Copy(_L("Filter test for appt span a long time range.")); |
|
1682 |
|
1683 // create single appt entry which crosses start of search time range |
|
1684 TTime startTime3(TDateTime(1980, EOctober, 21, 1, 0, 0, 0)); |
|
1685 TTime endTime3(TDateTime(1980, EOctober, 23, 1, 0, 0, 0)); |
|
1686 CCalEntry* entry3 = CreateEntryLC(CCalEntry::EAppt, KGUID2(), startTime3, endTime3); |
|
1687 |
|
1688 entry3->SetSummaryL(_L("1980 to 2100 appointment")); |
|
1689 entry3->SetDescriptionL(_L("1980 to 2100 appointment")); |
|
1690 |
|
1691 TCalTime ct3; |
|
1692 ct3.SetTimeLocalL(startTime3); |
|
1693 |
|
1694 TCalRRule rule(TCalRRule::EDaily); |
|
1695 rule.SetDtStart(ct3); |
|
1696 rule.SetCount(1000); |
|
1697 rule.SetInterval(7); |
|
1698 |
|
1699 entry3->SetRRuleL(rule); |
|
1700 |
|
1701 RPointerArray<CCalEntry> array; |
|
1702 CleanupClosePushL(array); |
|
1703 array.AppendL(entry3); |
|
1704 TInt success(0); |
|
1705 aEntryView->StoreL(array, success); |
|
1706 CleanupStack::PopAndDestroy(&array); |
|
1707 |
|
1708 CleanupStack::PopAndDestroy(entry3); |
|
1709 |
|
1710 aData.iStartDate = TDateTime(1980, EOctober, 22, 1, 0, 0, 0); |
|
1711 aData.iEndDate = TDateTime(2099, EDecember,30, 0, 0, 0, 0); |
|
1712 |
|
1713 aData.iSearchString = _L("1980 to 2100 appointment").AllocL(); |
|
1714 |
|
1715 TInt count = 0; |
|
1716 |
|
1717 // expected times - too many! |
|
1718 while (startTime3 < aData.iEndDate && count++ < 1000) |
|
1719 { |
|
1720 aData.iTimes.AppendL(startTime3); |
|
1721 startTime3 += TTimeIntervalDays(7); |
|
1722 } |
|
1723 |
|
1724 TTime* currentTime = new (ELeave) TTime; |
|
1725 currentTime->UniversalTime(); |
|
1726 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
1727 } |
|
1728 |
|
1729 void CTestData::CreateStartEndTimesTest7L(CTestDataStruct& aData, CCalEntryView* aView) |
|
1730 { |
|
1731 aData.iDescription.Copy(_L("Check appointment overlapping with second instance's end date.")); |
|
1732 |
|
1733 _LIT8(KGuid1, "Reminder-1"); |
|
1734 _LIT8(KGuid2, "Appt-1"); |
|
1735 |
|
1736 _LIT(KEntryStartTime, "20121119:013000.000000"); // 20-12-2012 01.30 |
|
1737 _LIT(KEntryEndTime, "20121119:090000.000000"); // 20-12-2012 09.00 |
|
1738 |
|
1739 _LIT(KTimeUntil, "20131119:013000.000000"); // 20-12-2013 01.30 |
|
1740 |
|
1741 _LIT(KSummary1, "Reminder summary"); |
|
1742 _LIT(KSummary2, "Appt summary"); |
|
1743 |
|
1744 //entry 1 |
|
1745 HBufC8* guid8 = HBufC8::NewL(KGuid1().Length()); |
|
1746 guid8->Des().Copy(KGuid1); |
|
1747 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EReminder, guid8, CCalEntry::EMethodAdd, (TUint)0); |
|
1748 entry->SetSummaryL(KSummary1); |
|
1749 |
|
1750 // entry2 |
|
1751 guid8 = HBufC8::NewL(KGuid2().Length()); |
|
1752 guid8->Des().Copy(KGuid2); |
|
1753 CCalEntry* entry2 = CCalEntry::NewL(CCalEntry::EAppt, guid8, CCalEntry::EMethodAdd, (TUint)0); |
|
1754 entry2->SetSummaryL(KSummary2); |
|
1755 |
|
1756 TTime time1(KEntryStartTime()); |
|
1757 TTime time2(KEntryEndTime()); |
|
1758 TCalTime st; |
|
1759 st.SetTimeUtcL(time1); |
|
1760 TCalTime end; |
|
1761 end.SetTimeUtcL(time2); |
|
1762 |
|
1763 entry->SetStartAndEndTimeL(st, end); |
|
1764 entry2->SetStartAndEndTimeL(st, end); |
|
1765 |
|
1766 TCalRRule rrule(TCalRRule::EYearly); |
|
1767 TCalTime calTime = entry->StartTimeL(); |
|
1768 rrule.SetDtStart(calTime); |
|
1769 rrule.SetInterval(1); |
|
1770 TTime until(KTimeUntil()); |
|
1771 TCalTime untilTime; |
|
1772 untilTime.SetTimeUtcL(until); |
|
1773 rrule.SetUntil(untilTime); |
|
1774 |
|
1775 entry->SetRRuleL(rrule); |
|
1776 entry2->SetRRuleL(rrule); |
|
1777 |
|
1778 TInt entriesStored(0); |
|
1779 RPointerArray<CCalEntry> entriesToStore; |
|
1780 CleanupResetAndDestroyPushL(entriesToStore); |
|
1781 |
|
1782 entriesToStore.AppendL(entry); |
|
1783 entriesToStore.AppendL(entry2); |
|
1784 aView->StoreL(entriesToStore, entriesStored); |
|
1785 |
|
1786 CleanupStack::PopAndDestroy(&entriesToStore); // entriesToStore.ResetAndDestroy() |
|
1787 |
|
1788 // Find |
|
1789 _LIT(KFindSt, "20131119:013100.000000"); // The event "overlaps" with this search range, hence must be caught. The reminder must not be caught (its end time = start time). |
|
1790 _LIT(KFindEnd, "20131119:093000.000000"); |
|
1791 |
|
1792 aData.iStartDate = TTime(KFindSt); |
|
1793 aData.iEndDate = TTime(KFindEnd); |
|
1794 |
|
1795 _LIT(KSearchText, "summary"); |
|
1796 aData.iSearchString = KSearchText().AllocL(); |
|
1797 |
|
1798 aData.iFilter = CalCommon::EIncludeAll; |
|
1799 aData.iSearchBehaviour = CalCommon::EFoldedTextSearch; |
|
1800 |
|
1801 aData.iTimes.AppendL(TDateTime(2013, EDecember, 19, 1, 30, 0, 0)); |
|
1802 } |
|
1803 |
|
1804 void CTestData::EmptyDatabase1L(CTestDataStruct& aData, CCalEntryView* /*aView*/) |
|
1805 { |
|
1806 aData.iDescription.Copy(_L("Search an empty database with filter range of MinTime and MaxTime.")); |
|
1807 |
|
1808 aData.iStartDate = TCalTime::MinTime(); |
|
1809 aData.iEndDate = TCalTime::MaxTime(); |
|
1810 |
|
1811 aData.iFilter = CalCommon::EIncludeAll; |
|
1812 } |
|
1813 |
|
1814 |
|
1815 void CTestData::EmptyDatabase2L(CTestDataStruct& aData, CCalEntryView* ) |
|
1816 { |
|
1817 aData.iDescription.Copy(_L("Search an empty database with filter range of a Month")); |
|
1818 |
|
1819 TTime startTime(TDateTime(2005, EMarch, 0, 0, 0, 0, 0)); // 1 Mar 05 |
|
1820 |
|
1821 aData.iStartDate = startTime; |
|
1822 aData.iEndDate = startTime + TTimeIntervalMonths(1); |
|
1823 |
|
1824 aData.iFilter = CalCommon::EIncludeAll; |
|
1825 } |
|
1826 |
|
1827 |
|
1828 void CTestData::CreateManyInstancesTestL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1829 { |
|
1830 aData.iDescription.Copy(_L("Test many instances")); |
|
1831 |
|
1832 TTime t1(TDateTime(2005, EJanuary, 0, 9, 0, 0, 0)); |
|
1833 TTime t2(TDateTime(2005, EJanuary, 0, 12, 0, 0, 0)); |
|
1834 TTime t3(TDateTime(2005, EJanuary, 0, 15, 0, 0, 0)); |
|
1835 |
|
1836 TCalTime ct1; |
|
1837 ct1.SetTimeLocalL(t1); |
|
1838 TCalTime ct2; |
|
1839 ct2.SetTimeLocalL(t2); |
|
1840 TCalTime ct3; |
|
1841 ct3.SetTimeLocalL(t3); |
|
1842 TCalRRule rule(TCalRRule::EDaily); |
|
1843 rule.SetDtStart(ct1); |
|
1844 rule.SetCount(273); |
|
1845 rule.SetInterval(1); |
|
1846 AddRuleL(rule, aEntryView, _L8("09:00"), CCalEntry::EAppt); |
|
1847 rule.SetDtStart(ct2); |
|
1848 AddRuleL(rule, aEntryView, _L8("12:00"), CCalEntry::EAppt); |
|
1849 rule.SetDtStart(ct3); |
|
1850 AddRuleL(rule, aEntryView, _L8("15:00"), CCalEntry::EAppt); |
|
1851 |
|
1852 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); |
|
1853 aData.iEndDate = TDateTime(2005, EOctober, 0, 0, 0, 0, 0); |
|
1854 |
|
1855 // expected times - too many! |
|
1856 while (t1 < aData.iEndDate) |
|
1857 { |
|
1858 aData.iTimes.AppendL(t1); // add an hour because todo instance occurs on end date (due date) |
|
1859 aData.iTimes.AppendL(t2); |
|
1860 aData.iTimes.AppendL(t3); |
|
1861 t1 += TTimeIntervalDays(1); |
|
1862 t2 += TTimeIntervalDays(1); |
|
1863 t3 += TTimeIntervalDays(1); |
|
1864 } |
|
1865 |
|
1866 TTime* currentTime = new (ELeave) TTime; |
|
1867 currentTime->UniversalTime(); |
|
1868 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
1869 } |
|
1870 |
|
1871 |
|
1872 void CTestData::CreateManyInstancesTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1873 { |
|
1874 aData.iDescription.Copy(_L("Test finding many instances with text search")); |
|
1875 |
|
1876 TTime t1(TDateTime(2005, EJanuary, 0, 9, 0, 0, 0)); |
|
1877 TTime t2(TDateTime(2005, EJanuary, 0, 12, 0, 0, 0)); |
|
1878 TTime t3(TDateTime(2005, EJanuary, 0, 15, 0, 0, 0)); |
|
1879 |
|
1880 TCalTime ct1; |
|
1881 ct1.SetTimeLocalL(t1); |
|
1882 TCalTime ct2; |
|
1883 ct2.SetTimeLocalL(t2); |
|
1884 TCalTime ct3; |
|
1885 ct3.SetTimeLocalL(t3); |
|
1886 TCalRRule rule(TCalRRule::EDaily); |
|
1887 rule.SetDtStart(ct1); |
|
1888 rule.SetCount(300); |
|
1889 rule.SetInterval(1); |
|
1890 AddRuleL(rule, aEntryView, _L8("09:00"), CCalEntry::EAppt); |
|
1891 rule.SetDtStart(ct2); |
|
1892 AddRuleL(rule, aEntryView, _L8("12:00"), CCalEntry::EAppt); |
|
1893 rule.SetDtStart(ct3); |
|
1894 |
|
1895 // add entry with text |
|
1896 CCalEntry* entry = CreateEntryLC(CCalEntry::EAppt, _L8("15:00"), ct3.TimeLocalL(), ct3.TimeLocalL() + TTimeIntervalHours(1)); |
|
1897 entry->SetRRuleL(rule); // doesn't take ownership |
|
1898 entry->SetSummaryL(_L("text to find")); |
|
1899 RPointerArray<CCalEntry> array; |
|
1900 CleanupClosePushL(array); |
|
1901 array.AppendL(entry); |
|
1902 TInt success(0); |
|
1903 aEntryView->StoreL(array, success); |
|
1904 CleanupStack::PopAndDestroy(&array); |
|
1905 CleanupStack::PopAndDestroy(entry); |
|
1906 |
|
1907 aData.iStartDate = TDateTime(2005, EJanuary, 0, 0, 0, 0, 0); |
|
1908 aData.iEndDate = TDateTime(2005, EOctober, 0, 0, 0, 0, 0); |
|
1909 |
|
1910 // expected times - too many! |
|
1911 while (t3 < aData.iEndDate) |
|
1912 { |
|
1913 aData.iTimes.AppendL(t3); |
|
1914 t3 += TTimeIntervalDays(1); |
|
1915 } |
|
1916 |
|
1917 TTime* currentTime = new (ELeave) TTime; |
|
1918 currentTime->UniversalTime(); |
|
1919 aData.iSearchString = _L("text to find").AllocL(); |
|
1920 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
1921 } |
|
1922 |
|
1923 |
|
1924 TInt CTestData::CompleteManyInstanceTest(TAny* aPtr) |
|
1925 { |
|
1926 if (aPtr != NULL) |
|
1927 { |
|
1928 TTime* startTime = static_cast<TTime*>(aPtr); |
|
1929 TTime endTime; |
|
1930 endTime.UniversalTime(); |
|
1931 |
|
1932 TTimeIntervalMicroSeconds micros = endTime.MicroSecondsFrom(*startTime); |
|
1933 |
|
1934 TUint32 ms = micros.Int64() / 1000; |
|
1935 RDebug::Print(_L("Time to find many instances: %d \n"), ms); |
|
1936 |
|
1937 delete startTime; |
|
1938 } |
|
1939 return KErrNone; |
|
1940 } |
|
1941 |
|
1942 |
|
1943 void CTestData::CreateManyInstancesTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1944 { |
|
1945 aData.iDescription.Copy(_L("Test many dated todos")); |
|
1946 |
|
1947 TTime t1(TDateTime(2005, EJanuary, 0, 9, 0, 0, 0)); |
|
1948 TTime t2(TDateTime(2005, EJanuary, 0, 12, 0, 0, 0)); |
|
1949 TTime t3(TDateTime(2005, EJanuary, 0, 15, 0, 0, 0)); |
|
1950 |
|
1951 TCalTime ct1; |
|
1952 ct1.SetTimeLocalL(t1); |
|
1953 TCalTime ct2; |
|
1954 ct2.SetTimeLocalL(t2); |
|
1955 TCalTime ct3; |
|
1956 ct3.SetTimeLocalL(t3); |
|
1957 TCalRRule rule(TCalRRule::EDaily); |
|
1958 rule.SetDtStart(ct1); |
|
1959 rule.SetCount(250); |
|
1960 rule.SetInterval(1); |
|
1961 AddRuleL(rule, aEntryView, _L8("09:00"), CCalEntry::ETodo); |
|
1962 rule.SetDtStart(ct2); |
|
1963 AddRuleL(rule, aEntryView, _L8("12:00"), CCalEntry::ETodo); |
|
1964 rule.SetDtStart(ct3); |
|
1965 AddRuleL(rule, aEntryView, _L8("15:00"), CCalEntry::ETodo); |
|
1966 |
|
1967 aData.iStartDate = TCalTime::MinTime(); |
|
1968 aData.iEndDate = TCalTime::MaxTime(); |
|
1969 |
|
1970 // expected times - too many! |
|
1971 TInt count = 0; |
|
1972 while (count < 250) |
|
1973 { |
|
1974 aData.iTimes.AppendL(t1 + TTimeIntervalHours(1)); // add an hour because todo instance occurs on end date (due date) |
|
1975 aData.iTimes.AppendL(t2 + TTimeIntervalHours(1)); |
|
1976 aData.iTimes.AppendL(t3 + TTimeIntervalHours(1)); |
|
1977 t1 += TTimeIntervalDays(1); |
|
1978 t2 += TTimeIntervalDays(1); |
|
1979 t3 += TTimeIntervalDays(1); |
|
1980 count++; |
|
1981 } |
|
1982 |
|
1983 TTime* currentTime = new (ELeave) TTime; |
|
1984 currentTime->UniversalTime(); |
|
1985 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
1986 } |
|
1987 |
|
1988 |
|
1989 void CTestData::CreateMaxRangeTestL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
1990 { |
|
1991 aData.iDescription.Copy(_L("Test non-repeating instances found correctly when searching maximum range")); |
|
1992 |
|
1993 TTime t1(TDateTime(2005, EJanuary, 10, 9, 0, 0, 0)); // 11 Jan, 09:00 |
|
1994 TTime t2(TDateTime(2005, EJanuary, 10, 10, 0, 0, 0)); // 11 Jan, 10:00 |
|
1995 CCalEntry* entry1 = CreateEntryLC(CCalEntry::EAppt, _L8("GUID1"), t1, t2); |
|
1996 CCalEntry* entry2 = CreateEntryLC(CCalEntry::EEvent, _L8("GUID2"), t1, t2); |
|
1997 CCalEntry* entry3 = CreateEntryLC(CCalEntry::ETodo, _L8("GUID3"), t1, t2); |
|
1998 CCalEntry* entry4 = CreateEntryLC(CCalEntry::EReminder, _L8("GUID4"), t1, t2); |
|
1999 CCalEntry* entry5 = CreateEntryLC(CCalEntry::EAnniv, _L8("GUID5"), t1, t2); |
|
2000 |
|
2001 RPointerArray<CCalEntry> array; |
|
2002 CleanupClosePushL(array); |
|
2003 array.AppendL(entry1); |
|
2004 array.AppendL(entry2); |
|
2005 array.AppendL(entry3); |
|
2006 array.AppendL(entry4); |
|
2007 array.AppendL(entry5); |
|
2008 TInt success(0); |
|
2009 aEntryView->StoreL(array, success); |
|
2010 CleanupStack::PopAndDestroy(&array); |
|
2011 |
|
2012 CleanupStack::PopAndDestroy(5, entry1); |
|
2013 |
|
2014 aData.iStartDate = TCalTime::MinTime(); |
|
2015 aData.iEndDate = TCalTime::MaxTime(); |
|
2016 |
|
2017 aData.iTimes.AppendL(t1); |
|
2018 aData.iTimes.AppendL(t1); |
|
2019 aData.iTimes.AppendL(t1); |
|
2020 aData.iTimes.AppendL(t1); |
|
2021 aData.iTimes.AppendL(t2); |
|
2022 |
|
2023 TTime* currentTime = new (ELeave) TTime; |
|
2024 currentTime->UniversalTime(); |
|
2025 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
2026 } |
|
2027 |
|
2028 |
|
2029 void CTestData::CreateMaxRangeTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2030 { |
|
2031 aData.iDescription.Copy(_L("Test repeating instances found correctly when searching maximum range")); |
|
2032 |
|
2033 TTime t1(TDateTime(2005, EJanuary, 10, 9, 0, 0, 0)); // 11 Jan, 09:00 |
|
2034 TTime t2(TDateTime(2005, EJanuary, 10, 10, 0, 0, 0)); // 11 Jan, 10:00 |
|
2035 |
|
2036 TCalTime dtStartCal; |
|
2037 dtStartCal.SetTimeLocalL(t1); |
|
2038 TCalRRule rule(TCalRRule::EWeekly); |
|
2039 rule.SetDtStart(dtStartCal); |
|
2040 rule.SetCount(2); |
|
2041 |
|
2042 RArray<TDay> days; |
|
2043 days.AppendL(ETuesday); |
|
2044 rule.SetByDay(days); |
|
2045 days.Reset(); |
|
2046 AddRuleL(rule, aEntryView, _L8("GUID1"), CCalEntry::EAppt); |
|
2047 AddRuleL(rule, aEntryView, _L8("GUID2"), CCalEntry::ETodo); |
|
2048 |
|
2049 aData.iStartDate = TCalTime::MinTime(); |
|
2050 aData.iEndDate = TCalTime::MaxTime(); |
|
2051 |
|
2052 aData.iTimes.AppendL(t1); |
|
2053 aData.iTimes.AppendL(t1 + TTimeIntervalDays(7)); |
|
2054 aData.iTimes.AppendL(t2); |
|
2055 aData.iTimes.AppendL(t2 + TTimeIntervalDays(7)); |
|
2056 |
|
2057 TTime* currentTime = new (ELeave) TTime; |
|
2058 currentTime->UniversalTime(); |
|
2059 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
2060 } |
|
2061 |
|
2062 |
|
2063 void CTestData::CreateMaxRangeTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2064 { |
|
2065 aData.iDescription.Copy(_L("Test text-search instances found correctly when searching maximum range")); |
|
2066 |
|
2067 TTime t1(TDateTime(2005, EJanuary, 10, 9, 0, 0, 0)); // 11 Jan, 09:00 |
|
2068 TTime t2(TDateTime(2005, EFebruary, 10, 9, 0, 0, 0)); // 11 Feb, 09:00 |
|
2069 TTime t3(TDateTime(2005, EMarch, 10, 9, 0, 0, 0)); // 11 Mar, 09:00 |
|
2070 TTime t4(TDateTime(2005, EApril, 10, 9, 0, 0, 0)); // 11 Apr, 09:00 |
|
2071 TTime t5(TDateTime(2005, EMay, 10, 9, 0, 0, 0)); // 11 May, 09:00 |
|
2072 TTime t6(TDateTime(2005, EJune, 10, 9, 0, 0, 0)); // 11 Jun, 09:00 |
|
2073 TTime t7(TDateTime(2005, EJuly, 10, 9, 0, 0, 0)); // 11 Jul, 09:00 |
|
2074 TTime t8(TDateTime(2005, EAugust, 10, 9, 0, 0, 0)); // 11 Aug, 09:00 |
|
2075 TTime t9(TDateTime(2005, ESeptember, 10, 9, 0, 0, 0)); // 11 Sep, 09:00 |
|
2076 TTime t0(TDateTime(2005, EOctober, 10, 9, 0, 0, 0)); // 11 Oct, 09:00 |
|
2077 |
|
2078 // add entry with text |
|
2079 StoreEntryWithTextL(aEntryView, CCalEntry::EAppt, _L8("GUID1"), t1, _L("text to find")); |
|
2080 StoreEntryWithTextL(aEntryView, CCalEntry::EAppt, _L8("GUID2"), t2, _L("text to not find")); |
|
2081 StoreEntryWithTextL(aEntryView, CCalEntry::ETodo, _L8("GUID3"), t3, _L("text to find")); |
|
2082 StoreEntryWithTextL(aEntryView, CCalEntry::ETodo, _L8("GUID4"), t4, _L("text to not find")); |
|
2083 StoreEntryWithTextL(aEntryView, CCalEntry::EEvent, _L8("GUID5"), t5, _L("text to find")); |
|
2084 StoreEntryWithTextL(aEntryView, CCalEntry::EEvent, _L8("GUID6"), t6, _L("text to not find")); |
|
2085 StoreEntryWithTextL(aEntryView, CCalEntry::EAnniv, _L8("GUID7"), t7, _L("text to find")); |
|
2086 StoreEntryWithTextL(aEntryView, CCalEntry::EAnniv, _L8("GUID8"), t8, _L("text to not find")); |
|
2087 StoreEntryWithTextL(aEntryView, CCalEntry::EReminder, _L8("GUID9"), t9, _L("text to find")); |
|
2088 StoreEntryWithTextL(aEntryView, CCalEntry::EReminder, _L8("GUID0"), t0, _L("text to not find")); |
|
2089 |
|
2090 aData.iStartDate = TCalTime::MinTime(); |
|
2091 aData.iEndDate = TCalTime::MaxTime(); |
|
2092 aData.iSearchString = _L("text to find").AllocL(); |
|
2093 aData.iFilter = CalCommon::EIncludeAppts|CalCommon::EIncludeEvents|CalCommon::EIncludeCompletedTodos|CalCommon::EIncludeIncompletedTodos; |
|
2094 |
|
2095 aData.iTimes.AppendL(t1); |
|
2096 aData.iTimes.AppendL(t3 + TTimeIntervalHours(1)); // add one hour because Todo has end date as instance date |
|
2097 aData.iTimes.AppendL(t5); |
|
2098 |
|
2099 TTime* currentTime = new (ELeave) TTime; |
|
2100 currentTime->UniversalTime(); |
|
2101 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
2102 } |
|
2103 |
|
2104 |
|
2105 void CTestData::CreateMaxRangeTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2106 { |
|
2107 aData.iDescription.Copy(_L("Test filtering instances found correctly when searching maximum range")); |
|
2108 |
|
2109 TTime t1(TDateTime(2005, EJanuary, 10, 9, 0, 0, 0)); // 11 Jan, 09:00 |
|
2110 TTime t2(TDateTime(2005, EFebruary, 10, 9, 0, 0, 0)); // 11 Feb, 09:00 |
|
2111 TTime t3(TDateTime(2005, EMarch, 10, 9, 0, 0, 0)); // 11 Mar, 09:00 |
|
2112 TTime t4(TDateTime(2005, EApril, 10, 9, 0, 0, 0)); // 11 Apr, 09:00 |
|
2113 TTime t5(TDateTime(2005, EMay, 10, 9, 0, 0, 0)); // 11 May, 09:00 |
|
2114 |
|
2115 // add entry with text |
|
2116 StoreEntryWithTextL(aEntryView, CCalEntry::EAppt, _L8("GUID1"), t1, _L("")); |
|
2117 StoreEntryWithTextL(aEntryView, CCalEntry::EEvent, _L8("GUID2"), t2, _L("")); |
|
2118 StoreEntryWithTextL(aEntryView, CCalEntry::EReminder, _L8("GUID3"), t3, _L("")); |
|
2119 StoreEntryWithTextL(aEntryView, CCalEntry::ETodo, _L8("GUID4"), t4, _L("")); |
|
2120 StoreEntryWithTextL(aEntryView, CCalEntry::EAnniv, _L8("GUID5"), t5, _L("")); |
|
2121 |
|
2122 aData.iStartDate = TCalTime::MinTime(); |
|
2123 aData.iEndDate = TCalTime::MaxTime(); |
|
2124 aData.iFilter = CalCommon::EIncludeReminder|CalCommon::EIncludeAnnivs|CalCommon::EIncludeIncompletedTodos; |
|
2125 |
|
2126 aData.iTimes.AppendL(t3); |
|
2127 aData.iTimes.AppendL(t4 + TTimeIntervalHours(1)); |
|
2128 aData.iTimes.AppendL(t5); |
|
2129 |
|
2130 TTime* currentTime = new (ELeave) TTime; |
|
2131 currentTime->UniversalTime(); |
|
2132 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
2133 } |
|
2134 |
|
2135 |
|
2136 void CTestData::CreateMaxRangeTest5L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2137 { |
|
2138 aData.iDescription.Copy(_L("Test filtering incompleted todos found correctly when searching maximum range")); |
|
2139 |
|
2140 // create one completed todo and one incomplete todo |
|
2141 TTime todoTime1(TDateTime(2005, EJanuary, 25, 0, 0, 0, 0)); |
|
2142 CCalEntry* entry = CreateTodoLC(KGUID1(), todoTime1, todoTime1); // 26 Jan - completed entry |
|
2143 |
|
2144 TTime todoTime2(TDateTime(2005, EJanuary, 15, 0, 0, 0, 0)); |
|
2145 CCalEntry* entry2 = CreateTodoLC(KGUID1(), todoTime2, Time::NullTTime()); // 16 Jan - incomplete entry |
|
2146 |
|
2147 RPointerArray<CCalEntry> array; |
|
2148 CleanupClosePushL(array); |
|
2149 array.AppendL(entry); |
|
2150 array.AppendL(entry2); |
|
2151 TInt success(0); |
|
2152 aEntryView->StoreL(array, success); |
|
2153 CleanupStack::PopAndDestroy(&array); |
|
2154 |
|
2155 CleanupStack::PopAndDestroy(entry2); |
|
2156 CleanupStack::PopAndDestroy(entry); |
|
2157 |
|
2158 aData.iFilter = CalCommon::EIncludeIncompletedTodos; |
|
2159 |
|
2160 aData.iStartDate = TCalTime::MinTime(); |
|
2161 aData.iEndDate = TCalTime::MaxTime(); |
|
2162 |
|
2163 // expected times: |
|
2164 aData.iTimes.AppendL(TTime(TDateTime(2005, EJanuary, 15, 0, 0, 0, 0))); // 16 Jan 05 |
|
2165 |
|
2166 TTime* currentTime = new (ELeave) TTime; |
|
2167 currentTime->UniversalTime(); |
|
2168 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
2169 } |
|
2170 |
|
2171 |
|
2172 void CTestData::CreateMaxRangeTest6L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2173 { |
|
2174 aData.iDescription.Copy(_L("Filter test for completed todos only.")); |
|
2175 |
|
2176 // create one completed todo and one incomplete todo |
|
2177 TTime todoTime1(TDateTime(2005, EJanuary, 25, 0, 0, 0, 0)); |
|
2178 CCalEntry* entry = CreateTodoLC(KGUID1(), todoTime1, todoTime1); // 26 Jan - completed entry |
|
2179 |
|
2180 TTime todoTime2(TDateTime(2005, EJanuary, 15, 0, 0, 0, 0)); |
|
2181 CCalEntry* entry2 = CreateTodoLC(KGUID2(), todoTime2, Time::NullTTime()); // 16 Jan - incomplete entry |
|
2182 |
|
2183 RPointerArray<CCalEntry> array; |
|
2184 CleanupClosePushL(array); |
|
2185 array.AppendL(entry); |
|
2186 array.AppendL(entry2); |
|
2187 TInt success(0); |
|
2188 aEntryView->StoreL(array, success); |
|
2189 CleanupStack::PopAndDestroy(&array); |
|
2190 |
|
2191 CleanupStack::PopAndDestroy(entry2); |
|
2192 CleanupStack::PopAndDestroy(entry); |
|
2193 |
|
2194 aData.iFilter = CalCommon::EIncludeCompletedTodos; |
|
2195 |
|
2196 aData.iStartDate = TCalTime::MinTime(); |
|
2197 aData.iEndDate = TCalTime::MaxTime(); |
|
2198 |
|
2199 // expected times: |
|
2200 aData.iTimes.AppendL(TTime(TDateTime(2005, EJanuary, 25, 0, 0, 0, 0))); // 16 Jan 05 |
|
2201 |
|
2202 TTime* currentTime = new (ELeave) TTime; |
|
2203 currentTime->UniversalTime(); |
|
2204 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
2205 } |
|
2206 |
|
2207 |
|
2208 void CTestData::CreateMaxRangeTest7L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2209 { |
|
2210 aData.iDescription.Copy(_L("Filter test for alarmed entries only (max range).")); |
|
2211 |
|
2212 TTime startTime1(TDateTime(2005, EFebruary, 0, 0, 0, 0, 0)); // 1 Feb 05 |
|
2213 |
|
2214 // create alarmed entry |
|
2215 CCalEntry* entry1 = CreateEntryLC(CCalEntry::EAppt, KGUID1(), startTime1, startTime1 + TTimeIntervalHours(1)); |
|
2216 |
|
2217 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
2218 CleanupStack::PushL(alarm); |
|
2219 alarm->SetTimeOffset(30); |
|
2220 entry1->SetAlarmL(alarm); |
|
2221 CleanupStack::PopAndDestroy(alarm); |
|
2222 |
|
2223 TTime startTime2(TDateTime(2005, EMarch, 0, 0, 0, 0, 0)); // 1 Mar 05 |
|
2224 CCalEntry* entry2 = CreateEntryLC(CCalEntry::EAppt, KGUID2(), startTime2, startTime2 + TTimeIntervalHours(1)); |
|
2225 |
|
2226 RPointerArray<CCalEntry> array; |
|
2227 CleanupClosePushL(array); |
|
2228 array.AppendL(entry1); |
|
2229 array.AppendL(entry2); |
|
2230 TInt success(0); |
|
2231 aEntryView->StoreL(array, success); |
|
2232 CleanupStack::PopAndDestroy(&array); |
|
2233 |
|
2234 CleanupStack::PopAndDestroy(entry2); |
|
2235 CleanupStack::PopAndDestroy(entry1); |
|
2236 |
|
2237 aData.iFilter = CalCommon::EIncludeAlarmedOnly|CalCommon::EIncludeAll; |
|
2238 |
|
2239 aData.iStartDate = TCalTime::MinTime(); |
|
2240 aData.iEndDate = TCalTime::MaxTime(); |
|
2241 |
|
2242 // expected times: |
|
2243 aData.iTimes.AppendL(startTime1); // 16 Jan 05 |
|
2244 |
|
2245 TTime* currentTime = new (ELeave) TTime; |
|
2246 currentTime->UniversalTime(); |
|
2247 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
2248 } |
|
2249 |
|
2250 |
|
2251 void CTestData::CreateMaxRangeTest8L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2252 { |
|
2253 aData.iDescription.Copy(_L("Filter test for next repeat only (max range).")); |
|
2254 |
|
2255 TCalRRule rpt(TCalRRule::EYearly); |
|
2256 rpt.SetInterval(12); |
|
2257 TCalTime startTime; |
|
2258 startTime.SetTimeLocalL(TDateTime(2004, EFebruary, 28, 0, 0, 0, 0)); // 29 Feb 2004 |
|
2259 rpt.SetDtStart(startTime); |
|
2260 TCalTime endTime; |
|
2261 endTime.SetTimeLocalL(TDateTime(2099, EMarch, 30, 0, 0, 0, 0)); // 2009 |
|
2262 rpt.SetUntil(endTime); |
|
2263 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
2264 |
|
2265 aData.iStartDate = TCalTime::MinTime(); |
|
2266 aData.iEndDate = TCalTime::MaxTime(); |
|
2267 |
|
2268 aData.iFilter = CalCommon::EIncludeRptsNextInstanceOnly|CalCommon::EIncludeAppts; |
|
2269 |
|
2270 // expected times: |
|
2271 aData.iTimes.AppendL(startTime.TimeLocalL()); // 29 Feb 04 |
|
2272 |
|
2273 TTime* currentTime = new (ELeave) TTime; |
|
2274 currentTime->UniversalTime(); |
|
2275 aData.iFunction = new (ELeave) TCallBack(&CTestData::CompleteManyInstanceTest, (TAny*)currentTime); |
|
2276 } |
|
2277 |
|
2278 |
|
2279 void CTestData::SetupMultipleTextFieldsTestL(CCalEntryView* aView) |
|
2280 { |
|
2281 // This test creates a number of entries with these test strings in different fields. |
|
2282 // These strings are searched for separately in a number of tests that call this function. |
|
2283 _LIT(KTestString1, "test1"); |
|
2284 _LIT(KTestString2, "test2"); |
|
2285 _LIT(KTestString3, "test3"); |
|
2286 _LIT(KTestString4, "test4"); |
|
2287 _LIT(KTestString5, "test5"); |
|
2288 _LIT(KTestString6, "test6"); |
|
2289 |
|
2290 RPointerArray<CCalEntry> entries; |
|
2291 CleanupResetAndDestroyPushL(entries); |
|
2292 |
|
2293 // First entry is at 12:00 on 1 Jan 2006 |
|
2294 TTime entryTime1 = TDateTime(2006, EJanuary, 0, 12, 0, 0, 0); |
|
2295 CCalEntry* entry1 = CreateEntryLC(CCalEntry::EAppt, KGUID1, entryTime1, entryTime1); |
|
2296 entry1->SetDescriptionL(KTestString1); |
|
2297 entry1->SetLocationL(KTestString2); |
|
2298 |
|
2299 CCalAttendee* attendee1 = CCalAttendee::NewL(KTestString2, KTestString1); |
|
2300 CleanupStack::PushL(attendee1); |
|
2301 attendee1->SetCommonNameL(KTestString6); |
|
2302 entry1->AddAttendeeL(attendee1); |
|
2303 CleanupStack::Pop(attendee1); |
|
2304 |
|
2305 entries.AppendL(entry1); |
|
2306 CleanupStack::Pop(entry1); |
|
2307 |
|
2308 // Entry at 12:00 on 1 Feb 2006 |
|
2309 TTime entryTime2 = TDateTime(2006, EFebruary, 0, 12, 0, 0, 0); |
|
2310 CCalEntry* entry2 = CreateEntryLC(CCalEntry::ETodo, KGUID2, entryTime2, entryTime2); |
|
2311 entry2->SetDescriptionL(KTestString6); |
|
2312 entry2->SetLocationL(KTestString1); |
|
2313 |
|
2314 CCalAttendee* attendee2 = CCalAttendee::NewL(KTestString1, KTestString2); |
|
2315 CleanupStack::PushL(attendee2); |
|
2316 attendee2->SetCommonNameL(KTestString3); |
|
2317 entry2->AddAttendeeL(attendee2); |
|
2318 CleanupStack::Pop(attendee2); |
|
2319 |
|
2320 entries.AppendL(entry2); |
|
2321 CleanupStack::Pop(entry2); |
|
2322 |
|
2323 // Entry at 12:00 on 1 Mar 2006 |
|
2324 TTime entryTime3 = TDateTime(2006, EMarch, 0, 12, 0, 0, 0); |
|
2325 CCalEntry* entry3 = CreateEntryLC(CCalEntry::ETodo, KGUID3, entryTime3, entryTime3); |
|
2326 entry3->SetDescriptionL(KTestString6); |
|
2327 entry3->SetLocationL(KTestString3); |
|
2328 |
|
2329 CCalAttendee* attendee3 = CCalAttendee::NewL(KTestString4, KTestString4); |
|
2330 CleanupStack::PushL(attendee3); |
|
2331 attendee3->SetCommonNameL(KTestString5); |
|
2332 entry3->AddAttendeeL(attendee3); |
|
2333 CleanupStack::Pop(attendee3); |
|
2334 |
|
2335 entries.AppendL(entry3); |
|
2336 CleanupStack::Pop(entry3); |
|
2337 |
|
2338 // Entry at 12:00 on 1 Apr 2006 |
|
2339 TTime entryTime4 = TDateTime(2006, EApril, 0, 12, 0, 0, 0); |
|
2340 CCalEntry* entry4 = CreateEntryLC(CCalEntry::EReminder, KGUID4, entryTime4, entryTime4); |
|
2341 entry4->SetDescriptionL(KTestString3); |
|
2342 entry4->SetLocationL(KTestString6); |
|
2343 |
|
2344 CCalAttendee* attendee4 = CCalAttendee::NewL(KTestString3, KTestString4); |
|
2345 CleanupStack::PushL(attendee4); |
|
2346 attendee4->SetCommonNameL(KTestString5); |
|
2347 entry4->SetOrganizerL(attendee4); |
|
2348 CleanupStack::Pop(attendee4); |
|
2349 |
|
2350 entries.AppendL(entry4); |
|
2351 CleanupStack::Pop(entry4); |
|
2352 |
|
2353 TInt success = 0; |
|
2354 aView->StoreL(entries, success); |
|
2355 |
|
2356 CleanupStack::PopAndDestroy(&entries); |
|
2357 } |
|
2358 |
|
2359 |
|
2360 void CTestData::CreateStringInFieldTest1L(CTestDataStruct& aData, CCalEntryView* aView) |
|
2361 { |
|
2362 aData.iDescription.Copy(_L("Filter test for description and attendee address.")); |
|
2363 |
|
2364 SetupMultipleTextFieldsTestL(aView); |
|
2365 |
|
2366 aData.iStartDate = TCalTime::MinTime(); |
|
2367 aData.iEndDate = TCalTime::MaxTime(); |
|
2368 |
|
2369 aData.iSearchBehaviour = CalCommon::TCalSearchBehaviour(CalCommon::ESearchEntryDescription | CalCommon::ESearchAttendeeAddress); |
|
2370 aData.iSearchString = _L("test1").AllocL(); |
|
2371 |
|
2372 // expected times: |
|
2373 aData.iTimes.AppendL(TDateTime(2006, EJanuary, 0, 12, 0, 0, 0)); // 1 Jan |
|
2374 aData.iTimes.AppendL(TDateTime(2006, EFebruary, 0, 12, 0, 0, 0)); // 1 Feb |
|
2375 } |
|
2376 |
|
2377 |
|
2378 void CTestData::CreateStringInFieldTest2L(CTestDataStruct& aData, CCalEntryView* aView) |
|
2379 { |
|
2380 aData.iDescription.Copy(_L("Filter test for location and attendee sent-by address.")); |
|
2381 |
|
2382 SetupMultipleTextFieldsTestL(aView); |
|
2383 |
|
2384 aData.iStartDate = TCalTime::MinTime(); |
|
2385 aData.iEndDate = TCalTime::MaxTime(); |
|
2386 |
|
2387 aData.iSearchBehaviour = CalCommon::TCalSearchBehaviour(CalCommon::ESearchEntryLocation | CalCommon::ESearchAttendeeSentByAddress); |
|
2388 aData.iSearchString = _L("test2").AllocL(); |
|
2389 |
|
2390 // expected times: |
|
2391 aData.iTimes.AppendL(TDateTime(2006, EJanuary, 0, 12, 0, 0, 0)); // 1 Jan |
|
2392 aData.iTimes.AppendL(TDateTime(2006, EFebruary, 0, 12, 0, 0, 0)); // 1 Feb |
|
2393 } |
|
2394 |
|
2395 |
|
2396 void CTestData::CreateStringInFieldTest3L(CTestDataStruct& aData, CCalEntryView* aView) |
|
2397 { |
|
2398 aData.iDescription.Copy(_L("Filter test for attendee common name and organizer address.")); |
|
2399 |
|
2400 SetupMultipleTextFieldsTestL(aView); |
|
2401 |
|
2402 aData.iStartDate = TCalTime::MinTime(); |
|
2403 aData.iEndDate = TCalTime::MaxTime(); |
|
2404 |
|
2405 aData.iSearchBehaviour = CalCommon::TCalSearchBehaviour(CalCommon::ESearchAttendeeCommonName | CalCommon::ESearchOrganizerAddress); |
|
2406 aData.iSearchString = _L("test3").AllocL(); |
|
2407 |
|
2408 // expected times: |
|
2409 aData.iTimes.AppendL(TDateTime(2006, EFebruary, 0, 12, 0, 0, 0)); // 1 Feb |
|
2410 aData.iTimes.AppendL(TDateTime(2006, EApril, 0, 12, 0, 0, 0)); // 1 Apr |
|
2411 } |
|
2412 |
|
2413 |
|
2414 void CTestData::CreateStringInFieldTest4L(CTestDataStruct& aData, CCalEntryView* aView) |
|
2415 { |
|
2416 aData.iDescription.Copy(_L("Filter test for organizer sent-by address.")); |
|
2417 |
|
2418 SetupMultipleTextFieldsTestL(aView); |
|
2419 |
|
2420 aData.iStartDate = TCalTime::MinTime(); |
|
2421 aData.iEndDate = TCalTime::MaxTime(); |
|
2422 |
|
2423 aData.iSearchBehaviour = CalCommon::ESearchOrganizerSentByAddress; |
|
2424 aData.iSearchString = _L("test4").AllocL(); |
|
2425 |
|
2426 // expected times: |
|
2427 aData.iTimes.AppendL(TDateTime(2006, EApril, 0, 12, 0, 0, 0)); // 1 Apr |
|
2428 } |
|
2429 |
|
2430 |
|
2431 void CTestData::CreateStringInFieldTest5L(CTestDataStruct& aData, CCalEntryView* aView) |
|
2432 { |
|
2433 aData.iDescription.Copy(_L("Filter test for organizer common name.")); |
|
2434 |
|
2435 SetupMultipleTextFieldsTestL(aView); |
|
2436 |
|
2437 aData.iStartDate = TCalTime::MinTime(); |
|
2438 aData.iEndDate = TCalTime::MaxTime(); |
|
2439 |
|
2440 aData.iSearchBehaviour = CalCommon::ESearchOrganizerCommonName; |
|
2441 aData.iSearchString = _L("test5").AllocL(); |
|
2442 |
|
2443 // expected times: |
|
2444 aData.iTimes.AppendL(TDateTime(2006, EApril, 0, 12, 0, 0, 0)); // 1 Apr |
|
2445 } |
|
2446 |
|
2447 |
|
2448 void CTestData::CreateStringInFieldTest6L(CTestDataStruct& aData, CCalEntryView* aView) |
|
2449 { |
|
2450 aData.iDescription.Copy(_L("Filter test for multiple selected fields.")); |
|
2451 |
|
2452 SetupMultipleTextFieldsTestL(aView); |
|
2453 |
|
2454 aData.iStartDate = TCalTime::MinTime(); |
|
2455 aData.iEndDate = TCalTime::MaxTime(); |
|
2456 |
|
2457 aData.iSearchBehaviour = CalCommon::ESearchAllTextFields; |
|
2458 aData.iSearchString = _L("test6").AllocL(); |
|
2459 |
|
2460 // expected times: |
|
2461 aData.iTimes.AppendL(TDateTime(2006, EJanuary, 0, 12, 0, 0, 0)); // 1 Jan |
|
2462 aData.iTimes.AppendL(TDateTime(2006, EFebruary, 0, 12, 0, 0, 0)); // 1 Feb |
|
2463 aData.iTimes.AppendL(TDateTime(2006, EMarch, 0, 12, 0, 0, 0)); // 1 Mar |
|
2464 aData.iTimes.AppendL(TDateTime(2006, EApril, 0, 12, 0, 0, 0)); // 1 Apr |
|
2465 } |
|
2466 |
|
2467 void CTestData::CreateRepeatingWithSecondGranularityL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2468 { |
|
2469 aData.iDescription.Copy(_L("Search for repeating entries with granularity in seconds")); |
|
2470 |
|
2471 TCalRRule rpt(TCalRRule::EWeekly); |
|
2472 rpt.SetInterval(1); |
|
2473 |
|
2474 RArray<TDay> days; |
|
2475 CleanupClosePushL(days); |
|
2476 days.AppendL(EWednesday); |
|
2477 rpt.SetByDay(days); |
|
2478 CleanupStack::PopAndDestroy(&days); |
|
2479 |
|
2480 TCalTime startTime; |
|
2481 startTime.SetTimeLocalL(TDateTime(2006, EFebruary, 0, 9, 0, 5, 0)); |
|
2482 rpt.SetDtStart(startTime); // 1 Feb |
|
2483 TCalTime endTime; |
|
2484 endTime.SetTimeLocalL(TDateTime(2006, EFebruary, 22, 12, 0, 5, 0)); |
|
2485 rpt.SetUntil(endTime); // Feb 22 |
|
2486 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
2487 |
|
2488 aData.iStartDate = TDateTime(2006, EFebruary, 0, 0, 0, 0, 0); // 1 Feb |
|
2489 aData.iEndDate = TDateTime(2006, EFebruary, 27, 0, 0, 0, 0); // 28 Feb |
|
2490 |
|
2491 // expected times: |
|
2492 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 0, 9, 0, 5, 0))); // 1 Feb |
|
2493 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 7, 9, 0, 5, 0))); // 8 Feb |
|
2494 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 14, 9, 0, 5, 0))); // 15 Feb |
|
2495 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 21, 9, 0, 5, 0))); // 22 Feb |
|
2496 } |
|
2497 |
|
2498 void CTestData::CreateRepeatingWithMSecondGranularityL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2499 { |
|
2500 aData.iDescription.Copy(_L("Search for repeating entries with granularity in microseconds")); |
|
2501 |
|
2502 TCalRRule rpt(TCalRRule::EWeekly); |
|
2503 rpt.SetInterval(1); |
|
2504 |
|
2505 RArray<TDay> days; |
|
2506 CleanupClosePushL(days); |
|
2507 days.AppendL(EWednesday); |
|
2508 rpt.SetByDay(days); |
|
2509 CleanupStack::PopAndDestroy(&days); |
|
2510 |
|
2511 TCalTime startTime; |
|
2512 startTime.SetTimeLocalL(TDateTime(2006, EFebruary, 0, 9, 30, 5, 100)); |
|
2513 rpt.SetDtStart(startTime); // 1 Feb |
|
2514 TCalTime endTime; |
|
2515 endTime.SetTimeLocalL(TDateTime(2006, EFebruary, 22, 23, 59, 59, 999)); |
|
2516 rpt.SetUntil(endTime); // Feb 23 |
|
2517 AddRuleL(rpt, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
2518 |
|
2519 aData.iStartDate = TDateTime(2006, EFebruary, 0, 0, 0, 0, 0); // 1 Feb |
|
2520 aData.iEndDate = TDateTime(2006, EFebruary, 27, 0, 0, 0, 0); // 28 Feb |
|
2521 |
|
2522 // expected times: |
|
2523 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 0, 9, 30, 5, 100))); // 1 Feb |
|
2524 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 7, 9, 30, 5, 100))); // 8 Feb |
|
2525 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 14, 9, 30, 5, 100))); // 15 Feb |
|
2526 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 21, 9, 30, 5, 100))); // 22 Feb |
|
2527 } |
|
2528 |
|
2529 |
|
2530 void CTestData::CreateRepeatingWithRuleAndDatesL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2531 { |
|
2532 aData.iDescription.Copy(_L("Search for repeating entries with both RRules and RDates")); |
|
2533 |
|
2534 TCalRRule rpt(TCalRRule::EWeekly); |
|
2535 rpt.SetInterval(1); |
|
2536 |
|
2537 RArray<TDay> days; |
|
2538 CleanupClosePushL(days); |
|
2539 days.AppendL(EWednesday); |
|
2540 rpt.SetByDay(days); |
|
2541 CleanupStack::PopAndDestroy(&days); |
|
2542 |
|
2543 TCalTime startTime; |
|
2544 startTime.SetTimeLocalL(TDateTime(2006, EFebruary, 0, 9, 0, 0, 0)); |
|
2545 rpt.SetDtStart(startTime); // 1 Feb |
|
2546 TCalTime endTime; |
|
2547 endTime.SetTimeLocalL(TDateTime(2006, EFebruary, 22, 12, 0, 0, 0)); |
|
2548 rpt.SetUntil(endTime); // Feb 22 |
|
2549 |
|
2550 RArray<TCalTime> rdates; |
|
2551 CleanupClosePushL(rdates); |
|
2552 TCalTime rdate1; |
|
2553 rdate1.SetTimeLocalL(TTime(TDateTime(2006,EFebruary, 7, 11, 30, 0, 0))); // 8 Feb |
|
2554 rdates.AppendL(rdate1); |
|
2555 |
|
2556 CCalEntry* entry = CreateEntryLC(CCalEntry::EAppt, KGUID1(), rpt.DtStart().TimeLocalL(), rpt.DtStart().TimeLocalL() + TTimeIntervalHours(1)); |
|
2557 entry->SetRRuleL(rpt); |
|
2558 entry->SetRDatesL(rdates); |
|
2559 |
|
2560 RPointerArray<CCalEntry> array; |
|
2561 CleanupClosePushL(array); |
|
2562 array.AppendL(entry); |
|
2563 TInt success(0); |
|
2564 aEntryView->StoreL(array, success); |
|
2565 CleanupStack::PopAndDestroy(&array); |
|
2566 |
|
2567 CleanupStack::PopAndDestroy(entry); |
|
2568 |
|
2569 CleanupStack::PopAndDestroy(&rdates); |
|
2570 |
|
2571 aData.iStartDate = TDateTime(2006, EFebruary, 0, 0, 0, 0, 0); // 1 Feb |
|
2572 aData.iEndDate = TDateTime(2006, EFebruary, 27, 0, 0, 0, 0); // 28 Feb |
|
2573 |
|
2574 // expected times: |
|
2575 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 0, 9, 0, 0, 0))); // 1 Feb |
|
2576 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 7, 9, 0, 0, 0))); // 8 Feb |
|
2577 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 7, 11, 30, 0, 0))); // 8 Feb |
|
2578 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 14, 9, 0, 0, 0))); // 15 Feb |
|
2579 aData.iTimes.AppendL(TTime(TDateTime(2006, EFebruary, 21, 9, 0, 0, 0))); // 22 Feb |
|
2580 } |
|
2581 |
|
2582 void CTestData::CreateNextInstanceOnlyTestL(CTestDataStruct& aData, CCalEntryView* aView) |
|
2583 { |
|
2584 aData.iDescription.Copy(_L("Search for next instance only of a repeating weekly and daily entry")); |
|
2585 |
|
2586 // Every Wednesday from 1st January 2006, 0900 |
|
2587 TCalRRule rpt(TCalRRule::EWeekly); |
|
2588 rpt.SetInterval(1); |
|
2589 |
|
2590 RArray<TDay> days; |
|
2591 CleanupClosePushL(days); |
|
2592 days.AppendL(EWednesday); |
|
2593 rpt.SetByDay(days); |
|
2594 CleanupStack::PopAndDestroy(&days); |
|
2595 |
|
2596 TCalTime startTime; |
|
2597 startTime.SetTimeLocalL(TDateTime(2006, EJanuary, 0, 9, 0, 0, 0)); |
|
2598 rpt.SetDtStart(startTime); |
|
2599 rpt.SetCount(100); |
|
2600 AddRuleL(rpt, aView, KGUID1(), CCalEntry::ETodo); |
|
2601 |
|
2602 // Every 3 days from 9th January 2006, 1500 |
|
2603 TCalRRule rpt2(TCalRRule::EDaily); |
|
2604 rpt2.SetInterval(3); |
|
2605 |
|
2606 startTime.SetTimeLocalL(TDateTime(2006, EJanuary, 8, 15, 0, 0, 0)); |
|
2607 rpt2.SetDtStart(startTime); |
|
2608 rpt2.SetCount(100); |
|
2609 AddRuleL(rpt2, aView, KGUID2(), CCalEntry::ETodo); |
|
2610 |
|
2611 aData.iStartDate = TCalTime::MinTime(); |
|
2612 aData.iEndDate = TCalTime::MaxTime(); |
|
2613 |
|
2614 aData.iFilter = CalCommon::EIncludeAll|CalCommon::EIncludeRptsNextInstanceOnly; |
|
2615 |
|
2616 // expected times: |
|
2617 aData.iTimes.AppendL(TTime(TDateTime(2006, EJanuary, 3, 10, 0, 0, 0))); // 4 Jan (weekly rule) |
|
2618 aData.iTimes.AppendL(TTime(TDateTime(2006, EJanuary, 8, 16, 0, 0, 0))); // 9 Jan (3-daily rule) |
|
2619 } |
|
2620 |
|
2621 void CTestData::DeleteEntryLastInstanceL(CTestDataStruct& aData, CCalEntryView* aEntryView, CCalInstanceView* aInstanceView) |
|
2622 { |
|
2623 aData.iDescription.Copy(_L("Check if deleting an instance would delete the child")); |
|
2624 |
|
2625 // Add Entries for Test |
|
2626 RPointerArray<CCalEntry> entriesToStore; |
|
2627 CleanupResetAndDestroyPushL(entriesToStore); |
|
2628 |
|
2629 //create an simple entry and store it to the file |
|
2630 _LIT8(KUid, "UID_xx"); |
|
2631 HBufC8* guid = KUid().AllocLC(); |
|
2632 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0); |
|
2633 CleanupStack::Pop(guid); |
|
2634 CleanupStack::PushL(entry); |
|
2635 entry->SetSummaryL(_L("random text")); |
|
2636 entriesToStore.AppendL(entry); |
|
2637 CleanupStack::Pop(entry); |
|
2638 |
|
2639 TTime startTime (TDateTime(2005, EJanuary, 7, 10, 0, 0, 0)); |
|
2640 TTime endTime (TDateTime(2005, EJanuary, 7, 11, 0, 0, 0)); |
|
2641 TCalTime calStartTime; |
|
2642 calStartTime.SetTimeLocalL(startTime); |
|
2643 TCalTime calEndTime; |
|
2644 calEndTime.SetTimeLocalL(endTime); |
|
2645 entry->SetStartAndEndTimeL(calStartTime, calEndTime); |
|
2646 |
|
2647 TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EDaily); |
|
2648 CleanupStack::PushL(rpt); |
|
2649 TTime daily1end(TDateTime(2005, EJanuary, 8, 10, 0, 0, 0)); |
|
2650 TCalTime rptendTime; |
|
2651 rptendTime.SetTimeLocalL(daily1end); |
|
2652 |
|
2653 rpt->SetDtStart(calStartTime); |
|
2654 rpt->SetUntil(rptendTime); |
|
2655 rpt->SetInterval(1); |
|
2656 entry->SetRRuleL(*rpt);//take a copy of the rule |
|
2657 CleanupStack::PopAndDestroy(rpt); |
|
2658 |
|
2659 TInt entriesStored(0); |
|
2660 aEntryView->StoreL(entriesToStore, entriesStored); |
|
2661 ASSERT(entriesStored == 1); |
|
2662 entriesToStore.ResetAndDestroy(); |
|
2663 |
|
2664 //create a child entry and store it |
|
2665 guid = KUid().AllocLC(); |
|
2666 TTime ttime (TDateTime(2005, EJanuary, 7, 10, 0, 0, 0)); |
|
2667 TCalTime recurrenceId; |
|
2668 recurrenceId.SetTimeUtcL(ttime); |
|
2669 entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodRequest, 0, recurrenceId, CalCommon::EThisOnly); |
|
2670 CleanupStack::Pop(guid); |
|
2671 CleanupStack::PushL(entry); |
|
2672 |
|
2673 // Set child entry time |
|
2674 TTime newStartDate (TDateTime(2005, EJanuary, 7, 11, 0, 0, 0)); |
|
2675 TTime newEndDate (TDateTime(2005, EJanuary, 7, 12, 0, 0, 0)); |
|
2676 |
|
2677 TCalTime newCalstartTime; |
|
2678 newCalstartTime.SetTimeUtcL(newStartDate); |
|
2679 TCalTime newCalendTime; |
|
2680 newCalendTime.SetTimeUtcL(newEndDate); |
|
2681 entry->SetStartAndEndTimeL(newCalstartTime, newCalendTime); |
|
2682 |
|
2683 entriesToStore.AppendL(entry); |
|
2684 CleanupStack::Pop(entry); |
|
2685 aEntryView->StoreL(entriesToStore, entriesStored); |
|
2686 entriesToStore.ResetAndDestroy(); |
|
2687 |
|
2688 aEntryView->FetchL(KUid, entriesToStore); |
|
2689 ASSERT(entriesToStore.Count() == 2); //1 parent and 1 child so far |
|
2690 entriesToStore.ResetAndDestroy(); |
|
2691 |
|
2692 //search for the second instance |
|
2693 RPointerArray<CCalInstance> instances; |
|
2694 CleanupResetAndDestroyPushL(instances); |
|
2695 |
|
2696 TCalTime start; |
|
2697 start.SetTimeLocalL(TDateTime(2005, EJanuary, 8, 10, 0, 0, 0)); |
|
2698 TCalTime end; |
|
2699 end.SetTimeLocalL(TDateTime(2005, EJanuary, 8, 11, 0, 0, 0)); |
|
2700 |
|
2701 CalCommon::TCalTimeRange timeRange(start, end); |
|
2702 aInstanceView->FindInstanceL(instances, CalCommon::EIncludeAll, timeRange); |
|
2703 ASSERT(instances.Count() == 1); |
|
2704 |
|
2705 //Delete the second instance which should not delete the child but update the parent |
|
2706 CCalInstance* instance = instances[0]; |
|
2707 aInstanceView->DeleteL(instance, CalCommon::EThisOnly); |
|
2708 instances.Remove(0); |
|
2709 instances.ResetAndDestroy(); |
|
2710 aEntryView->FetchL(KUid, entriesToStore); |
|
2711 |
|
2712 aData.iStartDate = TCalTime::MinTime(); |
|
2713 aData.iEndDate = TCalTime::MaxTime(); |
|
2714 aData.iFilter = CalCommon::EIncludeAll; |
|
2715 |
|
2716 // expected times: |
|
2717 aData.iTimes.AppendL(TTime(TDateTime(2005, EJanuary, 7, 11, 0, 0, 0))); // 4 Jan (weekly rule) |
|
2718 |
|
2719 CleanupStack::PopAndDestroy(&instances); |
|
2720 CleanupStack::PopAndDestroy(&entriesToStore); |
|
2721 } |
|
2722 |
|
2723 // Creates an entry that falls on the same day as the search criteria but the |
|
2724 // instance time falls outside of the time of the search. The entry should not |
|
2725 // be found. |
|
2726 void CTestData::TestFindInstanceWithTimeL( CTestDataStruct& aData, |
|
2727 CCalEntryView* aEntryView ) |
|
2728 { |
|
2729 aData.iDescription.Copy( _L( "Instance in calendar in afternoon, should not be found when looking in morning" ) ); |
|
2730 |
|
2731 // Create entry that starts in the afternoon: May 26, 2-3 pm. |
|
2732 TTime startTime1( TDateTime( 2006, EMay, 25, 14, 0, 0, 0 ) ); |
|
2733 CCalEntry* entry1 = CreateEntryLC( CCalEntry::EAppt, KGUID1(), startTime1, |
|
2734 startTime1 + TTimeIntervalHours(1) ); |
|
2735 |
|
2736 // Store the entry. |
|
2737 RPointerArray<CCalEntry> entryList; |
|
2738 CleanupClosePushL( entryList ); |
|
2739 entryList.AppendL( entry1 ); |
|
2740 TInt success = 0; |
|
2741 aEntryView->StoreL( entryList, success ); |
|
2742 CleanupStack::PopAndDestroy( &entryList ); |
|
2743 CleanupStack::PopAndDestroy( entry1 ); |
|
2744 |
|
2745 // Set search time range. The test expects no instances to be found so set |
|
2746 // the search time range to find all instances on May 26 from 10-11 AM. No |
|
2747 // matches should be found, there is 1 entry in the afternoon only. |
|
2748 aData.iStartDate = TDateTime( 2006, EMay, 25, 10, 0, 0, 0 ); |
|
2749 aData.iEndDate = TDateTime( 2006, EMay, 25, 11, 0, 0, 0 ); |
|
2750 } |
|
2751 |
|
2752 void CTestData::TestUpdateInstanceL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2753 { |
|
2754 //This test is to test that child entry's recurrence Id can still be fetched |
|
2755 //After a copy operation is performed. |
|
2756 |
|
2757 // Add Entries for Test |
|
2758 RPointerArray<CCalEntry> entriesToStore; |
|
2759 CleanupResetAndDestroyPushL(entriesToStore); |
|
2760 |
|
2761 //create an simple entry and store it to the file |
|
2762 _LIT8(KUid, "UID_xx"); |
|
2763 HBufC8* guid = KUid().AllocLC(); |
|
2764 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0); |
|
2765 CleanupStack::Pop(guid); |
|
2766 CleanupStack::PushL(entry); |
|
2767 entry->SetSummaryL(_L("random text")); |
|
2768 entriesToStore.AppendL(entry); |
|
2769 CleanupStack::Pop(entry); |
|
2770 |
|
2771 TTime startTime (TDateTime(2005, EJanuary, 7, 10, 0, 0, 0)); |
|
2772 TTime endTime (TDateTime(2005, EJanuary, 7, 11, 0, 0, 0)); |
|
2773 TCalTime calStartTime; |
|
2774 calStartTime.SetTimeLocalL(startTime); |
|
2775 TCalTime calEndTime; |
|
2776 calEndTime.SetTimeLocalL(endTime); |
|
2777 entry->SetStartAndEndTimeL(calStartTime, calEndTime); |
|
2778 |
|
2779 TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EDaily); |
|
2780 CleanupStack::PushL(rpt); |
|
2781 TTime daily1end(TDateTime(2005, EJanuary, 8, 10, 0, 0, 0)); |
|
2782 TCalTime rptendTime; |
|
2783 rptendTime.SetTimeLocalL(daily1end); |
|
2784 |
|
2785 rpt->SetDtStart(calStartTime); |
|
2786 rpt->SetUntil(rptendTime); |
|
2787 rpt->SetInterval(1); |
|
2788 entry->SetRRuleL(*rpt);//take a copy of the rule |
|
2789 CleanupStack::PopAndDestroy(rpt); |
|
2790 |
|
2791 TInt entriesStored(0); |
|
2792 aEntryView->StoreL(entriesToStore, entriesStored); |
|
2793 ASSERT(entriesStored == 1); |
|
2794 entriesToStore.ResetAndDestroy(); |
|
2795 |
|
2796 //create a child entry and store it |
|
2797 guid = KUid().AllocLC(); |
|
2798 TTime ttime (TDateTime(2005, EJanuary, 7, 10, 0, 0, 0)); |
|
2799 TCalTime recurrenceId; |
|
2800 recurrenceId.SetTimeUtcL(ttime); |
|
2801 entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodRequest, 0, recurrenceId, CalCommon::EThisOnly); |
|
2802 CleanupStack::Pop(guid); |
|
2803 CleanupStack::PushL(entry); |
|
2804 |
|
2805 // Set child entry time |
|
2806 TTime newStartDate (TDateTime(2005, EJanuary, 7, 11, 0, 0, 0)); |
|
2807 TTime newEndDate (TDateTime(2005, EJanuary, 8, 12, 0, 0, 0)); |
|
2808 |
|
2809 TCalTime newCalstartTime; |
|
2810 newCalstartTime.SetTimeUtcL(newStartDate); |
|
2811 TCalTime newCalendTime; |
|
2812 newCalendTime.SetTimeUtcL(newEndDate); |
|
2813 entry->SetStartAndEndTimeL(newCalstartTime, newCalendTime); |
|
2814 |
|
2815 entriesToStore.AppendL(entry); |
|
2816 aEntryView->StoreL(entriesToStore, entriesStored); |
|
2817 entriesToStore.ResetAndDestroy(); |
|
2818 CleanupStack::Pop(entry); |
|
2819 |
|
2820 //Fetch the entry |
|
2821 aEntryView->FetchL(KUid, entriesToStore); |
|
2822 ASSERT(entriesToStore.Count() == 2); //1 parent and 1 child so far |
|
2823 |
|
2824 //Following is the copy entry action. |
|
2825 // Allocate new guid for the entry. |
|
2826 entry = entriesToStore[1]; |
|
2827 |
|
2828 HBufC8* copyGuid = KUid().AllocLC(); |
|
2829 CCalEntry::TType type = entry->EntryTypeL(); |
|
2830 CCalEntry::TMethod method = entry->MethodL(); |
|
2831 TInt seqNumber = entry->SequenceNumberL(); |
|
2832 recurrenceId.SetTimeUtcL(Time::NullTTime());//daily1end); |
|
2833 |
|
2834 // Create a new child entry for the copy operation. |
|
2835 CCalEntry* newEntry = CCalEntry::NewL(type,copyGuid,method,seqNumber, recurrenceId, CalCommon::EThisOnly); |
|
2836 CleanupStack::Pop(copyGuid); |
|
2837 CleanupStack::PushL(newEntry); |
|
2838 // Set the summary to the new child. |
|
2839 |
|
2840 newEntry->SetSummaryL(_L("rename")); |
|
2841 |
|
2842 // Retrieve the GUID before copying. |
|
2843 TPtrC8 guidBeforeCopy = newEntry->UidL(); |
|
2844 ASSERT( guidBeforeCopy == KUid); |
|
2845 |
|
2846 // Copy the original entry to the new entry. |
|
2847 newEntry->CopyFromL(*entry, CCalEntry::ECopyAll); |
|
2848 |
|
2849 //Store the new child entry. |
|
2850 entriesToStore.ResetAndDestroy(); |
|
2851 entriesToStore.AppendL(newEntry); |
|
2852 CleanupStack::Pop(newEntry); |
|
2853 TInt numEntriesStored(0); |
|
2854 aEntryView->StoreL( entriesToStore, numEntriesStored ); |
|
2855 |
|
2856 //An instance should be found for the child |
|
2857 aData.iStartDate = TDateTime(2005, EJanuary, 7, 11, 0, 0, 0); |
|
2858 aData.iEndDate = TDateTime(2005, EJanuary, 7, 12, 0, 0, 0); |
|
2859 |
|
2860 aData.iTimes.AppendL(TTime(TDateTime(2005, EJanuary, 7, 11, 0, 0, 0))); // expected times |
|
2861 |
|
2862 CleanupStack::PopAndDestroy(&entriesToStore); |
|
2863 } |
|
2864 |
|
2865 void CTestData::CreateRDateBeforeDtStartTestL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2866 { |
|
2867 // to test defect DEF085855 |
|
2868 aData.iDescription.Copy(_L("Add an RDate to a child entry before the DTSTART date")); |
|
2869 |
|
2870 // add parent entry, repeating at 10:00 every Tuesday from 2 Feb 2008 for 5 occurences, RDate on Feb 8 at 09:00 |
|
2871 HBufC8* guid = KGUID1().AllocLC(); |
|
2872 CCalEntry* parent = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0); |
|
2873 CleanupStack::Pop(guid); |
|
2874 CleanupStack::PushL(parent); |
|
2875 |
|
2876 TCalTime startTime; |
|
2877 startTime.SetTimeLocalL(TDateTime(2008, EFebruary, 1, 10, 0, 0, 0)); |
|
2878 parent->SetStartAndEndTimeL(startTime, startTime); |
|
2879 |
|
2880 TCalRRule rule(TCalRRule::EWeekly); |
|
2881 rule.SetDtStart(startTime); |
|
2882 rule.SetCount(5); |
|
2883 rule.SetInterval(1); |
|
2884 |
|
2885 RArray<TDay> days; |
|
2886 CleanupClosePushL(days); |
|
2887 days.AppendL(ETuesday); |
|
2888 rule.SetByDay(days); |
|
2889 CleanupStack::PopAndDestroy(&days); |
|
2890 |
|
2891 parent->SetRRuleL(rule); |
|
2892 |
|
2893 RArray<TCalTime> rdateArray; |
|
2894 CleanupClosePushL(rdateArray); |
|
2895 TCalTime rdate; |
|
2896 rdate.SetTimeLocalL(TDateTime(2008, EFebruary, 7, 9, 0, 0, 0)); |
|
2897 rdateArray.AppendL(rdate); |
|
2898 parent->SetRDatesL(rdateArray); |
|
2899 CleanupStack::PopAndDestroy(&rdateArray); |
|
2900 |
|
2901 RArray<TCalTime> exceptionArray; |
|
2902 CleanupClosePushL(exceptionArray); |
|
2903 TCalTime exdate1, exdate2; |
|
2904 exdate1.SetTimeLocalL(TDateTime(2008, EFebruary, 7, 10, 0, 0, 0)); |
|
2905 exdate2.SetTimeLocalL(TDateTime(2008, EFebruary, 22, 10, 0, 0, 0)); |
|
2906 exceptionArray.AppendL(exdate1); |
|
2907 exceptionArray.AppendL(exdate2); |
|
2908 parent->SetExceptionDatesL(exceptionArray); |
|
2909 CleanupStack::PopAndDestroy(&exceptionArray); |
|
2910 |
|
2911 // add child entry to replace second instance of repeating parent's rule |
|
2912 // child entry has DTSTART on 2 March 2008 at 10:00 and RDate on 8 Feb 2008 at 10:00 |
|
2913 TCalTime recId; |
|
2914 recId.SetTimeLocalL(TDateTime(2008, EFebruary, 11, 10, 0, 0, 0)); |
|
2915 guid = KGUID1().AllocLC(); |
|
2916 CCalEntry* child = CCalEntry::NewL(CCalEntry::EEvent, guid, CCalEntry::EMethodNone, 0, recId, CalCommon::EThisAndFuture); |
|
2917 CleanupStack::Pop(guid); |
|
2918 CleanupStack::PushL(child); |
|
2919 |
|
2920 TCalTime chStartTime; |
|
2921 chStartTime.SetTimeLocalL(TDateTime(2008, EMarch, 1, 10, 0, 0, 0)); |
|
2922 child->SetStartAndEndTimeL(chStartTime, chStartTime); |
|
2923 |
|
2924 CleanupClosePushL(rdateArray); |
|
2925 rdate.SetTimeLocalL(TDateTime(2008, EFebruary, 7, 10, 0, 0, 0)); |
|
2926 rdateArray.AppendL(rdate); |
|
2927 child->SetRDatesL(rdateArray); |
|
2928 CleanupStack::PopAndDestroy(&rdateArray); |
|
2929 |
|
2930 RPointerArray<CCalEntry> entries; |
|
2931 CleanupClosePushL(entries); |
|
2932 TInt success = 0; |
|
2933 entries.AppendL(parent); |
|
2934 entries.AppendL(child); |
|
2935 aEntryView->StoreL(entries, success); |
|
2936 CleanupStack::PopAndDestroy(&entries); |
|
2937 |
|
2938 CleanupStack::PopAndDestroy(child); |
|
2939 CleanupStack::PopAndDestroy(parent); |
|
2940 |
|
2941 aData.iStartDate = TDateTime(2008, EJanuary, 0, 0, 0, 0, 0); // 1 Jan |
|
2942 aData.iEndDate = TDateTime(2008, EApril, 0, 0, 0, 0, 0); // 1 Apr |
|
2943 |
|
2944 // expected times: |
|
2945 // add parent entry, repeating at 10:00 every Tuesday from 2 Feb 2008 for 5 occurences, RDate on Feb 8 at 09:00 |
|
2946 aData.iTimes.AppendL(TTime(TDateTime(2008, EFebruary, 4, 10, 0, 0, 0))); // first instance of parent |
|
2947 aData.iTimes.AppendL(TTime(TDateTime(2008, EFebruary, 7, 9, 0, 0, 0))); // RDate of parent |
|
2948 aData.iTimes.AppendL(TTime(TDateTime(2008, EFebruary, 7, 10, 0, 0, 0))); // RDate of child |
|
2949 aData.iTimes.AppendL(TTime(TDateTime(2008, EMarch, 1, 10, 0, 0, 0))); // DTSTART of child |
|
2950 } |
|
2951 |
|
2952 void CTestData::CreateDstBoundaryTest1L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2953 { |
|
2954 aData.iDescription.Copy(_L("Add a repeating entry with an instance in the 'missing hour' that occurs when the clocks go forwards")); |
|
2955 |
|
2956 TCalTime dtStart; |
|
2957 dtStart.SetTimeLocalL(TDateTime(2006, EMarch, 24, 1, 30, 0, 0)); // 01:30 on 25th March 06, clocks change on 26th |
|
2958 |
|
2959 TCalRRule rule(TCalRRule::EDaily); |
|
2960 rule.SetDtStart(dtStart); |
|
2961 rule.SetInterval(1); |
|
2962 rule.SetCount(4); |
|
2963 |
|
2964 AddRuleL(rule, aEntryView, KGUID1); |
|
2965 |
|
2966 aData.iStartDate = TDateTime(2006, EMarch, 24, 0, 0, 0, 0); // 25 Mar |
|
2967 aData.iEndDate = TDateTime(2006, EApril, 0, 0, 0, 0, 0); // 1 Apr |
|
2968 |
|
2969 // expected times: |
|
2970 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 24, 1, 30, 0, 0))); // 01:30 on 25th March |
|
2971 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 25, 2, 30, 0, 0))); // 02:30 on 26th March (01:30 doesn't exist) |
|
2972 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 26, 1, 30, 0, 0))); // 01:30 on 27th March |
|
2973 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 27, 1, 30, 0, 0))); // 01:30 on 28th March |
|
2974 } |
|
2975 |
|
2976 void CTestData::CreateDstBoundaryTest2L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
2977 { |
|
2978 aData.iDescription.Copy(_L("Add a repeating entry with an instance at the start of the 'missing hour' that occurs when the clocks go forwards")); |
|
2979 |
|
2980 TCalTime dtStart; |
|
2981 dtStart.SetTimeLocalL(TDateTime(2006, EMarch, 24, 1, 0, 0, 0)); // 01:00 on 25th March 06, clocks change on 26th |
|
2982 |
|
2983 TCalRRule rule(TCalRRule::EDaily); |
|
2984 rule.SetDtStart(dtStart); |
|
2985 rule.SetInterval(1); |
|
2986 rule.SetCount(4); |
|
2987 |
|
2988 AddRuleL(rule, aEntryView, KGUID1); |
|
2989 |
|
2990 aData.iStartDate = TDateTime(2006, EMarch, 24, 0, 0, 0, 0); // 25 Mar |
|
2991 aData.iEndDate = TDateTime(2006, EApril, 0, 0, 0, 0, 0); // 1 Apr |
|
2992 |
|
2993 // expected times: |
|
2994 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 24, 1, 0, 0, 0))); // 01:00 on 25th March |
|
2995 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 25, 2, 0, 0, 0))); // 02:00 on 26th March (01:00 doesn't exist) |
|
2996 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 26, 1, 0, 0, 0))); // 01:00 on 27th March |
|
2997 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 27, 1, 0, 0, 0))); // 01:00 on 28th March |
|
2998 } |
|
2999 |
|
3000 void CTestData::CreateDstBoundaryTest3L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
3001 { |
|
3002 aData.iDescription.Copy(_L("Add a repeating entry with an instance at the end of the 'missing hour' that occurs when the clocks go forwards")); |
|
3003 |
|
3004 TCalTime dtStart; |
|
3005 dtStart.SetTimeLocalL(TDateTime(2006, EMarch, 24, 2, 0, 0, 0)); // 02:00 on 25th March 06, clocks change on 26th |
|
3006 |
|
3007 TCalRRule rule(TCalRRule::EDaily); |
|
3008 rule.SetDtStart(dtStart); |
|
3009 rule.SetInterval(1); |
|
3010 rule.SetCount(4); |
|
3011 |
|
3012 AddRuleL(rule, aEntryView, KGUID1); |
|
3013 |
|
3014 aData.iStartDate = TDateTime(2006, EMarch, 24, 0, 0, 0, 0); // 25 Mar |
|
3015 aData.iEndDate = TDateTime(2006, EApril, 0, 0, 0, 0, 0); // 1 Apr |
|
3016 |
|
3017 // expected times: |
|
3018 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 24, 2, 0, 0, 0))); // 02:00 on 25th March |
|
3019 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 25, 2, 0, 0, 0))); // 02:00 on 26th March |
|
3020 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 26, 2, 0, 0, 0))); // 02:00 on 27th March |
|
3021 aData.iTimes.AppendL(TTime(TDateTime(2006, EMarch, 27, 2, 0, 0, 0))); // 02:00 on 28th March |
|
3022 } |
|
3023 |
|
3024 void CTestData::CreateDstBoundaryTest4L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
3025 { |
|
3026 aData.iDescription.Copy(_L("Add a repeating entry with an instance in the 'repeated hour' that occurs when the clocks go backwards")); |
|
3027 |
|
3028 TCalTime dtStart; |
|
3029 dtStart.SetTimeLocalL(TDateTime(2006, EOctober, 27, 1, 30, 0, 0)); // 01:30 on 28th October 06, clocks change on 29th |
|
3030 |
|
3031 TCalRRule rule(TCalRRule::EDaily); |
|
3032 rule.SetDtStart(dtStart); |
|
3033 rule.SetInterval(1); |
|
3034 rule.SetCount(4); |
|
3035 |
|
3036 AddRuleL(rule, aEntryView, KGUID1); |
|
3037 |
|
3038 aData.iStartDate = TDateTime(2006, EOctober, 27, 0, 0, 0, 0); // 28 Oct |
|
3039 aData.iEndDate = TDateTime(2006, ENovember, 0, 0, 0, 0, 0); // 1 Nov |
|
3040 |
|
3041 // expected times: |
|
3042 aData.iTimes.AppendL(TTime(TDateTime(2006, EOctober, 27, 1, 30, 0, 0))); // 01:30 on 28th EOctober |
|
3043 aData.iTimes.AppendL(TTime(TDateTime(2006, EOctober, 28, 1, 30, 0, 0))); // 01:30 on 29th EOctober |
|
3044 aData.iTimes.AppendL(TTime(TDateTime(2006, EOctober, 29, 1, 30, 0, 0))); // 01:30 on 30th EOctober |
|
3045 aData.iTimes.AppendL(TTime(TDateTime(2006, EOctober, 30, 1, 30, 0, 0))); // 01:30 on 31st EOctober |
|
3046 } |
|
3047 |
|
3048 void CTestData::CreateDstBoundaryTest5L(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
3049 { |
|
3050 aData.iDescription.Copy(_L("Add an entry when the clocks change and start search from 1 second afterwards")); |
|
3051 |
|
3052 TCalTime dtStart, until; |
|
3053 dtStart.SetTimeUtcL(TDateTime(2015, EMarch, 28, 1, 0, 0, 0)); // 01:00 on 29th March 2015, when clocks change |
|
3054 until.SetTimeUtcL(TDateTime(2016, EDecember, 19, 0, 0, 0, 0)); // December 2016 |
|
3055 |
|
3056 TCalRRule rule(TCalRRule::EDaily); |
|
3057 rule.SetDtStart(dtStart); |
|
3058 rule.SetInterval(1); |
|
3059 rule.SetUntil(until); |
|
3060 |
|
3061 AddRuleL(rule, aEntryView, KGUID1); |
|
3062 |
|
3063 aData.iStartDate = TDateTime(2015, EMarch, 28, 2, 0, 1, 0); // 02:00:01 on 29th March 2015 local |
|
3064 aData.iEndDate = TDateTime(2015, EMarch, 28, 5, 30, 0, 0); // 05:30:00 on 29th March 2015 local |
|
3065 |
|
3066 // expected times: |
|
3067 aData.iTimes.AppendL(TTime(TDateTime(2015, EMarch, 28, 2, 0, 0, 0))); // 02:00 on 29th March 2015 local |
|
3068 } |
|
3069 |
|
3070 void CTestData::ExcludeInstanceAdjoiningRangeTestNonRepeatL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
3071 { |
|
3072 aData.iDescription.Copy(_L("Test excluding non-repeating instances that adjoin the search range")); |
|
3073 |
|
3074 aData.iStartDate = TDateTime(2015, EApril, 27, 0, 0, 0, 0); |
|
3075 aData.iEndDate = TDateTime(2015, EApril, 28, 0, 0, 0, 0); |
|
3076 |
|
3077 aData.iFilter |= CalCommon::EExcludeInstanceAdjoiningRange; |
|
3078 |
|
3079 CCalEntry* entry1 = CreateEntryLC(CCalEntry::EAppt, _L8("ExcludeInstanceAdjoiningRange1"), aData.iStartDate - TTimeIntervalHours(1), aData.iStartDate); |
|
3080 CCalEntry* entry2 = CreateEntryLC(CCalEntry::EAppt, _L8("ExcludeInstanceAdjoiningRange2"), aData.iStartDate, aData.iStartDate); |
|
3081 CCalEntry* entry3 = CreateEntryLC(CCalEntry::EAppt, _L8("ExcludeInstanceAdjoiningRange3"), aData.iEndDate, aData.iEndDate); |
|
3082 CCalEntry* entry4 = CreateEntryLC(CCalEntry::EAppt, _L8("ExcludeInstanceAdjoiningRange4"), aData.iEndDate, aData.iEndDate + TTimeIntervalHours(1)); |
|
3083 |
|
3084 RPointerArray<CCalEntry> entryList; |
|
3085 CleanupClosePushL(entryList); |
|
3086 entryList.AppendL(entry1); |
|
3087 entryList.AppendL(entry2); |
|
3088 entryList.AppendL(entry3); |
|
3089 entryList.AppendL(entry4); |
|
3090 TInt success(0); |
|
3091 aEntryView->StoreL(entryList, success); // takes ownership |
|
3092 CleanupStack::PopAndDestroy(&entryList); |
|
3093 CleanupStack::PopAndDestroy(entry4); |
|
3094 CleanupStack::PopAndDestroy(entry3); |
|
3095 CleanupStack::PopAndDestroy(entry2); |
|
3096 CleanupStack::PopAndDestroy(entry1); |
|
3097 |
|
3098 // Expected times: |
|
3099 // With EExcludeInstanceAdjoiningRange set we should only expect the instance that starts and ends on the start range |
|
3100 aData.iTimes.AppendL(aData.iStartDate); |
|
3101 } |
|
3102 |
|
3103 void CTestData::ExcludeInstanceAdjoiningRangeTestRepeatL(CTestDataStruct& aData, CCalEntryView* aEntryView) |
|
3104 { |
|
3105 aData.iDescription.Copy(_L("Test excluding repeating instances that adjoin the search range")); |
|
3106 |
|
3107 aData.iStartDate = TDateTime(2015, EApril, 27, 0, 0, 0, 0); |
|
3108 aData.iEndDate = TDateTime(2015, EApril, 28, 0, 0, 0, 0); |
|
3109 |
|
3110 aData.iFilter |= CalCommon::EExcludeInstanceAdjoiningRange; |
|
3111 |
|
3112 TCalRRule rule(TCalRRule::EDaily); |
|
3113 rule.SetInterval(2); |
|
3114 rule.SetCount(3); |
|
3115 |
|
3116 TCalTime dtStart; |
|
3117 |
|
3118 dtStart.SetTimeLocalL(aData.iStartDate - TTimeIntervalHours(1)); |
|
3119 rule.SetDtStart(dtStart); |
|
3120 AddRuleL(rule, aEntryView, _L8("ExcludeInstanceAdjoiningRange1"), CCalEntry::EEvent, TTimeIntervalHours(1)); |
|
3121 |
|
3122 dtStart.SetTimeLocalL(aData.iStartDate); |
|
3123 rule.SetDtStart(dtStart); |
|
3124 AddRuleL(rule, aEntryView, _L8("ExcludeInstanceAdjoiningRange2"), CCalEntry::EEvent, TTimeIntervalHours(0)); |
|
3125 |
|
3126 dtStart.SetTimeLocalL(aData.iEndDate); |
|
3127 rule.SetDtStart(dtStart); |
|
3128 AddRuleL(rule, aEntryView, _L8("ExcludeInstanceAdjoiningRange3"), CCalEntry::EEvent, TTimeIntervalHours(0)); |
|
3129 |
|
3130 dtStart.SetTimeLocalL(aData.iEndDate); |
|
3131 rule.SetDtStart(dtStart); |
|
3132 AddRuleL(rule, aEntryView, _L8("ExcludeInstanceAdjoiningRange4"), CCalEntry::EEvent, TTimeIntervalHours(1)); |
|
3133 |
|
3134 // Expected times: |
|
3135 // With EExcludeInstanceAdjoiningRange set we should only expect the instance that starts and ends on the start range |
|
3136 aData.iTimes.AppendL(aData.iStartDate); |
|
3137 } |
|
3138 |
|
3139 void CTestData::TestTodoOnMaxDateL( CTestDataStruct& aData, CCalEntryView* aEntryView ) |
|
3140 { |
|
3141 aData.iDescription.Copy( _L( "Create Todo's (dated and undated) on Max Calendar Date,and find instances, There should not be any duplicate instances" ) ); |
|
3142 |
|
3143 TTime time; |
|
3144 time.HomeTime(); |
|
3145 // Setting the seconds and microseconds to 0, Please refer to NOTE in CDummyCalendarApp::ExtractFromDatabaseL() |
|
3146 // Making sure the code below and the result check are done in the same minute by setting the time at the start |
|
3147 // of the current minute |
|
3148 TDateTime dateTime = time.DateTime(); |
|
3149 dateTime.SetMicroSecond(0); |
|
3150 dateTime.SetSecond(0); |
|
3151 TTime newTime(dateTime); |
|
3152 User::SetHomeTime(newTime); |
|
3153 RPointerArray<CCalEntry> entryList; |
|
3154 CleanupResetAndDestroyPushL( entryList ); |
|
3155 |
|
3156 // Create todo entry that on: Dec 31 2100 |
|
3157 TTime startTime( TDateTime( 2100, EDecember, 30, 0, 0, 0, 0 ) ); |
|
3158 CCalEntry* entry = CreateEntryLC( CCalEntry::ETodo, KGUID1(), startTime,startTime); |
|
3159 entryList.AppendL( entry ); |
|
3160 CleanupStack::Pop( entry ); |
|
3161 |
|
3162 // Create todo entry that on: Dec 31 2100 |
|
3163 entry = CreateEntryLC( CCalEntry::ETodo, KGUID2(), startTime,startTime); |
|
3164 entryList.AppendL( entry ); |
|
3165 CleanupStack::Pop( entry ); |
|
3166 |
|
3167 // Create an undated todo entry |
|
3168 TTime nullTime = Time::NullTTime(); |
|
3169 entry = CreateEntryLC( CCalEntry::ETodo, KGUID3(), nullTime, nullTime); |
|
3170 entryList.AppendL( entry ); |
|
3171 CleanupStack::Pop( entry ); |
|
3172 |
|
3173 // Create an undated todo entry |
|
3174 entry = CreateEntryLC( CCalEntry::ETodo, KGUID4(), nullTime, nullTime); |
|
3175 entryList.AppendL( entry ); |
|
3176 CleanupStack::Pop( entry ); |
|
3177 |
|
3178 TInt success = 0; |
|
3179 aEntryView->StoreL( entryList, success ); |
|
3180 // Store the entry |
|
3181 CleanupStack::PopAndDestroy( &entryList ); |
|
3182 |
|
3183 // Set search time range to Min and Max time. |
|
3184 aData.iStartDate = TCalTime::MinTime().DateTime(); //Search Range |
|
3185 aData.iEndDate = TCalTime::MaxTime().DateTime(); |
|
3186 aData.iTimes.AppendL(TTime(TDateTime( 2100, EDecember, 30, 0, 0, 0, 0 ))); // expected times |
|
3187 aData.iTimes.AppendL(TTime(TDateTime( 2100, EDecember, 30, 0, 0, 0, 0 ))); // expected times |
|
3188 aData.iTimes.AppendL(TTime(dateTime)); // expected times |
|
3189 aData.iTimes.AppendL(TTime(dateTime)); // expected times |
|
3190 } |
|
3191 |