author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// SYSTEM INCLUDE FILES |
|
22 |
#include <e32base.h> |
|
23 |
#include <f32file.h> //for RFile and Rfs |
|
24 |
||
25 |
#include "calendarheader.h" |
|
26 |
#include "calendarservice.h" |
|
27 |
||
28 |
// USER INCLUDE FILES |
|
29 |
#include "calimptestcases.h" |
|
30 |
#include "teststartconsolealarmserver.h" |
|
31 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
32 |
#include<ascliclientutils.h> |
19 | 33 |
|
34 |
||
35 |
_LIT(KCalName ,"c:Calendar"); |
|
36 |
||
37 |
||
38 |
||
39 |
_LIT(KImportGuidsFile ,"C:\\ImportGuidsOutput.txt"); |
|
40 |
_LIT(KImportLuidsFile ,"C:\\ImportLuidsOutput.txt"); |
|
41 |
||
42 |
_LIT(KImportAsyncGuidsFile ,"C:\\ImportGuidsOutputAsync.txt"); |
|
43 |
_LIT(KImportAsyncLuidsFile ,"C:\\ImportLuidsOutputAsync.txt"); |
|
44 |
||
45 |
_LIT8(KParseToken ,"|"); |
|
46 |
||
47 |
_LIT(KICALImportGuidsFile ,"C:\\ICALImportGuidsOutput.txt"); |
|
48 |
_LIT(KICALImportLuidsFile ,"C:\\ICALImportLuidsOutput.txt"); |
|
49 |
||
50 |
_LIT(KICALImportAsyncGuidsFile ,"C:\\ICALImportAsyncGuidsOutput.txt"); |
|
51 |
_LIT(KICALImportAsyncLuidsFile ,"C:\\ICALImportAsyncLuidsOutput.txt"); |
|
52 |
||
53 |
||
54 |
||
55 |
_LIT(KTestCal1Name ,"c:testcal1imp"); |
|
56 |
_LIT(KTestCal2Name ,"c:testcal2imp"); |
|
57 |
||
58 |
_LIT(KTestCal1NameAsync ,"c:testcal1impAsync"); |
|
59 |
_LIT(KTestCal2NameAsync ,"c:testcal2impAsync"); |
|
60 |
||
61 |
CCalImpTestCases* CCalImpTestCases::NewL( TInt& aResult, TInt aVCalOrICal) //1 means VCal else ICal |
|
62 |
{ |
|
63 |
CCalImpTestCases* self = new(ELeave)CCalImpTestCases( aResult, aVCalOrICal ); |
|
64 |
||
65 |
self->ConstructL(); |
|
66 |
||
67 |
return self; |
|
68 |
} |
|
69 |
||
70 |
CCalImpTestCases::~CCalImpTestCases() |
|
71 |
{ |
|
72 |
Cancel(); |
|
73 |
||
74 |
if(iWaitSchedular->IsStarted()) |
|
75 |
iWaitSchedular->AsyncStop(); |
|
76 |
||
77 |
if(iCalendarService) |
|
78 |
delete iCalendarService; |
|
79 |
||
80 |
if(iWaitSchedular) |
|
81 |
delete iWaitSchedular; |
|
82 |
||
83 |
if(iArruids.Count()) |
|
84 |
iArruids.ResetAndDestroy(); |
|
85 |
} |
|
86 |
||
87 |
||
88 |
// |
|
89 |
//Whats done here? |
|
90 |
// Export all the contents of Default System Calender to a buffer using Export of CCalendarService |
|
91 |
// Use the buffer to import them to "importtothiscalender" and the generated guids and luids are outputted to |
|
92 |
// ImportGuidsOutput.txt and ImportLuidsOutput.txt respectively |
|
93 |
// |
|
94 |
TInt CCalImpTestCases::TestImportL() |
|
95 |
{ |
|
96 |
iTestCaseType = KImportSync; |
|
97 |
||
98 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
99 |
||
100 |
iResult = AddCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
101 |
||
102 |
if(iResult != KErrNone) |
|
103 |
return iResult ; |
|
104 |
||
105 |
RPointerArray<TUIDSet> arruids(5); |
|
106 |
||
107 |
TUIDSet* uids = NULL; |
|
108 |
||
109 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
110 |
{ |
|
111 |
arruids.Append(uids); |
|
112 |
uids = NULL; |
|
113 |
} |
|
114 |
||
115 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
116 |
{ |
|
117 |
arruids.Append(uids); |
|
118 |
uids = NULL; |
|
119 |
} |
|
120 |
||
121 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
122 |
{ |
|
123 |
arruids.Append(uids); |
|
124 |
uids = NULL; |
|
125 |
} |
|
126 |
||
127 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
128 |
{ |
|
129 |
arruids.Append(uids); |
|
130 |
uids = NULL; |
|
131 |
} |
|
132 |
||
133 |
if(AddToDo(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids) |
|
134 |
{ |
|
135 |
arruids.Append(uids); |
|
136 |
uids = NULL; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL(); |
|
141 |
||
142 |
HBufC8* buffer = NULL; |
|
143 |
||
144 |
if( iVCalOrICal == 1) |
|
145 |
{ |
|
146 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) ); |
|
147 |
} |
|
148 |
else |
|
149 |
{ |
|
150 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) ); |
|
151 |
} |
|
152 |
||
153 |
delete expParams; |
|
154 |
||
155 |
if(iResult != KErrNone) |
|
156 |
{ |
|
157 |
delete buffer; |
|
158 |
arruids.ResetAndDestroy(); |
|
159 |
return iResult; |
|
160 |
} |
|
161 |
||
162 |
||
163 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
164 |
||
165 |
iResult = AddCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
166 |
||
167 |
if(iResult != KErrNone) |
|
168 |
return iResult ; |
|
169 |
||
170 |
RPointerArray<TUIDSet> uIDSet(5); |
|
171 |
||
172 |
if( iVCalOrICal == 1) |
|
173 |
{ |
|
174 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *buffer ,uIDSet ) ); |
|
175 |
} |
|
176 |
else |
|
177 |
{ |
|
178 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *buffer ,uIDSet ) ); |
|
179 |
} |
|
180 |
||
181 |
||
182 |
if(iResult != KErrNone) |
|
183 |
{ |
|
184 |
delete buffer; |
|
185 |
arruids.ResetAndDestroy(); |
|
186 |
uIDSet.ResetAndDestroy(); |
|
187 |
return iResult; |
|
188 |
} |
|
189 |
||
190 |
if ( arruids.Count() != uIDSet.Count() ) |
|
191 |
iResult = KErrGeneral; |
|
192 |
||
193 |
delete buffer; |
|
194 |
arruids.ResetAndDestroy(); |
|
195 |
uIDSet.ResetAndDestroy(); |
|
196 |
||
197 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()()); |
|
198 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()()); |
|
199 |
||
200 |
return iResult; |
|
201 |
} |
|
202 |
||
203 |
||
204 |
// |
|
205 |
//Whats done here? |
|
206 |
// Export all the contents of Default System Calender to a buffer using Export of CCalendarService |
|
207 |
// Use the buffer to import them to "importtothiscalender" and the generated guids and luids are outputted to |
|
208 |
// ImportGuidsOutputAsync.txt and ImportLuidsOutputAsync.txt respectively |
|
209 |
// |
|
210 |
void CCalImpTestCases::TestImportAsyncL() |
|
211 |
{ |
|
212 |
Start(); |
|
213 |
} |
|
214 |
||
215 |
TInt CCalImpTestCases::Result() |
|
216 |
{ |
|
217 |
return iResult; |
|
218 |
} |
|
219 |
||
220 |
void CCalImpTestCases::ConstructL() |
|
221 |
{ |
|
222 |
CActiveScheduler::Add(this); |
|
223 |
||
224 |
iCalendarService = CCalendarService::NewL(); |
|
225 |
||
226 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
227 |
} |
|
228 |
||
229 |
CCalImpTestCases::CCalImpTestCases( TInt& aResult, TInt aVCalOrICal): CActive(EPriorityStandard), iResult(aResult) , |
|
230 |
iVCalOrICal(aVCalOrICal) |
|
231 |
{ |
|
232 |
||
233 |
} |
|
234 |
||
235 |
//for the sake of ActiveObject |
|
236 |
void CCalImpTestCases::DoCancel() |
|
237 |
{ |
|
238 |
||
239 |
} |
|
240 |
||
241 |
void CCalImpTestCases::RunL() |
|
242 |
{ |
|
243 |
RemoveCalendarFile(iCalendarService, KTestCal1NameAsync.operator()()); |
|
244 |
||
245 |
iResult = AddCalendarFile(iCalendarService, KTestCal1NameAsync.operator()()); |
|
246 |
||
247 |
if(iResult != KErrNone) |
|
248 |
goto Final; |
|
249 |
||
250 |
TUIDSet* uids = NULL; |
|
251 |
||
252 |
if(AddAppointment(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids) |
|
253 |
{ |
|
254 |
iArruids.Append(uids); |
|
255 |
uids = NULL; |
|
256 |
} |
|
257 |
||
258 |
if(AddEvent(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids) |
|
259 |
{ |
|
260 |
iArruids.Append(uids); |
|
261 |
uids = NULL; |
|
262 |
} |
|
263 |
||
264 |
if(AddReminder(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids) |
|
265 |
{ |
|
266 |
iArruids.Append(uids); |
|
267 |
uids = NULL; |
|
268 |
} |
|
269 |
||
270 |
if(AddAnny(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids) |
|
271 |
{ |
|
272 |
iArruids.Append(uids); |
|
273 |
uids = NULL; |
|
274 |
} |
|
275 |
||
276 |
if(AddToDo(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids) |
|
277 |
{ |
|
278 |
iArruids.Append(uids); |
|
279 |
uids = NULL; |
|
280 |
} |
|
281 |
||
282 |
||
283 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL(); |
|
284 |
||
285 |
||
286 |
HBufC8* buffer = NULL; |
|
287 |
||
288 |
if( iVCalOrICal == 1) |
|
289 |
{ |
|
290 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatVCal.operator()() , expParams ,buffer ) ); |
|
291 |
} |
|
292 |
else |
|
293 |
{ |
|
294 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatICal.operator()() , expParams ,buffer ) ); |
|
295 |
} |
|
296 |
||
297 |
delete expParams; |
|
298 |
||
299 |
if(iResult != KErrNone) |
|
300 |
{ |
|
301 |
delete buffer; |
|
302 |
iWaitSchedular->AsyncStop(); |
|
303 |
goto Final; |
|
304 |
} |
|
305 |
||
306 |
||
307 |
RemoveCalendarFile(iCalendarService, KTestCal2NameAsync.operator()()); |
|
308 |
||
309 |
iResult = AddCalendarFile(iCalendarService, KTestCal2NameAsync.operator()()); |
|
310 |
||
311 |
if(iResult != KErrNone) |
|
312 |
{ |
|
313 |
delete buffer; |
|
314 |
iWaitSchedular->AsyncStop(); |
|
315 |
goto Final; |
|
316 |
} |
|
317 |
||
318 |
if( iVCalOrICal == 1) |
|
319 |
{ |
|
320 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatVCal.operator()() , *buffer ,this ) ); |
|
321 |
} |
|
322 |
else |
|
323 |
{ |
|
324 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatICal.operator()() , *buffer ,this ) ); |
|
325 |
} |
|
326 |
||
327 |
if(iResult != KErrNone) |
|
328 |
{ |
|
329 |
iWaitSchedular->AsyncStop(); |
|
330 |
} |
|
331 |
||
332 |
delete buffer; |
|
333 |
Final: ; |
|
334 |
} |
|
335 |
||
336 |
||
337 |
void CCalImpTestCases::Start() |
|
338 |
{ |
|
339 |
SetActive(); |
|
340 |
||
341 |
TRequestStatus* temp = &iStatus; |
|
342 |
||
343 |
User::RequestComplete(temp, KErrNone); |
|
344 |
||
345 |
iWaitSchedular->Start(); |
|
346 |
||
347 |
} |
|
348 |
||
349 |
||
350 |
void CCalImpTestCases::NotifyResultL(TInt aErrCode, TAny* aResult) |
|
351 |
{ |
|
352 |
//******************* set iResult **************************** |
|
353 |
iResult = aErrCode; |
|
354 |
//******************* set iResult **************************** |
|
355 |
//write the result to the corresponding file basing on the iTestCaseType |
|
356 |
||
357 |
RPointerArray<TUIDSet>* uIDSet = (RPointerArray<TUIDSet>*)aResult; |
|
358 |
if(iResult != KErrNone) |
|
359 |
goto EndPoint; |
|
360 |
||
361 |
if ( iArruids.Count() != uIDSet->Count() ) |
|
362 |
iResult = KErrGeneral; |
|
363 |
||
364 |
||
365 |
EndPoint: |
|
366 |
TRAPD(err,RemoveCalendarFile(iCalendarService, KTestCal1NameAsync.operator()()) ); |
|
367 |
// TRAP(err ,RemoveCalendarFile(iCalendarService, KTestCal2NameAsync.operator()()) ); |
|
368 |
||
369 |
iWaitSchedular->AsyncStop(); |
|
370 |
||
371 |
} |