author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:33:04 +0300 | |
branch | RCL_3 |
changeset 46 | ed95320285d0 |
parent 35 | 5f281e37a2f5 |
permissions | -rw-r--r-- |
35 | 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 "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: This cpp file has the functions to test Services DB API. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
// [INCLUDE FILES] |
|
21 |
#include <e32svr.h> |
|
22 |
#include <StifParser.h> |
|
46
ed95320285d0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
23 |
#include <Stiftestinterface.h> |
35 | 24 |
#include "ServicesDbApiTest.h" |
46
ed95320285d0
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
35
diff
changeset
|
25 |
#include <ServicesDbApiTest.rsg> |
35 | 26 |
|
27 |
||
28 |
// ============================ MEMBER FUNCTIONS =============================== |
|
29 |
||
30 |
// ----------------------------------------------------------------------------- |
|
31 |
// CServicesDbApiTest::Delete |
|
32 |
// Delete here all resources allocated and opened from test methods. |
|
33 |
// Called from destructor. |
|
34 |
// ----------------------------------------------------------------------------- |
|
35 |
// |
|
36 |
void CServicesDbApiTest::Delete() |
|
37 |
{ |
|
38 |
||
39 |
} |
|
40 |
||
41 |
// ----------------------------------------------------------------------------- |
|
42 |
// CServicesDbApiTest::RunMethodL |
|
43 |
// Run specified method. Contains also table of test mothods and their names. |
|
44 |
// ----------------------------------------------------------------------------- |
|
45 |
// |
|
46 |
TInt CServicesDbApiTest::RunMethodL( |
|
47 |
CStifItemParser& aItem ) |
|
48 |
{ |
|
49 |
||
50 |
static TStifFunctionInfo const KFunctions[] = |
|
51 |
{ |
|
52 |
ENTRY( "InitializeSeviceDB", CServicesDbApiTest::InitializeSeviceDB ), |
|
53 |
ENTRY( "InitializeonStackSeviceDB", CServicesDbApiTest::InitializeonStackSeviceDB ), |
|
54 |
ENTRY( "CountSeviceDB", CServicesDbApiTest::CountSeviceDB), |
|
55 |
ENTRY( "ServiceUidLSeviceDB", CServicesDbApiTest::ServiceUidLSeviceDB), |
|
56 |
ENTRY( "ServiceStringLCSeviceDB", CServicesDbApiTest::ServiceStringLCSeviceDB), |
|
57 |
ENTRY( "ServiceStringLCUIDSeviceDB", CServicesDbApiTest::ServiceStringLCuidSeviceDB), |
|
58 |
ENTRY( "ServiceNameLCSeviceDB", CServicesDbApiTest::ServiceNameLCSeviceDB), |
|
59 |
ENTRY( "ServiceNameLCuidSeviceDB", CServicesDbApiTest::ServiceNameLCuidSeviceDB), |
|
60 |
}; |
|
61 |
||
62 |
const TInt count = sizeof( KFunctions ) / |
|
63 |
sizeof( TStifFunctionInfo ); |
|
64 |
||
65 |
return RunInternalL( KFunctions, count, aItem ); |
|
66 |
||
67 |
} |
|
68 |
||
69 |
||
70 |
// ----------------------------------------------------------------------------- |
|
71 |
// CServicesDbApiTest::CreateSeviceDBL |
|
72 |
// This function is used to create CServicesDB object. This function is used |
|
73 |
// to call CServicesDB::NewL and CServicesDB::NewLC functions. |
|
74 |
// ----------------------------------------------------------------------------- |
|
75 |
// |
|
76 |
TInt CServicesDbApiTest::CreateSeviceDBL( TInt aOption ) |
|
77 |
{ |
|
78 |
||
79 |
// Get CCoeEnv instance |
|
80 |
CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
81 |
// Initialize loader |
|
82 |
//open our resource file |
|
83 |
RConeResourceLoader resources(*eikEnv); |
|
84 |
||
85 |
TParse parse; |
|
86 |
parse.Set(_L("c:ServicesDbApiTest.rsc"), &KDC_RESOURCE_FILES_DIR, NULL ); |
|
87 |
||
88 |
TFileName fileName( parse.FullName() ); |
|
89 |
iLog->Log(_L("Opened Resource file named :: ")); iLog->Log(fileName); |
|
90 |
||
91 |
TRAPD( error, resources.OpenL(fileName) ); //Open resource file |
|
92 |
if ( KErrNone != error ) |
|
93 |
{ |
|
94 |
iLog->Log(_L("Error in opening resource file. ERROR = %d "),error); //return( error ); |
|
95 |
//Check on Z drive if not found on C drive |
|
96 |
parse.Set(_L("z:ServicesDbApiTest.rsc"), &KDC_RESOURCE_FILES_DIR, NULL ); |
|
97 |
TFileName fileName1( parse.FullName() ); |
|
98 |
iLog->Log(_L("Opening Resource file named :: ")); iLog->Log(fileName1); |
|
99 |
||
100 |
TRAPD( error1 , resources.OpenL(fileName1) ); |
|
101 |
if ( KErrNone != error1 ) |
|
102 |
{ |
|
103 |
iLog->Log(_L("Error in opening resource file. ERROR = %d "),error1); |
|
104 |
return( error1 ); |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
TResourceReader reader; |
|
109 |
eikEnv->CreateResourceReaderLC( reader, R_DA_SERVICE_MIME ); |
|
110 |
||
111 |
if ( KFirstOption == aOption ) |
|
112 |
{ |
|
113 |
TRAPD( errorinNewL, iServicesDB=CServicesDB::NewL(&reader) ); |
|
114 |
if ( KErrNone != errorinNewL ) |
|
115 |
{ |
|
116 |
iLog->Log(_L("=>CServicesDB::NewL leaves")); |
|
117 |
} |
|
118 |
CleanupStack::PopAndDestroy(); //reader's resource |
|
119 |
resources.Close(); |
|
120 |
return ( errorinNewL ); |
|
121 |
} |
|
122 |
else |
|
123 |
{ |
|
124 |
TRAPD( errorinNewLC, CallNewlcL(reader) ); |
|
125 |
if( KErrNone != errorinNewLC ) |
|
126 |
{ |
|
127 |
iLog->Log(_L("=>CServicesDB::NewLC leaves")); |
|
128 |
} |
|
129 |
CleanupStack::PopAndDestroy(); |
|
130 |
resources.Close(); |
|
131 |
return ( errorinNewLC ); |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
||
136 |
// ----------------------------------------------------------------------------- |
|
137 |
// CServicesDbApiTest::CallNewlcL |
|
138 |
// This function is used because we can not TRAP CServicesDB::NewLC |
|
139 |
// ----------------------------------------------------------------------------- |
|
140 |
// |
|
141 |
void CServicesDbApiTest::CallNewlcL( TResourceReader aResReader ) |
|
142 |
{ |
|
143 |
iServicesDB = CServicesDB::NewLC( &aResReader ); |
|
144 |
CleanupStack::Pop(); |
|
145 |
} |
|
146 |
||
147 |
||
148 |
// ----------------------------------------------------------------------------- |
|
149 |
// CServicesDbApiTest::InitializeSeviceDB |
|
150 |
// Is used to test CServicesDB::NewL |
|
151 |
// ----------------------------------------------------------------------------- |
|
152 |
// |
|
153 |
TInt CServicesDbApiTest::InitializeSeviceDB( ) |
|
154 |
{ |
|
155 |
TInt result; |
|
156 |
TRAPD( error , result = CreateSeviceDBL( KFirstOption ) ); |
|
157 |
if ( KErrNone != error ) |
|
158 |
{ iLog->Log(_L("Services DB object not created with NewL.")); return ( error ); } |
|
159 |
else |
|
160 |
{ |
|
161 |
if ( KErrNone != result ) |
|
162 |
{ |
|
163 |
iLog->Log(_L("Services DB object not created with NewL.")); return ( result ); |
|
164 |
} |
|
165 |
else |
|
166 |
{ |
|
167 |
iLog->Log(_L("Services DB object created with NewL.")); |
|
168 |
} |
|
169 |
} |
|
170 |
return ( result ); |
|
171 |
} |
|
172 |
||
173 |
||
174 |
// ----------------------------------------------------------------------------- |
|
175 |
// CServicesDbApiTest::InitializeonStackSeviceDB |
|
176 |
// Is used to test CServicesDB::NewLC |
|
177 |
// ----------------------------------------------------------------------------- |
|
178 |
// |
|
179 |
TInt CServicesDbApiTest::InitializeonStackSeviceDB( ) |
|
180 |
{ |
|
181 |
TInt result; |
|
182 |
TRAPD( error, result = CreateSeviceDBL( KSecondOption ) ); |
|
183 |
if ( KErrNone != error ) |
|
184 |
{ iLog->Log(_L("Services DB object not created with NewLC.")); return ( error ); } |
|
185 |
else |
|
186 |
{ |
|
187 |
if ( KErrNone != result ) |
|
188 |
{ |
|
189 |
iLog->Log(_L("Services DB object not created with NewLC.")); return ( result ); |
|
190 |
} |
|
191 |
else |
|
192 |
{ |
|
193 |
iLog->Log(_L("Services DB object created with NewLC.")); |
|
194 |
} |
|
195 |
} |
|
196 |
return ( result ); |
|
197 |
} |
|
198 |
||
199 |
||
200 |
// ----------------------------------------------------------------------------- |
|
201 |
// CServicesDbApiTest::CountSeviceDB |
|
202 |
// Testing - IMPORT_C TInt Count() const; |
|
203 |
// ----------------------------------------------------------------------------- |
|
204 |
// |
|
205 |
TInt CServicesDbApiTest::CountSeviceDB() |
|
206 |
{ |
|
207 |
TInt result = InitializeSeviceDB(); |
|
208 |
if ( KErrNone != result ) |
|
209 |
{ |
|
210 |
return ( result ); |
|
211 |
} |
|
212 |
TInt nrServices=iServicesDB->Count(); |
|
213 |
iLog->Log(_L("Number of Services listed in resource file = %d"),nrServices); |
|
214 |
if ( KNoOfServices != nrServices ) |
|
215 |
{ |
|
216 |
iLog->Log(_L("The number of services returned by CServicesDB::COUNT is incorrect")); |
|
217 |
return ( KErrGeneral ); |
|
218 |
} |
|
219 |
return ( KErrNone ); |
|
220 |
} |
|
221 |
||
222 |
// ----------------------------------------------------------------------------- |
|
223 |
// CServicesDbApiTest::ServiceUidLSeviceDB |
|
224 |
// Testing - IMPORT_C TUid ServiceUidL(TInt aIndex) const; |
|
225 |
// ----------------------------------------------------------------------------- |
|
226 |
// |
|
227 |
TInt CServicesDbApiTest::ServiceUidLSeviceDB( CStifItemParser& aItem ) |
|
228 |
{ |
|
229 |
TInt result = InitializeSeviceDB(); |
|
230 |
if ( KErrNone != result ) |
|
231 |
{ |
|
232 |
return ( result ); |
|
233 |
} |
|
234 |
TUid serviceUid; |
|
235 |
TInt index; |
|
236 |
||
237 |
if( aItem.GetNextInt(index) != KErrNone ) |
|
238 |
{ |
|
239 |
iLog->Log(_L("NO Index number provided, index is required parameter for testing ServiceUid ")); |
|
240 |
return ( KErrGeneral ); |
|
241 |
} |
|
242 |
||
243 |
TRAPD( error, serviceUid = iServicesDB->ServiceUidL(index) ); |
|
244 |
if ( KErrNone != error ) |
|
245 |
{ |
|
246 |
iLog->Log(_L("Incorrect Index. There is no service matching the Index Number.")); |
|
247 |
iLog->Log(_L("=> ServiceUidL leaves when index is incorrect.")); |
|
248 |
return (error); |
|
249 |
} |
|
250 |
||
251 |
iLog->Log(_L("UID of the Service[%d]=%d"),index,serviceUid.iUid); |
|
252 |
||
253 |
switch (index) |
|
254 |
{ |
|
255 |
case KFirstServiceIndex: if (serviceUid.iUid == 0x101) |
|
256 |
{ iLog->Log(_L("Service UID is correct")); } |
|
257 |
else |
|
258 |
{ iLog->Log(_L("Service UID is incorrect")); return ( KErrGeneral ); } |
|
259 |
break; |
|
260 |
case KSecondServiceIndex: if (serviceUid.iUid == 0x102) |
|
261 |
{ iLog->Log(_L("Service UID is correct")); } |
|
262 |
else |
|
263 |
{ iLog->Log(_L("Service UID is incorrect")); return ( KErrGeneral ); } |
|
264 |
break; |
|
265 |
case KThirdServiceIndex: if (serviceUid.iUid == 0x103) |
|
266 |
{ iLog->Log(_L("Service UID is correct")); } |
|
267 |
else |
|
268 |
{ iLog->Log(_L("Service UID is incorrect")); return ( KErrGeneral ); } |
|
269 |
break; |
|
270 |
default : break; |
|
271 |
}; |
|
272 |
||
273 |
return ( KErrNone ); |
|
274 |
} |
|
275 |
||
276 |
||
277 |
// ----------------------------------------------------------------------------- |
|
278 |
// CServicesDbApiTest::ServiceStringLCSeviceDB |
|
279 |
// Testing - IMPORT_C HBufC* ServiceStringLC(TInt aIndex, const TDes& aParam) const; |
|
280 |
// ----------------------------------------------------------------------------- |
|
281 |
// |
|
282 |
TInt CServicesDbApiTest::ServiceStringLCSeviceDB( CStifItemParser& aItem ) |
|
283 |
{ |
|
284 |
TInt result = InitializeSeviceDB(); |
|
285 |
if ( KErrNone != result ) |
|
286 |
{ |
|
287 |
return ( result ); |
|
288 |
} |
|
289 |
TInt index; |
|
290 |
TBuf<KBufSize> format(KEmptyString); |
|
291 |
||
292 |
if( aItem.GetNextInt(index) != KErrNone ) |
|
293 |
{ |
|
294 |
iLog->Log(_L("NO Index number provided, index is required parameter for testing ServiceUid ")); |
|
295 |
return ( KErrGeneral ); |
|
296 |
} |
|
297 |
TInt res; |
|
298 |
TRAPD( error, res = CallServiceStringLCSeviceDBL(index,format )); |
|
299 |
if ( KErrNone != error ) |
|
300 |
{ |
|
301 |
iLog->Log(_L("Incorrect Index. There is no service matching the Index Number.")); |
|
302 |
iLog->Log(_L("=> ServiceStringLC leaves when index is incorrect.")); |
|
303 |
return (error); |
|
304 |
} |
|
305 |
||
306 |
return ( res ); |
|
307 |
} |
|
308 |
||
309 |
||
310 |
// ----------------------------------------------------------------------------- |
|
311 |
// CServicesDbApiTest::CallServiceStringLCSeviceDBL |
|
312 |
// This function is used because we can not trap ServiceStringLC |
|
313 |
// ----------------------------------------------------------------------------- |
|
314 |
// |
|
315 |
TInt CServicesDbApiTest::CallServiceStringLCSeviceDBL(TInt aIndex,const TDes& aParam ) |
|
316 |
{ |
|
317 |
HBufC *string; |
|
318 |
string=iServicesDB->ServiceStringLC(aIndex,aParam); |
|
319 |
iLog->Log(_L("LOCALIZED name of the Service[%d] = "),aIndex); |
|
320 |
iLog->Log(*string); |
|
321 |
||
322 |
switch (aIndex) |
|
323 |
{ |
|
324 |
case KFirstServiceIndex: if(!(string->Des().Compare(_L("Open Localized")))) |
|
325 |
{ iLog->Log(_L("LOCALIZED name is correct")); } |
|
326 |
else |
|
327 |
{ iLog->Log(_L("LOCALIZED name is incorrect")); |
|
328 |
CleanupStack::PopAndDestroy(string); return ( KErrGeneral ); } |
|
329 |
break; |
|
330 |
case KSecondServiceIndex: if(!(string->Des().Compare(_L("Upload Localized")))) |
|
331 |
{ iLog->Log(_L("LOCALIZED name is correct")); } |
|
332 |
else |
|
333 |
{ iLog->Log(_L("LOCALIZED name is incorrect")); |
|
334 |
CleanupStack::PopAndDestroy(string); return ( KErrGeneral ); } |
|
335 |
break; |
|
336 |
case KThirdServiceIndex: if(!(string->Des().Compare(_L("Print Localized %U")))) |
|
337 |
{ iLog->Log(_L("LOCALIZED name is correct")); } |
|
338 |
else |
|
339 |
{ iLog->Log(_L("LOCALIZED name is incorrect")); |
|
340 |
CleanupStack::PopAndDestroy(string);return ( KErrGeneral ); } |
|
341 |
break; |
|
342 |
default : break; |
|
343 |
}; |
|
344 |
||
345 |
CleanupStack::PopAndDestroy(string); |
|
346 |
return ( KErrNone ); |
|
347 |
||
348 |
} |
|
349 |
||
350 |
||
351 |
// ----------------------------------------------------------------------------- |
|
352 |
// CServicesDbApiTest::ServiceStringLCuidSeviceDB |
|
353 |
// Testing - IMPORT_C HBufC* ServiceStringLC(TUid aServiceUid, const TDes& aParam) const; |
|
354 |
// ----------------------------------------------------------------------------- |
|
355 |
// |
|
356 |
TInt CServicesDbApiTest::ServiceStringLCuidSeviceDB( CStifItemParser& aItem ) |
|
357 |
{ |
|
358 |
TInt result = InitializeSeviceDB(); |
|
359 |
if ( KErrNone != result ) |
|
360 |
{ |
|
361 |
return ( result ); |
|
362 |
} |
|
363 |
TBuf<KBufSize> format(KEmptyString); |
|
364 |
TInt uid; |
|
365 |
||
366 |
if( aItem.GetNextInt(uid) != KErrNone ) |
|
367 |
{ |
|
368 |
iLog->Log(_L("NO UID number provided, UID is required parameter for testing ServiceStringLC ")); |
|
369 |
return ( KErrGeneral ); |
|
370 |
} |
|
371 |
TUid serviceUID= TUid::Uid(uid); |
|
372 |
iLog->Log(_L("serviceUID = %d"),serviceUID.iUid); |
|
373 |
TInt res ; |
|
374 |
TRAPD(error, res = CallServiceStringLCuidSeviceDBL(serviceUID,format)); |
|
375 |
if ( KErrNone != error ) |
|
376 |
{ |
|
377 |
iLog->Log(_L("=> ServiceStringLC leaves. Error code = %d"),error); |
|
378 |
return (error); |
|
379 |
} |
|
380 |
return ( res ); |
|
381 |
||
382 |
} |
|
383 |
||
384 |
||
385 |
// ----------------------------------------------------------------------------- |
|
386 |
// CServicesDbApiTest::CallServiceStringLCuidSeviceDBL |
|
387 |
// This function is used because we can not trap ServiceStringLC |
|
388 |
// ----------------------------------------------------------------------------- |
|
389 |
// |
|
390 |
TInt CServicesDbApiTest::CallServiceStringLCuidSeviceDBL( TUid aServiceUid, const TDes& aParam ) |
|
391 |
{ |
|
392 |
HBufC *string; |
|
393 |
string=iServicesDB->ServiceStringLC(aServiceUid,aParam); |
|
394 |
if ( NULL != string ) |
|
395 |
{ |
|
396 |
iLog->Log(_L("LOCALIZED name of the Service with UID(%d) = "),aServiceUid.iUid); |
|
397 |
iLog->Log(*string); |
|
398 |
} |
|
399 |
else |
|
400 |
{ |
|
401 |
iLog->Log(_L("No matching service found, Service UID provided is incorrect")); |
|
402 |
} |
|
403 |
||
404 |
switch (aServiceUid.iUid) |
|
405 |
{ |
|
406 |
case KFirstServiceUid: if(!(string->Des().Compare(_L("Open Localized")))) |
|
407 |
{ iLog->Log(_L("LOCALIZED name is correct")); } |
|
408 |
else |
|
409 |
{ iLog->Log(_L("LOCALIZED name is incorrect")); |
|
410 |
CleanupStack::PopAndDestroy(string); return ( KErrGeneral ); } |
|
411 |
break; |
|
412 |
case KSecondServiceUid: if(!(string->Des().Compare(_L("Upload Localized")))) |
|
413 |
{ iLog->Log(_L("LOCALIZED name is correct")); } |
|
414 |
else |
|
415 |
{ iLog->Log(_L("LOCALIZED name is incorrect")); |
|
416 |
CleanupStack::PopAndDestroy(string); return ( KErrGeneral ); } |
|
417 |
break; |
|
418 |
case KThirdServiceUid: if(!(string->Des().Compare(_L("Print Localized %U")))) |
|
419 |
{ iLog->Log(_L("LOCALIZED name is correct")); } |
|
420 |
else |
|
421 |
{ iLog->Log(_L("LOCALIZED name is incorrect")); |
|
422 |
CleanupStack::PopAndDestroy(string);return ( KErrGeneral ); } |
|
423 |
break; |
|
424 |
default : break; |
|
425 |
}; |
|
426 |
||
427 |
CleanupStack::PopAndDestroy(string); |
|
428 |
return ( KErrNone ); |
|
429 |
} |
|
430 |
||
431 |
// ----------------------------------------------------------------------------- |
|
432 |
// CServicesDbApiTest::ServiceNameLCSeviceDB |
|
433 |
// Testing - IMPORT_C HBufC* ServiceNameLC(TInt aIndex) const; |
|
434 |
// ----------------------------------------------------------------------------- |
|
435 |
// |
|
436 |
TInt CServicesDbApiTest::ServiceNameLCSeviceDB( CStifItemParser& aItem ) |
|
437 |
{ |
|
438 |
TInt result = InitializeSeviceDB(); |
|
439 |
if ( KErrNone != result ) |
|
440 |
{ |
|
441 |
return ( result ); |
|
442 |
} |
|
443 |
TInt index; |
|
444 |
TBuf<KBufSize> format(KEmptyString); |
|
445 |
||
446 |
if( aItem.GetNextInt(index) != KErrNone ) |
|
447 |
{ |
|
448 |
iLog->Log(_L("NO Index number provided, index is required parameter for testing ServiceNameLC ")); |
|
449 |
return ( KErrGeneral ); |
|
450 |
} |
|
451 |
iLog->Log(_L("checked till here")); |
|
452 |
iLog->Log(_L("index = %d"),index); |
|
453 |
||
454 |
TRAPD(error,TInt res = CallServiceNameLCSeviceDBL(index)); |
|
455 |
if ( KErrNone != error ) |
|
456 |
{ |
|
457 |
iLog->Log(_L("Incorrect Index. There is no service matching the Index Number.")); |
|
458 |
iLog->Log(_L("=> ServiceNameLC leaves when index is incorrect.")); |
|
459 |
return (error); |
|
460 |
} |
|
461 |
return ( KErrNone ); |
|
462 |
||
463 |
} |
|
464 |
||
465 |
||
466 |
// ----------------------------------------------------------------------------- |
|
467 |
// CServicesDbApiTest::ServiceNameLCSeviceDB |
|
468 |
// This function is used because we can not trap ServiceNameLC |
|
469 |
// ----------------------------------------------------------------------------- |
|
470 |
// |
|
471 |
TInt CServicesDbApiTest::CallServiceNameLCSeviceDBL(TInt aIndex) |
|
472 |
{ |
|
473 |
HBufC *string; |
|
474 |
string=iServicesDB->ServiceNameLC(aIndex); |
|
475 |
iLog->Log(_L("GENERIC name of the Service[%d] = "),aIndex); |
|
476 |
iLog->Log(*string); |
|
477 |
||
478 |
switch (aIndex) |
|
479 |
{ |
|
480 |
case KFirstServiceIndex: if(!(string->Des().Compare(_L("Open")))) |
|
481 |
{ iLog->Log(_L("GENERIC name is correct")); } |
|
482 |
else |
|
483 |
{ iLog->Log(_L("GENERIC name is incorrect")); |
|
484 |
CleanupStack::PopAndDestroy(string); return ( KErrGeneral ); } |
|
485 |
break; |
|
486 |
case KSecondServiceIndex: if(!(string->Des().Compare(_L("Upload")))) |
|
487 |
{ iLog->Log(_L("GENERIC name is correct")); } |
|
488 |
else |
|
489 |
{ iLog->Log(_L("GENERIC name is incorrect")); |
|
490 |
CleanupStack::PopAndDestroy(string); return ( KErrGeneral ); } |
|
491 |
break; |
|
492 |
case KThirdServiceIndex: if(!(string->Des().Compare(_L("Print")))) |
|
493 |
{ iLog->Log(_L("GENERIC name is correct")); } |
|
494 |
else |
|
495 |
{ iLog->Log(_L("GENERIC name is incorrect")); |
|
496 |
CleanupStack::PopAndDestroy(string);return ( KErrGeneral ); } |
|
497 |
break; |
|
498 |
default : break; |
|
499 |
}; |
|
500 |
||
501 |
CleanupStack::PopAndDestroy(string); |
|
502 |
return ( KErrNone ); |
|
503 |
||
504 |
} |
|
505 |
||
506 |
||
507 |
// ----------------------------------------------------------------------------- |
|
508 |
// CServicesDbApiTest::ServiceNameLCuidSeviceDB |
|
509 |
// Testing - IMPORT_C HBufC* ServiceNameLC(TUid aServiceUid) const; |
|
510 |
// ----------------------------------------------------------------------------- |
|
511 |
// |
|
512 |
TInt CServicesDbApiTest::ServiceNameLCuidSeviceDB( CStifItemParser& aItem ) |
|
513 |
{ |
|
514 |
||
515 |
TInt result = InitializeSeviceDB(); |
|
516 |
if ( KErrNone != result ) |
|
517 |
{ |
|
518 |
return ( result ); |
|
519 |
} |
|
520 |
TBuf<KBufSize> format(KEmptyString); |
|
521 |
TInt uid; |
|
522 |
||
523 |
if( aItem.GetNextInt(uid) != KErrNone ) |
|
524 |
{ |
|
525 |
iLog->Log(_L("NO UID number provided, UID is required parameter for testing ServiceStringLC ")); |
|
526 |
return ( KErrGeneral ); |
|
527 |
} |
|
528 |
iLog->Log(_L("checked till here")); |
|
529 |
||
530 |
TUid serviceUID= TUid::Uid(uid); |
|
531 |
iLog->Log(_L("serviceUID = %d"),serviceUID.iUid); |
|
532 |
||
533 |
TRAPD(error,TInt res = CallServiceNameLCuidSeviceDBL(serviceUID)); |
|
534 |
if ( KErrNone != error ) |
|
535 |
{ |
|
536 |
iLog->Log(_L("=> ServiceNameLC leaves."),error); |
|
537 |
return (error); |
|
538 |
} |
|
539 |
return ( KErrNone ); |
|
540 |
} |
|
541 |
||
542 |
||
543 |
// ----------------------------------------------------------------------------- |
|
544 |
// CServicesDbApiTest::ServiceNameLCuidSeviceDB |
|
545 |
// This function is used because we can not trap ServiceNameLC |
|
546 |
// ----------------------------------------------------------------------------- |
|
547 |
// |
|
548 |
TInt CServicesDbApiTest::CallServiceNameLCuidSeviceDBL( TUid aServiceUid ) |
|
549 |
{ |
|
550 |
HBufC *string; |
|
551 |
string=iServicesDB->ServiceNameLC(aServiceUid); |
|
552 |
if ( NULL != string ) |
|
553 |
{ |
|
554 |
iLog->Log(_L("GENERIC name of the Service with UID(%d) = "),aServiceUid.iUid); |
|
555 |
iLog->Log(*string); |
|
556 |
} |
|
557 |
else |
|
558 |
{ |
|
559 |
iLog->Log(_L("No matching service found, Service UID provided is incorrect")); |
|
560 |
} |
|
561 |
||
562 |
switch (aServiceUid.iUid) |
|
563 |
{ |
|
564 |
case KFirstServiceUid: if(!(string->Des().Compare(_L("Open")))) |
|
565 |
{ iLog->Log(_L("GENERIC name is correct")); } |
|
566 |
else |
|
567 |
{ iLog->Log(_L("GENERIC name is incorrect")); |
|
568 |
CleanupStack::PopAndDestroy(string); return ( KErrGeneral ); } |
|
569 |
break; |
|
570 |
case KSecondServiceUid: if(!(string->Des().Compare(_L("Upload")))) |
|
571 |
{ iLog->Log(_L("GENERIC name is correct")); } |
|
572 |
else |
|
573 |
{ iLog->Log(_L("GENERIC name is incorrect")); |
|
574 |
CleanupStack::PopAndDestroy(string); return ( KErrGeneral ); } |
|
575 |
break; |
|
576 |
case KThirdServiceUid: if(!(string->Des().Compare(_L("Print")))) |
|
577 |
{ iLog->Log(_L("GENERIC name is correct")); } |
|
578 |
else |
|
579 |
{ iLog->Log(_L("GENERIC name is incorrect")); |
|
580 |
CleanupStack::PopAndDestroy(string);return ( KErrGeneral ); } |
|
581 |
break; |
|
582 |
default : break; |
|
583 |
}; |
|
584 |
||
585 |
CleanupStack::PopAndDestroy(string); |
|
586 |
return ( KErrNone ); |
|
587 |
} |
|
588 |
||
589 |
||
590 |
// [End of File] - Do not remove |