author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 22 | fc9cf246af83 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 - 2007 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 |
// INCLUDE FILES |
|
22 |
#include <e32svr.h> |
|
23 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
24 |
#include <StifTestInterface.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
25 |
#include "tcontact_import.h" |
19 | 26 |
|
27 |
// EXTERNAL DATA STRUCTURES |
|
28 |
//extern ?external_data; |
|
29 |
||
30 |
// EXTERNAL FUNCTION PROTOTYPES |
|
31 |
//extern ?external_function( ?arg_type,?arg_type ); |
|
32 |
||
33 |
// CONSTANTS |
|
34 |
//const ?type ?constant_var = ?constant; |
|
35 |
||
36 |
// MACROS |
|
37 |
//#define ?macro ?macro_def |
|
38 |
||
39 |
// LOCAL CONSTANTS AND MACROS |
|
40 |
//const ?type ?constant_var = ?constant; |
|
41 |
//#define ?macro_name ?macro_def |
|
42 |
||
43 |
// MODULE DATA STRUCTURES |
|
44 |
//enum ?declaration |
|
45 |
//typedef ?declaration |
|
46 |
||
47 |
// LOCAL FUNCTION PROTOTYPES |
|
48 |
//?type ?function_name( ?arg_type, ?arg_type ); |
|
49 |
||
50 |
// FORWARD DECLARATIONS |
|
51 |
//class ?FORWARD_CLASSNAME; |
|
52 |
||
53 |
// ============================= LOCAL FUNCTIONS =============================== |
|
54 |
||
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// ?function_name ?description. |
|
57 |
// ?description |
|
58 |
// Returns: ?value_1: ?description |
|
59 |
// ?value_n: ?description_line1 |
|
60 |
// ?description_line2 |
|
61 |
// ----------------------------------------------------------------------------- |
|
62 |
// |
|
63 |
/* |
|
64 |
?type ?function_name( |
|
65 |
?arg_type arg, // ?description |
|
66 |
?arg_type arg) // ?description |
|
67 |
{ |
|
68 |
||
69 |
?code // ?comment |
|
70 |
||
71 |
// ?comment |
|
72 |
?code |
|
73 |
} |
|
74 |
*/ |
|
75 |
||
76 |
TInt Iterator_cnt; |
|
77 |
||
78 |
HBufC8* contactid; |
|
79 |
CSingleContact* myContact=NULL; |
|
80 |
||
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
81 |
void CContactCallback::HandleReturnArray( const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
82 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
83 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
84 |
iError= aError ; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
85 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
86 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
87 |
void CContactCallback::HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
88 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
89 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
90 |
} |
19 | 91 |
|
92 |
||
93 |
void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId ) |
|
94 |
{ |
|
95 |
iError= aError; |
|
96 |
CActiveScheduler::Stop(); |
|
97 |
} |
|
98 |
||
99 |
||
100 |
void CContactCallback:: HandleReturnIter( const TInt& aError, CContactIter* aIter, TInt aTransId ) |
|
101 |
{ |
|
102 |
||
103 |
CActiveScheduler::Stop(); |
|
104 |
||
105 |
CSingleContactField* field = NULL; |
|
106 |
HBufC8* buf = NULL; |
|
107 |
TBuf8<100> buf1; |
|
108 |
TBuf<100> buf2; |
|
109 |
TBuf<100> buf3; |
|
110 |
TInt count=0 ; |
|
111 |
HBufC8* tmpid; |
|
112 |
RPointerArray<HBufC8> idarray ; |
|
113 |
TBuf<100> grouplabel; |
|
114 |
||
115 |
if(aError==KErrNone) |
|
116 |
{ |
|
117 |
aIter->NextL(myContact,tmpid); |
|
118 |
||
119 |
while(myContact) |
|
120 |
{ |
|
121 |
Iterator_cnt++; |
|
122 |
aIter->NextL(myContact,tmpid); |
|
123 |
||
124 |
||
125 |
} //while |
|
126 |
} //if |
|
127 |
||
128 |
delete aIter ; |
|
129 |
} |
|
130 |
||
131 |
// ============================ MEMBER FUNCTIONS =============================== |
|
132 |
||
133 |
// ----------------------------------------------------------------------------- |
|
134 |
// Cteximport::Delete |
|
135 |
// Delete here all resources allocated and opened from test methods. |
|
136 |
// Called from destructor. |
|
137 |
// ----------------------------------------------------------------------------- |
|
138 |
// |
|
139 |
void Cteximport::Delete() |
|
140 |
{ |
|
141 |
||
142 |
} |
|
143 |
||
144 |
// ----------------------------------------------------------------------------- |
|
145 |
// Cteximport::RunMethodL |
|
146 |
// Run specified method. Contains also table of test mothods and their names. |
|
147 |
// ----------------------------------------------------------------------------- |
|
148 |
// |
|
149 |
TInt Cteximport::RunMethodL( |
|
150 |
CStifItemParser& aItem ) |
|
151 |
{ |
|
152 |
||
153 |
static TStifFunctionInfo const KFunctions[] = |
|
154 |
{ |
|
155 |
// Copy this line for every implemented function. |
|
156 |
// First string is the function name used in TestScripter script file. |
|
157 |
// Second is the actual implementation member function. |
|
158 |
ENTRY( "Import_Test1", Cteximport::Import_Test1L ), |
|
159 |
ENTRY( "Import_Test2", Cteximport::Import_Test2L ), |
|
160 |
ENTRY( "Import_Test3", Cteximport::Import_Test3L ), |
|
161 |
ENTRY( "Import_Test4", Cteximport::Import_Test4L ), |
|
162 |
ENTRY( "Import_Test5", Cteximport::Import_Test5L ), |
|
163 |
}; |
|
164 |
||
165 |
const TInt count = sizeof( KFunctions ) / |
|
166 |
sizeof( TStifFunctionInfo ); |
|
167 |
||
168 |
return RunInternalL( KFunctions, count, aItem ); |
|
169 |
||
170 |
} |
|
171 |
||
172 |
// ----------------------------------------------------------------------------- |
|
173 |
// Cteximport::ExampleL |
|
174 |
// Example test method function. |
|
175 |
// (other items were commented in a header). |
|
176 |
// ----------------------------------------------------------------------------- |
|
177 |
// |
|
178 |
TInt Cteximport::Import_Test1L( CStifItemParser& aItem ) |
|
179 |
{ |
|
180 |
||
181 |
// Print to UI |
|
182 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
183 |
_LIT( KExample, "In Import_ValL" ); |
|
184 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
185 |
// Print to log file |
|
186 |
iLog->Log( KExample ); |
|
187 |
||
188 |
||
189 |
||
190 |
TPtrC String; |
|
191 |
/* get the filename for import */ |
|
192 |
if(aItem.GetNextString(String) != KErrNone ) |
|
193 |
{ |
|
194 |
_LIT(Kerr , "Failed to read input file name"); |
|
195 |
iLog->Log(Kerr) ; |
|
196 |
return KErrGeneral ; |
|
197 |
} |
|
198 |
||
199 |
||
200 |
TBuf<256> string1; |
|
201 |
string1.Copy(String); |
|
202 |
TInt flag=0; |
|
203 |
||
204 |
/*call import */ |
|
205 |
icontactservice->ImportVCardToStoreL(icallback,1,string1); |
|
206 |
CActiveScheduler::Start(); |
|
207 |
||
208 |
||
209 |
/* verify whther import returns the expected error */ |
|
210 |
aItem.GetNextInt(flag) ; |
|
211 |
if(icallback->iError == flag) |
|
212 |
return KErrNone; |
|
213 |
||
214 |
else |
|
215 |
return KErrGeneral; |
|
216 |
} |
|
217 |
||
218 |
||
219 |
/* Importing the same contact vcard file twice */ |
|
220 |
TInt Cteximport::Import_Test2L( CStifItemParser& aItem ) |
|
221 |
{ |
|
222 |
||
223 |
// Print to UI |
|
224 |
_LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
|
225 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
226 |
_LIT( KExample, "In Import_InvL" ); |
|
227 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
228 |
// Print to log file |
|
229 |
iLog->Log( KExample ); |
|
230 |
||
231 |
||
232 |
TPtrC String; |
|
233 |
||
234 |
/* get the filename for import */ |
|
235 |
if(aItem.GetNextString(String) != KErrNone ) |
|
236 |
{ |
|
237 |
_LIT(Kerr , "Failed to read input file name") ; |
|
238 |
iLog->Log(Kerr) ; |
|
239 |
return KErrGeneral ; |
|
240 |
} |
|
241 |
||
242 |
TBuf<256> string1; |
|
243 |
string1.Copy(String); |
|
244 |
||
245 |
||
246 |
TInt flag=0,cnt=0; |
|
247 |
||
248 |
/*call import */ |
|
249 |
icontactservice->ImportVCardToStoreL(icallback,1,string1); |
|
250 |
CActiveScheduler::Start(); |
|
251 |
||
252 |
/*call import */ |
|
253 |
icontactservice->ImportVCardToStoreL(icallback,2,string1); |
|
254 |
CActiveScheduler::Start(); |
|
255 |
||
256 |
TPtrC searchval(_L("import")); |
|
257 |
TBuf8<15> fstname(_L8("FirstName")); |
|
258 |
CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
259 |
srchfield->AppendL(fstname); |
|
260 |
||
261 |
icontactservice->GetListL(icallback,0,EContacts,KNullDesC8,searchval,srchfield); |
|
262 |
CActiveScheduler::Start(); |
|
263 |
||
264 |
/* verify whther import returns the expected error */ |
|
265 |
aItem.GetNextInt(flag) ; |
|
266 |
if(icallback->iError == flag) |
|
267 |
{ |
|
268 |
if(Iterator_cnt==1) |
|
269 |
return KErrNone; |
|
270 |
} |
|
271 |
||
272 |
||
273 |
||
274 |
return KErrGeneral; |
|
275 |
||
276 |
||
277 |
} |
|
278 |
||
279 |
TInt Cteximport::Import_Test3L( CStifItemParser& aItem ) |
|
280 |
{ |
|
281 |
||
282 |
// Print to UI |
|
283 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
284 |
_LIT( KExample, "In Import_ValL" ); |
|
285 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
286 |
// Print to log file |
|
287 |
iLog->Log( KExample ); |
|
288 |
||
289 |
TPtrC db1(_L("cntdb://c:temp.cdb")); |
|
290 |
||
291 |
TPtrC String; |
|
292 |
/* get the filename for import */ |
|
293 |
if(aItem.GetNextString(String) != KErrNone ) |
|
294 |
{ |
|
295 |
_LIT(Kerr , "Failed to read input file name"); |
|
296 |
iLog->Log(Kerr) ; |
|
297 |
return KErrGeneral ; |
|
298 |
} |
|
299 |
||
300 |
||
301 |
TBuf<256> string1; |
|
302 |
string1.Copy(String); |
|
303 |
TInt flag=0; |
|
304 |
||
305 |
/*call import */ |
|
306 |
icontactservice->ImportVCardToStoreL(icallback,1,string1,db1); |
|
307 |
CActiveScheduler::Start(); |
|
308 |
||
309 |
||
310 |
/* verify whther import returns the expected error */ |
|
311 |
aItem.GetNextInt(flag) ; |
|
312 |
if(icallback->iError == flag) |
|
313 |
return KErrNone; |
|
314 |
||
315 |
else |
|
316 |
return KErrGeneral; |
|
317 |
} |
|
318 |
||
319 |
/* Importing a contact and Getlist the same contact */ |
|
320 |
||
321 |
TInt Cteximport::Import_Test4L( CStifItemParser& aItem ) |
|
322 |
{ |
|
323 |
_LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
|
324 |
// Print to UI |
|
325 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
326 |
_LIT( KExample, "In Import_ValL" ); |
|
327 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
328 |
// Print to log file |
|
329 |
iLog->Log( KExample ); |
|
330 |
||
331 |
||
332 |
||
333 |
TPtrC String; |
|
334 |
/* get the filename for import */ |
|
335 |
if(aItem.GetNextString(String) != KErrNone ) |
|
336 |
{ |
|
337 |
_LIT(Kerr , "Failed to read input file name"); |
|
338 |
iLog->Log(Kerr) ; |
|
339 |
return KErrGeneral ; |
|
340 |
} |
|
341 |
||
342 |
||
343 |
TBuf<256> string1; |
|
344 |
string1.Copy(String); |
|
345 |
TInt flag=0; |
|
346 |
||
347 |
/*call import */ |
|
348 |
icontactservice->ImportVCardToStoreL(icallback,1,string1); |
|
349 |
CActiveScheduler::Start(); |
|
350 |
||
351 |
TPtrC searchval(_L("Lee")); |
|
352 |
TBuf8<15> fstname(_L8("LastName")); |
|
353 |
CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
354 |
srchfield->AppendL(fstname); |
|
355 |
icontactservice->GetListL(icallback,0,EContacts,KNullDesC8,searchval,srchfield); |
|
356 |
CActiveScheduler::Start(); |
|
357 |
||
358 |
// icontactservice->GetListL(icallback,0,EContacts,KNullDesC8); |
|
359 |
// CActiveScheduler::Start(); |
|
360 |
/* verify whther import returns the expected error */ |
|
361 |
aItem.GetNextInt(flag) ; |
|
362 |
if(icallback->iError == flag) |
|
363 |
return KErrNone; |
|
364 |
||
365 |
else |
|
366 |
return KErrGeneral; |
|
367 |
} |
|
368 |
||
369 |
/* Importing the same contact vcard file twice */ |
|
370 |
TInt Cteximport::Import_Test5L( CStifItemParser& aItem ) |
|
371 |
{ |
|
372 |
||
373 |
// Print to UI |
|
374 |
_LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
|
375 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
376 |
_LIT( KExample, "In Import_InvL" ); |
|
377 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
378 |
// Print to log file |
|
379 |
iLog->Log( KExample ); |
|
380 |
||
381 |
||
382 |
TPtrC String; |
|
383 |
||
384 |
/* get the filename for import */ |
|
385 |
if(aItem.GetNextString(String) != KErrNone ) |
|
386 |
{ |
|
387 |
_LIT(Kerr , "Failed to read input file name") ; |
|
388 |
iLog->Log(Kerr) ; |
|
389 |
return KErrGeneral ; |
|
390 |
} |
|
391 |
||
392 |
TBuf<256> string1; |
|
393 |
string1.Copy(String); |
|
394 |
||
395 |
if(aItem.GetNextString(String) != KErrNone ) |
|
396 |
{ |
|
397 |
_LIT(Kerr , "Failed to read input file name") ; |
|
398 |
iLog->Log(Kerr) ; |
|
399 |
return KErrGeneral ; |
|
400 |
} |
|
401 |
||
402 |
TBuf<256> string2; |
|
403 |
string2.Copy(String); |
|
404 |
TInt flag=0,cnt=0; |
|
405 |
||
406 |
/*call import */ |
|
407 |
icontactservice->ImportVCardToStoreL(icallback,1,string1); |
|
408 |
CActiveScheduler::Start(); |
|
409 |
||
410 |
/*call import */ |
|
411 |
icontactservice->ImportVCardToStoreL(icallback,2,string2); |
|
412 |
CActiveScheduler::Start(); |
|
413 |
||
414 |
TPtrC searchval(_L("first")); |
|
415 |
TBuf8<15> fstname(_L8("FirstName")); |
|
416 |
CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
417 |
srchfield->AppendL(fstname); |
|
418 |
||
419 |
icontactservice->GetListL(icallback,0,EContacts,KNullDesC8,searchval,srchfield); |
|
420 |
CActiveScheduler::Start(); |
|
421 |
||
422 |
/* verify whther import returns the expected error */ |
|
423 |
aItem.GetNextInt(flag) ; |
|
424 |
if(icallback->iError == flag) |
|
425 |
{ |
|
426 |
if(Iterator_cnt==2) |
|
427 |
return KErrNone; |
|
428 |
} |
|
429 |
||
430 |
||
431 |
||
432 |
return KErrGeneral; |
|
433 |
||
434 |
||
435 |
} |
|
436 |
||
437 |
// End of File |