5
|
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 "importestcases.h"
|
|
30 |
#include "teststartconsolealarmserver.h"
|
|
31 |
|
|
32 |
#include<ASCliClientUtils.h>
|
|
33 |
|
|
34 |
|
|
35 |
_LIT(KCalName ,"c:Calendar");
|
|
36 |
_LIT8(KTest, "abc");
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
_LIT(KImportGuidsFile ,"C:\\ImportGuidsOutput.txt");
|
|
41 |
_LIT(KVcalImportGuidsFile ,"C:\\ImportVcalGuidsOutput.txt");
|
|
42 |
_LIT(KImportGuidsTestFile ,"C:\\ImportGuidsOutput");
|
|
43 |
_LIT(KImportInvalidFile ,"xyz");
|
|
44 |
_LIT(KImportLuidsFile ,"C:\\ImportLuidsOutput.txt");
|
|
45 |
|
|
46 |
_LIT(KImportAsyncGuidsFile ,"C:\\ImportGuidsOutputAsync.txt");
|
|
47 |
_LIT(KImportAsyncLuidsFile ,"C:\\ImportLuidsOutputAsync.txt");
|
|
48 |
|
|
49 |
_LIT8(KParseToken ,"|");
|
|
50 |
|
|
51 |
_LIT(KICALImportGuidsFile ,"C:\\ICALImportGuidsOutput.txt");
|
|
52 |
_LIT(KICALImportLuidsFile ,"C:\\ICALImportLuidsOutput.txt");
|
|
53 |
|
|
54 |
_LIT(KICALImportAsyncGuidsFile ,"C:\\ICALImportAsyncGuidsOutput.txt");
|
|
55 |
_LIT(KICALImportAsyncLuidsFile ,"C:\\ICALImportAsyncLuidsOutput.txt");
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
_LIT(KTestCal1Name ,"c:testcal1imp");
|
|
60 |
_LIT(KTestCal2Name ,"c:testcal2imp");
|
|
61 |
_LIT(KTestCal3Name ,"c:testcal3imp");
|
|
62 |
|
|
63 |
_LIT(KTestCal1NameAsync ,"c:testcal1impAsync");
|
|
64 |
_LIT(KTestCal2NameAsync ,"c:testcal2impAsync");
|
|
65 |
_LIT(KTestCal3NameAsync ,"c:testcal3impAsync");
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
CCalImpTestCases* CCalImpTestCases::NewL( TInt& aResult, TInt aVCalOrICal) //1 means VCal else ICal
|
|
70 |
{
|
|
71 |
CCalImpTestCases* self = new(ELeave)CCalImpTestCases( aResult, aVCalOrICal );
|
|
72 |
|
|
73 |
self->ConstructL();
|
|
74 |
|
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
CCalImpTestCases::~CCalImpTestCases()
|
|
79 |
{
|
|
80 |
Cancel();
|
|
81 |
|
|
82 |
if(iWaitSchedular->IsStarted())
|
|
83 |
iWaitSchedular->AsyncStop();
|
|
84 |
|
|
85 |
if(iArruids.Count())
|
|
86 |
iArruids.ResetAndDestroy();
|
|
87 |
RemoveCalendarFile(iCalendarService, KTestCal2NameAsync.operator()());
|
|
88 |
if(iCalendarService)
|
|
89 |
delete iCalendarService;
|
|
90 |
|
|
91 |
if(iWaitSchedular)
|
|
92 |
delete iWaitSchedular;
|
|
93 |
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
//
|
|
98 |
//Whats done here?
|
|
99 |
// Export all the contents of Default System Calender to a buffer using Export of CCalendarService
|
|
100 |
// Use the buffer to import them to "importtothiscalender" and the generated guids and luids are outputted to
|
|
101 |
// ImportGuidsOutput.txt and ImportLuidsOutput.txt respectively
|
|
102 |
//
|
|
103 |
TInt CCalImpTestCases::TestImportGuidL()
|
|
104 |
{
|
|
105 |
iTestCaseType = KImportSync;
|
|
106 |
|
|
107 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
108 |
|
|
109 |
iResult = AddCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
110 |
|
|
111 |
if(iResult != KErrNone)
|
|
112 |
return iResult ;
|
|
113 |
|
|
114 |
RPointerArray<TUIDSet> arruids(5);
|
|
115 |
|
|
116 |
TUIDSet* uids = NULL;
|
|
117 |
|
|
118 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
119 |
{
|
|
120 |
arruids.Append(uids);
|
|
121 |
uids = NULL;
|
|
122 |
}
|
|
123 |
|
|
124 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
125 |
{
|
|
126 |
arruids.Append(uids);
|
|
127 |
uids = NULL;
|
|
128 |
}
|
|
129 |
|
|
130 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
131 |
{
|
|
132 |
arruids.Append(uids);
|
|
133 |
uids = NULL;
|
|
134 |
}
|
|
135 |
|
|
136 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
137 |
{
|
|
138 |
arruids.Append(uids);
|
|
139 |
uids = NULL;
|
|
140 |
}
|
|
141 |
|
|
142 |
if(AddToDo(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
143 |
{
|
|
144 |
arruids.Append(uids);
|
|
145 |
uids = NULL;
|
|
146 |
}
|
|
147 |
|
|
148 |
|
|
149 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL();
|
|
150 |
|
|
151 |
expParams->AddGuidL( *(arruids[0])->iGlobalUID );
|
|
152 |
expParams->AddGuidL( *(arruids[4])->iGlobalUID );
|
|
153 |
expParams->AddGuidL( *(arruids[3])->iGlobalUID );
|
|
154 |
// expParams->AddLocalUid( arruids[2]->iLocalUID );
|
|
155 |
|
|
156 |
|
|
157 |
HBufC8* buffer = NULL;
|
|
158 |
TInt err_export;
|
|
159 |
|
|
160 |
if( iVCalOrICal == 1)
|
|
161 |
{
|
|
162 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
163 |
}
|
|
164 |
else
|
|
165 |
{
|
|
166 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
167 |
}
|
|
168 |
|
|
169 |
delete expParams;
|
|
170 |
|
|
171 |
if(err_export != KErrNone)
|
|
172 |
{
|
|
173 |
delete buffer;
|
|
174 |
arruids.ResetAndDestroy();
|
|
175 |
return iResult;
|
|
176 |
}
|
|
177 |
|
|
178 |
|
|
179 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
180 |
|
|
181 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
RPointerArray<TUIDSet> uIDSet(5);
|
|
186 |
|
|
187 |
if( iVCalOrICal == 1)
|
|
188 |
{
|
|
189 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *buffer ,uIDSet ) );
|
|
190 |
}
|
|
191 |
else
|
|
192 |
{
|
|
193 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *buffer ,uIDSet ) );
|
|
194 |
}
|
|
195 |
|
|
196 |
|
|
197 |
if(iResult != KErrNone)
|
|
198 |
{
|
|
199 |
delete buffer;
|
|
200 |
arruids.ResetAndDestroy();
|
|
201 |
uIDSet.ResetAndDestroy();
|
|
202 |
return iResult;
|
|
203 |
}
|
|
204 |
TInt count = uIDSet.Count();
|
|
205 |
TInt arr_count = arruids.Count() - 2;
|
|
206 |
|
|
207 |
if ( arr_count != uIDSet.Count() )
|
|
208 |
iResult = KErrGeneral;
|
|
209 |
|
|
210 |
delete buffer;
|
|
211 |
arruids.ResetAndDestroy();
|
|
212 |
uIDSet.ResetAndDestroy();
|
|
213 |
|
|
214 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
215 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
216 |
|
|
217 |
return iResult;
|
|
218 |
}
|
|
219 |
|
|
220 |
|
|
221 |
|
|
222 |
TInt CCalImpTestCases::TestImportLuidL()
|
|
223 |
{
|
|
224 |
iTestCaseType = KImportSync;
|
|
225 |
|
|
226 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
227 |
|
|
228 |
iResult = AddCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
229 |
|
|
230 |
if(iResult != KErrNone)
|
|
231 |
return iResult ;
|
|
232 |
|
|
233 |
RPointerArray<TUIDSet> arruids(5);
|
|
234 |
|
|
235 |
TUIDSet* uids = NULL;
|
|
236 |
|
|
237 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
238 |
{
|
|
239 |
arruids.Append(uids);
|
|
240 |
uids = NULL;
|
|
241 |
}
|
|
242 |
|
|
243 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
244 |
{
|
|
245 |
arruids.Append(uids);
|
|
246 |
uids = NULL;
|
|
247 |
}
|
|
248 |
|
|
249 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
250 |
{
|
|
251 |
arruids.Append(uids);
|
|
252 |
uids = NULL;
|
|
253 |
}
|
|
254 |
|
|
255 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
256 |
{
|
|
257 |
arruids.Append(uids);
|
|
258 |
uids = NULL;
|
|
259 |
}
|
|
260 |
|
|
261 |
if(AddToDo(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
262 |
{
|
|
263 |
arruids.Append(uids);
|
|
264 |
uids = NULL;
|
|
265 |
}
|
|
266 |
|
|
267 |
|
|
268 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL();
|
|
269 |
|
|
270 |
expParams->AddLocalUid( arruids[2]->iLocalUID );
|
|
271 |
expParams->AddLocalUid( arruids[3]->iLocalUID );
|
|
272 |
expParams->AddLocalUid( arruids[4]->iLocalUID );
|
|
273 |
|
|
274 |
|
|
275 |
HBufC8* buffer = NULL;
|
|
276 |
TInt err_export;
|
|
277 |
|
|
278 |
if( iVCalOrICal == 1)
|
|
279 |
{
|
|
280 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
281 |
}
|
|
282 |
else
|
|
283 |
{
|
|
284 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
285 |
}
|
|
286 |
|
|
287 |
delete expParams;
|
|
288 |
|
|
289 |
if(err_export != KErrNone)
|
|
290 |
{
|
|
291 |
delete buffer;
|
|
292 |
arruids.ResetAndDestroy();
|
|
293 |
return iResult;
|
|
294 |
}
|
|
295 |
|
|
296 |
|
|
297 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
298 |
|
|
299 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
RPointerArray<TUIDSet> uIDSet(5);
|
|
304 |
|
|
305 |
if( iVCalOrICal == 1)
|
|
306 |
{
|
|
307 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *buffer ,uIDSet ) );
|
|
308 |
}
|
|
309 |
else
|
|
310 |
{
|
|
311 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *buffer ,uIDSet ) );
|
|
312 |
}
|
|
313 |
|
|
314 |
|
|
315 |
if(iResult != KErrNone)
|
|
316 |
{
|
|
317 |
delete buffer;
|
|
318 |
arruids.ResetAndDestroy();
|
|
319 |
uIDSet.ResetAndDestroy();
|
|
320 |
return iResult;
|
|
321 |
}
|
|
322 |
TInt count = uIDSet.Count();
|
|
323 |
TInt arr_count = arruids.Count() - 2;
|
|
324 |
|
|
325 |
if ( arr_count != uIDSet.Count() )
|
|
326 |
iResult = KErrGeneral;
|
|
327 |
|
|
328 |
delete buffer;
|
|
329 |
arruids.ResetAndDestroy();
|
|
330 |
uIDSet.ResetAndDestroy();
|
|
331 |
|
|
332 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
333 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
334 |
|
|
335 |
return iResult;
|
|
336 |
}
|
|
337 |
|
|
338 |
|
|
339 |
TInt CCalImpTestCases::TestImportCases1()
|
|
340 |
{
|
|
341 |
iTestCaseType = KImportSync;
|
|
342 |
|
|
343 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
344 |
|
|
345 |
AddCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
346 |
|
|
347 |
|
|
348 |
RPointerArray<TUIDSet> arruids(5);
|
|
349 |
|
|
350 |
TUIDSet* uids = NULL;
|
|
351 |
|
|
352 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
353 |
{
|
|
354 |
arruids.Append(uids);
|
|
355 |
uids = NULL;
|
|
356 |
}
|
|
357 |
|
|
358 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
359 |
{
|
|
360 |
arruids.Append(uids);
|
|
361 |
uids = NULL;
|
|
362 |
}
|
|
363 |
|
|
364 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
365 |
{
|
|
366 |
arruids.Append(uids);
|
|
367 |
uids = NULL;
|
|
368 |
}
|
|
369 |
|
|
370 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
371 |
{
|
|
372 |
arruids.Append(uids);
|
|
373 |
uids = NULL;
|
|
374 |
}
|
|
375 |
|
|
376 |
|
|
377 |
HBufC8* buffer = NULL;
|
|
378 |
TInt err_export;
|
|
379 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL();
|
|
380 |
|
|
381 |
|
|
382 |
expParams->AddLocalUid( arruids[2]->iLocalUID );
|
|
383 |
expParams->AddLocalUid( arruids[3]->iLocalUID );
|
|
384 |
|
|
385 |
|
|
386 |
if( iVCalOrICal == 1)
|
|
387 |
{
|
|
388 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
389 |
}
|
|
390 |
else
|
|
391 |
{
|
|
392 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
393 |
}
|
|
394 |
|
|
395 |
// delete expParams;
|
|
396 |
|
|
397 |
if(err_export != KErrNone)
|
|
398 |
{
|
|
399 |
delete buffer;
|
|
400 |
delete expParams;
|
|
401 |
delete uids;
|
|
402 |
uids = NULL;
|
|
403 |
arruids.ResetAndDestroy();
|
|
404 |
iResult = err_export;
|
|
405 |
return iResult;
|
|
406 |
}
|
|
407 |
|
|
408 |
|
|
409 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
410 |
|
|
411 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
RPointerArray<TUIDSet> uIDSet(5);
|
|
417 |
TInt err_import;
|
|
418 |
//import from unexisting file
|
|
419 |
if( iVCalOrICal == 1)
|
|
420 |
{
|
|
421 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KImportLuidsFile.operator()() ,uIDSet ) );
|
|
422 |
}
|
|
423 |
else
|
|
424 |
{
|
|
425 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KImportLuidsFile.operator()() ,uIDSet ) );
|
|
426 |
}
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
if(err_import != KErrNotFound)
|
|
431 |
{
|
|
432 |
delete uids;
|
|
433 |
delete buffer;
|
|
434 |
delete expParams;
|
|
435 |
uids = NULL;
|
|
436 |
arruids.ResetAndDestroy();
|
|
437 |
uIDSet.ResetAndDestroy();
|
|
438 |
iResult = err_import;
|
|
439 |
return iResult;
|
|
440 |
}
|
|
441 |
|
|
442 |
//import from calendar file
|
|
443 |
if( iVCalOrICal == 1)
|
|
444 |
{
|
|
445 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KTestCal1Name.operator()() ,uIDSet ) );
|
|
446 |
}
|
|
447 |
else
|
|
448 |
{
|
|
449 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KTestCal1Name.operator()() ,uIDSet ) );
|
|
450 |
}
|
|
451 |
|
|
452 |
|
|
453 |
|
|
454 |
if(err_import != KErrPathNotFound)
|
|
455 |
{
|
|
456 |
delete uids;
|
|
457 |
uids = NULL;
|
|
458 |
delete buffer;
|
|
459 |
delete expParams;
|
|
460 |
arruids.ResetAndDestroy();
|
|
461 |
uIDSet.ResetAndDestroy();
|
|
462 |
iResult = err_import;
|
|
463 |
return iResult;
|
|
464 |
}
|
|
465 |
|
|
466 |
//file name as Null
|
|
467 |
if( iVCalOrICal == 1)
|
|
468 |
{
|
|
469 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KNullDesC ,uIDSet ) );
|
|
470 |
}
|
|
471 |
else
|
|
472 |
{
|
|
473 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KNullDesC ,uIDSet ) );
|
|
474 |
}
|
|
475 |
|
|
476 |
|
|
477 |
if(err_import != KErrBadName)
|
|
478 |
{
|
|
479 |
|
|
480 |
delete uids;
|
|
481 |
delete buffer;
|
|
482 |
delete expParams;
|
|
483 |
arruids.ResetAndDestroy();
|
|
484 |
uIDSet.ResetAndDestroy();
|
|
485 |
iResult = err_import;
|
|
486 |
return iResult;
|
|
487 |
}
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
delete expParams;
|
|
492 |
delete buffer;
|
|
493 |
delete uids;
|
|
494 |
uids=NULL;
|
|
495 |
arruids.ResetAndDestroy();
|
|
496 |
uIDSet.ResetAndDestroy();
|
|
497 |
|
|
498 |
|
|
499 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
500 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
501 |
|
|
502 |
return iResult;
|
|
503 |
}
|
|
504 |
|
|
505 |
|
|
506 |
TInt CCalImpTestCases::TestImportCases2()
|
|
507 |
{
|
|
508 |
iTestCaseType = KImportSync;
|
|
509 |
|
|
510 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
511 |
|
|
512 |
AddCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
513 |
|
|
514 |
RPointerArray<TUIDSet> arruids;
|
|
515 |
|
|
516 |
TUIDSet* uids = NULL;
|
|
517 |
TUIDSet* new_uids = NULL;
|
|
518 |
|
|
519 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
520 |
{
|
|
521 |
arruids.Append(uids);
|
|
522 |
uids = NULL;
|
|
523 |
}
|
|
524 |
|
|
525 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
526 |
{
|
|
527 |
arruids.Append(uids);
|
|
528 |
uids = NULL;
|
|
529 |
}
|
|
530 |
|
|
531 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
532 |
{
|
|
533 |
arruids.Append(uids);
|
|
534 |
uids = NULL;
|
|
535 |
}
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL();
|
|
540 |
|
|
541 |
expParams->AddGuidL( *(arruids[0])->iGlobalUID );
|
|
542 |
expParams->AddGuidL( *(arruids[1])->iGlobalUID );
|
|
543 |
expParams->AddGuidL( *(arruids[2])->iGlobalUID );
|
|
544 |
|
|
545 |
|
|
546 |
HBufC8* buffer = NULL;
|
|
547 |
TInt err_export;
|
|
548 |
|
|
549 |
if( iVCalOrICal == 1)
|
|
550 |
{
|
|
551 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
552 |
}
|
|
553 |
else
|
|
554 |
{
|
|
555 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
556 |
}
|
|
557 |
|
|
558 |
delete expParams;
|
|
559 |
|
|
560 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
561 |
|
|
562 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
563 |
|
|
564 |
AddAnny(iCalendarService, KTestCal1Name.operator()(), new_uids);
|
|
565 |
delete new_uids;
|
|
566 |
new_uids = NULL;
|
|
567 |
|
|
568 |
|
|
569 |
RPointerArray<TUIDSet> uIDSet;
|
|
570 |
|
|
571 |
if( iVCalOrICal == 1)
|
|
572 |
{
|
|
573 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , *buffer ,uIDSet ) );
|
|
574 |
}
|
|
575 |
else
|
|
576 |
{
|
|
577 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , *buffer ,uIDSet ) );
|
|
578 |
}
|
|
579 |
|
|
580 |
|
|
581 |
TInt count = uIDSet.Count();
|
|
582 |
if(count != 3)
|
|
583 |
iResult = KErrGeneral;
|
|
584 |
|
|
585 |
delete buffer;
|
|
586 |
// delete filter;
|
|
587 |
arruids.ResetAndDestroy();
|
|
588 |
uIDSet.ResetAndDestroy();
|
|
589 |
|
|
590 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
591 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
592 |
|
|
593 |
return iResult;
|
|
594 |
}
|
|
595 |
|
|
596 |
//Import cases - Three
|
|
597 |
TInt CCalImpTestCases::TestImportCases3()
|
|
598 |
{
|
|
599 |
iTestCaseType = KImportSync;
|
|
600 |
|
|
601 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
602 |
|
|
603 |
AddCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
604 |
|
|
605 |
RPointerArray<TUIDSet> arruids;
|
|
606 |
|
|
607 |
TUIDSet* uids = NULL;
|
|
608 |
|
|
609 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
610 |
{
|
|
611 |
arruids.Append(uids);
|
|
612 |
uids = NULL;
|
|
613 |
}
|
|
614 |
|
|
615 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
616 |
{
|
|
617 |
arruids.Append(uids);
|
|
618 |
uids = NULL;
|
|
619 |
}
|
|
620 |
|
|
621 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
622 |
{
|
|
623 |
arruids.Append(uids);
|
|
624 |
uids = NULL;
|
|
625 |
}
|
|
626 |
|
|
627 |
|
|
628 |
|
|
629 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL();
|
|
630 |
CCalendarExportParams *new_expParams = CCalendarExportParams::NewL();
|
|
631 |
|
|
632 |
// expParams->AddLocalUid( arruids[2]->iLocalUID );
|
|
633 |
//expParams->AddLocalUid( arruids[3]->iLocalUID );
|
|
634 |
expParams->SetExportFileNameL(KImportGuidsTestFile);
|
|
635 |
|
|
636 |
HBufC8* buffer = NULL;
|
|
637 |
TInt err_export;
|
|
638 |
TInt err_import;
|
|
639 |
|
|
640 |
if( iVCalOrICal == 1)
|
|
641 |
{
|
|
642 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
643 |
}
|
|
644 |
else
|
|
645 |
{
|
|
646 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
647 |
}
|
|
648 |
|
|
649 |
// delete expParams;
|
|
650 |
|
|
651 |
|
|
652 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
653 |
|
|
654 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
655 |
|
|
656 |
delete uids;
|
|
657 |
uids = NULL;
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
RPointerArray<TUIDSet> uIDSet;
|
|
662 |
|
|
663 |
if( iVCalOrICal == 1)
|
|
664 |
{
|
|
665 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KImportGuidsTestFile.operator()() ,uIDSet ) );
|
|
666 |
}
|
|
667 |
else
|
|
668 |
{
|
|
669 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KImportGuidsTestFile.operator()() ,uIDSet ) );
|
|
670 |
}
|
|
671 |
|
|
672 |
TInt count = uIDSet.Count();
|
|
673 |
if(count != 3 && iResult == KErrNone)
|
|
674 |
iResult = KErrGeneral;
|
|
675 |
count =0;
|
|
676 |
|
|
677 |
|
|
678 |
// import - export for invalid file
|
|
679 |
TRAPD(err_setfile,expParams->SetExportFileNameL(KImportInvalidFile));
|
|
680 |
|
|
681 |
if( iVCalOrICal == 1)
|
|
682 |
{
|
|
683 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
684 |
}
|
|
685 |
else
|
|
686 |
{
|
|
687 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
688 |
}
|
|
689 |
|
|
690 |
|
|
691 |
|
|
692 |
uIDSet.ResetAndDestroy();
|
|
693 |
if( iVCalOrICal == 1)
|
|
694 |
{
|
|
695 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KImportInvalidFile.operator()() ,uIDSet ) );
|
|
696 |
}
|
|
697 |
else
|
|
698 |
{
|
|
699 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KImportInvalidFile.operator()() ,uIDSet ) );
|
|
700 |
}
|
|
701 |
|
|
702 |
count = uIDSet.Count();
|
|
703 |
if((count != 0 || err_export != KErrPathNotFound) && iResult == KErrNone)
|
|
704 |
iResult = KErrGeneral;
|
|
705 |
count =0;
|
|
706 |
|
|
707 |
// Import from file multiple times
|
|
708 |
|
|
709 |
expParams->SetExportFileNameL(KImportGuidsFile);
|
|
710 |
expParams->AddLocalUid( arruids[1]->iLocalUID );
|
|
711 |
expParams->AddLocalUid( arruids[2]->iLocalUID );
|
|
712 |
|
|
713 |
if( iVCalOrICal == 1)
|
|
714 |
{
|
|
715 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
716 |
}
|
|
717 |
else
|
|
718 |
{
|
|
719 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
720 |
}
|
|
721 |
|
|
722 |
uIDSet.ResetAndDestroy();
|
|
723 |
if( iVCalOrICal == 1)
|
|
724 |
{
|
|
725 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
726 |
}
|
|
727 |
else
|
|
728 |
{
|
|
729 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
730 |
}
|
|
731 |
|
|
732 |
count = uIDSet.Count();
|
|
733 |
count =0;
|
|
734 |
|
|
735 |
if( iVCalOrICal == 1)
|
|
736 |
{
|
|
737 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
738 |
}
|
|
739 |
else
|
|
740 |
{
|
|
741 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
742 |
}
|
|
743 |
|
|
744 |
count = uIDSet.Count();
|
|
745 |
if(count != 4 && iResult == KErrNone)
|
|
746 |
iResult = KErrGeneral;
|
|
747 |
count =0;
|
|
748 |
|
|
749 |
|
|
750 |
// Try to import from default calendar
|
|
751 |
|
|
752 |
uIDSet.ResetAndDestroy();
|
|
753 |
|
|
754 |
if( iVCalOrICal == 1)
|
|
755 |
{
|
|
756 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KCalName.operator()() ,uIDSet ) );
|
|
757 |
}
|
|
758 |
else
|
|
759 |
{
|
|
760 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KCalName.operator()() ,uIDSet ) );
|
|
761 |
}
|
|
762 |
|
|
763 |
|
|
764 |
if(err_import != KErrPathNotFound && iResult == KErrNone)
|
|
765 |
iResult = KErrGeneral;
|
|
766 |
|
|
767 |
|
|
768 |
// Import with invalid format
|
|
769 |
expParams->SetExportFileNameL(KImportGuidsFile);
|
|
770 |
|
|
771 |
uIDSet.ResetAndDestroy();
|
|
772 |
|
|
773 |
if( iVCalOrICal == 1)
|
|
774 |
{
|
|
775 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
776 |
}
|
|
777 |
else
|
|
778 |
{
|
|
779 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
780 |
}
|
|
781 |
|
|
782 |
|
|
783 |
|
|
784 |
if( iVCalOrICal == 1)
|
|
785 |
{
|
|
786 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KTest.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
787 |
}
|
|
788 |
else
|
|
789 |
{
|
|
790 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KTest.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
791 |
}
|
|
792 |
|
|
793 |
if(err_import != KErrNotSupported && iResult == KErrNone)
|
|
794 |
iResult = KErrGeneral;
|
|
795 |
|
|
796 |
// Import with invalid luid
|
|
797 |
|
|
798 |
new_expParams->AddLocalUid( 10000 );
|
|
799 |
new_expParams->AddLocalUid( -3000 );
|
|
800 |
new_expParams->SetExportFileNameL(KVcalImportGuidsFile);
|
|
801 |
delete buffer;
|
|
802 |
buffer = NULL;
|
|
803 |
|
|
804 |
if( iVCalOrICal == 1)
|
|
805 |
{
|
|
806 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , new_expParams ,buffer ) );
|
|
807 |
}
|
|
808 |
else
|
|
809 |
{
|
|
810 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , new_expParams ,buffer ) );
|
|
811 |
}
|
|
812 |
|
|
813 |
uIDSet.ResetAndDestroy();
|
|
814 |
if( iVCalOrICal == 1)
|
|
815 |
{
|
|
816 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KVcalImportGuidsFile.operator()() ,uIDSet ) );
|
|
817 |
}
|
|
818 |
else
|
|
819 |
{
|
|
820 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KVcalImportGuidsFile.operator()() ,uIDSet ) );
|
|
821 |
}
|
|
822 |
|
|
823 |
count = uIDSet.Count();
|
|
824 |
if(count != 0)
|
|
825 |
iResult = KErrGeneral;
|
|
826 |
|
|
827 |
|
|
828 |
// delete buffer;
|
|
829 |
delete new_expParams;
|
|
830 |
delete expParams;
|
|
831 |
arruids.ResetAndDestroy();
|
|
832 |
uIDSet.ResetAndDestroy();
|
|
833 |
|
|
834 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
835 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
836 |
|
|
837 |
return iResult;
|
|
838 |
}
|
|
839 |
|
|
840 |
TInt CCalImpTestCases::TestImportFromFileL()
|
|
841 |
{
|
|
842 |
iTestCaseType = KImportSync;
|
|
843 |
|
|
844 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
845 |
|
|
846 |
AddCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
847 |
|
|
848 |
|
|
849 |
RPointerArray<TUIDSet> arruids;
|
|
850 |
|
|
851 |
TUIDSet* uids = NULL;
|
|
852 |
|
|
853 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
854 |
{
|
|
855 |
arruids.Append(uids);
|
|
856 |
uids = NULL;
|
|
857 |
}
|
|
858 |
|
|
859 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
860 |
{
|
|
861 |
arruids.Append(uids);
|
|
862 |
uids = NULL;
|
|
863 |
}
|
|
864 |
|
|
865 |
if(AddReminder(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
866 |
{
|
|
867 |
arruids.Append(uids);
|
|
868 |
uids = NULL;
|
|
869 |
}
|
|
870 |
|
|
871 |
if(AddAnny(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
872 |
{
|
|
873 |
arruids.Append(uids);
|
|
874 |
uids = NULL;
|
|
875 |
}
|
|
876 |
|
|
877 |
if(AddToDo(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
878 |
{
|
|
879 |
arruids.Append(uids);
|
|
880 |
uids = NULL;
|
|
881 |
}
|
|
882 |
|
|
883 |
delete uids;
|
|
884 |
uids = NULL;
|
|
885 |
|
|
886 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL();
|
|
887 |
|
|
888 |
|
|
889 |
|
|
890 |
expParams->AddGuidL( *(arruids[0])->iGlobalUID );
|
|
891 |
expParams->AddGuidL( *(arruids[4])->iGlobalUID );
|
|
892 |
expParams->AddGuidL( *(arruids[3])->iGlobalUID );
|
|
893 |
expParams->SetExportFileNameL(KImportGuidsFile);
|
|
894 |
|
|
895 |
|
|
896 |
HBufC8* buffer = NULL;
|
|
897 |
TInt err_export;
|
|
898 |
|
|
899 |
if( iVCalOrICal == 1)
|
|
900 |
{
|
|
901 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
902 |
}
|
|
903 |
else
|
|
904 |
{
|
|
905 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
906 |
}
|
|
907 |
|
|
908 |
delete expParams;
|
|
909 |
|
|
910 |
if(buffer != NULL)
|
|
911 |
{
|
|
912 |
delete buffer;
|
|
913 |
arruids.ResetAndDestroy();
|
|
914 |
iResult = KErrGeneral;
|
|
915 |
return iResult;
|
|
916 |
}
|
|
917 |
|
|
918 |
|
|
919 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
920 |
|
|
921 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
922 |
|
|
923 |
|
|
924 |
RPointerArray<TUIDSet> uIDSet(5);
|
|
925 |
TInt err_import;
|
|
926 |
|
|
927 |
if( iVCalOrICal == 1)
|
|
928 |
{
|
|
929 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
930 |
}
|
|
931 |
else
|
|
932 |
{
|
|
933 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal2Name.operator()() , KFormatICal.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
934 |
}
|
|
935 |
|
|
936 |
|
|
937 |
if(err_import != KErrNone)
|
|
938 |
{
|
|
939 |
delete buffer;
|
|
940 |
arruids.ResetAndDestroy();
|
|
941 |
uIDSet.ResetAndDestroy();
|
|
942 |
iResult = err_import;
|
|
943 |
return iResult;
|
|
944 |
}
|
|
945 |
|
|
946 |
TInt count = uIDSet.Count();
|
|
947 |
TInt arr_count = arruids.Count() - 2;
|
|
948 |
|
|
949 |
if ( arr_count != uIDSet.Count() )
|
|
950 |
iResult = KErrGeneral;
|
|
951 |
|
|
952 |
delete buffer;
|
|
953 |
arruids.ResetAndDestroy();
|
|
954 |
uIDSet.ResetAndDestroy();
|
|
955 |
|
|
956 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
957 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
958 |
|
|
959 |
return iResult;
|
|
960 |
}
|
|
961 |
|
|
962 |
|
|
963 |
TInt CCalImpTestCases::TestImportMultipleEntry()
|
|
964 |
{
|
|
965 |
iTestCaseType = KImportSync;
|
|
966 |
|
|
967 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
968 |
|
|
969 |
AddCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
970 |
|
|
971 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
972 |
|
|
973 |
AddCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
974 |
|
|
975 |
|
|
976 |
RPointerArray<TUIDSet> arruids;
|
|
977 |
|
|
978 |
TUIDSet* uids = NULL;
|
|
979 |
TUIDSet* new_uids = NULL;
|
|
980 |
|
|
981 |
if(AddAppointment(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
982 |
{
|
|
983 |
arruids.Append(uids);
|
|
984 |
uids = NULL;
|
|
985 |
}
|
|
986 |
|
|
987 |
if(AddEvent(iCalendarService, KTestCal1Name.operator()(), uids) == KErrNone && uids)
|
|
988 |
{
|
|
989 |
arruids.Append(uids);
|
|
990 |
uids = NULL;
|
|
991 |
}
|
|
992 |
|
|
993 |
if(AddReminder(iCalendarService, KTestCal2Name.operator()(), new_uids) == KErrNone && new_uids)
|
|
994 |
{
|
|
995 |
arruids.Append(new_uids);
|
|
996 |
new_uids = NULL;
|
|
997 |
}
|
|
998 |
|
|
999 |
if(AddAnny(iCalendarService, KTestCal2Name.operator()(), new_uids) == KErrNone && new_uids)
|
|
1000 |
{
|
|
1001 |
arruids.Append(new_uids);
|
|
1002 |
new_uids = NULL;
|
|
1003 |
}
|
|
1004 |
|
|
1005 |
if(AddToDo(iCalendarService, KTestCal2Name.operator()(), new_uids) == KErrNone && new_uids)
|
|
1006 |
{
|
|
1007 |
arruids.Append(new_uids);
|
|
1008 |
new_uids = NULL;
|
|
1009 |
}
|
|
1010 |
|
|
1011 |
delete uids;
|
|
1012 |
uids = NULL;
|
|
1013 |
delete new_uids;
|
|
1014 |
new_uids = NULL;
|
|
1015 |
|
|
1016 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL();
|
|
1017 |
|
|
1018 |
|
|
1019 |
|
|
1020 |
/* expParams->AddGuidL( *(arruids[0])->iGlobalUID );
|
|
1021 |
expParams->AddGuidL( *(arruids[4])->iGlobalUID );
|
|
1022 |
expParams->AddGuidL( *(arruids[3])->iGlobalUID );*/
|
|
1023 |
expParams->SetExportFileNameL(KImportGuidsFile);
|
|
1024 |
|
|
1025 |
|
|
1026 |
HBufC8* buffer = NULL;
|
|
1027 |
TInt err_export;
|
|
1028 |
|
|
1029 |
if( iVCalOrICal == 1)
|
|
1030 |
{
|
|
1031 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal2Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
1032 |
}
|
|
1033 |
else
|
|
1034 |
{
|
|
1035 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal2Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
1036 |
}
|
|
1037 |
|
|
1038 |
if( iVCalOrICal == 1)
|
|
1039 |
{
|
|
1040 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
1041 |
}
|
|
1042 |
else
|
|
1043 |
{
|
|
1044 |
TRAP( err_export ,iCalendarService->ExportL( KTestCal1Name.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
1045 |
}
|
|
1046 |
|
|
1047 |
delete expParams;
|
|
1048 |
|
|
1049 |
if(buffer != NULL)
|
|
1050 |
{
|
|
1051 |
delete buffer;
|
|
1052 |
arruids.ResetAndDestroy();
|
|
1053 |
iResult = KErrGeneral;
|
|
1054 |
return iResult;
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
|
|
1058 |
RemoveCalendarFile(iCalendarService, KTestCal3Name.operator()());
|
|
1059 |
|
|
1060 |
AddCalendarFile(iCalendarService, KTestCal3Name.operator()());
|
|
1061 |
|
|
1062 |
|
|
1063 |
RPointerArray<TUIDSet> uIDSet(5);
|
|
1064 |
TInt err_import;
|
|
1065 |
|
|
1066 |
if( iVCalOrICal == 1)
|
|
1067 |
{
|
|
1068 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal3Name.operator()() , KFormatVCal.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
1069 |
}
|
|
1070 |
else
|
|
1071 |
{
|
|
1072 |
TRAP( err_import ,iCalendarService->ImportL( KTestCal3Name.operator()() , KFormatICal.operator()() , KImportGuidsFile.operator()() ,uIDSet ) );
|
|
1073 |
}
|
|
1074 |
|
|
1075 |
|
|
1076 |
if(err_import != KErrNone)
|
|
1077 |
{
|
|
1078 |
delete buffer;
|
|
1079 |
arruids.ResetAndDestroy();
|
|
1080 |
uIDSet.ResetAndDestroy();
|
|
1081 |
iResult = err_import;
|
|
1082 |
return iResult;
|
|
1083 |
}
|
|
1084 |
|
|
1085 |
TInt count = uIDSet.Count();
|
|
1086 |
TInt arr_count = arruids.Count() ;
|
|
1087 |
|
|
1088 |
if ( count != 2 )
|
|
1089 |
iResult = KErrGeneral;
|
|
1090 |
|
|
1091 |
delete buffer;
|
|
1092 |
arruids.ResetAndDestroy();
|
|
1093 |
uIDSet.ResetAndDestroy();
|
|
1094 |
|
|
1095 |
RemoveCalendarFile(iCalendarService, KTestCal1Name.operator()());
|
|
1096 |
RemoveCalendarFile(iCalendarService, KTestCal2Name.operator()());
|
|
1097 |
RemoveCalendarFile(iCalendarService, KTestCal3Name.operator()());
|
|
1098 |
return iResult;
|
|
1099 |
}
|
|
1100 |
|
|
1101 |
|
|
1102 |
|
|
1103 |
|
|
1104 |
//
|
|
1105 |
//Whats done here?
|
|
1106 |
// Export all the contents of Default System Calender to a buffer using Export of CCalendarService
|
|
1107 |
// Use the buffer to import them to "importtothiscalender" and the generated guids and luids are outputted to
|
|
1108 |
// ImportGuidsOutputAsync.txt and ImportLuidsOutputAsync.txt respectively
|
|
1109 |
//
|
|
1110 |
void CCalImpTestCases::TestImportUsingGuidAsyncL()
|
|
1111 |
{
|
|
1112 |
iTestCaseType = KImportGuidAsync;
|
|
1113 |
Start();
|
|
1114 |
}
|
|
1115 |
|
|
1116 |
void CCalImpTestCases::TestImportUsingLuidAsyncL()
|
|
1117 |
{
|
|
1118 |
iTestCaseType = KImportLuidAsync;
|
|
1119 |
Start();
|
|
1120 |
}
|
|
1121 |
|
|
1122 |
void CCalImpTestCases::TestImportUsingFileAsyncL()
|
|
1123 |
{
|
|
1124 |
iTestCaseType = KImportUsingFileAsync;
|
|
1125 |
Start();
|
|
1126 |
}
|
|
1127 |
|
|
1128 |
void CCalImpTestCases::TestImportMultipleEntryAsyncL()
|
|
1129 |
{
|
|
1130 |
iTestCaseType = KMultipleImportUsingFileAsync;
|
|
1131 |
Start();
|
|
1132 |
}
|
|
1133 |
void CCalImpTestCases::TestImportCaseAsyncL()
|
|
1134 |
{
|
|
1135 |
iTestCaseType = KImportAsync;
|
|
1136 |
Start();
|
|
1137 |
}
|
|
1138 |
|
|
1139 |
|
|
1140 |
|
|
1141 |
TInt CCalImpTestCases::Result()
|
|
1142 |
{
|
|
1143 |
return iResult;
|
|
1144 |
}
|
|
1145 |
|
|
1146 |
void CCalImpTestCases::ConstructL()
|
|
1147 |
{
|
|
1148 |
CActiveScheduler::Add(this);
|
|
1149 |
|
|
1150 |
iCalendarService = CCalendarService::NewL();
|
|
1151 |
|
|
1152 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait();
|
|
1153 |
}
|
|
1154 |
|
|
1155 |
CCalImpTestCases::CCalImpTestCases( TInt& aResult, TInt aVCalOrICal): CActive(EPriorityStandard), iResult(aResult) ,
|
|
1156 |
iVCalOrICal(aVCalOrICal)
|
|
1157 |
{
|
|
1158 |
|
|
1159 |
}
|
|
1160 |
|
|
1161 |
//for the sake of ActiveObject
|
|
1162 |
void CCalImpTestCases::DoCancel()
|
|
1163 |
{
|
|
1164 |
|
|
1165 |
}
|
|
1166 |
|
|
1167 |
void CCalImpTestCases::RunL()
|
|
1168 |
{
|
|
1169 |
RemoveCalendarFile(iCalendarService, KTestCal1NameAsync.operator()());
|
|
1170 |
|
|
1171 |
AddCalendarFile(iCalendarService, KTestCal1NameAsync.operator()());
|
|
1172 |
|
|
1173 |
|
|
1174 |
RemoveCalendarFile(iCalendarService, KTestCal2NameAsync.operator()());
|
|
1175 |
|
|
1176 |
AddCalendarFile(iCalendarService, KTestCal2NameAsync.operator()());
|
|
1177 |
|
|
1178 |
|
|
1179 |
|
|
1180 |
|
|
1181 |
|
|
1182 |
TUIDSet* uids = NULL;
|
|
1183 |
TUIDSet* new_uids = NULL;
|
|
1184 |
|
|
1185 |
if(AddAppointment(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids)
|
|
1186 |
{
|
|
1187 |
iArruids.Append(uids);
|
|
1188 |
uids = NULL;
|
|
1189 |
}
|
|
1190 |
|
|
1191 |
if(AddEvent(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids)
|
|
1192 |
{
|
|
1193 |
iArruids.Append(uids);
|
|
1194 |
uids = NULL;
|
|
1195 |
}
|
|
1196 |
|
|
1197 |
if(AddReminder(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids)
|
|
1198 |
{
|
|
1199 |
iArruids.Append(new_uids);
|
|
1200 |
uids = NULL;
|
|
1201 |
}
|
|
1202 |
|
|
1203 |
if(AddAnny(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids)
|
|
1204 |
{
|
|
1205 |
iArruids.Append(uids);
|
|
1206 |
uids = NULL;
|
|
1207 |
}
|
|
1208 |
|
|
1209 |
if(AddToDo(iCalendarService, KTestCal1NameAsync.operator()(), uids) == KErrNone && uids)
|
|
1210 |
{
|
|
1211 |
iArruids.Append(uids);
|
|
1212 |
uids = NULL;
|
|
1213 |
}
|
|
1214 |
|
|
1215 |
|
|
1216 |
CCalendarExportParams *expParams = CCalendarExportParams::NewL();
|
|
1217 |
|
|
1218 |
switch(iTestCaseType)
|
|
1219 |
{
|
|
1220 |
case KImportGuidAsync :
|
|
1221 |
expParams->AddGuidL( *(iArruids[0])->iGlobalUID );
|
|
1222 |
expParams->AddGuidL( *(iArruids[4])->iGlobalUID );
|
|
1223 |
expParams->AddGuidL( *(iArruids[3])->iGlobalUID );
|
|
1224 |
|
|
1225 |
|
|
1226 |
HBufC8* buffer = NULL;
|
|
1227 |
|
|
1228 |
if( iVCalOrICal == 1)
|
|
1229 |
{
|
|
1230 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
1231 |
}
|
|
1232 |
else
|
|
1233 |
{
|
|
1234 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
1235 |
}
|
|
1236 |
|
|
1237 |
if( iVCalOrICal == 1)
|
|
1238 |
{
|
|
1239 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatVCal.operator()() , *buffer ,this ) );
|
|
1240 |
}
|
|
1241 |
else
|
|
1242 |
{
|
|
1243 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatICal.operator()() , *buffer ,this ) );
|
|
1244 |
}
|
|
1245 |
delete buffer;
|
|
1246 |
buffer = NULL;
|
|
1247 |
break;
|
|
1248 |
|
|
1249 |
case KImportLuidAsync :
|
|
1250 |
expParams->AddLocalUid( iArruids[0]->iLocalUID );
|
|
1251 |
expParams->AddLocalUid( iArruids[4]->iLocalUID );
|
|
1252 |
|
|
1253 |
|
|
1254 |
//HBufC8* buffer = NULL;
|
|
1255 |
TInt err_exp;
|
|
1256 |
|
|
1257 |
if( iVCalOrICal == 1)
|
|
1258 |
{
|
|
1259 |
TRAP( err_exp ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
1260 |
}
|
|
1261 |
else
|
|
1262 |
{
|
|
1263 |
TRAP( err_exp ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
1264 |
}
|
|
1265 |
|
|
1266 |
if( iVCalOrICal == 1)
|
|
1267 |
{
|
|
1268 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatVCal.operator()() , *buffer ,this ) );
|
|
1269 |
}
|
|
1270 |
else
|
|
1271 |
{
|
|
1272 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatICal.operator()() , *buffer ,this ) );
|
|
1273 |
}
|
|
1274 |
delete buffer;
|
|
1275 |
buffer = NULL;
|
|
1276 |
break;
|
|
1277 |
|
|
1278 |
/* expParams->AddLocalUid( iArruids[2]->iLocalUID );
|
|
1279 |
expParams->AddLocalUid( iArruids[4]->iLocalUID );
|
|
1280 |
|
|
1281 |
HBufC8* new_buffer = NULL;
|
|
1282 |
|
|
1283 |
if( iVCalOrICal == 1)
|
|
1284 |
{
|
|
1285 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatVCal.operator()() , expParams ,new_buffer ) );
|
|
1286 |
}
|
|
1287 |
else
|
|
1288 |
{
|
|
1289 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatICal.operator()() , expParams ,new_buffer ) );
|
|
1290 |
}
|
|
1291 |
|
|
1292 |
if( iVCalOrICal == 1)
|
|
1293 |
{
|
|
1294 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatVCal.operator()() , *new_buffer ,this ) );
|
|
1295 |
}
|
|
1296 |
else
|
|
1297 |
{
|
|
1298 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatICal.operator()() , *new_buffer ,this ) );
|
|
1299 |
}
|
|
1300 |
delete new_buffer;
|
|
1301 |
new_buffer = NULL;
|
|
1302 |
break; */
|
|
1303 |
|
|
1304 |
case KImportUsingFileAsync :
|
|
1305 |
expParams->AddGuidL( *(iArruids[0])->iGlobalUID );
|
|
1306 |
expParams->AddGuidL( *(iArruids[4])->iGlobalUID );
|
|
1307 |
expParams->AddGuidL( *(iArruids[3])->iGlobalUID );
|
|
1308 |
|
|
1309 |
expParams->SetExportFileNameL(KImportAsyncGuidsFile);
|
|
1310 |
if( iVCalOrICal == 1)
|
|
1311 |
{
|
|
1312 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
1313 |
}
|
|
1314 |
else
|
|
1315 |
{
|
|
1316 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
if( iVCalOrICal == 1)
|
|
1320 |
{
|
|
1321 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatVCal.operator()() , KImportAsyncGuidsFile.operator()() ,this ) );
|
|
1322 |
}
|
|
1323 |
else
|
|
1324 |
{
|
|
1325 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatICal.operator()() , KImportAsyncGuidsFile.operator()() ,this ) );
|
|
1326 |
}
|
|
1327 |
break;
|
|
1328 |
|
|
1329 |
case KMultipleImportUsingFileAsync :
|
|
1330 |
|
|
1331 |
RemoveCalendarFile(iCalendarService, KTestCal3NameAsync.operator()());
|
|
1332 |
|
|
1333 |
AddCalendarFile(iCalendarService, KTestCal3NameAsync.operator()());
|
|
1334 |
expParams->SetExportFileNameL(KImportAsyncGuidsFile);
|
|
1335 |
AddReminder(iCalendarService, KTestCal3NameAsync.operator()(), new_uids);
|
|
1336 |
|
|
1337 |
AddAnny(iCalendarService, KTestCal3NameAsync.operator()(), new_uids);
|
|
1338 |
if( iVCalOrICal == 1)
|
|
1339 |
{
|
|
1340 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
1341 |
}
|
|
1342 |
else
|
|
1343 |
{
|
|
1344 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal1NameAsync.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
1345 |
}
|
|
1346 |
|
|
1347 |
if( iVCalOrICal == 1)
|
|
1348 |
{
|
|
1349 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal3NameAsync.operator()() , KFormatVCal.operator()() , expParams ,buffer ) );
|
|
1350 |
}
|
|
1351 |
else
|
|
1352 |
{
|
|
1353 |
TRAP( iResult ,iCalendarService->ExportL( KTestCal3NameAsync.operator()() , KFormatICal.operator()() , expParams ,buffer ) );
|
|
1354 |
}
|
|
1355 |
|
|
1356 |
if( iVCalOrICal == 1)
|
|
1357 |
{
|
|
1358 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatVCal.operator()() , KImportAsyncGuidsFile.operator()() ,this ) );
|
|
1359 |
}
|
|
1360 |
else
|
|
1361 |
{
|
|
1362 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatICal.operator()() , KImportAsyncGuidsFile.operator()() ,this ) );
|
|
1363 |
}
|
|
1364 |
|
|
1365 |
delete new_uids;
|
|
1366 |
new_uids = NULL;
|
|
1367 |
break;
|
|
1368 |
|
|
1369 |
case KImportAsync :
|
|
1370 |
if( iVCalOrICal == 1)
|
|
1371 |
{
|
|
1372 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatVCal.operator()() , KCalName.operator()() ,this ) );
|
|
1373 |
}
|
|
1374 |
else
|
|
1375 |
{
|
|
1376 |
TRAP( iResult ,iCalendarService->ImportL( KTestCal2NameAsync.operator()() , KFormatICal.operator()() , KCalName.operator()() ,this ) );
|
|
1377 |
}
|
|
1378 |
break;
|
|
1379 |
|
|
1380 |
}
|
|
1381 |
|
|
1382 |
delete expParams;
|
|
1383 |
delete uids;
|
|
1384 |
uids = NULL;
|
|
1385 |
|
|
1386 |
|
|
1387 |
Final: ;
|
|
1388 |
}
|
|
1389 |
|
|
1390 |
|
|
1391 |
void CCalImpTestCases::Start()
|
|
1392 |
{
|
|
1393 |
SetActive();
|
|
1394 |
|
|
1395 |
TRequestStatus* temp = &iStatus;
|
|
1396 |
|
|
1397 |
User::RequestComplete(temp, KErrNone);
|
|
1398 |
|
|
1399 |
iWaitSchedular->Start();
|
|
1400 |
|
|
1401 |
}
|
|
1402 |
|
|
1403 |
|
|
1404 |
void CCalImpTestCases::NotifyResultL(TInt aErrCode, TAny* aResult)
|
|
1405 |
{
|
|
1406 |
//******************* set iResult ****************************
|
|
1407 |
iResult = aErrCode;
|
|
1408 |
//******************* set iResult ****************************
|
|
1409 |
//write the result to the corresponding file basing on the iTestCaseType
|
|
1410 |
RPointerArray<TUIDSet>* uIDSet = (RPointerArray<TUIDSet>*)aResult;
|
|
1411 |
switch(iTestCaseType)
|
|
1412 |
{
|
|
1413 |
case KImportGuidAsync :
|
|
1414 |
TInt count = uIDSet->Count();
|
|
1415 |
if ( iArruids.Count() -2 != uIDSet->Count() )
|
|
1416 |
iResult = KErrGeneral;
|
|
1417 |
uIDSet->ResetAndDestroy();
|
|
1418 |
|
|
1419 |
break;
|
|
1420 |
case KImportLuidAsync :
|
|
1421 |
count = uIDSet->Count();
|
|
1422 |
if ( iArruids.Count() -3 != uIDSet->Count() )
|
|
1423 |
iResult = KErrGeneral;
|
|
1424 |
uIDSet->ResetAndDestroy();
|
|
1425 |
|
|
1426 |
break;
|
|
1427 |
case KImportUsingFileAsync :
|
|
1428 |
count = uIDSet->Count();
|
|
1429 |
if(count != 3)
|
|
1430 |
iResult = KErrGeneral;
|
|
1431 |
uIDSet->ResetAndDestroy();
|
|
1432 |
|
|
1433 |
break;
|
|
1434 |
case KMultipleImportUsingFileAsync:
|
|
1435 |
count = uIDSet->Count();
|
|
1436 |
if(count != 2)
|
|
1437 |
iResult = KErrGeneral;
|
|
1438 |
uIDSet->ResetAndDestroy();
|
|
1439 |
|
|
1440 |
RemoveCalendarFile(iCalendarService, KTestCal3NameAsync.operator()());
|
|
1441 |
break;
|
|
1442 |
case KImportAsync : if(iResult != KErrPathNotFound)
|
|
1443 |
iResult = KErrGeneral;
|
|
1444 |
else
|
|
1445 |
iResult = KErrNone;
|
|
1446 |
break;
|
|
1447 |
}
|
|
1448 |
|
|
1449 |
|
|
1450 |
|
|
1451 |
|
|
1452 |
TInt err;
|
|
1453 |
RemoveCalendarFile(iCalendarService, KTestCal1NameAsync.operator()());
|
|
1454 |
//RemoveCalendarFile(iCalendarService, KTestCal2NameAsync.operator()());
|
|
1455 |
|
|
1456 |
iWaitSchedular->AsyncStop();
|
|
1457 |
|
|
1458 |
}
|