|
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_gsentry_testdata.h" |
|
17 |
|
18 #include <calentryview.h> |
|
19 #include <calinstance.h> |
|
20 #include <calrrule.h> |
|
21 #include <calalarm.h> |
|
22 |
|
23 template <class T> |
|
24 class CleanupResetAndDestroy |
|
25 { |
|
26 public: |
|
27 inline static void PushL(T& aRef); |
|
28 private: |
|
29 static void ResetAndDestroy(TAny *aPtr); |
|
30 }; |
|
31 |
|
32 template <class T> inline void CleanupResetAndDestroyPushL(T& aRef); |
|
33 |
|
34 |
|
35 template <class T> inline void CleanupResetAndDestroy<T>::PushL(T& aRef) |
|
36 { |
|
37 CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef)); |
|
38 } |
|
39 |
|
40 template <class T> void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr) |
|
41 { |
|
42 (static_cast<T*>(aPtr))->ResetAndDestroy(); |
|
43 } |
|
44 |
|
45 |
|
46 template <class T> inline void CleanupResetAndDestroyPushL(T& aRef) |
|
47 { |
|
48 CleanupResetAndDestroy<T>::PushL(aRef); |
|
49 } |
|
50 |
|
51 |
|
52 TTestDataStruct::TTestDataStruct() |
|
53 { |
|
54 iFilter = CalCommon::EIncludeAll; |
|
55 iSearchBehaviour = CalCommon::EExactTextSearch; |
|
56 iFunction = NULL; |
|
57 iSearchString = NULL; |
|
58 } |
|
59 |
|
60 TTestDataStruct::~TTestDataStruct() |
|
61 { |
|
62 iTimes.Reset(); |
|
63 delete iFunction; |
|
64 delete iSearchString; |
|
65 iGuidsToExtract.Close(); |
|
66 iRecIds.Reset(); |
|
67 } |
|
68 |
|
69 TTestDataStruct* CTestData::GetTestDataL(TTestNumber aTestNumber, CCalInstanceView* aInstanceView, CCalEntryView* aEntryView, TBool aFloating, TBool aSummerTime) |
|
70 { |
|
71 TTestDataStruct* testData = new (ELeave) TTestDataStruct(); |
|
72 testData->iTimes.Reset(); |
|
73 testData->iRecIds.Reset(); |
|
74 switch (aTestNumber) |
|
75 { |
|
76 |
|
77 case ECreateParent: |
|
78 { |
|
79 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
80 testData->iDescription.Copy(_L("Entry Test: ECreateParent\n")); |
|
81 testData->iTestType = TTestDataStruct::EEntryTest; |
|
82 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
83 } |
|
84 break; |
|
85 case ECreateAndDeleteParent: |
|
86 { |
|
87 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
88 testData->iDescription.Copy(_L("Entry Test: ECreateAndDeleteParent, delete using DeleteL(const CDesC8Array&)\n")); |
|
89 testData->iTestType = TTestDataStruct::EEntryTest; |
|
90 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
91 DeleteParentGsEntryL(aEntryView, KGUID1()); |
|
92 } |
|
93 break; |
|
94 case ECreateSameParentTwice: |
|
95 { |
|
96 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
97 testData->iDescription.Copy(_L("Entry Test: ECreateSameParentTwice, create another Parent with the same Guid - 2nd should replace 1st\n")); |
|
98 testData->iTestType = TTestDataStruct::EEntryTest; |
|
99 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
100 |
|
101 delete testData; |
|
102 TTestDataStruct* testData1 = new (ELeave) TTestDataStruct(); |
|
103 testData1->iTimes.Reset(); |
|
104 testData1->iRecIds.Reset(); |
|
105 testData1->iGuidsToExtract.AppendL(KGUID1()); |
|
106 testData1->iDescription.Copy(_L("Entry Test: ECreateSameParentTwice, Create Parent, then create another with the same Guid - 2nd should replace 1st\n")); |
|
107 testData1->iTestType = TTestDataStruct::EEntryTest; |
|
108 CreateParentGsEntryL(GetDailyTestData1L(*testData1), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
109 testData = testData1; |
|
110 } |
|
111 break; |
|
112 |
|
113 case ECreateAndSingleDeleteParent: |
|
114 { |
|
115 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
116 testData->iDescription.Copy(_L("Entry Test: ECreateAndSingleDeleteParent, delete using DeleteL(CCalEntry&)\n")); |
|
117 testData->iTestType = TTestDataStruct::EEntryTest; |
|
118 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
119 SingleDeleteParentGsEntryL(aEntryView, KGUID1()); |
|
120 } |
|
121 break; |
|
122 |
|
123 case ECreateParentAnd1Child: |
|
124 { |
|
125 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
126 testData->iDescription.Copy(_L("Entry Test: ECreateParentAnd1Child\n")); |
|
127 testData->iTestType = TTestDataStruct::EEntryTest; |
|
128 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
129 CreateChildGsEntryL(testData, 4, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
130 } |
|
131 break; |
|
132 |
|
133 |
|
134 case ECreateParentAnd2Child: |
|
135 { |
|
136 testData->iGuidsToExtract.AppendL(KGUID2()); |
|
137 testData->iDescription.Copy(_L("Entry Test: ECreateParentAnd2Child\n")); |
|
138 testData->iTestType = TTestDataStruct::EEntryTest; |
|
139 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID2(), CCalEntry::EAppt, aFloating); |
|
140 CreateChildGsEntryL(testData, 4, aEntryView, KGUID2(), CCalEntry::EAppt, aFloating); |
|
141 CreateChildGsEntryL(testData, 7, aEntryView, KGUID2(), CCalEntry::EAppt, aFloating); |
|
142 } |
|
143 break; |
|
144 |
|
145 case EAddMultipleEntries: |
|
146 { |
|
147 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
148 testData->iGuidsToExtract.AppendL(KGUID2()); |
|
149 testData->iGuidsToExtract.AppendL(KGUID3()); |
|
150 testData->iDescription.Copy(_L("Entry Test: EAddMultipleEntries, create multiple Parent GS entries\n")); |
|
151 testData->iTestType = TTestDataStruct::EEntryTest; |
|
152 AddMultipleEntriesL(GetDailyTestData1L(*testData), aEntryView, CCalEntry::EAppt, aFloating); |
|
153 } |
|
154 break; |
|
155 |
|
156 |
|
157 case EReplaceExistingChild: |
|
158 { |
|
159 testData->iGuidsToExtract.AppendL(KGUID2()); |
|
160 testData->iDescription.Copy(_L("Entry Test: EReplaceExistingChild, Add an already existing child (should replace it)\n")); |
|
161 testData->iTestType = TTestDataStruct::EEntryTest; |
|
162 CreateParentGsEntryL(GetDailyTestData1L(*testData, aSummerTime), aEntryView, KGUID2(), CCalEntry::EAppt, aFloating); |
|
163 CreateChildGsEntryL(testData, 4, aEntryView, KGUID2(), CCalEntry::EAppt, aFloating); |
|
164 CreateChildGsEntryL(testData, 7, aEntryView, KGUID2(), CCalEntry::EAppt, aFloating); |
|
165 CreateChildGsEntryL(testData, 4, aEntryView, KGUID2(), CCalEntry::EAppt, aFloating); // Adding identical child should replace the existing one |
|
166 } |
|
167 break; |
|
168 |
|
169 case EGetInstancesParentOnly: |
|
170 { |
|
171 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
172 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentOnly\n")); |
|
173 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
174 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
175 |
|
176 // expected times: |
|
177 testData->iTimes.Reset(); |
|
178 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 5, 0, 0, 0, 0))); // 6 March |
|
179 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 6, 0, 0, 0, 0))); // 7 March |
|
180 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 7, 0, 0, 0, 0))); // 8 March |
|
181 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 9 March |
|
182 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 9, 0, 0, 0, 0))); // 10 March |
|
183 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 10, 0, 0, 0, 0))); // 11 March |
|
184 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 11, 0, 0, 0, 0))); // 12 March |
|
185 } |
|
186 break; |
|
187 |
|
188 case EGetInstancesParentWithExceptionDates: |
|
189 // Set some exception dates on the parent |
|
190 { |
|
191 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
192 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithExceptionDates, Parent with some exception dates\n")); |
|
193 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
194 CreateParentGsEntryWithExceptionsL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
195 |
|
196 // expected times: |
|
197 testData->iTimes.Reset(); |
|
198 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 6, 0, 0, 0, 0))); // 7 March |
|
199 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 7, 0, 0, 0, 0))); // 8 March |
|
200 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 9, 0, 0, 0, 0))); // 10 March |
|
201 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 10, 0, 0, 0, 0))); // 11 March |
|
202 } |
|
203 break; |
|
204 |
|
205 case EGetInstancesParentWithSporadicDates: |
|
206 // Set some sporadic dates on the parent |
|
207 { |
|
208 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
209 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithSporadicDates, Parent with some sporadic dates\n")); |
|
210 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
211 CreateParentGsEntryWithSporadicsL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
212 |
|
213 // expected times: |
|
214 testData->iTimes.Reset(); |
|
215 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 2, 0, 0, 0, 0))); // 3 March |
|
216 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 5, 0, 0, 0, 0))); // 6 March |
|
217 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 6, 0, 0, 0, 0))); // 7 March |
|
218 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 7, 0, 0, 0, 0))); // 8 March |
|
219 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 9 March |
|
220 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 9, 0, 0, 0, 0))); // 10 March |
|
221 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 10, 0, 0, 0, 0))); // 11 March |
|
222 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 11, 0, 0, 0, 0))); // 12 March |
|
223 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 12, 0, 0, 0, 0))); // 13 March |
|
224 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 18, 0, 0, 0, 0))); // 19 March |
|
225 } |
|
226 break; |
|
227 |
|
228 case EGetInstancesParentAnd1ChildException: |
|
229 // Child specifies a modification to a date using RecId and Start/End date |
|
230 { |
|
231 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
232 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentAnd1ChildException, Parent and 1 Child exception\n")); |
|
233 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
234 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
235 CreateChildExceptionGsEntryL(testData, 4, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
236 |
|
237 // expected times: |
|
238 testData->iTimes.Reset(); |
|
239 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 5, 0, 0, 0, 0))); // 6 March |
|
240 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 6, 0, 0, 0, 0))); // 7 March |
|
241 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 7, 0, 0, 0, 0))); // 8 March |
|
242 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 9, 0, 0, 0, 0))); // 10 March |
|
243 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 10, 0, 0, 0, 0))); // 11 March |
|
244 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 11, 0, 0, 0, 0))); // 12 March |
|
245 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 18, 0, 0, 0, 0))); // 19 March |
|
246 } |
|
247 break; |
|
248 |
|
249 case EGetInstancesParentAnd1ChildRule: |
|
250 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef |
|
251 { |
|
252 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
253 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentAnd1ChildRule, Parent weekly RRule and Child with RRule (range=This+Future)\n")); |
|
254 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
255 if (aFloating) |
|
256 { |
|
257 CreateParentGsEntryL(GetWeeklyTestData1FloatingL(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
258 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 2, CalCommon::EThisAndFuture, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
259 } |
|
260 else |
|
261 { |
|
262 CreateParentGsEntryL(GetWeeklyTestData1L(*testData), aEntryView, KGUID1()); |
|
263 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 2, CalCommon::EThisAndFuture, aEntryView, KGUID1()); |
|
264 } |
|
265 |
|
266 // expected times: |
|
267 testData->iTimes.Reset(); |
|
268 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 9 March |
|
269 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
270 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
271 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
272 } |
|
273 break; |
|
274 |
|
275 case EGetInstancesParentAnd1ChildRuleMultiFetch: |
|
276 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef |
|
277 { |
|
278 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
279 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentAnd1ChildRuleMultiFetch, Parent weekly RRule and Child with RRule (range=This+Future)\n")); |
|
280 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
281 if (aFloating) |
|
282 { |
|
283 CreateParentGsEntryL(GetWeeklyTestData1FloatingL(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
284 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 2, CalCommon::EThisAndFuture, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
285 } |
|
286 else |
|
287 { |
|
288 CreateParentGsEntryL(GetWeeklyTestData1L(*testData), aEntryView, KGUID1()); |
|
289 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 2, CalCommon::EThisAndFuture, aEntryView, KGUID1()); |
|
290 } |
|
291 |
|
292 DoMultipleFetchAndStoreTestRuleChildL(testData, aEntryView, KGUID1(), 2); |
|
293 |
|
294 // expected times: |
|
295 testData->iTimes.Reset(); |
|
296 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 9 March |
|
297 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
298 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
299 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
300 } |
|
301 break; |
|
302 |
|
303 case ETestGetSetMethods: |
|
304 { |
|
305 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
306 testData->iTestType = TTestDataStruct::EEntryTest; |
|
307 testData->iDescription.Copy(_L("Entry Test: ETestGetSetMethods\n")); |
|
308 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
309 CreateChildGsEntryL(testData, 4, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
310 if (aFloating) |
|
311 { |
|
312 TestSetGetMethodsFloatingL(aEntryView,KGUID1()); |
|
313 } |
|
314 else |
|
315 { |
|
316 TestSetGetMethodsL(aEntryView,KGUID1()); |
|
317 } |
|
318 } |
|
319 break; |
|
320 |
|
321 case ETestUpdate: |
|
322 { |
|
323 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
324 testData->iTestType = TTestDataStruct::EEntryTest; |
|
325 testData->iDescription.Copy(_L("Entry Test: ETestUpdate\n")); |
|
326 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
327 CreateChildGsEntryL(testData, 7, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
328 TRAP_IGNORE(TestUpdateL(aEntryView,KGUID1())); |
|
329 } |
|
330 break; |
|
331 |
|
332 case EGetInstancesParentWithExceptionsAnd1ChildRuleThisAndFuture: |
|
333 { |
|
334 // Parent has rpt rule plus exceptions. |
|
335 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef. |
|
336 testData->iGuidsToExtract.Reset(); |
|
337 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
338 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithExceptionsAnd1ChildRuleThisAndFuture, Parent,weekly rpt rule plus some exception and 1 Child with RRule (This+Future)\n")); |
|
339 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
340 CreateWeeklyParentGsEntryWithExceptionsRdatesL(*testData, aEntryView, KGUID1(), EException, CCalEntry::EAppt, aFloating); |
|
341 if (aFloating) |
|
342 { |
|
343 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 2, CalCommon::EThisAndFuture, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
344 } |
|
345 else |
|
346 { |
|
347 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 2, CalCommon::EThisAndFuture, aEntryView, KGUID1()); |
|
348 } |
|
349 |
|
350 // Expected Instances if no parameters are changed: 8 April, 15, 22 |
|
351 testData->iTimes.Reset(); |
|
352 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
353 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
354 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
355 } |
|
356 break; |
|
357 |
|
358 case EGetInstancesParentWithExceptionsRDatesAnd1ChildRuleThisAndFuture: |
|
359 { |
|
360 // Parent has rpt rule plus exceptions and sporadic rdates. |
|
361 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef. |
|
362 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
363 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithExceptionsRDatesAnd1ChildRuleThisAndFuture, Parent,weekly rpt rule, some exceptions & rdates and 1 Child with RRule (This+Future)\n")); |
|
364 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
365 CreateWeeklyParentGsEntryWithExceptionsRdatesL(*testData, aEntryView, KGUID1(), EExceptionAndRDate, CCalEntry::EAppt, aFloating); |
|
366 if (aFloating) |
|
367 { |
|
368 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 5, CalCommon::EThisAndFuture, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
369 } |
|
370 else |
|
371 { |
|
372 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 5, CalCommon::EThisAndFuture, aEntryView, KGUID1()); |
|
373 } |
|
374 |
|
375 // Expected Instances if no parameters are changed: 16March, 17, 24, 8April, 15, 22 |
|
376 testData->iTimes.Reset(); |
|
377 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 15, 0, 0, 0, 0))); // 16 March |
|
378 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 16, 0, 0, 0, 0))); // 17 March |
|
379 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 23, 0, 0, 0, 0))); // 24 March |
|
380 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
381 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
382 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
383 } |
|
384 break; |
|
385 |
|
386 case EGetInstancesParentWithExceptionsRDatesNonRptChildsAnd1ChildRuleThisAndFuture: |
|
387 { |
|
388 // Parent has rpt rule plus exceptions, sporadic rdates and non-repeating child entry. |
|
389 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef. |
|
390 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
391 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithExceptionsRDatesNonRptChildsAnd1ChildRuleThisAndFuture, Parent,weekly rpt rule, some exceptions & rdates and 1 Child with RRule (This+Future)\n")); |
|
392 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
393 CreateWeeklyParentGsEntryWithExceptionsRdatesL(*testData, aEntryView, KGUID1(), EExceptionAndRDate, CCalEntry::EAppt, aFloating); |
|
394 CreateChildExceptionGsEntryL(testData, 2, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
395 if (aFloating) |
|
396 { |
|
397 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 5, CalCommon::EThisAndFuture, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
398 } |
|
399 else |
|
400 { |
|
401 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 5, CalCommon::EThisAndFuture, aEntryView, KGUID1()); |
|
402 } |
|
403 |
|
404 // Expected Instances if no parameters are changed: 17March, 19, 24, 8April, 15, 22 |
|
405 testData->iTimes.Reset(); |
|
406 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 16, 0, 0, 0, 0))); // 17 March |
|
407 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 18, 0, 0, 0, 0))); // 19 March |
|
408 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 23, 0, 0, 0, 0))); // 24 March |
|
409 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
410 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
411 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
412 } |
|
413 break; |
|
414 |
|
415 case EGetInstancesParentWithExceptionsAnd1ChildRuleThisAndPrior: |
|
416 { |
|
417 // Parent has rpt rule plus exceptions. |
|
418 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef. |
|
419 testData->iGuidsToExtract.Reset(); |
|
420 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
421 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithExceptionsAnd1ChildRuleThisAndPrior, Parent,weekly rpt rule plus some exception and 1 Child with RRule (This+Prior)\n")); |
|
422 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
423 CreateWeeklyParentGsEntryWithExceptionsRdatesL(*testData, aEntryView, KGUID1(), EException, CCalEntry::EAppt, aFloating); |
|
424 if (aFloating) |
|
425 { |
|
426 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 2, CalCommon::EThisAndPrior, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
427 } |
|
428 else |
|
429 { |
|
430 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 2, CalCommon::EThisAndPrior, aEntryView, KGUID1()); |
|
431 } |
|
432 |
|
433 // Expected Instances if no parameters are changed: 6April, 8, 13, 15, 20, 22 |
|
434 testData->iTimes.Reset(); |
|
435 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 5, 0, 0, 0, 0))); // 6 April |
|
436 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
437 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // 13 April |
|
438 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
439 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 19, 0, 0, 0, 0))); // 20 April |
|
440 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
441 } |
|
442 break; |
|
443 |
|
444 case EGetInstancesParentWithExceptionsRDatesAnd1ChildRuleThisAndPrior: |
|
445 { |
|
446 // Parent has rpt rule plus exceptions and sporadic rdates. |
|
447 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef. |
|
448 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
449 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithExceptionsRDatesAnd1ChildRuleThisAndPrior, Parent,weekly rpt rule, some exceptions & rdates and 1 Child with RRule (This+Prior)\n")); |
|
450 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
451 CreateWeeklyParentGsEntryWithExceptionsRdatesL(*testData, aEntryView, KGUID1(), EExceptionAndRDate, CCalEntry::EAppt, aFloating); |
|
452 if (aFloating) |
|
453 { |
|
454 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 5, CalCommon::EThisAndPrior, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
455 } |
|
456 else |
|
457 { |
|
458 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 5, CalCommon::EThisAndPrior, aEntryView, KGUID1()); |
|
459 } |
|
460 |
|
461 // Expected Instances if no parameters are changed: 8April, 13, 15, 20, 22 |
|
462 testData->iTimes.Reset(); |
|
463 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
464 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // 13 April |
|
465 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
466 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 19, 0, 0, 0, 0))); // 20 April |
|
467 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
468 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 23, 0, 0, 0, 0))); // 24 April |
|
469 } |
|
470 break; |
|
471 |
|
472 case EGetInstancesParentWithExceptionsRDatesNonRptChildsAnd1ChildRuleThisAndPrior: |
|
473 { |
|
474 // Parent has rpt rule plus exceptions, sporadic rdates and non-repeating child entry. |
|
475 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef. |
|
476 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
477 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithExceptionsRDatesNonRptChildsAnd1ChildRuleThisAndPrior, Parent,weekly rpt rule, some exceptions & rdates and 1 Child with RRule (This+Prior)\n")); |
|
478 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
479 CreateWeeklyParentGsEntryWithExceptionsRdatesL(*testData, aEntryView, KGUID1(), EExceptionAndRDate, CCalEntry::EAppt, aFloating); |
|
480 CreateChildExceptionGsEntryL(testData, 2, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
481 CreateChildExceptionGsEntry_1L(testData, 7, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
482 if (aFloating) |
|
483 { |
|
484 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 5, CalCommon::EThisAndPrior, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
485 } |
|
486 else |
|
487 { |
|
488 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 5, CalCommon::EThisAndPrior, aEntryView, KGUID1()); |
|
489 } |
|
490 |
|
491 // Expected Instances if no parameters are changed: 8April, 13, 15, 18, 22 |
|
492 testData->iTimes.Reset(); |
|
493 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
494 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // 13 April |
|
495 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
496 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 17, 0, 0, 0, 0))); // 18 April |
|
497 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
498 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 23, 0, 0, 0, 0))); // 24 April |
|
499 } |
|
500 break; |
|
501 |
|
502 /* |
|
503 * This tests adding a second child-rule entry to a parent. |
|
504 * Adding a second child-rule entry is dis-allowed and causes a Leave. |
|
505 * However this test is commented out as the TRAPD below was for some reason not catching the Leave. |
|
506 */ |
|
507 case EGetInstancesParentWithExceptionsAnd2ChildRuleThisAndFuture: |
|
508 { |
|
509 // Parent has rpt rule plus exceptions. |
|
510 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef. |
|
511 testData->iGuidsToExtract.Reset(); |
|
512 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
513 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithExceptionsAnd2ChildRuleThisAndFuture, Parent,weekly rpt rule plus some exception and 2 Child with RRule\n")); |
|
514 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
515 CreateWeeklyParentGsEntryWithExceptionsRdatesL(*testData, aEntryView, KGUID1(), EException, CCalEntry::EAppt, aFloating); |
|
516 if (aFloating) |
|
517 { |
|
518 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 2, CalCommon::EThisAndPrior, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
519 } |
|
520 else |
|
521 { |
|
522 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 2, CalCommon::EThisAndPrior, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
523 } |
|
524 |
|
525 |
|
526 // CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 4, CalCommon::EThisAndFuture, aEntryView, KGUID1()); |
|
527 TCalRRule* rule = NULL; |
|
528 if (aFloating) |
|
529 { |
|
530 rule = GetWeeklyTestDataModification1FloatingL(*testData); |
|
531 } |
|
532 else |
|
533 { |
|
534 rule = GetWeeklyTestDataModification1L(*testData); |
|
535 } |
|
536 TRAP_IGNORE( |
|
537 CreateChildRRuleGsEntryL(rule, testData, 4, CalCommon::EThisAndFuture, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
538 ); |
|
539 |
|
540 // Expected Instances if no parameters are changed: 6April, 8, 13, 15, 20, 22 |
|
541 testData->iTimes.Reset(); |
|
542 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 5, 0, 0, 0, 0))); // 6 April |
|
543 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 7, 0, 0, 0, 0))); // 8 April |
|
544 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // 13 April |
|
545 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 14, 0, 0, 0, 0))); // 15 April |
|
546 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 19, 0, 0, 0, 0))); // 20 April |
|
547 testData->iTimes.Append(TTime(TDateTime(2005, EApril, 21, 0, 0, 0, 0))); // 22 April |
|
548 |
|
549 } |
|
550 break; |
|
551 |
|
552 case EGetInstancesParentWithRDateBeforeRRule: |
|
553 { |
|
554 testData->iGuidsToExtract.Reset(); |
|
555 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
556 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithRDateBeforeRRule\n")); |
|
557 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
558 CreateWeeklyParentGsEntryWithRDateRRuleL(*testData, aEntryView, KGUID1(), ERDateBeforeRRule, CCalEntry::EAppt, aFloating); |
|
559 |
|
560 // Expected Instances |
|
561 testData->iTimes.Reset(); |
|
562 testData->iTimes.Append(TTime(TDateTime(2005, EDecember, 11, 9, 0, 0, 0))); // 12 Dec |
|
563 testData->iTimes.Append(TTime(TDateTime(2005, EDecember, 13, 10, 0, 0, 0))); // 14 Dec |
|
564 testData->iTimes.Append(TTime(TDateTime(2005, EDecember, 14, 10, 0, 0, 0))); // 15 Dec |
|
565 testData->iTimes.Append(TTime(TDateTime(2005, EDecember, 15, 10, 0, 0, 0))); // 16 Dec |
|
566 } |
|
567 break; |
|
568 |
|
569 case EGetInstancesParentWithRDateAfterRRule: |
|
570 { |
|
571 testData->iGuidsToExtract.Reset(); |
|
572 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
573 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentWithRDateAfterRRule\n")); |
|
574 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
575 CreateWeeklyParentGsEntryWithRDateRRuleL(*testData, aEntryView, KGUID1(), ERDateAfterRRule, CCalEntry::EAppt, aFloating); |
|
576 |
|
577 // Expected Instances |
|
578 testData->iTimes.Reset(); |
|
579 testData->iTimes.Append(TTime(TDateTime(2005, EDecember, 13, 10, 0, 0, 0))); // 14 Dec |
|
580 testData->iTimes.Append(TTime(TDateTime(2005, EDecember, 14, 10, 0, 0, 0))); // 15 Dec |
|
581 testData->iTimes.Append(TTime(TDateTime(2005, EDecember, 15, 10, 0, 0, 0))); // 16 Dec |
|
582 testData->iTimes.Append(TTime(TDateTime(2005, EDecember, 19, 9, 0, 0, 0))); // 20 Dec |
|
583 } |
|
584 break; |
|
585 |
|
586 case EDeleteAllChildExceptions: |
|
587 { |
|
588 // Parent has rpt rule plus exceptions, sporadic rdates and non-repeating child entry. |
|
589 // Child specifies a change to parent's repeat rule by defining a RecId and new RptDef. |
|
590 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
591 testData->iDescription.Copy(_L("Entry Test: EDeleteAllChildExceptions, Delete all child exceptions and see what happens\n")); |
|
592 testData->iTestType = TTestDataStruct::EEntryTest; |
|
593 CreateParentGsEntryL(GetWeeklyTestData2L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
594 CreateChildExceptionGsEntryL(testData, 1, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
595 CreateChildExceptionGsEntryL(testData, 2, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
596 TestDeletionOfChildExceptionsL(aEntryView, aInstanceView, KGUID1()); |
|
597 } |
|
598 break; |
|
599 |
|
600 case ECreateParentInvalidChildFloating: |
|
601 { |
|
602 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
603 testData->iDescription.Copy(_L("Entry Test: ECreateParentInvalidChildFloating\n")); |
|
604 testData->iTestType = TTestDataStruct::EEntryTest; |
|
605 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
606 TRAPD(err, CreateChildGsEntryL(testData, 4, aEntryView, KGUID1())); |
|
607 test(err == KErrArgument); |
|
608 } |
|
609 break; |
|
610 |
|
611 case ECreateParentInvalidChildFloating2: |
|
612 { |
|
613 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
614 testData->iDescription.Copy(_L("Entry Test: ECreateParentInvalidChildFloating2\n")); |
|
615 testData->iTestType = TTestDataStruct::EEntryTest; |
|
616 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1()); |
|
617 TRAPD(err, CreateChildGsEntryL(testData, 4, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue)); |
|
618 test(err == KErrArgument); |
|
619 } |
|
620 break; |
|
621 |
|
622 case EGetInstancesParentAnd1ChildExceptionMultiFetch: |
|
623 // Child specifies a modification to a date using RecId and Start/End date |
|
624 { |
|
625 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
626 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentAnd1ChildExceptionMultiFetch, Parent and 1 Child exception\n")); |
|
627 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
628 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
629 CreateChildExceptionGsEntryL(testData, 4, aEntryView, KGUID1(), CCalEntry::EAppt, aFloating); |
|
630 |
|
631 DoMultipleFetchAndStoreTestExceptionChildL(testData, aEntryView, KGUID1(), 4); |
|
632 |
|
633 // expected times: |
|
634 testData->iTimes.Reset(); |
|
635 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 5, 0, 0, 0, 0))); // 6 March |
|
636 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 6, 0, 0, 0, 0))); // 7 March |
|
637 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 7, 0, 0, 0, 0))); // 8 March |
|
638 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 9, 0, 0, 0, 0))); // 10 March |
|
639 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 10, 0, 0, 0, 0))); // 11 March |
|
640 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 11, 0, 0, 0, 0))); // 12 March |
|
641 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 18, 0, 0, 0, 0))); // 19 March |
|
642 } |
|
643 break; |
|
644 |
|
645 case EDeleteEntryThatHasNoInstances: |
|
646 { |
|
647 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
648 testData->iDescription.Copy(_L("Instance Test: EDeleteEntryThatHasNoInstances\n")); |
|
649 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
650 TestDeletionOfEntryThatHasNoInstancesL(GetDailyTestData1L(*testData), *testData, aEntryView, aInstanceView, |
|
651 KGUID1(), CCalEntry::EAppt, aFloating); |
|
652 } |
|
653 break; |
|
654 |
|
655 case EStoreRestoreParentWithAChild: |
|
656 { |
|
657 testData->iGuidsToExtract.Reset(); |
|
658 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
659 testData->iDescription.Copy(_L("Instance Test: EStoreRestoreParentWithAChild, Update parent who had one child\n")); |
|
660 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
661 CreateWeeklyParentGsEntryWithExceptionsRdatesL(*testData, aEntryView, KGUID1(), EException, CCalEntry::EAppt, aFloating); |
|
662 if (aFloating) |
|
663 { |
|
664 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1FloatingL(*testData), testData, 2, CalCommon::EThisAndFuture, aEntryView, KGUID1(), CCalEntry::EAppt, ETrue); |
|
665 } |
|
666 else |
|
667 { |
|
668 CreateChildRRuleGsEntryL(GetWeeklyTestDataModification1L(*testData), testData, 2, CalCommon::EThisAndFuture, aEntryView, KGUID1()); |
|
669 } |
|
670 |
|
671 StoreRestoreL(aEntryView, KGUID1()); |
|
672 |
|
673 // Expected Instances - none. |
|
674 // because child entry was deleted when parent was updated and only child held actual instances |
|
675 testData->iTimes.Reset(); |
|
676 } |
|
677 break; |
|
678 |
|
679 case EGetInstancesParentAnd1ChildExceptionModify: |
|
680 // Child specifies a modification to a date using RecId and Start/End date |
|
681 // Try to modify this child entry, by getting it from the instance. |
|
682 { |
|
683 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
684 testData->iDescription.Copy(_L("Instance Test: EGetInstancesParentAnd1ChildExceptionModify, Parent and 1 Child exception modify\n")); |
|
685 testData->iTestType = TTestDataStruct::EInstanceTest; |
|
686 CreateParentGsEntryL(GetDailyTestData1L(*testData), aEntryView, KGUID1(), CCalEntry::EAppt); |
|
687 |
|
688 // here 4 means array offset ie 5+4 = 9 march |
|
689 CreateChildExceptionGsEntryL(testData, 4, aEntryView, KGUID1(), CCalEntry::EAppt); |
|
690 TestEntryFromInstanceAndModifyL(testData, aEntryView, aInstanceView, KGUID1(), 4); |
|
691 |
|
692 // expected times: |
|
693 testData->iTimes.Reset(); |
|
694 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 5, 0, 0, 0, 0))); // 6 March |
|
695 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 6, 0, 0, 0, 0))); // 7 March |
|
696 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 7, 0, 0, 0, 0))); // 8 March |
|
697 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 9, 0, 0, 0, 0))); // 10 March |
|
698 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 10, 0, 0, 0, 0))); // 11 March |
|
699 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 11, 0, 0, 0, 0))); // 12 March |
|
700 testData->iTimes.Append(TTime(TDateTime(2005, EMarch, 21, 0, 0, 0, 0))); // 19 March |
|
701 } |
|
702 break; |
|
703 case EStoreParentHaveNoInstanceAndChildren: |
|
704 { |
|
705 testData->iGuidsToExtract.AppendL(KGUID1()); |
|
706 testData->iDescription.Copy(_L("Entry Test: EStoreParentHaveNoInstanceAndChildren")); |
|
707 testData->iTestType = TTestDataStruct::EEntryTest; |
|
708 StoreParentHaveNoInstanceAndChildrenL(aEntryView, KGUID1()); |
|
709 } |
|
710 break; |
|
711 |
|
712 default: |
|
713 ASSERT(0); |
|
714 break; |
|
715 } |
|
716 |
|
717 return testData; |
|
718 } |
|
719 |
|
720 void CTestData::StoreParentHaveNoInstanceAndChildrenL(CCalEntryView* aEntryView, const TDesC8& aGuid) |
|
721 {// Add an entry |
|
722 RPointerArray<CCalEntry> entries; |
|
723 CleanupResetAndDestroyPushL(entries); |
|
724 |
|
725 //create an simple entry and store it to the file |
|
726 TBuf<50> summary; |
|
727 |
|
728 HBufC8* guid = aGuid.AllocLC(); |
|
729 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0); |
|
730 CleanupStack::Pop(guid); |
|
731 CleanupStack::PushL(entry); |
|
732 |
|
733 entry->SetSummaryL(_L( "Parent Entry" )); |
|
734 |
|
735 TTime startTime = TDateTime( 2006, EMay, 24, 13, 0, 0, 0 ); |
|
736 TTime endTime = TDateTime( 2006, EMay, 24, 14, 0, 0, 0 ); |
|
737 |
|
738 TCalTime calStartTime; |
|
739 calStartTime.SetTimeUtcL(startTime); |
|
740 TCalTime calEndTime; |
|
741 calEndTime.SetTimeUtcL(endTime); |
|
742 entry->SetStartAndEndTimeL(calStartTime, calEndTime); |
|
743 |
|
744 TCalRRule rptRule; |
|
745 |
|
746 RArray<TDay> daysArray; |
|
747 CleanupClosePushL( daysArray ); |
|
748 daysArray.AppendL( calStartTime.TimeLocalL().DayNoInWeek() ); |
|
749 |
|
750 TCalTime untilCalTime; |
|
751 TTime untilTime = TDateTime( 2006, EJune, 0, 14, 0, 0, 0 ); |
|
752 untilCalTime.SetTimeUtcL( untilTime ); |
|
753 |
|
754 rptRule.SetDtStart( calStartTime ); |
|
755 rptRule.SetType( TCalRRule::EWeekly ); |
|
756 rptRule.SetByDay( daysArray ); |
|
757 rptRule.SetUntil( untilCalTime ); |
|
758 rptRule.SetInterval( 1 ); |
|
759 |
|
760 CleanupStack::PopAndDestroy( &daysArray ); |
|
761 |
|
762 entry->SetRRuleL(rptRule); |
|
763 |
|
764 entries.AppendL(entry); |
|
765 CleanupStack::Pop(entry); |
|
766 |
|
767 TInt entriesStored = 0; |
|
768 aEntryView->StoreL(entries, entriesStored); |
|
769 TInt localuid = entries[0]->LocalUidL(); |
|
770 test(entriesStored ==1); |
|
771 entries.ResetAndDestroy(); |
|
772 |
|
773 //update the first instance |
|
774 guid = aGuid.AllocLC(); |
|
775 entry = CCalEntry::NewL( CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0, calStartTime, CalCommon::EThisOnly ); |
|
776 CleanupStack::Pop( guid ); |
|
777 |
|
778 entries.AppendL( entry ); |
|
779 |
|
780 entry->SetStartAndEndTimeL( calStartTime, calEndTime ); |
|
781 entry->SetSummaryL( _L("Repeating Entry") ); |
|
782 entry->SetLocationL( _L( "Prague" ) ); |
|
783 |
|
784 aEntryView->StoreL(entries, entriesStored); |
|
785 localuid = entries[0]->LocalUidL(); |
|
786 entries.ResetAndDestroy(); |
|
787 |
|
788 //update the sencond instance |
|
789 |
|
790 TTime recTime; |
|
791 TCalTime startCalTimeChanged; |
|
792 TCalTime endCalTimeChanged; |
|
793 TCalTime recCalTime; |
|
794 startTime = calStartTime.TimeUtcL(); |
|
795 recTime = startTime + TTimeIntervalDays( 7 ); |
|
796 recCalTime.SetTimeUtcL( recTime ); |
|
797 |
|
798 guid = aGuid.AllocLC(); |
|
799 entry = CCalEntry::NewL( CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0, recCalTime, CalCommon::EThisOnly ); |
|
800 CleanupStack::Pop( guid ); |
|
801 |
|
802 entries.AppendL( entry ); |
|
803 |
|
804 startTime = recTime + TTimeIntervalHours( 1 ); |
|
805 endTime = startTime + TTimeIntervalHours( 1 ); |
|
806 |
|
807 startCalTimeChanged.SetTimeUtcL( startTime ); |
|
808 endCalTimeChanged.SetTimeUtcL( endTime ); |
|
809 |
|
810 entry->SetStartAndEndTimeL( startCalTimeChanged, endCalTimeChanged ); |
|
811 entry->SetSummaryL( _L("Repeating Entry") ); |
|
812 entry->SetLocationL( _L( "Dallas" ) ); |
|
813 |
|
814 aEntryView->StoreL(entries, entriesStored); |
|
815 localuid = entries[0]->LocalUidL(); |
|
816 entries.ResetAndDestroy(); |
|
817 |
|
818 //Fetch the entry |
|
819 aEntryView->FetchL(aGuid, entries); |
|
820 |
|
821 //store again |
|
822 aEntryView->StoreL(entries, entriesStored); |
|
823 |
|
824 CleanupStack::PopAndDestroy(&entries); |
|
825 } |
|
826 |
|
827 // Sub-routine that tests fetching and storing of a parent and child multiple times making sure the child's recId is correct. |
|
828 // This should only be called for a Parent and a single non-repeating child. |
|
829 void CTestData::DoMultipleFetchAndStoreTestExceptionChildL(TTestDataStruct* aTestData, CCalEntryView* aEntryView, const TDesC8& aGuid, TInt aRecIdToUse) |
|
830 { |
|
831 --aRecIdToUse; |
|
832 |
|
833 // Fetch both parent and child which have been stored |
|
834 RPointerArray<CCalEntry> entryArray; |
|
835 CleanupResetAndDestroyPushL(entryArray); |
|
836 HBufC8* guid = aGuid.AllocLC(); |
|
837 aEntryView->FetchL(*guid, entryArray); |
|
838 test(entryArray.Count() == 2); |
|
839 // Check RecId of child entry |
|
840 TCalTime recId = entryArray[1]->RecurrenceIdL(); |
|
841 test(recId.TimeLocalL() == aTestData->iRecIds[aRecIdToUse]); |
|
842 |
|
843 // Fetch only the child (via its local id) |
|
844 TCalLocalUid luid = entryArray[1]->LocalUidL(); |
|
845 CCalEntry* child = aEntryView->FetchL(luid); |
|
846 CleanupStack::PushL(child); |
|
847 TCalTime recId2 = child->RecurrenceIdL(); |
|
848 test(recId2.TimeLocalL() == aTestData->iRecIds[aRecIdToUse]); |
|
849 test(child->UidL() == aGuid); |
|
850 |
|
851 // Edit child in some way |
|
852 child->SetLastModifiedDateL(); |
|
853 |
|
854 // Store only the child |
|
855 RPointerArray<CCalEntry> arrayCh; |
|
856 CleanupClosePushL(arrayCh); |
|
857 arrayCh.Append(child); |
|
858 TInt successCh(0); |
|
859 aEntryView->StoreL(arrayCh, successCh); |
|
860 test(successCh == 1); |
|
861 CleanupStack::Pop(&arrayCh); |
|
862 arrayCh.Reset(); |
|
863 |
|
864 CleanupStack::PopAndDestroy(child); |
|
865 |
|
866 // Fetch both parent & child again |
|
867 RPointerArray<CCalEntry> entryArray2; |
|
868 CleanupResetAndDestroyPushL(entryArray2); |
|
869 aEntryView->FetchL(*guid, entryArray2); |
|
870 test(entryArray2.Count() == 2); |
|
871 // Test RecId of Child |
|
872 recId = entryArray2[1]->RecurrenceIdL(); |
|
873 test(recId.TimeLocalL() == aTestData->iRecIds[aRecIdToUse]); |
|
874 |
|
875 // Store child only |
|
876 RPointerArray<CCalEntry> arrayCh2; |
|
877 CleanupClosePushL(arrayCh2); |
|
878 arrayCh2.Append(entryArray2[1]); |
|
879 TInt successCh2(0); |
|
880 aEntryView->StoreL(arrayCh2, successCh2); |
|
881 test(successCh2 == 1); |
|
882 |
|
883 // Fetch only the child (via its local id) |
|
884 luid = arrayCh2[0]->LocalUidL(); |
|
885 CCalEntry* child2 = aEntryView->FetchL(luid); |
|
886 CleanupStack::PushL(child2); |
|
887 recId2 = child2->RecurrenceIdL(); |
|
888 test(recId2.TimeLocalL() == aTestData->iRecIds[aRecIdToUse]); |
|
889 |
|
890 // Store both the parent & child again |
|
891 RPointerArray<CCalEntry> arrayS; |
|
892 CleanupClosePushL(arrayS); |
|
893 arrayS.Append(entryArray2[0]); |
|
894 arrayS.Append(child2); |
|
895 TInt success(0); |
|
896 aEntryView->StoreL(arrayS, success); |
|
897 CleanupStack::Pop(&arrayS); |
|
898 arrayS.Reset(); |
|
899 |
|
900 CleanupStack::PopAndDestroy(child2); |
|
901 CleanupStack::Pop(&arrayCh2); |
|
902 arrayCh2.Reset(); |
|
903 CleanupStack::Pop(&entryArray2); |
|
904 entryArray2.ResetAndDestroy(); |
|
905 |
|
906 // Fetch both parent & child again |
|
907 RPointerArray<CCalEntry> entryArray3; |
|
908 CleanupResetAndDestroyPushL(entryArray3); |
|
909 aEntryView->FetchL(*guid, entryArray3); |
|
910 test(entryArray3.Count() == 2); |
|
911 // Test RecId of Child |
|
912 recId = entryArray3[1]->RecurrenceIdL(); |
|
913 test(recId.TimeLocalL() == aTestData->iRecIds[aRecIdToUse]); |
|
914 CleanupStack::Pop(&entryArray3); |
|
915 |
|
916 // Finally store both again |
|
917 success = 0; |
|
918 aEntryView->StoreL(entryArray3, success); |
|
919 |
|
920 entryArray3.ResetAndDestroy(); |
|
921 |
|
922 CleanupStack::PopAndDestroy(guid); |
|
923 CleanupStack::Pop(&entryArray); |
|
924 entryArray.ResetAndDestroy(); |
|
925 } |
|
926 |
|
927 |
|
928 // Sub-routine that tests fetching of a parent and child making sure the child's recId is correct. |
|
929 // This should only be called for a Parent and a single repeating child. |
|
930 // Note we can not re-store the fetched child object as it will not contain its recId range value. |
|
931 void CTestData::DoMultipleFetchAndStoreTestRuleChildL(TTestDataStruct* aTestData, CCalEntryView* aEntryView, const TDesC8& aGuid, TInt aRecIdToUse) |
|
932 { |
|
933 --aRecIdToUse; |
|
934 |
|
935 // Fetch both parent and child which have been stored |
|
936 RPointerArray<CCalEntry> entryArray; |
|
937 CleanupResetAndDestroyPushL(entryArray); |
|
938 HBufC8* guid = aGuid.AllocLC(); |
|
939 aEntryView->FetchL(*guid, entryArray); |
|
940 test(entryArray.Count() == 2); |
|
941 // Check RecId of child entry |
|
942 TCalTime recId = entryArray[1]->RecurrenceIdL(); |
|
943 test(recId.TimeLocalL() == aTestData->iRecIds[aRecIdToUse]); |
|
944 |
|
945 // Fetch only the child (via its local id) |
|
946 TCalLocalUid luid = entryArray[1]->LocalUidL(); |
|
947 CCalEntry* child = aEntryView->FetchL(luid); |
|
948 CleanupStack::PushL(child); |
|
949 TCalTime recId2 = child->RecurrenceIdL(); |
|
950 test(recId2.TimeLocalL() == aTestData->iRecIds[aRecIdToUse]); |
|
951 test(child->UidL() == aGuid); |
|
952 |
|
953 CleanupStack::PopAndDestroy(child); |
|
954 CleanupStack::PopAndDestroy(guid); |
|
955 CleanupStack::Pop(&entryArray); |
|
956 entryArray.ResetAndDestroy(); |
|
957 } |
|
958 |
|
959 // Fetch a child using the instance method, and then modify the same. |
|
960 void CTestData::TestEntryFromInstanceAndModifyL(TTestDataStruct* aTestData, CCalEntryView* aEntryView, CCalInstanceView* aInstanceView, const TDesC8& aGuid, TInt aRecIdToUse) |
|
961 { |
|
962 --aRecIdToUse; |
|
963 |
|
964 // The exception child was created on 19 march. |
|
965 TTime filterStartTime(TDateTime(2005, EMarch, 18, 0, 0, 0, 0)); |
|
966 TTime filterEndTime(TDateTime(2005, EMarch, 18, 23, 0, 0, 0)); |
|
967 TCalTime filterStartTimeCal; |
|
968 TCalTime filterEndTimeCal; |
|
969 filterStartTimeCal.SetTimeLocalL(filterStartTime); |
|
970 filterEndTimeCal.SetTimeLocalL(filterEndTime); |
|
971 |
|
972 // Fetch the instance |
|
973 RPointerArray< CCalInstance > instanceList; |
|
974 CalCommon::TCalTimeRange aTimeRange(filterStartTimeCal,filterEndTimeCal) ; |
|
975 aInstanceView->FindInstanceL( instanceList, CalCommon::EIncludeAppts, aTimeRange); |
|
976 test(1 == instanceList.Count()); |
|
977 |
|
978 // Get the recurrance id from the instance. |
|
979 CCalEntry & entryFromIns = instanceList[0]->Entry(); |
|
980 TCalTime recId = entryFromIns.RecurrenceIdL(); |
|
981 test(recId.TimeLocalL() == aTestData->iRecIds[aRecIdToUse]); |
|
982 instanceList.ResetAndDestroy(); |
|
983 |
|
984 // Using this rec id obtained from instanceL, create a new modifying entry |
|
985 HBufC8* guid = aGuid.AllocLC(); |
|
986 CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 2, recId, CalCommon::EThisOnly); |
|
987 CleanupStack::Pop(guid); |
|
988 CleanupStack::PushL(entry); |
|
989 TTime secondModStartTime(TDateTime(2005, EMarch, 21, 0, 0, 0, 0)); |
|
990 TTime secondModEndTime(secondModStartTime + TTimeIntervalHours(1)); |
|
991 TCalTime startTimeCal; |
|
992 startTimeCal.SetTimeLocalL(secondModStartTime); |
|
993 TCalTime endTimeCal; |
|
994 endTimeCal.SetTimeLocalL(secondModEndTime); |
|
995 entry->SetStartAndEndTimeL(startTimeCal, endTimeCal); |
|
996 |
|
997 RPointerArray<CCalEntry> entries; |
|
998 CleanupClosePushL(entries); |
|
999 entries.AppendL(entry); |
|
1000 TInt success(0); |
|
1001 aEntryView->StoreL(entries, success); |
|
1002 test(success == entries.Count()); |
|
1003 CleanupStack::Pop(&entries); |
|
1004 entries.Reset(); |
|
1005 CleanupStack::PopAndDestroy(entry); |
|
1006 } |
|
1007 |
|
1008 |
|
1009 CCalEntry* CTestData::CreateParentLC(TCalRRule* aRpt, const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
1010 { |
|
1011 |
|
1012 HBufC8* guid = aGuid.AllocLC(); // Create GUID on heap |
|
1013 |
|
1014 // Below takes ownership of guid |
|
1015 CCalEntry* entry = CCalEntry::NewL(aType, guid, CCalEntry::EMethodRequest, (TUint)0); |
|
1016 |
|
1017 CleanupStack::Pop(guid); |
|
1018 CleanupStack::PushL(entry); |
|
1019 |
|
1020 TCalTime startTime; |
|
1021 TCalTime calEndTime; |
|
1022 if (aFloating) |
|
1023 { |
|
1024 startTime.SetTimeLocalFloatingL(aRpt->DtStart().TimeLocalL()); |
|
1025 |
|
1026 // Set the start time to be same as repeat def's start time |
|
1027 // and the end time to be 1 hour after start time. |
|
1028 TTime endTime = aRpt->DtStart().TimeLocalL() + TTimeIntervalHours(1); |
|
1029 calEndTime.SetTimeLocalFloatingL(endTime); |
|
1030 } |
|
1031 else |
|
1032 { |
|
1033 startTime = aRpt->DtStart(); |
|
1034 |
|
1035 // Set the start time to be same as repeat def's start time |
|
1036 // and the end time to be 1 hour after start time. |
|
1037 TTime endTime = aRpt->DtStart().TimeUtcL() + TTimeIntervalHours(1); |
|
1038 calEndTime.SetTimeUtcL(endTime); |
|
1039 } |
|
1040 entry->SetStartAndEndTimeL(startTime, calEndTime); |
|
1041 entry->SetRRuleL(*aRpt); // doesn't take ownership |
|
1042 |
|
1043 return entry; |
|
1044 } |
|
1045 |
|
1046 |
|
1047 void CTestData::CreateParentGsEntryL(TCalRRule* aRpt, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
1048 { |
|
1049 CleanupStack::PushL(aRpt); |
|
1050 |
|
1051 CCalEntry* entry = CreateParentLC(aRpt, aGuid, aType, aFloating); |
|
1052 |
|
1053 RPointerArray<CCalEntry> array; |
|
1054 CleanupClosePushL(array); |
|
1055 array.Append(entry); |
|
1056 TInt success(0); |
|
1057 aEntryView->StoreL(array, success); |
|
1058 CleanupStack::Pop(&array); |
|
1059 array.Reset(); |
|
1060 |
|
1061 CleanupStack::PopAndDestroy(entry); |
|
1062 CleanupStack::PopAndDestroy(aRpt); |
|
1063 } |
|
1064 |
|
1065 |
|
1066 // Creates a parent entry with a weekly rpt rule (GetWeeklyTestData1L()) |
|
1067 // and adds exceptions and/or rdates to the parent entry. |
|
1068 void CTestData::CreateWeeklyParentGsEntryWithExceptionsRdatesL(TTestDataStruct& aTestData, CCalEntryView* aEntryView, const TDesC8& aGuid, TExceptionRDate aExcpnRDate, CCalEntry::TType aType, TBool aFloating) |
|
1069 { |
|
1070 TCalRRule* rptRule; |
|
1071 if (aFloating) |
|
1072 { |
|
1073 rptRule = GetWeeklyTestData1FloatingL(aTestData); |
|
1074 } |
|
1075 else |
|
1076 { |
|
1077 rptRule = GetWeeklyTestData1L(aTestData); |
|
1078 } |
|
1079 CleanupStack::PushL(rptRule); |
|
1080 |
|
1081 CCalEntry* entry = CreateParentLC(rptRule, aGuid, aType, aFloating); |
|
1082 |
|
1083 RArray<TCalTime> exArray; |
|
1084 RArray<TCalTime> rDateArray; |
|
1085 |
|
1086 // Add exceptions or rdates to parent rpt rule |
|
1087 |
|
1088 if ((aExcpnRDate == EException) || (aExcpnRDate == EExceptionAndRDate)) |
|
1089 { |
|
1090 // Set 3 exceptions on the parent rpt rule (GetWeeklyTestData1L()) of 6,13,20 April 2005 |
|
1091 TCalTime exTime1; |
|
1092 TCalTime exTime2; |
|
1093 TCalTime exTime3; |
|
1094 if (aFloating) |
|
1095 { |
|
1096 exTime1.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 8, 0, 0, 0, 0)); // 9 March |
|
1097 exTime2.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 22, 0, 0, 0, 0)); // 23 March |
|
1098 exTime3.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 29, 0, 0, 0, 0)); // 30 March |
|
1099 } |
|
1100 else |
|
1101 { |
|
1102 exTime1.SetTimeLocalL(TDateTime(2005, EMarch, 8, 0, 0, 0, 0)); // 9 March |
|
1103 exTime2.SetTimeLocalL(TDateTime(2005, EMarch, 22, 0, 0, 0, 0)); // 23 March |
|
1104 exTime3.SetTimeLocalL(TDateTime(2005, EMarch, 29, 0, 0, 0, 0)); // 30 March |
|
1105 } |
|
1106 exArray.Append(exTime1); |
|
1107 exArray.Append(exTime2); |
|
1108 exArray.Append(exTime3); |
|
1109 |
|
1110 entry->SetExceptionDatesL(exArray); |
|
1111 } |
|
1112 |
|
1113 if ((aExcpnRDate == ERDate) || (aExcpnRDate == EExceptionAndRDate)) |
|
1114 { |
|
1115 // Set 3 sporadic dates on the parent (3, 24 March & 24 April 2005) |
|
1116 |
|
1117 TCalTime rDate1; |
|
1118 TCalTime rDate2; |
|
1119 TCalTime rDate3; |
|
1120 |
|
1121 if (aFloating) |
|
1122 { |
|
1123 rDate1.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 16, 0, 0, 0, 0)); // 17 March |
|
1124 rDate2.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 23, 0, 0, 0, 0)); // 24 March |
|
1125 rDate3.SetTimeLocalFloatingL(TDateTime(2005, EApril, 23, 0, 0, 0, 0)); // 24 April |
|
1126 } |
|
1127 else |
|
1128 { |
|
1129 rDate1.SetTimeLocalL(TDateTime(2005, EMarch, 16, 0, 0, 0, 0)); // 17 March |
|
1130 rDate2.SetTimeLocalL(TDateTime(2005, EMarch, 23, 0, 0, 0, 0)); // 24 March |
|
1131 rDate3.SetTimeLocalL(TDateTime(2005, EApril, 23, 0, 0, 0, 0)); // 24 April |
|
1132 } |
|
1133 |
|
1134 rDateArray.Append(rDate1); |
|
1135 rDateArray.Append(rDate2); |
|
1136 rDateArray.Append(rDate3); |
|
1137 |
|
1138 |
|
1139 entry->SetRDatesL(rDateArray); |
|
1140 } |
|
1141 |
|
1142 RPointerArray<CCalEntry> array; |
|
1143 CleanupClosePushL(array); |
|
1144 array.Append(entry); |
|
1145 TInt success(0); |
|
1146 aEntryView->StoreL(array, success); |
|
1147 CleanupStack::Pop(&array); |
|
1148 array.Reset(); |
|
1149 |
|
1150 rDateArray.Reset(); |
|
1151 exArray.Reset(); |
|
1152 CleanupStack::PopAndDestroy(entry); |
|
1153 CleanupStack::PopAndDestroy(rptRule); |
|
1154 } |
|
1155 |
|
1156 |
|
1157 TCalRRule* CTestData::GetDailyTestData1L(TTestDataStruct& aData,TBool aSummerTime) |
|
1158 { |
|
1159 TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EDaily); |
|
1160 rpt->SetInterval(1); |
|
1161 TCalTime startTime; |
|
1162 if (!aSummerTime) |
|
1163 { |
|
1164 startTime.SetTimeLocalL(TDateTime(2005, EMarch, 5, 0, 0, 0, 0)); |
|
1165 } |
|
1166 else |
|
1167 { |
|
1168 startTime.SetTimeLocalFloatingL(TDateTime(2005, EAugust, 5, 0, 0, 0, 0)); |
|
1169 } |
|
1170 |
|
1171 rpt->SetDtStart(startTime); // 6 March 2005 |
|
1172 TCalTime endTime; |
|
1173 if (!aSummerTime) |
|
1174 { |
|
1175 endTime.SetTimeLocalL(TDateTime(2005, EMarch, 11, 0, 0, 0, 0)); |
|
1176 } |
|
1177 else |
|
1178 { |
|
1179 endTime.SetTimeLocalFloatingL(TDateTime(2005, EAugust, 11, 0, 0, 0, 0)); |
|
1180 } |
|
1181 rpt->SetUntil(endTime); // 12 March 2005 |
|
1182 |
|
1183 if (!aSummerTime) |
|
1184 { |
|
1185 aData.iStartDate = TDateTime(2005, EMarch, 0, 0, 0, 0, 0); // 1 March 2005 |
|
1186 aData.iEndDate = TDateTime(2005, EMarch, 30, 0, 0, 0, 0); // 31 March 2005 |
|
1187 aData.iDescription.Append(_L(" Every 1 days from 6 March 05\n")); |
|
1188 |
|
1189 // Set up the RecId's (used for Child entries) |
|
1190 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 5, 0, 0, 0, 0))); // 6 Mar |
|
1191 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 6, 0, 0, 0, 0))); // 7 Mar |
|
1192 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 7, 0, 0, 0, 0))); // 8 Mar |
|
1193 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 9 Mar |
|
1194 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 9, 0, 0, 0, 0))); // 10 Mar |
|
1195 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 10, 0, 0, 0, 0))); // 11 Mar |
|
1196 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 11, 0, 0, 0, 0))); // 12 Mar |
|
1197 } |
|
1198 else |
|
1199 { |
|
1200 aData.iStartDate = TDateTime(2005, EAugust, 0, 0, 0, 0, 0); // 1 August 2005 |
|
1201 aData.iEndDate = TDateTime(2005, EAugust, 30, 0, 0, 0, 0); // 31 August 2005 |
|
1202 aData.iDescription.Append(_L(" Every 1 days from 6 August 05\n")); |
|
1203 |
|
1204 // Set up the RecId's (used for Child entries) |
|
1205 aData.iRecIds.Append(TTime(TDateTime(2005, EAugust, 5, 0, 0, 0, 0))); // 6 Aug |
|
1206 aData.iRecIds.Append(TTime(TDateTime(2005, EAugust, 6, 0, 0, 0, 0))); // 7 Aug |
|
1207 aData.iRecIds.Append(TTime(TDateTime(2005, EAugust, 7, 0, 0, 0, 0))); // 8 Aug |
|
1208 aData.iRecIds.Append(TTime(TDateTime(2005, EAugust, 8, 0, 0, 0, 0))); // 9 Aug |
|
1209 aData.iRecIds.Append(TTime(TDateTime(2005, EAugust, 9, 0, 0, 0, 0))); // 10 Aug |
|
1210 aData.iRecIds.Append(TTime(TDateTime(2005, EAugust, 10, 0, 0, 0, 0))); // 11 Aug |
|
1211 aData.iRecIds.Append(TTime(TDateTime(2005, EAugust, 11, 0, 0, 0, 0))); // 12 Aug |
|
1212 } |
|
1213 return rpt; |
|
1214 } |
|
1215 |
|
1216 |
|
1217 TCalRRule* CTestData::GetWeeklyTestData1L(TTestDataStruct& aData) |
|
1218 { |
|
1219 TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EWeekly); |
|
1220 rpt->SetInterval(1); |
|
1221 RArray<TDay> days; |
|
1222 days.Append(EWednesday); |
|
1223 rpt->SetByDay(days); |
|
1224 days.Reset(); |
|
1225 TCalTime startTime; |
|
1226 startTime.SetTimeLocalL(TDateTime(2005, EMarch, 5, 0, 0, 0, 0)); // 6 March |
|
1227 rpt->SetDtStart(startTime); |
|
1228 TCalTime endTime; |
|
1229 endTime.SetTimeLocalL(TDateTime(2005, EApril, 20, 0, 0, 0, 0)); // 21 Apr |
|
1230 rpt->SetUntil(endTime); |
|
1231 |
|
1232 aData.iStartDate = TDateTime(2005, EMarch, 0, 0, 0, 0, 0); // 1 March 2005 |
|
1233 aData.iEndDate = TDateTime(2005, EApril, 26, 0, 0, 0, 0); // 27 April 2005 |
|
1234 aData.iDescription.Append(_L(" Every Wed from 6 Mar 05 until 21 Apr 05\n")); |
|
1235 |
|
1236 // Set up the RecId's (used for Child entries) |
|
1237 // Clear array first |
|
1238 aData.iRecIds.Reset(); |
|
1239 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 09 Mar |
|
1240 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 15, 0, 0, 0, 0))); // 16 Mar |
|
1241 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 22, 0, 0, 0, 0))); // 23 Mar |
|
1242 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 28, 23, 0, 0, 0))); // 30 Mar |
|
1243 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 04, 23, 0, 0, 0))); // 06 April |
|
1244 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 11, 23, 0, 0, 0))); // 13 April |
|
1245 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 18, 23, 0, 0, 0))); // 20 April |
|
1246 |
|
1247 return rpt; |
|
1248 } |
|
1249 |
|
1250 TCalRRule* CTestData::GetWeeklyTestData1FloatingL(TTestDataStruct& aData) |
|
1251 { |
|
1252 TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EWeekly); |
|
1253 rpt->SetInterval(1); |
|
1254 RArray<TDay> days; |
|
1255 days.Append(EWednesday); |
|
1256 rpt->SetByDay(days); |
|
1257 days.Reset(); |
|
1258 TCalTime startTime; |
|
1259 startTime.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 5, 0, 0, 0, 0)); // 6 March |
|
1260 rpt->SetDtStart(startTime); |
|
1261 TCalTime endTime; |
|
1262 endTime.SetTimeLocalFloatingL(TDateTime(2005, EApril, 20, 0, 0, 0, 0)); // 21 Apr |
|
1263 rpt->SetUntil(endTime); |
|
1264 |
|
1265 aData.iStartDate = TDateTime(2005, EMarch, 0, 0, 0, 0, 0); // 1 March 2005 |
|
1266 aData.iEndDate = TDateTime(2005, EApril, 26, 0, 0, 0, 0); // 27 April 2005 |
|
1267 aData.iDescription.Append(_L(" Every Wed from 6 Mar 05 until 21 Apr 05\n")); |
|
1268 |
|
1269 // Set up the RecId's (used for Child entries) |
|
1270 // Clear array first |
|
1271 aData.iRecIds.Reset(); |
|
1272 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 09 Mar |
|
1273 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 15, 0, 0, 0, 0))); // 16 Mar |
|
1274 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 22, 0, 0, 0, 0))); // 23 Mar |
|
1275 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 29, 0, 0, 0, 0))); // 30 Mar |
|
1276 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 05, 0, 0, 0, 0))); // 06 April |
|
1277 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // 13 April |
|
1278 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 19, 0, 0, 0, 0))); // 20 April |
|
1279 |
|
1280 return rpt; |
|
1281 } |
|
1282 |
|
1283 TCalRRule* CTestData::GetWeeklyTestData2L(TTestDataStruct& aData) |
|
1284 { |
|
1285 TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EWeekly); |
|
1286 rpt->SetInterval(1); |
|
1287 RArray<TDay> days; |
|
1288 days.Append(EWednesday); |
|
1289 rpt->SetByDay(days); |
|
1290 days.Reset(); |
|
1291 TCalTime startTime; |
|
1292 startTime.SetTimeLocalL(TDateTime(2005, EMarch, 8, 0, 0, 0, 0)); // 9 March |
|
1293 rpt->SetDtStart(startTime); |
|
1294 TCalTime endTime; |
|
1295 endTime.SetTimeLocalL(TDateTime(2005, EMarch, 15, 0, 0, 0, 0)); // 16 Apr |
|
1296 rpt->SetUntil(endTime); |
|
1297 |
|
1298 aData.iStartDate = TDateTime(2005, EMarch, 0, 0, 0, 0, 0); // 1 March 2005 |
|
1299 aData.iEndDate = TDateTime(2005, EApril, 26, 0, 0, 0, 0); // 27 April 2005 |
|
1300 aData.iDescription.Append(_L(" Every Wed from 9 Mar 05 until 16 Mar 05\n")); |
|
1301 |
|
1302 // Set up the RecId's (used for Child entries) |
|
1303 // Clear array first |
|
1304 aData.iRecIds.Reset(); |
|
1305 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 09 Mar |
|
1306 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 15, 0, 0, 0, 0))); // 16 Mar |
|
1307 |
|
1308 return rpt; |
|
1309 } |
|
1310 |
|
1311 |
|
1312 // This creates a rule which proposes a change to the rule in GetWeeklyTestData1L() |
|
1313 // ie Weekly, wed from 6 Mar to 10 Apr 2005. |
|
1314 // This rrule proposes Weekly, Fri from 11 Mar to Fri 8 April. |
|
1315 TCalRRule* CTestData::GetWeeklyTestDataModification1L(TTestDataStruct& aData) |
|
1316 { |
|
1317 TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EWeekly); |
|
1318 rpt->SetInterval(1); |
|
1319 RArray<TDay> days; |
|
1320 days.Append(EFriday); |
|
1321 rpt->SetByDay(days); |
|
1322 days.Reset(); |
|
1323 TCalTime startTime; |
|
1324 startTime.SetTimeLocalL(TDateTime(2005, EApril, 5, 0, 0, 0, 0)); // 6th April |
|
1325 rpt->SetDtStart(startTime); |
|
1326 TCalTime endTime; |
|
1327 endTime.SetTimeLocalL(TDateTime(2005, EApril, 21, 0, 0, 0, 0)); // 22 Apr |
|
1328 rpt->SetUntil(endTime); |
|
1329 |
|
1330 aData.iStartDate = TDateTime(2005, EMarch, 0, 0, 0, 0, 0); // 1 March 2005 |
|
1331 aData.iEndDate = TDateTime(2005, EApril, 26, 0, 0, 0, 0); // 27 April 2005 |
|
1332 aData.iDescription.Append(_L(" Modifies a parent rrule. This child's rrule is every Fri from 11 Mar to Fri 22 Apr 05\n")); |
|
1333 |
|
1334 // Set up the RecIds (used for Child entries) - these are the instance dates of the parent (GetWeeklyTestData1L()) |
|
1335 // Note CCalEntry::NewL() expects the RecIds in Utc hence they're values after BST are expressed as localtime - 1hr. |
|
1336 // Clear array first |
|
1337 aData.iRecIds.Reset(); |
|
1338 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 09 Mar |
|
1339 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 15, 0, 0, 0, 0))); // 16 Mar |
|
1340 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 22, 0, 0, 0, 0))); // 23 Mar |
|
1341 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 28, 23, 0, 0, 0))); // 30 Mar BST |
|
1342 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 04, 23, 0, 0, 0))); // 06 April BST |
|
1343 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 11, 23, 0, 0, 0))); // 13 April BST |
|
1344 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 18, 23, 0, 0, 0))); // 20 April BST |
|
1345 |
|
1346 return rpt; |
|
1347 } |
|
1348 |
|
1349 // This function is the floating version of GetWeeklyTestDataModification1L() |
|
1350 TCalRRule* CTestData::GetWeeklyTestDataModification1FloatingL(TTestDataStruct& aData) |
|
1351 { |
|
1352 TCalRRule* rpt = new (ELeave) TCalRRule(TCalRRule::EWeekly); |
|
1353 rpt->SetInterval(1); |
|
1354 RArray<TDay> days; |
|
1355 days.Append(EFriday); |
|
1356 rpt->SetByDay(days); |
|
1357 days.Reset(); |
|
1358 TCalTime startTime; |
|
1359 startTime.SetTimeLocalFloatingL(TDateTime(2005, EApril, 5, 0, 0, 0, 0)); // 6th April |
|
1360 rpt->SetDtStart(startTime); |
|
1361 TCalTime endTime; |
|
1362 endTime.SetTimeLocalFloatingL(TDateTime(2005, EApril, 21, 0, 0, 0, 0)); // 22 Apr |
|
1363 rpt->SetUntil(endTime); |
|
1364 |
|
1365 aData.iStartDate = TDateTime(2005, EMarch, 0, 0, 0, 0, 0); // 1 March 2005 |
|
1366 aData.iEndDate = TDateTime(2005, EApril, 26, 0, 0, 0, 0); // 27 April 2005 |
|
1367 aData.iDescription.Append(_L(" Modifies a parent rrule. This child's rrule is every Fri from 11 Mar to Fri 22 Apr 05\n")); |
|
1368 |
|
1369 // Set up the RecIds (used for Child entries) - these are the instance dates of the parent (GetWeeklyTestData1L()) |
|
1370 // Note CCalEntry::NewL() expects the RecIds in Utc hence they're values after BST are expressed as localtime - 1hr. |
|
1371 // Clear array first |
|
1372 aData.iRecIds.Reset(); |
|
1373 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 8, 0, 0, 0, 0))); // 09 Mar |
|
1374 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 15, 0, 0, 0, 0))); // 16 Mar |
|
1375 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 22, 0, 0, 0, 0))); // 23 Mar |
|
1376 aData.iRecIds.Append(TTime(TDateTime(2005, EMarch, 29, 0, 0, 0, 0))); // 30 Mar |
|
1377 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 05, 0, 0, 0, 0))); // 06 April |
|
1378 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 12, 0, 0, 0, 0))); // 13 April |
|
1379 aData.iRecIds.Append(TTime(TDateTime(2005, EApril, 19, 0, 0, 0, 0))); // 20 April |
|
1380 |
|
1381 return rpt; |
|
1382 } |
|
1383 |
|
1384 |
|
1385 void CTestData::DeleteParentGsEntryL(CCalEntryView* aEntryView, const TDesC8& aGuid) |
|
1386 { |
|
1387 CDesC8ArrayFlat* guidArray = new(ELeave)CDesC8ArrayFlat(1); |
|
1388 CleanupStack::PushL(guidArray); |
|
1389 guidArray->AppendL(aGuid); |
|
1390 aEntryView->DeleteL(*guidArray); |
|
1391 CleanupStack::PopAndDestroy(guidArray); |
|
1392 } |
|
1393 |
|
1394 void CTestData::SingleDeleteParentGsEntryL(CCalEntryView* aEntryView, const TDesC8& aGuid) |
|
1395 { |
|
1396 RPointerArray<CCalEntry> entryArray; |
|
1397 CleanupResetAndDestroyPushL(entryArray); |
|
1398 HBufC8* guid = aGuid.AllocLC(); |
|
1399 aEntryView->FetchL(*guid, entryArray); |
|
1400 // Expect only 1 (parent) entry |
|
1401 if(entryArray.Count()) |
|
1402 { |
|
1403 CCalEntry* parent = entryArray[0]; |
|
1404 aEntryView->DeleteL(*parent); |
|
1405 } |
|
1406 |
|
1407 CleanupStack::PopAndDestroy(guid); |
|
1408 CleanupStack::Pop(&entryArray); |
|
1409 entryArray.ResetAndDestroy(); |
|
1410 } |
|
1411 |
|
1412 void CTestData::CreateChildGsEntryL(TTestDataStruct* aTestData, TInt aRecIdToUse, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
1413 { |
|
1414 |
|
1415 HBufC8* guid = aGuid.AllocLC(); // Create GUID on heap |
|
1416 |
|
1417 // Use Rec-id as given by test-data |
|
1418 TTime ttime = aTestData->iRecIds[aRecIdToUse-1]; |
|
1419 TCalTime recurrenceId; |
|
1420 if (aFloating) |
|
1421 { |
|
1422 recurrenceId.SetTimeLocalFloatingL(ttime); |
|
1423 } |
|
1424 else |
|
1425 { |
|
1426 recurrenceId.SetTimeUtcL(ttime); |
|
1427 } |
|
1428 CalCommon::TRecurrenceRange range = CalCommon::EThisOnly; |
|
1429 |
|
1430 // Create a child |
|
1431 // Below takes ownership of guid |
|
1432 CCalEntry* entry = CCalEntry::NewL( aType, guid, CCalEntry::EMethodRequest, (TUint)0, |
|
1433 recurrenceId, range); |
|
1434 |
|
1435 CleanupStack::Pop(guid); |
|
1436 CleanupStack::PushL(entry); |
|
1437 |
|
1438 // Start date same as RecId. End time is 1 hour later. |
|
1439 TTime startDate = aTestData->iRecIds[aRecIdToUse-1]; |
|
1440 TTime endDate = (startDate + TTimeIntervalHours(1)); |
|
1441 |
|
1442 TCalTime startTime; |
|
1443 TCalTime endTime; |
|
1444 |
|
1445 if (aFloating) |
|
1446 { |
|
1447 startTime.SetTimeLocalFloatingL(startDate); |
|
1448 endTime.SetTimeLocalFloatingL(endDate); |
|
1449 } |
|
1450 else |
|
1451 { |
|
1452 startTime.SetTimeUtcL(startDate); |
|
1453 endTime.SetTimeUtcL(endDate); |
|
1454 } |
|
1455 entry->SetStartAndEndTimeL(startTime, endTime); |
|
1456 |
|
1457 RPointerArray<CCalEntry> array; |
|
1458 CleanupClosePushL(array); |
|
1459 array.Append(entry); |
|
1460 TInt success(0); |
|
1461 aEntryView->StoreL(array, success); |
|
1462 |
|
1463 // Ensure that storeL has not modified its recurrence Id. |
|
1464 test(recurrenceId.TimeLocalL() == entry->RecurrenceIdL().TimeLocalL()); |
|
1465 |
|
1466 CleanupStack::Pop(&array); |
|
1467 array.Reset(); |
|
1468 |
|
1469 CleanupStack::PopAndDestroy(entry); |
|
1470 } |
|
1471 |
|
1472 |
|
1473 void CTestData::AddMultipleEntriesL(TCalRRule* aRpt, CCalEntryView* aEntryView, CCalEntry::TType aType, TBool aFloating) |
|
1474 { |
|
1475 |
|
1476 CleanupStack::PushL(aRpt); |
|
1477 |
|
1478 |
|
1479 CDesC8ArrayFlat* guidArray = new(ELeave) CDesC8ArrayFlat(3); |
|
1480 CleanupStack::PushL(guidArray); // CleanupArrayDeletePushL(guidArray); |
|
1481 guidArray->AppendL(KGUID1()); |
|
1482 guidArray->AppendL(KGUID2()); |
|
1483 guidArray->AppendL(KGUID3()); |
|
1484 |
|
1485 TCalTime startTime; |
|
1486 TCalTime calEndTime; |
|
1487 if (aFloating) |
|
1488 { |
|
1489 startTime.SetTimeLocalFloatingL(aRpt->DtStart().TimeLocalL()); |
|
1490 |
|
1491 TTime endTime = aRpt->DtStart().TimeLocalL() + TTimeIntervalHours(1); |
|
1492 calEndTime.SetTimeLocalFloatingL(endTime); |
|
1493 } |
|
1494 else |
|
1495 { |
|
1496 startTime = aRpt->DtStart(); |
|
1497 TTime endTime = aRpt->DtStart().TimeUtcL() + TTimeIntervalHours(1); |
|
1498 calEndTime.SetTimeUtcL(endTime); |
|
1499 } |
|
1500 |
|
1501 RPointerArray<CCalEntry> entryArray; |
|
1502 CleanupResetAndDestroyPushL(entryArray); |
|
1503 for(TInt a = 0; a < guidArray->Count(); a++ ) |
|
1504 { |
|
1505 HBufC8* guid = (*guidArray)[a].AllocLC(); // Create GUID on heap |
|
1506 |
|
1507 // Below takes ownership of guid |
|
1508 CCalEntry* entry = CCalEntry::NewL(aType, guid, CCalEntry::EMethodRequest, (TUint)0); |
|
1509 |
|
1510 CleanupStack::Pop(guid); |
|
1511 CleanupStack::PushL(entry); |
|
1512 |
|
1513 // Set same rpt rule on all entries |
|
1514 entry->SetStartAndEndTimeL(startTime, calEndTime); |
|
1515 entry->SetRRuleL(*aRpt); // doesn't take ownership |
|
1516 |
|
1517 entryArray.Append(entry); |
|
1518 CleanupStack::Pop(entry); |
|
1519 } |
|
1520 |
|
1521 TInt success(0); |
|
1522 aEntryView->StoreL(entryArray, success); |
|
1523 |
|
1524 //CleanupStack::PopAndDestroy(&entryArray); |
|
1525 CleanupStack::Pop(&entryArray); |
|
1526 entryArray.ResetAndDestroy(); |
|
1527 |
|
1528 CleanupStack::PopAndDestroy(guidArray); |
|
1529 CleanupStack::PopAndDestroy(aRpt); |
|
1530 |
|
1531 } |
|
1532 |
|
1533 void CTestData::DeleteAllEntriesByGuidL(CCalEntryView* aEntryView) |
|
1534 { |
|
1535 |
|
1536 CDesC8ArrayFlat* guidArray = new(ELeave) CDesC8ArrayFlat(3); |
|
1537 CleanupArrayDeletePushL(guidArray); |
|
1538 guidArray->AppendL(KGUID1()); |
|
1539 guidArray->AppendL(KGUID2()); |
|
1540 guidArray->AppendL(KGUID3()); |
|
1541 |
|
1542 aEntryView->DeleteL(*guidArray); |
|
1543 |
|
1544 CleanupStack::PopAndDestroy(guidArray); |
|
1545 } |
|
1546 |
|
1547 void CTestData::TestSetGetMethodsL(CCalEntryView* aEntryView, const TDesC8& aGuid) |
|
1548 { |
|
1549 // create test values |
|
1550 _LIT(KSummary,"VIM"); |
|
1551 _LIT(KDescription,"Very Important Meeting"); |
|
1552 _LIT(KLocation,"London"); |
|
1553 |
|
1554 TTime tempTime; |
|
1555 |
|
1556 TCalTime startTime; |
|
1557 tempTime.Set(_L("20101123:120000")); //YYYYMMDD:HHMMSS.MMMMMM |
|
1558 startTime.SetTimeLocalL(tempTime); |
|
1559 |
|
1560 TCalTime endTime; |
|
1561 tempTime.Set(_L("20101123:130000")); //YYYYMMDD:HHMMSS.MMMMMM |
|
1562 endTime.SetTimeLocalL(tempTime); |
|
1563 |
|
1564 // TBool completed(EFalse); |
|
1565 |
|
1566 TCalTime completedTime; |
|
1567 tempTime.Set(_L("20101123:140000")); //YYYYMMDD:HHMMSS.MMMMMM |
|
1568 completedTime.SetTimeLocalL(tempTime); |
|
1569 |
|
1570 //TCalRRule* calRRule; |
|
1571 |
|
1572 tempTime.Set(_L("20101124:120000")); // date1 |
|
1573 TCalTime date1; |
|
1574 date1.SetTimeLocalL(tempTime); |
|
1575 tempTime.Set(_L("20101125:120000")); // date2 |
|
1576 TCalTime date2; |
|
1577 date2.SetTimeLocalL(tempTime); |
|
1578 |
|
1579 RArray<TCalTime> rDateList1; |
|
1580 rDateList1.Append(date1); |
|
1581 rDateList1.Append(date2); |
|
1582 |
|
1583 RArray<TCalTime> rDateList2; |
|
1584 |
|
1585 RArray<TCalTime> exDateList; |
|
1586 exDateList.Append(date2); |
|
1587 |
|
1588 CCalEntry::TStatus status(CCalEntry::ETentative); |
|
1589 CCalEntry::TReplicationStatus replicationStatus(CCalEntry::EOpen); |
|
1590 |
|
1591 TUint priority(22); |
|
1592 |
|
1593 CCalEntry::TMethod method(CCalEntry::EMethodNone); |
|
1594 TInt seq(0); |
|
1595 |
|
1596 // get an entry out of the calendar file |
|
1597 RPointerArray<CCalEntry> calEntryArray; |
|
1598 CleanupResetAndDestroyPushL(calEntryArray); |
|
1599 aEntryView->FetchL(aGuid,calEntryArray); |
|
1600 |
|
1601 // call all the set methods |
|
1602 calEntryArray[0]->SetStartAndEndTimeL(startTime, endTime); |
|
1603 calEntryArray[0]->SetLastModifiedDateL(); |
|
1604 calEntryArray[0]->ClearRepeatingPropertiesL(); |
|
1605 calEntryArray[0]->SetRDatesL(rDateList1); |
|
1606 calEntryArray[0]->SetExceptionDatesL(exDateList); |
|
1607 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
1608 CleanupStack::PushL(alarm); |
|
1609 TTimeIntervalMinutes offset(5); |
|
1610 alarm->SetTimeOffset(offset); |
|
1611 calEntryArray[0]->SetAlarmL(alarm); |
|
1612 CleanupStack::PopAndDestroy(alarm); |
|
1613 calEntryArray[0]->SetStatusL(status); |
|
1614 calEntryArray[0]->SetReplicationStatusL(replicationStatus); |
|
1615 calEntryArray[0]->SetPriorityL(priority); |
|
1616 calEntryArray[0]->SetSummaryL(KSummary()); |
|
1617 calEntryArray[0]->SetDescriptionL(KDescription()); |
|
1618 calEntryArray[0]->SetLocationL(KLocation()); |
|
1619 calEntryArray[0]->SetMethodL(method); |
|
1620 calEntryArray[0]->SetSequenceNumberL(seq); |
|
1621 |
|
1622 // call all the get methods |
|
1623 // test that they are as expected |
|
1624 test( startTime.TimeLocalL() == calEntryArray[0]->StartTimeL().TimeLocalL()); |
|
1625 test( endTime.TimeLocalL() == calEntryArray[0]->EndTimeL().TimeLocalL()); |
|
1626 RArray<TCalTime> returnedRDateList; |
|
1627 calEntryArray[0]->GetRDatesL(returnedRDateList); |
|
1628 test( date1.TimeLocalL() == returnedRDateList[0].TimeLocalL() ); |
|
1629 test( date2.TimeLocalL() == returnedRDateList[1].TimeLocalL() ); |
|
1630 RArray<TCalTime> returnedEXDateList; |
|
1631 calEntryArray[0]->GetExceptionDatesL(returnedEXDateList); |
|
1632 test( date2.TimeLocalL() == returnedEXDateList[0].TimeLocalL() ); |
|
1633 alarm = calEntryArray[0]->AlarmL(); |
|
1634 test( offset == alarm->TimeOffset() ); |
|
1635 delete alarm; |
|
1636 test( replicationStatus == calEntryArray[0]->ReplicationStatusL() ); |
|
1637 test( priority == calEntryArray[0]->PriorityL()); |
|
1638 test( calEntryArray[0]->CompareL(*calEntryArray[0]) ); |
|
1639 TPtrC temp(calEntryArray[0]->SummaryL()); |
|
1640 test( KSummary().CompareF(calEntryArray[0]->SummaryL()) == 0 ); |
|
1641 test( KDescription().CompareF(calEntryArray[0]->DescriptionL()) == 0); |
|
1642 test( KLocation().CompareF(calEntryArray[0]->LocationL()) == 0); |
|
1643 test( method == calEntryArray[0]->MethodL() ); |
|
1644 test( seq == calEntryArray[0]->SequenceNumberL() ); |
|
1645 test( status == calEntryArray[0]->StatusL() ); // TStatus status(calEntryArray[0]->StatusL()); |
|
1646 |
|
1647 // Set RDates with an empty list, we should delete the exception date aswell !! |
|
1648 calEntryArray[0]->SetRDatesL(rDateList2); |
|
1649 |
|
1650 rDateList1.Close(); |
|
1651 rDateList2.Close(); |
|
1652 exDateList.Close(); |
|
1653 returnedRDateList.Close(); |
|
1654 returnedEXDateList.Close(); |
|
1655 |
|
1656 CleanupStack::PopAndDestroy(); // calEntryArray |
|
1657 |
|
1658 } |
|
1659 |
|
1660 void CTestData::TestSetGetMethodsFloatingL(CCalEntryView* aEntryView, const TDesC8& aGuid) |
|
1661 { |
|
1662 // create test values |
|
1663 _LIT(KSummary,"VIM"); |
|
1664 _LIT(KDescription,"Very Important Meeting"); |
|
1665 _LIT(KLocation,"London"); |
|
1666 |
|
1667 TTime tempTime; |
|
1668 |
|
1669 TCalTime startTime; |
|
1670 tempTime.Set(_L("20101123:120000")); //YYYYMMDD:HHMMSS.MMMMMM |
|
1671 startTime.SetTimeLocalFloatingL(tempTime); |
|
1672 |
|
1673 TCalTime endTime; |
|
1674 tempTime.Set(_L("20101123:130000")); //YYYYMMDD:HHMMSS.MMMMMM |
|
1675 endTime.SetTimeLocalFloatingL(tempTime); |
|
1676 |
|
1677 // TBool completed(EFalse); |
|
1678 |
|
1679 TCalTime completedTime; |
|
1680 tempTime.Set(_L("20101123:140000")); //YYYYMMDD:HHMMSS.MMMMMM |
|
1681 completedTime.SetTimeLocalFloatingL(tempTime); |
|
1682 |
|
1683 tempTime.Set(_L("20101124:120000")); // date1 |
|
1684 TCalTime date1; |
|
1685 date1.SetTimeLocalFloatingL(tempTime); |
|
1686 tempTime.Set(_L("20101125:120000")); // date2 |
|
1687 TCalTime date2; |
|
1688 date2.SetTimeLocalFloatingL(tempTime); |
|
1689 |
|
1690 RArray<TCalTime> rDateList1; |
|
1691 rDateList1.Append(date1); |
|
1692 rDateList1.Append(date2); |
|
1693 |
|
1694 RArray<TCalTime> rDateList2; |
|
1695 |
|
1696 RArray<TCalTime> exDateList; |
|
1697 exDateList.Append(date2); |
|
1698 |
|
1699 CCalEntry::TStatus status(CCalEntry::ETentative); |
|
1700 CCalEntry::TReplicationStatus replicationStatus(CCalEntry::EOpen); |
|
1701 |
|
1702 TUint priority(22); |
|
1703 |
|
1704 CCalEntry::TMethod method(CCalEntry::EMethodNone); |
|
1705 TInt seq(0); |
|
1706 |
|
1707 // get an entry out of the calendar file |
|
1708 RPointerArray<CCalEntry> calEntryArray; |
|
1709 CleanupResetAndDestroyPushL(calEntryArray); |
|
1710 aEntryView->FetchL(aGuid,calEntryArray); |
|
1711 |
|
1712 // call all the set methods |
|
1713 calEntryArray[0]->SetStartAndEndTimeL(startTime, endTime); |
|
1714 calEntryArray[0]->SetLastModifiedDateL(); |
|
1715 calEntryArray[0]->ClearRepeatingPropertiesL(); |
|
1716 calEntryArray[0]->SetRDatesL(rDateList1); |
|
1717 calEntryArray[0]->SetExceptionDatesL(exDateList); |
|
1718 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
1719 CleanupStack::PushL(alarm); |
|
1720 TTimeIntervalMinutes offset(5); |
|
1721 alarm->SetTimeOffset(offset); |
|
1722 calEntryArray[0]->SetAlarmL(alarm); |
|
1723 CleanupStack::PopAndDestroy(alarm); |
|
1724 calEntryArray[0]->SetStatusL(status); |
|
1725 calEntryArray[0]->SetReplicationStatusL(replicationStatus); |
|
1726 calEntryArray[0]->SetPriorityL(priority); |
|
1727 calEntryArray[0]->SetSummaryL(KSummary()); |
|
1728 calEntryArray[0]->SetDescriptionL(KDescription()); |
|
1729 calEntryArray[0]->SetLocationL(KLocation()); |
|
1730 calEntryArray[0]->SetMethodL(method); |
|
1731 calEntryArray[0]->SetSequenceNumberL(seq); |
|
1732 |
|
1733 // call all the get methods |
|
1734 // test that they are as expected |
|
1735 test( startTime.TimeLocalL() == calEntryArray[0]->StartTimeL().TimeLocalL()); |
|
1736 test( endTime.TimeLocalL() == calEntryArray[0]->EndTimeL().TimeLocalL()); |
|
1737 RArray<TCalTime> returnedRDateList; |
|
1738 calEntryArray[0]->GetRDatesL(returnedRDateList); |
|
1739 test( date1.TimeLocalL() == returnedRDateList[0].TimeLocalL() ); |
|
1740 test( date2.TimeLocalL() == returnedRDateList[1].TimeLocalL() ); |
|
1741 RArray<TCalTime> returnedEXDateList; |
|
1742 calEntryArray[0]->GetExceptionDatesL(returnedEXDateList); |
|
1743 test( date2.TimeLocalL() == returnedEXDateList[0].TimeLocalL() ); |
|
1744 alarm = calEntryArray[0]->AlarmL(); |
|
1745 test( offset == alarm->TimeOffset() ); |
|
1746 delete alarm; |
|
1747 test( replicationStatus == calEntryArray[0]->ReplicationStatusL() ); |
|
1748 test( priority == calEntryArray[0]->PriorityL()); |
|
1749 test( calEntryArray[0]->CompareL(*calEntryArray[0]) ); |
|
1750 TPtrC temp(calEntryArray[0]->SummaryL()); |
|
1751 test( KSummary().CompareF(calEntryArray[0]->SummaryL()) == 0 ); |
|
1752 test( KDescription().CompareF(calEntryArray[0]->DescriptionL()) == 0); |
|
1753 test( KLocation().CompareF(calEntryArray[0]->LocationL()) == 0); |
|
1754 test( method == calEntryArray[0]->MethodL() ); |
|
1755 test( seq == calEntryArray[0]->SequenceNumberL() ); |
|
1756 test( status == calEntryArray[0]->StatusL() ); // TStatus status(calEntryArray[0]->StatusL()); |
|
1757 |
|
1758 // Set RDates with an empty list, we should delete the exception date aswell !! |
|
1759 calEntryArray[0]->SetRDatesL(rDateList2); |
|
1760 |
|
1761 rDateList1.Close(); |
|
1762 rDateList2.Close(); |
|
1763 exDateList.Close(); |
|
1764 returnedRDateList.Close(); |
|
1765 returnedEXDateList.Close(); |
|
1766 |
|
1767 CleanupStack::PopAndDestroy(); // calEntryArray |
|
1768 |
|
1769 } |
|
1770 |
|
1771 void CTestData::TestUpdateL(CCalEntryView* aEntryView, const TDesC8& aGuid) |
|
1772 { |
|
1773 RPointerArray<CCalEntry> calEntryArray; |
|
1774 aEntryView->FetchL(aGuid,calEntryArray); |
|
1775 CleanupResetAndDestroyPushL(calEntryArray); |
|
1776 |
|
1777 // Change the description of the entry |
|
1778 _LIT(KDescription,"Very Important Meeting"); |
|
1779 calEntryArray[0]->SetDescriptionL(KDescription()); |
|
1780 |
|
1781 //remove the child entry |
|
1782 delete calEntryArray[1]; |
|
1783 calEntryArray.Remove(1); |
|
1784 |
|
1785 TInt NumberOfEntries(0); |
|
1786 aEntryView->UpdateL(calEntryArray,NumberOfEntries); |
|
1787 |
|
1788 // Test the entry was updated |
|
1789 test( NumberOfEntries == calEntryArray.Count()); |
|
1790 |
|
1791 calEntryArray.ResetAndDestroy(); |
|
1792 // Fetch the entry again |
|
1793 aEntryView->FetchL(aGuid,calEntryArray); |
|
1794 |
|
1795 test( !KDescription().CompareF(calEntryArray[0]->DescriptionL()) ); |
|
1796 |
|
1797 CleanupStack::PopAndDestroy(); // calEntryArray |
|
1798 } |
|
1799 |
|
1800 |
|
1801 // Creates a Parent entry and sets some exception dates on the parent |
|
1802 // Intended to be used with GetDailyTestData1L(). |
|
1803 void CTestData::CreateParentGsEntryWithExceptionsL(TCalRRule* aRpt, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
1804 { |
|
1805 CleanupStack::PushL(aRpt); |
|
1806 |
|
1807 CCalEntry* entry = CreateParentLC(aRpt, aGuid, aType, aFloating); |
|
1808 |
|
1809 // Set 3 exceptions on the parent (6, 9, 12 March 2005) |
|
1810 RArray<TCalTime> exArray; |
|
1811 |
|
1812 TCalTime exTime1; |
|
1813 TCalTime exTime2; |
|
1814 TCalTime exTime3; |
|
1815 |
|
1816 if (aFloating) |
|
1817 { |
|
1818 exTime1.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 5, 0, 0, 0, 0)); // 6 March |
|
1819 exTime2.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 8, 0, 0, 0, 0)); // 9 March |
|
1820 exTime3.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 11, 0, 0, 0, 0)); // 12 March |
|
1821 } |
|
1822 else |
|
1823 { |
|
1824 exTime1.SetTimeUtcL(TDateTime(2005, EMarch, 5, 0, 0, 0, 0)); // 6 March |
|
1825 exTime2.SetTimeUtcL(TDateTime(2005, EMarch, 8, 0, 0, 0, 0)); // 9 March |
|
1826 exTime3.SetTimeUtcL(TDateTime(2005, EMarch, 11, 0, 0, 0, 0)); // 12 March |
|
1827 } |
|
1828 |
|
1829 exArray.Append(exTime1); |
|
1830 exArray.Append(exTime2); |
|
1831 exArray.Append(exTime3); |
|
1832 |
|
1833 entry->SetExceptionDatesL(exArray); |
|
1834 |
|
1835 RPointerArray<CCalEntry> array; |
|
1836 CleanupClosePushL(array); |
|
1837 array.Append(entry); |
|
1838 TInt success(0); |
|
1839 aEntryView->StoreL(array, success); |
|
1840 CleanupStack::Pop(&array); |
|
1841 array.Reset(); |
|
1842 |
|
1843 exArray.Reset(); |
|
1844 CleanupStack::PopAndDestroy(entry); |
|
1845 CleanupStack::PopAndDestroy(aRpt); |
|
1846 } |
|
1847 |
|
1848 |
|
1849 void CTestData::CreateParentGsEntryWithSporadicsL(TCalRRule* aRpt, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
1850 { |
|
1851 CleanupStack::PushL(aRpt); |
|
1852 |
|
1853 CCalEntry* entry = CreateParentLC(aRpt, aGuid, aType, aFloating); |
|
1854 |
|
1855 // Set 3 sporadic dates on the parent (3, 13, 19 March 2005) |
|
1856 RArray<TCalTime> rDateArray; |
|
1857 |
|
1858 TCalTime rDate1; |
|
1859 TCalTime rDate2; |
|
1860 TCalTime rDate3; |
|
1861 |
|
1862 if (aFloating) |
|
1863 { |
|
1864 rDate1.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 2, 0, 0, 0, 0)); // 3 March |
|
1865 rDate2.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 12, 0, 0, 0, 0)); // 13 March |
|
1866 rDate3.SetTimeLocalFloatingL(TDateTime(2005, EMarch, 18, 0, 0, 0, 0)); // 19 March |
|
1867 } |
|
1868 else |
|
1869 { |
|
1870 rDate1.SetTimeUtcL(TDateTime(2005, EMarch, 2, 0, 0, 0, 0)); // 3 March |
|
1871 rDate2.SetTimeUtcL(TDateTime(2005, EMarch, 12, 0, 0, 0, 0)); // 13 March |
|
1872 rDate3.SetTimeUtcL(TDateTime(2005, EMarch, 18, 0, 0, 0, 0)); // 19 March |
|
1873 } |
|
1874 |
|
1875 rDateArray.Append(rDate1); |
|
1876 rDateArray.Append(rDate2); |
|
1877 rDateArray.Append(rDate3); |
|
1878 |
|
1879 entry->SetRDatesL(rDateArray); |
|
1880 |
|
1881 RPointerArray<CCalEntry> array; |
|
1882 CleanupClosePushL(array); |
|
1883 array.Append(entry); |
|
1884 TInt success(0); |
|
1885 aEntryView->StoreL(array, success); |
|
1886 CleanupStack::Pop(&array); |
|
1887 array.Reset(); |
|
1888 |
|
1889 rDateArray.Reset(); |
|
1890 CleanupStack::PopAndDestroy(entry); |
|
1891 CleanupStack::PopAndDestroy(aRpt); |
|
1892 } |
|
1893 |
|
1894 // Creates a child exception entry which has a RecId refering to an occurrence in the parent |
|
1895 // and specifies a new occurrence to replace the original according to the child entry's start/end date. |
|
1896 void CTestData::CreateChildExceptionGsEntryL(TTestDataStruct* aTestData, TInt aRecIdToUse, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
1897 { |
|
1898 HBufC8* guid = aGuid.AllocLC(); // Create GUID on heap |
|
1899 |
|
1900 // Use Rec-id as given by test-data |
|
1901 TTime ttime = aTestData->iRecIds[aRecIdToUse-1]; |
|
1902 TCalTime recurrenceId; |
|
1903 if (aFloating) |
|
1904 { |
|
1905 recurrenceId.SetTimeLocalFloatingL(ttime); |
|
1906 } |
|
1907 else |
|
1908 { |
|
1909 recurrenceId.SetTimeUtcL(ttime); |
|
1910 } |
|
1911 CalCommon::TRecurrenceRange range = CalCommon::EThisOnly; |
|
1912 |
|
1913 // Create a child |
|
1914 // Below takes ownership of guid |
|
1915 CCalEntry* entry = CCalEntry::NewL( aType, guid, CCalEntry::EMethodRequest, (TUint)0, |
|
1916 recurrenceId, range); |
|
1917 |
|
1918 CleanupStack::Pop(guid); |
|
1919 CleanupStack::PushL(entry); |
|
1920 |
|
1921 // Set Start date to be somewhere outside of parent's schedule. End time is 1 hour later. |
|
1922 TTime startDate = TDateTime(2005, EMarch, 18, 0, 0, 0, 0); // 19 March |
|
1923 TTime endDate = (startDate + TTimeIntervalHours(1)); |
|
1924 |
|
1925 TCalTime startTime; |
|
1926 TCalTime endTime; |
|
1927 |
|
1928 if (aFloating) |
|
1929 { |
|
1930 startTime.SetTimeLocalFloatingL(startDate); |
|
1931 endTime.SetTimeLocalFloatingL(endDate); |
|
1932 } |
|
1933 else |
|
1934 { |
|
1935 startTime.SetTimeUtcL(startDate); |
|
1936 endTime.SetTimeUtcL(endDate); |
|
1937 } |
|
1938 entry->SetStartAndEndTimeL(startTime, endTime); |
|
1939 |
|
1940 RPointerArray<CCalEntry> array; |
|
1941 CleanupClosePushL(array); |
|
1942 array.Append(entry); |
|
1943 TInt success(0); |
|
1944 aEntryView->StoreL(array, success); |
|
1945 CleanupStack::Pop(&array); |
|
1946 array.Reset(); |
|
1947 |
|
1948 CleanupStack::PopAndDestroy(entry); |
|
1949 } |
|
1950 |
|
1951 // Creates a child exception entry which has a RecId refering to an occurrence in the parent |
|
1952 // and specifies a new occurrence to replace the original according to the child entry's start/end date. |
|
1953 void CTestData::CreateChildExceptionGsEntry_1L(TTestDataStruct* aTestData, TInt aRecIdToUse, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
1954 { |
|
1955 HBufC8* guid = aGuid.AllocLC(); // Create GUID on heap |
|
1956 |
|
1957 // Use Rec-id as given by test-data |
|
1958 TTime ttime = aTestData->iRecIds[aRecIdToUse-1]; |
|
1959 TCalTime recurrenceId; |
|
1960 if (aFloating) |
|
1961 { |
|
1962 recurrenceId.SetTimeLocalFloatingL(ttime); |
|
1963 } |
|
1964 else |
|
1965 { |
|
1966 recurrenceId.SetTimeUtcL(ttime); |
|
1967 } |
|
1968 CalCommon::TRecurrenceRange range = CalCommon::EThisOnly; |
|
1969 |
|
1970 // Create a child |
|
1971 // Below takes ownership of guid |
|
1972 CCalEntry* entry = CCalEntry::NewL( aType, guid, CCalEntry::EMethodRequest, (TUint)0, |
|
1973 recurrenceId, range); |
|
1974 |
|
1975 CleanupStack::Pop(guid); |
|
1976 CleanupStack::PushL(entry); |
|
1977 |
|
1978 // Set Start date to be somewhere outside of parent's schedule. End time is 1 hour later. |
|
1979 TTime startDate = TDateTime(2005, EApril, 17, 0, 0, 0, 0); // 18 April |
|
1980 TTime endDate = (startDate + TTimeIntervalHours(1)); |
|
1981 |
|
1982 TCalTime startTime; |
|
1983 TCalTime endTime; |
|
1984 |
|
1985 if (aFloating) |
|
1986 { |
|
1987 startTime.SetTimeLocalFloatingL(startDate); |
|
1988 endTime.SetTimeLocalFloatingL(endDate); |
|
1989 } |
|
1990 else |
|
1991 { |
|
1992 startTime.SetTimeLocalL(startDate); |
|
1993 endTime.SetTimeLocalL(endDate); |
|
1994 } |
|
1995 entry->SetStartAndEndTimeL(startTime, endTime); |
|
1996 |
|
1997 RPointerArray<CCalEntry> array; |
|
1998 CleanupClosePushL(array); |
|
1999 array.Append(entry); |
|
2000 TInt success(0); |
|
2001 aEntryView->StoreL(array, success); |
|
2002 CleanupStack::Pop(&array); |
|
2003 array.Reset(); |
|
2004 |
|
2005 CleanupStack::PopAndDestroy(entry); |
|
2006 } |
|
2007 |
|
2008 // Creates a child rpt rule entry which has a RecId refering to an occurrence in the parent |
|
2009 // and specifies a rpt rule to modify the parent's rrule. |
|
2010 // The parent rrule this is intended to work with is defined in GetWeeklyTestData1L() |
|
2011 // and is Weekly, Wed from 6 March to 10 April 2005. |
|
2012 void CTestData::CreateChildRRuleGsEntryL(TCalRRule* aRpt, TTestDataStruct* aTestData, TInt aRecIdToUse, CalCommon::TRecurrenceRange aRange, CCalEntryView* aEntryView, const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
2013 { |
|
2014 CleanupStack::PushL(aRpt); |
|
2015 |
|
2016 HBufC8* guid = aGuid.AllocLC(); // Create GUID on heap |
|
2017 |
|
2018 // Use Rec-id as given by test-data |
|
2019 TTime ttime = aTestData->iRecIds[aRecIdToUse-1]; |
|
2020 TCalTime recurrenceId; |
|
2021 if (aFloating) |
|
2022 { |
|
2023 recurrenceId.SetTimeLocalFloatingL(ttime); |
|
2024 } |
|
2025 else |
|
2026 { |
|
2027 recurrenceId.SetTimeUtcL(ttime); |
|
2028 } |
|
2029 |
|
2030 // Create a child |
|
2031 // Below takes ownership of guid |
|
2032 CCalEntry* entry = CCalEntry::NewL( aType, guid, CCalEntry::EMethodRequest, (TUint)0, |
|
2033 recurrenceId, aRange); |
|
2034 |
|
2035 CleanupStack::Pop(guid); |
|
2036 CleanupStack::PushL(entry); |
|
2037 |
|
2038 // Set the start time to be same as repeat def's start time |
|
2039 // and the end time to be 1 hour after start time. |
|
2040 TCalTime startTime; |
|
2041 TCalTime calEndTime; |
|
2042 if (aFloating) |
|
2043 { |
|
2044 startTime.SetTimeLocalFloatingL(aRpt->DtStart().TimeLocalL()); |
|
2045 TTime endTime = aRpt->DtStart().TimeLocalL() + TTimeIntervalHours(1); |
|
2046 calEndTime.SetTimeLocalFloatingL(endTime); |
|
2047 } |
|
2048 else |
|
2049 { |
|
2050 startTime = aRpt->DtStart(); |
|
2051 TTime endTime = aRpt->DtStart().TimeUtcL() + TTimeIntervalHours(1); |
|
2052 calEndTime.SetTimeUtcL(endTime); |
|
2053 } |
|
2054 |
|
2055 entry->SetStartAndEndTimeL(startTime, calEndTime); |
|
2056 entry->SetRRuleL(*aRpt); // doesn't take ownership |
|
2057 |
|
2058 RPointerArray<CCalEntry> array; |
|
2059 CleanupClosePushL(array); |
|
2060 array.Append(entry); |
|
2061 TInt success(0); |
|
2062 |
|
2063 aEntryView->StoreL(array, success); |
|
2064 |
|
2065 CleanupStack::Pop(&array); |
|
2066 array.Reset(); |
|
2067 |
|
2068 CleanupStack::PopAndDestroy(entry); |
|
2069 CleanupStack::PopAndDestroy(aRpt); |
|
2070 } |
|
2071 |
|
2072 void CTestData::TestDeletionOfChildExceptionsL(CCalEntryView* aEntryView, CCalInstanceView* aInstanceView, const TDesC8& aGuid) |
|
2073 { |
|
2074 RPointerArray<CCalEntry> calEntryList; |
|
2075 CleanupResetAndDestroyPushL(calEntryList); |
|
2076 aEntryView->FetchL(aGuid, calEntryList); |
|
2077 |
|
2078 // delete the child exceptions |
|
2079 // this should delete the parent as it will be redundant |
|
2080 const TInt KEntryCount(calEntryList.Count()); |
|
2081 for (TInt i(1) ; i < KEntryCount ; ++i) |
|
2082 { |
|
2083 aEntryView->DeleteL(*calEntryList[i]); |
|
2084 } |
|
2085 |
|
2086 // set up time range to search for instances |
|
2087 TCalTime startCalTime; |
|
2088 TCalTime endCalTime; |
|
2089 startCalTime.SetTimeLocalL(TTime(TDateTime(2005, EMarch, 0, 0, 0, 0, 0))); // 1 March 2005 |
|
2090 endCalTime.SetTimeLocalL(TTime(TDateTime(2005, EApril, 26, 0, 0, 0, 0))); // 27 April 2005 |
|
2091 CalCommon::TCalTimeRange calTimeRange(startCalTime, endCalTime); |
|
2092 |
|
2093 RPointerArray<CCalInstance> instanceList; |
|
2094 CleanupResetAndDestroyPushL(instanceList); |
|
2095 aInstanceView->FindInstanceL(instanceList, CalCommon::EIncludeAll, calTimeRange); |
|
2096 |
|
2097 // test that there are no instances in the time range |
|
2098 test(instanceList.Count() == 0); |
|
2099 |
|
2100 CleanupStack::PopAndDestroy(2); // instanceList, calEntryList |
|
2101 } |
|
2102 |
|
2103 // Creates a parent entry with a daily rpt rule |
|
2104 // and adds rdates to the parent entry. |
|
2105 void CTestData::CreateWeeklyParentGsEntryWithRDateRRuleL(TTestDataStruct& aTestData, CCalEntryView* aEntryView, const TDesC8& aGuid, TExceptionRDate aExcpnRDate, CCalEntry::TType aType, TBool aFloating) |
|
2106 { |
|
2107 TCalRRule rptRule(TCalRRule::EDaily); |
|
2108 if (aFloating) |
|
2109 { |
|
2110 rptRule.SetInterval(1); |
|
2111 TCalTime startTime; |
|
2112 startTime.SetTimeLocalFloatingL(TDateTime(2005, EDecember, 13, 10, 0, 0, 0)); |
|
2113 rptRule.SetDtStart(startTime); // 13 Dec 2005 |
|
2114 TCalTime endTime; |
|
2115 endTime.SetTimeLocalFloatingL(TDateTime(2005, EDecember, 15, 10, 0, 0, 0)); |
|
2116 rptRule.SetUntil(endTime); // 16 Dec 2005 |
|
2117 |
|
2118 aTestData.iStartDate = TDateTime(2005, EDecember, 0, 0, 0, 0, 0); // 1 Dec 2005 |
|
2119 aTestData.iEndDate = TDateTime(2005, EDecember, 30, 0, 0, 0, 0); // 31 Dec 2005 |
|
2120 aTestData.iDescription.Append(_L(" Every 1 days from 13 Dec 05\n")); |
|
2121 |
|
2122 // Set up the RecId's |
|
2123 aTestData.iRecIds.Append(TTime(TDateTime(2005, EDecember, 13, 10, 0, 0, 0))); // 14 Dec |
|
2124 aTestData.iRecIds.Append(TTime(TDateTime(2005, EDecember, 14, 10, 0, 0, 0))); // 15 Dec |
|
2125 aTestData.iRecIds.Append(TTime(TDateTime(2005, EDecember, 15, 10, 0, 0, 0))); // 16 Dec |
|
2126 } |
|
2127 else |
|
2128 { |
|
2129 rptRule.SetInterval(1); |
|
2130 TCalTime startTime; |
|
2131 startTime.SetTimeLocalL(TDateTime(2005, EDecember, 13, 10, 0, 0, 0)); |
|
2132 rptRule.SetDtStart(startTime); // 13 Dec 2005 |
|
2133 TCalTime endTime; |
|
2134 endTime.SetTimeLocalL(TDateTime(2005, EDecember, 15, 10, 0, 0, 0)); |
|
2135 rptRule.SetUntil(endTime); // 16 Dec 2005 |
|
2136 |
|
2137 aTestData.iStartDate = TDateTime(2005, EDecember, 0, 0, 0, 0, 0); // 1 Dec 2005 |
|
2138 aTestData.iEndDate = TDateTime(2005, EDecember, 30, 0, 0, 0, 0); // 31 Dec 2005 |
|
2139 aTestData.iDescription.Append(_L(" Every 1 days from 13 Dec 05\n")); |
|
2140 |
|
2141 // Set up the RecId's |
|
2142 aTestData.iRecIds.Append(TTime(TDateTime(2005, EDecember, 13, 10, 0, 0, 0))); // 14 Dec |
|
2143 aTestData.iRecIds.Append(TTime(TDateTime(2005, EDecember, 14, 10, 0, 0, 0))); // 15 Dec |
|
2144 aTestData.iRecIds.Append(TTime(TDateTime(2005, EDecember, 15, 10, 0, 0, 0))); // 16 Dec |
|
2145 } |
|
2146 |
|
2147 CCalEntry* entry = CreateParentLC(&rptRule, aGuid, aType, aFloating); |
|
2148 |
|
2149 RArray<TCalTime> rDateArray; |
|
2150 CleanupClosePushL(rDateArray); |
|
2151 |
|
2152 // Add rdates to parent rpt rule |
|
2153 TCalTime rDate1; |
|
2154 if (aExcpnRDate == ERDateBeforeRRule) // etrue for now |
|
2155 { |
|
2156 if (aFloating) |
|
2157 { |
|
2158 rDate1.SetTimeLocalFloatingL(TDateTime(2005, EDecember, 11, 9, 0, 0, 0)); // 12 Dec |
|
2159 } |
|
2160 else |
|
2161 { |
|
2162 rDate1.SetTimeLocalL(TDateTime(2005, EDecember, 11, 9, 0, 0, 0)); // 12 Dec |
|
2163 } |
|
2164 } |
|
2165 else if (aExcpnRDate == ERDateAfterRRule) |
|
2166 { |
|
2167 if (aFloating) |
|
2168 { |
|
2169 rDate1.SetTimeLocalFloatingL(TDateTime(2005, EDecember, 19, 9, 0, 0, 0)); // 20 Dec |
|
2170 } |
|
2171 else |
|
2172 { |
|
2173 rDate1.SetTimeLocalL(TDateTime(2005, EDecember, 19, 9, 0, 0, 0)); // 20 Dec |
|
2174 } |
|
2175 } |
|
2176 rDateArray.Append(rDate1); |
|
2177 entry->SetRDatesL(rDateArray); |
|
2178 |
|
2179 // set RRule again as mentioned in defect DEF076160 |
|
2180 //TCalRRule rptRule2; |
|
2181 //entry->GetRRuleL(rptRule2); |
|
2182 //entry->SetRRuleL(rptRule2); |
|
2183 |
|
2184 RPointerArray<CCalEntry> array; |
|
2185 CleanupClosePushL(array); |
|
2186 array.Append(entry); |
|
2187 TInt success(0); |
|
2188 aEntryView->StoreL(array, success); |
|
2189 CleanupStack::Pop(&array); |
|
2190 array.Reset(); |
|
2191 |
|
2192 CleanupStack::PopAndDestroy(); // rDateArray |
|
2193 CleanupStack::PopAndDestroy(entry); |
|
2194 } |
|
2195 |
|
2196 |
|
2197 void CTestData::SetExceptionsL(CCalEntry* aEntry, RArray<TTime>& aTimes, TBool aFloating) |
|
2198 { |
|
2199 RArray<TCalTime> exArray; |
|
2200 CleanupClosePushL(exArray); |
|
2201 |
|
2202 TCalTime calTime; |
|
2203 TInt nExceptions = aTimes.Count(); |
|
2204 for (TInt i=0; i<nExceptions; i++) |
|
2205 { |
|
2206 aFloating ? calTime.SetTimeLocalFloatingL(aTimes[i]) : calTime.SetTimeUtcL(aTimes[i]); |
|
2207 exArray.Append(calTime); |
|
2208 } |
|
2209 aEntry->SetExceptionDatesL(exArray); |
|
2210 CleanupStack::PopAndDestroy(&exArray); |
|
2211 } |
|
2212 |
|
2213 void CTestData::TestDeletionOfEntryThatHasNoInstancesL(TCalRRule* aRpt, TTestDataStruct& aData, |
|
2214 CCalEntryView* aEntryView, CCalInstanceView* /*aInstanceView*/, |
|
2215 const TDesC8& aGuid, CCalEntry::TType aType, TBool aFloating) |
|
2216 { |
|
2217 CleanupStack::PushL(aRpt); |
|
2218 |
|
2219 RPointerArray<CCalEntry> entries; |
|
2220 CleanupResetAndDestroyPushL(entries); |
|
2221 |
|
2222 // Attempt addition of an entry that has all its instances marked as exceptions. |
|
2223 // Such entry has no effective occurences. StoreL() ignores this fact and |
|
2224 // allows to store such dummy entry without problem. |
|
2225 CCalEntry* entry = CreateParentLC(aRpt, aGuid, aType, aFloating); |
|
2226 SetExceptionsL(entry, aData.iRecIds, aFloating); |
|
2227 entries.Append(entry); |
|
2228 CleanupStack::Pop(entry); |
|
2229 TInt success(0); |
|
2230 TRAPD(err, aEntryView->StoreL(entries, success)); |
|
2231 test(err==KErrNone); // allow dummy entry (all instances are exceptions) to be stored |
|
2232 entries.ResetAndDestroy(); |
|
2233 |
|
2234 // Store valid entry first, then fetch it, set exceptions on all instances, store again. |
|
2235 // Expect that StoreL() results in deletion of the entry as it no longer has any instances. |
|
2236 entry = CreateParentLC(aRpt, aGuid, aType, aFloating); |
|
2237 entries.Append(entry); |
|
2238 CleanupStack::Pop(entry); |
|
2239 aEntryView->StoreL(entries, success); |
|
2240 test(success==1); |
|
2241 entries.ResetAndDestroy(); |
|
2242 |
|
2243 aEntryView->FetchL(aGuid, entries); |
|
2244 test(entries.Count()==1); |
|
2245 |
|
2246 SetExceptionsL(entries[0], aData.iRecIds, aFloating); |
|
2247 TRAP(err, aEntryView->StoreL(entries, success)); |
|
2248 test(err==KErrNone); |
|
2249 test(success==1); // success is 1, although in fact the entry was deleted, check this below. |
|
2250 entries.ResetAndDestroy(); |
|
2251 |
|
2252 aEntryView->FetchL(aGuid, entries); |
|
2253 TInt nEntries = entries.Count(); |
|
2254 test(nEntries==0); |
|
2255 |
|
2256 CleanupStack::PopAndDestroy(&entries); |
|
2257 CleanupStack::PopAndDestroy(aRpt); |
|
2258 } |
|
2259 |
|
2260 |
|
2261 void CTestData::StoreRestoreL(CCalEntryView* aEntryView, const TDesC8& aGuid) |
|
2262 { |
|
2263 // parent: CreateWeeklyParentGsEntryWithExceptionsRdatesL(EException) |
|
2264 // march:X[09]wed [16] X[23] X[30] april:[06] [13] [20] (7 instances, 3 exceptions) |
|
2265 // |
|
2266 // child: GetWeeklyTestDataModification1L() |
|
2267 // april: [08]fri [15] [22] |
|
2268 // |
|
2269 // hang the child on the 2nd instance of the parent (16/03) This&Future: |
|
2270 // |
|
2271 // parent becomes: |
|
2272 // march:X[09] X[16] - others trimmed (2 instances, 2 exceptions) |
|
2273 // |
|
2274 // TEST: fetch the parent, and store it back again without modification. |
|
2275 // EXPECTED RESULT: although all instances of the parent are exceptioned, you would expect the parent |
|
2276 // entry not to be deleted, because of a child. |
|
2277 // The truth is that the child is deleted when parent is updated. |
|
2278 // If you re-store (update) the parent one more time (without a child this time), |
|
2279 // such parent will be deleted as a result of the update operation. |
|
2280 |
|
2281 RPointerArray<CCalEntry> entries; |
|
2282 CleanupResetAndDestroyPushL(entries); |
|
2283 |
|
2284 aEntryView->FetchL(aGuid, entries); |
|
2285 test(entries.Count()==2); // a parent and a child |
|
2286 |
|
2287 delete entries[1]; // discard the child |
|
2288 entries.Remove(1); |
|
2289 |
|
2290 TInt success(0); |
|
2291 TRAPD(err, aEntryView->StoreL(entries, success)); // re-store parent only |
|
2292 test(err==KErrNone); |
|
2293 test(success==1); |
|
2294 entries.ResetAndDestroy(); |
|
2295 aEntryView->FetchL(aGuid, entries); |
|
2296 test(entries.Count()==1); // child is deleted as a result of update of the parent entry |
|
2297 |
|
2298 TRAP(err, aEntryView->StoreL(entries, success)); // re-store parent (has no child any more) |
|
2299 test(err==KErrNone); |
|
2300 test(success==1); |
|
2301 entries.ResetAndDestroy(); |
|
2302 aEntryView->FetchL(aGuid, entries); |
|
2303 test(entries.Count()==0); // single parent was deleted as a result of update operation |
|
2304 |
|
2305 CleanupStack::PopAndDestroy(&entries); |
|
2306 } |