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 |
#include <e32svr.h> |
|
21 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
22 |
#include <StifTestInterface.h> |
19 | 23 |
#include <liwcommon.h> |
24 |
#include <liwservicehandler.h> |
|
25 |
#include <EPos_HPosLmDatabaseInfo.h> |
|
26 |
#include <EPos_CPosLmDatabaseManager.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#include <EPos_CPosLandmarkDatabase.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
28 |
#include <EPos_Landmarks.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
29 |
#include <EPos_CPosLandmark.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include <liwcommon.h> |
19 | 31 |
#include "tlmproviderdbtests.h" |
32 |
#include "landmarkliwparams.hrh" |
|
33 |
||
34 |
#define PASS TInt(0) |
|
35 |
#define FAIL (!PASS) |
|
36 |
||
37 |
_LIT(KDbInvalidUri1, "file:/c:invalid.ldb"); |
|
38 |
_LIT(KDbInvalidUri2, "z:invalid.ldb"); |
|
39 |
_LIT(KDbInvalidUri3, "c:invalid"); |
|
40 |
_LIT(KDbInvalidUri4, "c:\\invalid.ldb"); |
|
41 |
_LIT(KDbInvalidUri5, "e:invalid.ldb"); |
|
42 |
_LIT(KRemoteUnsupportedDbUri, "http://remote.ldb"); |
|
43 |
// ============================ MEMBER FUNCTIONS =============================== |
|
44 |
// ----------------------------------------------------------------------------- |
|
45 |
// CTLmDbTests::RunMethodL |
|
46 |
// Run specified method. Contains also table of test mothods and their names. |
|
47 |
// ----------------------------------------------------------------------------- |
|
48 |
// |
|
49 |
TInt CTLmDbTests::RunMethodL( |
|
50 |
CStifItemParser& aItem ) |
|
51 |
{ |
|
52 |
||
53 |
static TStifFunctionInfo const KFunctions[] = |
|
54 |
{ |
|
55 |
// Copy this line for every implemented function. |
|
56 |
// First string is the function name used in TestScripter script file. |
|
57 |
// Second is the actual implementation member function. |
|
58 |
ENTRY( "AddDatabase", CTLmDbTests::AddDatabase ), |
|
59 |
ENTRY( "DeleteDatabase", CTLmDbTests::DeleteDatabase), |
|
60 |
ENTRY( "AddExistingDatabase", CTLmDbTests::AddExistingDatabase), |
|
61 |
ENTRY( "AddInvalidDatabase", CTLmDbTests::AddInvalidDatabase), |
|
62 |
ENTRY( "AddRemoteDatabase", CTLmDbTests::AddRemoteDatabase), |
|
63 |
ENTRY( "UpdateDatabase" , CTLmDbTests::UpdateDatabase), |
|
64 |
// ENTRY( "SetActiveDb", CTLmDbTests::SetActiveDb ), |
|
65 |
ENTRY( "GetDbList", CTLmDbTests::GetDbList ), |
|
66 |
ENTRY( "AddDatabasePos", CTLmDbTests::AddDatabasePos ), |
|
67 |
ENTRY( "DeleteDatabasePos", CTLmDbTests::DeleteDatabasePos), |
|
68 |
ENTRY( "AddExistingDatabasePos", CTLmDbTests::AddExistingDatabasePos), |
|
69 |
ENTRY( "AddInvalidDatabasePos", CTLmDbTests::AddInvalidDatabasePos), |
|
70 |
ENTRY( "AddRemoteDatabasePos", CTLmDbTests::AddRemoteDatabasePos), |
|
71 |
ENTRY( "UpdateDatabasePos" , CTLmDbTests::UpdateDatabasePos), |
|
72 |
ENTRY( "GetDbListPos", CTLmDbTests::GetDbListPos ) |
|
73 |
||
74 |
}; |
|
75 |
||
76 |
const TInt count = sizeof( KFunctions ) / |
|
77 |
sizeof( TStifFunctionInfo ); |
|
78 |
||
79 |
return RunInternalL( KFunctions, count, aItem ); |
|
80 |
||
81 |
} |
|
82 |
||
83 |
// ----------------------------------------------------------------------------- |
|
84 |
// CTLmDbTests::AddDatabase |
|
85 |
// test method function. |
|
86 |
// ----------------------------------------------------------------------------- |
|
87 |
// |
|
88 |
TInt CTLmDbTests::AddDatabase( CStifItemParser& /*aItem*/ ) |
|
89 |
{ |
|
90 |
_LIT( KExample, "AddDatabase" ); |
|
91 |
iLog->Log( KExample ); |
|
92 |
||
93 |
// TInt ret = 0; |
|
94 |
TInt32 err=0; |
|
95 |
/* |
|
96 |
DeleteAllLocalDatabasesL(); |
|
97 |
||
98 |
TLiwGenericParam content(KContentType,TLiwVariant(KDatabase)); |
|
99 |
||
100 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
101 |
||
102 |
dbinfo->InsertL(KDbUri,TLiwVariant(_L("c:landmark1.ldb"))); |
|
103 |
||
104 |
TLiwGenericParam db(KDataFields,TLiwVariant(dbinfo)); |
|
105 |
||
106 |
iInList->AppendL(content); |
|
107 |
iInList->AppendL(db); |
|
108 |
||
109 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
110 |
||
111 |
ret |= CheckErrorCode (*iOutList,err); |
|
112 |
if ( err ) |
|
113 |
{ |
|
114 |
iLog->Log( _L("Database Creation failed : %d"),err ); |
|
115 |
ret |= FAIL; |
|
116 |
} |
|
117 |
||
118 |
TRAPD (err1, iDatabaseManager->DatabaseExistsL(_L("c:landmark1.ldb"))); |
|
119 |
if (err1) |
|
120 |
{ |
|
121 |
iLog->Log( _L("Database haven't been created : %d"),err ); |
|
122 |
ret |= FAIL; |
|
123 |
} |
|
124 |
||
125 |
dbinfo->DecRef(); |
|
126 |
||
127 |
DeleteAllLocalDatabasesL(); |
|
128 |
iLog->Log( _L("End of AddDatabase test" )); |
|
129 |
*/ |
|
130 |
return err; |
|
131 |
} |
|
132 |
||
133 |
// ----------------------------------------------------------------------------- |
|
134 |
// CTLmDbTests::AddDatabasePos |
|
135 |
// test method function. |
|
136 |
// ----------------------------------------------------------------------------- |
|
137 |
// |
|
138 |
TInt CTLmDbTests::AddDatabasePos( CStifItemParser& /*aItem*/ ) |
|
139 |
{ |
|
140 |
_LIT( KExample, "AddDatabasePos" ); |
|
141 |
iLog->Log( KExample ); |
|
142 |
||
143 |
// TInt ret = 0; |
|
144 |
TInt32 err=0; |
|
145 |
/* |
|
146 |
DeleteAllLocalDatabasesL(); |
|
147 |
||
148 |
TLiwGenericParam content(KNullDesC8,TLiwVariant(KDatabase)); |
|
149 |
||
150 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
151 |
||
152 |
dbinfo->InsertL(KDbUri,TLiwVariant(_L("c:landmark1.ldb"))); |
|
153 |
||
154 |
TLiwGenericParam db(KNullDesC8,TLiwVariant(dbinfo)); |
|
155 |
||
156 |
iInList->AppendL(content); |
|
157 |
iInList->AppendL(db); |
|
158 |
||
159 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
160 |
||
161 |
ret |= CheckErrorCode (*iOutList,err); |
|
162 |
if ( err ) |
|
163 |
{ |
|
164 |
iLog->Log( _L("Database Creation failed : %d"),err ); |
|
165 |
ret |= FAIL; |
|
166 |
} |
|
167 |
||
168 |
TRAPD (err1, iDatabaseManager->DatabaseExistsL(_L("c:landmark1.ldb"))); |
|
169 |
if (err1) |
|
170 |
{ |
|
171 |
iLog->Log( _L("Database haven't been created : %d"),err ); |
|
172 |
ret |= FAIL; |
|
173 |
} |
|
174 |
||
175 |
dbinfo->DecRef(); |
|
176 |
||
177 |
DeleteAllLocalDatabasesL(); |
|
178 |
iLog->Log( _L("End of AddDatabase test" )); |
|
179 |
*/ |
|
180 |
return err; |
|
181 |
} |
|
182 |
||
183 |
// ----------------------------------------------------------------------------- |
|
184 |
// CTLmDbTests::AddExistingDatabase |
|
185 |
// test method function. |
|
186 |
// ----------------------------------------------------------------------------- |
|
187 |
// |
|
188 |
TInt CTLmDbTests::AddExistingDatabase( CStifItemParser& /*aItem*/ ) |
|
189 |
{ |
|
190 |
_LIT( KExample, "AddExistingDatabase" ); |
|
191 |
iLog->Log( KExample ); |
|
192 |
||
193 |
// TInt32 err; |
|
194 |
TInt ret = 0; |
|
195 |
/* |
|
196 |
DeleteAllLocalDatabasesL(); |
|
197 |
||
198 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(_L("c:landmark1.ldb")); |
|
199 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
200 |
CleanupStack::PopAndDestroy(dbInfo); |
|
201 |
||
202 |
||
203 |
TLiwGenericParam content(KContentType,TLiwVariant(KDatabase)); |
|
204 |
||
205 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
206 |
||
207 |
dbinfo->InsertL(KDbUri,TLiwVariant(_L("c:landmark1.ldb"))); |
|
208 |
||
209 |
TLiwGenericParam db(KDataFields,TLiwVariant(dbinfo)); |
|
210 |
||
211 |
iInList->AppendL(content); |
|
212 |
iInList->AppendL(db); |
|
213 |
||
214 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
215 |
||
216 |
ret |= CheckErrorCode (*iOutList,err); |
|
217 |
if ( err ) |
|
218 |
{ |
|
219 |
iLog->Log( _L("Incorrect Error returned : %d"),err ); |
|
220 |
ret |= FAIL; |
|
221 |
} |
|
222 |
||
223 |
dbinfo->DecRef(); |
|
224 |
||
225 |
DeleteAllLocalDatabasesL(); |
|
226 |
*/ |
|
227 |
return ( ret ); |
|
228 |
} |
|
229 |
||
230 |
// ----------------------------------------------------------------------------- |
|
231 |
// CTLmDbTests::AddExistingDatabase |
|
232 |
// test method function. |
|
233 |
// ----------------------------------------------------------------------------- |
|
234 |
// |
|
235 |
TInt CTLmDbTests::AddExistingDatabasePos( CStifItemParser& /*aItem*/ ) |
|
236 |
{ |
|
237 |
_LIT( KExample, "AddExistingDatabasePos" ); |
|
238 |
iLog->Log( KExample ); |
|
239 |
||
240 |
// TInt32 err; |
|
241 |
TInt ret = 0; |
|
242 |
/* |
|
243 |
DeleteAllLocalDatabasesL(); |
|
244 |
||
245 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(_L("c:landmark1.ldb")); |
|
246 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
247 |
CleanupStack::PopAndDestroy(dbInfo); |
|
248 |
||
249 |
||
250 |
TLiwGenericParam content(KNullDesC8,TLiwVariant(KDatabase)); |
|
251 |
||
252 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
253 |
||
254 |
dbinfo->InsertL(KDbUri,TLiwVariant(_L("c:landmark1.ldb"))); |
|
255 |
||
256 |
TLiwGenericParam db(KNullDesC8,TLiwVariant(dbinfo)); |
|
257 |
||
258 |
iInList->AppendL(content); |
|
259 |
iInList->AppendL(db); |
|
260 |
||
261 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
262 |
||
263 |
ret |= CheckErrorCode (*iOutList,err); |
|
264 |
if ( err ) |
|
265 |
{ |
|
266 |
iLog->Log( _L("Incorrect Error returned : %d"),err ); |
|
267 |
ret |= FAIL; |
|
268 |
} |
|
269 |
||
270 |
dbinfo->DecRef(); |
|
271 |
||
272 |
DeleteAllLocalDatabasesL(); |
|
273 |
*/ |
|
274 |
return ( ret ); |
|
275 |
} |
|
276 |
||
277 |
// ----------------------------------------------------------------------------- |
|
278 |
// CTLmDbTests::AddInvalidDatabase |
|
279 |
// test method function. |
|
280 |
// ----------------------------------------------------------------------------- |
|
281 |
// |
|
282 |
TInt CTLmDbTests::AddInvalidDatabase( CStifItemParser& /*aItem*/ ) |
|
283 |
{ |
|
284 |
_LIT( KExample, "AddInvalidDatabase" ); |
|
285 |
iLog->Log( KExample ); |
|
286 |
// TInt32 err; |
|
287 |
TInt ret = PASS; |
|
288 |
/* |
|
289 |
DeleteAllLocalDatabasesL(); |
|
290 |
||
291 |
TLiwGenericParam content(KContentType,TLiwVariant(KDatabase)); |
|
292 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
293 |
||
294 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDbInvalidUri1)); |
|
295 |
TLiwGenericParam db(KDataFields,TLiwVariant(dbinfo)); |
|
296 |
ResetParams(); |
|
297 |
iInList->AppendL(content); |
|
298 |
iInList->AppendL(db); |
|
299 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
300 |
ret |= CheckErrorCode (*iOutList,err); |
|
301 |
if ( !err ) |
|
302 |
{ |
|
303 |
iLog->Log( _L("invalid uri1 failed : %d"),err ); |
|
304 |
ret |= FAIL; |
|
305 |
} |
|
306 |
||
307 |
||
308 |
ResetParams(); |
|
309 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDbInvalidUri2)); |
|
310 |
iInList->AppendL(content); |
|
311 |
iInList->AppendL(TLiwGenericParam(KDataFields,TLiwVariant(dbinfo)) ); |
|
312 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
313 |
ret |= CheckErrorCode (*iOutList,err); |
|
314 |
if ( err != SErrAccessDenied ) |
|
315 |
{ |
|
316 |
iLog->Log( _L("invalid uri2 failed : %d"),err ); |
|
317 |
ret |= FAIL; |
|
318 |
} |
|
319 |
||
320 |
||
321 |
ResetParams(); |
|
322 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDbInvalidUri3)); |
|
323 |
iInList->AppendL(content); |
|
324 |
iInList->AppendL(TLiwGenericParam(KDataFields,TLiwVariant(dbinfo)) ); |
|
325 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
326 |
ret |= CheckErrorCode (*iOutList,err); |
|
327 |
if ( err != SErrBadArgumentType ) |
|
328 |
{ |
|
329 |
iLog->Log( _L("invalid uri3 failed : %d"),err ); |
|
330 |
ret |= FAIL; |
|
331 |
} |
|
332 |
||
333 |
||
334 |
ResetParams(); |
|
335 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDbInvalidUri4)); |
|
336 |
iInList->AppendL(content); |
|
337 |
iInList->AppendL(TLiwGenericParam(KDataFields,TLiwVariant(dbinfo)) ); |
|
338 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
339 |
ret |= CheckErrorCode (*iOutList,err); |
|
340 |
if ( err != SErrBadArgumentType ) |
|
341 |
{ |
|
342 |
iLog->Log( _L("invalid uri4 failed : %d"),err ); |
|
343 |
ret |= FAIL; |
|
344 |
} |
|
345 |
||
346 |
||
347 |
||
348 |
DeleteAllLocalDatabasesL(); |
|
349 |
*/ |
|
350 |
return ret; |
|
351 |
} |
|
352 |
||
353 |
// ----------------------------------------------------------------------------- |
|
354 |
// CTLmDbTests::AddInvalidDatabase |
|
355 |
// test method function. |
|
356 |
// ----------------------------------------------------------------------------- |
|
357 |
// |
|
358 |
TInt CTLmDbTests::AddInvalidDatabasePos( CStifItemParser& /*aItem*/ ) |
|
359 |
{ |
|
360 |
_LIT( KExample, "AddInvalidDatabasePos" ); |
|
361 |
iLog->Log( KExample ); |
|
362 |
// TInt32 err; |
|
363 |
TInt ret = PASS; |
|
364 |
/* |
|
365 |
DeleteAllLocalDatabasesL(); |
|
366 |
||
367 |
TLiwGenericParam content(KNullDesC8,TLiwVariant(KDatabase)); |
|
368 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
369 |
||
370 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDbInvalidUri1)); |
|
371 |
TLiwGenericParam db(KNullDesC8,TLiwVariant(dbinfo)); |
|
372 |
ResetParams(); |
|
373 |
iInList->AppendL(content); |
|
374 |
iInList->AppendL(db); |
|
375 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
376 |
ret |= CheckErrorCode (*iOutList,err); |
|
377 |
if ( !err ) |
|
378 |
{ |
|
379 |
iLog->Log( _L("invalid uri1 failed : %d"),err ); |
|
380 |
ret |= FAIL; |
|
381 |
} |
|
382 |
||
383 |
||
384 |
ResetParams(); |
|
385 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDbInvalidUri2)); |
|
386 |
iInList->AppendL(content); |
|
387 |
iInList->AppendL(TLiwGenericParam(KNullDesC8,TLiwVariant(dbinfo)) ); |
|
388 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
389 |
ret |= CheckErrorCode (*iOutList,err); |
|
390 |
if ( err != SErrAccessDenied ) |
|
391 |
{ |
|
392 |
iLog->Log( _L("invalid uri2 failed : %d"),err ); |
|
393 |
ret |= FAIL; |
|
394 |
} |
|
395 |
||
396 |
DeleteAllLocalDatabasesL(); |
|
397 |
*/ |
|
398 |
return ret; |
|
399 |
} |
|
400 |
||
401 |
// ----------------------------------------------------------------------------- |
|
402 |
// CTLmDbTests::AddRemoteDatabase |
|
403 |
// test method function. |
|
404 |
// ----------------------------------------------------------------------------- |
|
405 |
// |
|
406 |
TInt CTLmDbTests::AddRemoteDatabase( CStifItemParser& /*aItem*/ ) |
|
407 |
{ |
|
408 |
_LIT( KExample, "AddRemoteDatabase" ); |
|
409 |
iLog->Log( KExample ); |
|
410 |
||
411 |
TInt ret=0; |
|
412 |
// TInt32 err; |
|
413 |
/* |
|
414 |
DeleteAllLocalDatabasesL(); |
|
415 |
||
416 |
TLiwGenericParam content(KContentType,TLiwVariant(KDatabase)); |
|
417 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
418 |
||
419 |
dbinfo->InsertL(KDbUri,TLiwVariant(KRemoteUnsupportedDbUri)); |
|
420 |
TLiwGenericParam db(KDataFields,TLiwVariant(dbinfo)); |
|
421 |
ResetParams(); |
|
422 |
iInList->AppendL(content); |
|
423 |
iInList->AppendL(db); |
|
424 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
425 |
ret |= CheckErrorCode (*iOutList,err); |
|
426 |
if ( err != SErrServiceNotSupported ) |
|
427 |
{ |
|
428 |
iLog->Log( _L("invalid AddRemoteDatabase failed : %d"),err ); |
|
429 |
ret |= FAIL; |
|
430 |
} |
|
431 |
ResetParams(); |
|
432 |
*/ |
|
433 |
return ret; |
|
434 |
} |
|
435 |
||
436 |
// ----------------------------------------------------------------------------- |
|
437 |
// CTLmDbTests::AddRemoteDatabase |
|
438 |
// test method function. |
|
439 |
// ----------------------------------------------------------------------------- |
|
440 |
// |
|
441 |
TInt CTLmDbTests::AddRemoteDatabasePos( CStifItemParser& /*aItem*/ ) |
|
442 |
{ |
|
443 |
_LIT( KExample, "AddRemoteDatabasePos" ); |
|
444 |
iLog->Log( KExample ); |
|
445 |
||
446 |
TInt ret=0; |
|
447 |
// TInt32 err; |
|
448 |
/* |
|
449 |
DeleteAllLocalDatabasesL(); |
|
450 |
||
451 |
TLiwGenericParam content(KNullDesC8,TLiwVariant(KDatabase)); |
|
452 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
453 |
||
454 |
dbinfo->InsertL(KDbUri,TLiwVariant(KRemoteUnsupportedDbUri)); |
|
455 |
TLiwGenericParam db(KNullDesC8,TLiwVariant(dbinfo)); |
|
456 |
ResetParams(); |
|
457 |
iInList->AppendL(content); |
|
458 |
iInList->AppendL(db); |
|
459 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
460 |
ret |= CheckErrorCode (*iOutList,err); |
|
461 |
if ( err != SErrServiceNotSupported ) |
|
462 |
{ |
|
463 |
iLog->Log( _L("invalid AddRemoteDatabase failed : %d"),err ); |
|
464 |
ret |= FAIL; |
|
465 |
} |
|
466 |
ResetParams(); |
|
467 |
*/ |
|
468 |
return ret; |
|
469 |
} |
|
470 |
||
471 |
// ----------------------------------------------------------------------------- |
|
472 |
// CTLmDbTests::DeleteDatabase |
|
473 |
// test method function. |
|
474 |
// ----------------------------------------------------------------------------- |
|
475 |
// |
|
476 |
TInt CTLmDbTests ::DeleteDatabase(CStifItemParser& /*aItem*/) |
|
477 |
{ |
|
478 |
_LIT(KDb1, "c:eposlm1.ldb"); |
|
479 |
_LIT( KExample, "DeleteDatabase" ); |
|
480 |
iLog->Log( KExample ); |
|
481 |
||
482 |
// TInt32 err; |
|
483 |
TInt ret=0; |
|
484 |
/* DeleteAllLocalDatabasesL(); |
|
485 |
||
486 |
HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewL(KDb1); |
|
487 |
CleanupStack::PushL(info); |
|
488 |
iDatabaseManager->CreateDatabaseL (*info); |
|
489 |
CleanupStack::PopAndDestroy(info); |
|
490 |
||
491 |
TLiwGenericParam content(KContentType,TLiwVariant(KDatabase)); |
|
492 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
493 |
||
494 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDb1)); |
|
495 |
TLiwGenericParam db(KDataFields,TLiwVariant(dbinfo)); |
|
496 |
ResetParams(); |
|
497 |
iInList->AppendL(content); |
|
498 |
iInList->AppendL(db); |
|
499 |
iLandmarkIf->ExecuteCmdL(KRemove,*iInList,*iOutList); |
|
500 |
ret |= CheckErrorCode (*iOutList,err); |
|
501 |
if ( err != KErrNone ) |
|
502 |
{ |
|
503 |
iLog->Log( _L("deletion of database failed : %d"),err ); |
|
504 |
ret |= FAIL; |
|
505 |
} |
|
506 |
ResetParams(); |
|
507 |
||
508 |
DeleteAllLocalDatabasesL(); |
|
509 |
*/ |
|
510 |
return ret; |
|
511 |
} |
|
512 |
||
513 |
// ----------------------------------------------------------------------------- |
|
514 |
// CTLmDbTests::DeleteDatabase |
|
515 |
// test method function. |
|
516 |
// ----------------------------------------------------------------------------- |
|
517 |
// |
|
518 |
TInt CTLmDbTests ::DeleteDatabasePos(CStifItemParser& /*aItem*/) |
|
519 |
{ |
|
520 |
_LIT(KDb1, "c:eposlm1.ldb"); |
|
521 |
_LIT( KExample, "DeleteDatabase" ); |
|
522 |
iLog->Log( KExample ); |
|
523 |
||
524 |
// TInt32 err; |
|
525 |
TInt ret=0; |
|
526 |
/* DeleteAllLocalDatabasesL(); |
|
527 |
||
528 |
HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewL(KDb1); |
|
529 |
CleanupStack::PushL(info); |
|
530 |
iDatabaseManager->CreateDatabaseL (*info); |
|
531 |
CleanupStack::PopAndDestroy(info); |
|
532 |
||
533 |
TLiwGenericParam content(KNullDesC8,TLiwVariant(KDatabase)); |
|
534 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
535 |
||
536 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDb1)); |
|
537 |
TLiwGenericParam db(KNullDesC8,TLiwVariant(dbinfo)); |
|
538 |
ResetParams(); |
|
539 |
iInList->AppendL(content); |
|
540 |
iInList->AppendL(db); |
|
541 |
iLandmarkIf->ExecuteCmdL(KRemove,*iInList,*iOutList); |
|
542 |
ret |= CheckErrorCode (*iOutList,err); |
|
543 |
if ( err != KErrNone ) |
|
544 |
{ |
|
545 |
iLog->Log( _L("deletion of database failed : %d"),err ); |
|
546 |
ret |= FAIL; |
|
547 |
} |
|
548 |
ResetParams(); |
|
549 |
||
550 |
DeleteAllLocalDatabasesL(); |
|
551 |
*/ |
|
552 |
return ret; |
|
553 |
} |
|
554 |
||
555 |
// ----------------------------------------------------------------------------- |
|
556 |
// CTLmDbTests::UpdateDatabase |
|
557 |
// test method function. |
|
558 |
// ----------------------------------------------------------------------------- |
|
559 |
// |
|
560 |
TInt CTLmDbTests ::UpdateDatabase(CStifItemParser& /*aItem*/) |
|
561 |
{ |
|
562 |
_LIT( KExample, "UpdateDatabase" ); |
|
563 |
_LIT( KDatabaseUri, "C:landmark1.ldb"); |
|
564 |
_LIT( KDatabaseName,"mylandmarkdb1"); |
|
565 |
||
566 |
iLog->Log( KExample ); |
|
567 |
||
568 |
// TInt32 err; |
|
569 |
TInt ret=PASS; |
|
570 |
/* |
|
571 |
DeleteAllLocalDatabasesL(); |
|
572 |
||
573 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KDatabaseUri); |
|
574 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
575 |
CleanupStack::PopAndDestroy(dbInfo); |
|
576 |
||
577 |
TLiwGenericParam content(KContentType,TLiwVariant(KDatabase)); |
|
578 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
579 |
||
580 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDatabaseUri)); |
|
581 |
dbinfo->InsertL(KDbName,TLiwVariant(KDatabaseName)); |
|
582 |
TLiwGenericParam db(KDataFields,TLiwVariant(dbinfo)); |
|
583 |
iInList->AppendL(content); |
|
584 |
iInList->AppendL(db); |
|
585 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
586 |
ret |= CheckErrorCode (*iOutList,err); |
|
587 |
if ( err != KErrNone ) |
|
588 |
{ |
|
589 |
iLog->Log( _L("updation of database failed : %d"),err ); |
|
590 |
ret |= FAIL; |
|
591 |
} |
|
592 |
||
593 |
dbinfo->DecRef(); |
|
594 |
||
595 |
if (!ret) |
|
596 |
{ |
|
597 |
HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewL(KDatabaseUri); |
|
598 |
CleanupStack::PushL(info); |
|
599 |
TRAPD(err1,iDatabaseManager->GetDatabaseInfoL (*info)); |
|
600 |
if (!err1) |
|
601 |
{ |
|
602 |
const TPosLmDatabaseSettings settings = info->Settings(); |
|
603 |
TPtrC dbname = settings.DatabaseName(); |
|
604 |
if ( !dbname.Compare( KDatabaseName ) ) |
|
605 |
{ |
|
606 |
iLog->Log( _L("Database updated correctly") ); |
|
607 |
ret |= PASS; |
|
608 |
} |
|
609 |
else |
|
610 |
{ |
|
611 |
iLog->Log( _L("Database not updated") ); |
|
612 |
ret |= FAIL; |
|
613 |
} |
|
614 |
} |
|
615 |
CleanupStack::PopAndDestroy(info); |
|
616 |
} |
|
617 |
else |
|
618 |
{ |
|
619 |
iLog->Log( _L("Error updating database") ); |
|
620 |
} |
|
621 |
||
622 |
DeleteAllLocalDatabasesL(); |
|
623 |
*/ |
|
624 |
return ( ret ); |
|
625 |
} |
|
626 |
||
627 |
// ----------------------------------------------------------------------------- |
|
628 |
// CTLmDbTests::UpdateDatabase |
|
629 |
// test method function. |
|
630 |
// ----------------------------------------------------------------------------- |
|
631 |
// |
|
632 |
TInt CTLmDbTests ::UpdateDatabasePos(CStifItemParser& /*aItem*/) |
|
633 |
{ |
|
634 |
_LIT( KExample, "UpdateDatabasePos" ); |
|
635 |
_LIT( KDatabaseUri, "C:landmark1.ldb"); |
|
636 |
_LIT( KDatabaseName,"mylandmarkdb1"); |
|
637 |
||
638 |
iLog->Log( KExample ); |
|
639 |
||
640 |
// TInt32 err; |
|
641 |
TInt ret=PASS; |
|
642 |
/* |
|
643 |
DeleteAllLocalDatabasesL(); |
|
644 |
||
645 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KDatabaseUri); |
|
646 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
647 |
CleanupStack::PopAndDestroy(dbInfo); |
|
648 |
||
649 |
TLiwGenericParam content(KNullDesC8,TLiwVariant(KDatabase)); |
|
650 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
651 |
||
652 |
dbinfo->InsertL(KDbUri,TLiwVariant(KDatabaseUri)); |
|
653 |
dbinfo->InsertL(KDbName,TLiwVariant(KDatabaseName)); |
|
654 |
TLiwGenericParam db(KNullDesC8,TLiwVariant(dbinfo)); |
|
655 |
iInList->AppendL(content); |
|
656 |
iInList->AppendL(db); |
|
657 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList); |
|
658 |
ret |= CheckErrorCode (*iOutList,err); |
|
659 |
if ( err != KErrNone ) |
|
660 |
{ |
|
661 |
iLog->Log( _L("updation of database failed : %d"),err ); |
|
662 |
ret |= FAIL; |
|
663 |
} |
|
664 |
||
665 |
dbinfo->DecRef(); |
|
666 |
||
667 |
if (!ret) |
|
668 |
{ |
|
669 |
HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewL(KDatabaseUri); |
|
670 |
CleanupStack::PushL(info); |
|
671 |
TRAPD(err1,iDatabaseManager->GetDatabaseInfoL (*info)); |
|
672 |
if (!err1) |
|
673 |
{ |
|
674 |
const TPosLmDatabaseSettings settings = info->Settings(); |
|
675 |
TPtrC dbname = settings.DatabaseName(); |
|
676 |
if ( !dbname.Compare( KDatabaseName ) ) |
|
677 |
{ |
|
678 |
iLog->Log( _L("Database updated correctly") ); |
|
679 |
ret |= PASS; |
|
680 |
} |
|
681 |
else |
|
682 |
{ |
|
683 |
iLog->Log( _L("Database not updated") ); |
|
684 |
ret |= FAIL; |
|
685 |
} |
|
686 |
} |
|
687 |
CleanupStack::PopAndDestroy(info); |
|
688 |
} |
|
689 |
else |
|
690 |
{ |
|
691 |
iLog->Log( _L("Error updating database") ); |
|
692 |
} |
|
693 |
||
694 |
DeleteAllLocalDatabasesL(); |
|
695 |
*/ |
|
696 |
return ( ret ); |
|
697 |
} |
|
698 |
||
699 |
// ----------------------------------------------------------------------------- |
|
700 |
// CTLmDbTests::SetActiveDb |
|
701 |
// test method function. |
|
702 |
// ----------------------------------------------------------------------------- |
|
703 |
// |
|
704 |
||
705 |
TInt CTLmDbTests ::SetActiveDb(CStifItemParser& /*aItem*/) |
|
706 |
{ |
|
707 |
_LIT(KActiveDb1, "file://c:activelm1.ldb"); |
|
708 |
_LIT(KActiveDb2, "file://c:activelm2.ldb"); |
|
709 |
||
710 |
_LIT( KExample, "SetActiveDb" ); |
|
711 |
iLog->Log( KExample ); |
|
712 |
// TInt32 err; |
|
713 |
TInt ret=0; |
|
714 |
/* |
|
715 |
DeleteAllLocalDatabasesL(); |
|
716 |
HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewL(KActiveDb1); |
|
717 |
CleanupStack::PushL(info); |
|
718 |
iDatabaseManager->CreateDatabaseL (*info); |
|
719 |
CleanupStack::PopAndDestroy(info); |
|
720 |
||
721 |
info = HPosLmDatabaseInfo::NewL(KActiveDb2); |
|
722 |
CleanupStack::PushL(info); |
|
723 |
iDatabaseManager->CreateDatabaseL (*info); |
|
724 |
CleanupStack::PopAndDestroy(info); |
|
725 |
||
726 |
||
727 |
TLiwGenericParam content(KContentType,TLiwVariant(KDatabase)); |
|
728 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
729 |
||
730 |
dbinfo->InsertL(KDbUri,TLiwVariant(KActiveDb1)); |
|
731 |
ResetParams(); |
|
732 |
iInList->AppendL(content); |
|
733 |
iInList->AppendL(TLiwGenericParam(KDataFields,TLiwVariant(dbinfo))); |
|
734 |
// iLandmarkIf->ExecuteCmdL(KSetActive,*iInList,*iOutList); |
|
735 |
ret |= CheckErrorCode (*iOutList,err); |
|
736 |
if ( err != KErrNone ) |
|
737 |
{ |
|
738 |
iLog->Log( _L("Setting activedb1 failed") ); |
|
739 |
ret |= FAIL; |
|
740 |
} |
|
741 |
||
742 |
dbinfo->InsertL(KDbUri,TLiwVariant(KActiveDb2)); |
|
743 |
ResetParams(); |
|
744 |
iInList->AppendL(content); |
|
745 |
iInList->AppendL(TLiwGenericParam(KDataFields,TLiwVariant(dbinfo))); |
|
746 |
// iLandmarkIf->ExecuteCmdL(KSetActive,*iInList,*iOutList); |
|
747 |
ret |= CheckErrorCode (*iOutList,err); |
|
748 |
if ( err != KErrNone ) |
|
749 |
{ |
|
750 |
iLog->Log( _L("Setting activedb2 failed") ); |
|
751 |
ret |= FAIL; |
|
752 |
} |
|
753 |
ResetParams(); |
|
754 |
dbinfo->DecRef(); |
|
755 |
*/ |
|
756 |
return ret; |
|
757 |
} |
|
758 |
||
759 |
// ----------------------------------------------------------------------------- |
|
760 |
// CTLmDbTests::GetDbList |
|
761 |
// test method function. |
|
762 |
// ----------------------------------------------------------------------------- |
|
763 |
// |
|
764 |
TInt CTLmDbTests ::GetDbList(CStifItemParser& /*aItem*/) |
|
765 |
{ |
|
766 |
_LIT(KDb1, "file://c:lmdb1.ldb"); |
|
767 |
_LIT(KDb2, "file://c:lmdb2.ldb"); |
|
768 |
_LIT(KDb3, "file://c:lmdb3.ldb"); |
|
769 |
_LIT(KDb4, "file://c:lmdb4.ldb"); |
|
770 |
||
771 |
__UHEAP_MARK; |
|
772 |
||
773 |
_LIT( KExample, "GetDbList" ); |
|
774 |
iLog->Log( KExample ); |
|
775 |
TInt32 err; |
|
776 |
TInt ret=0; |
|
777 |
||
778 |
DeleteAllLocalDatabasesL(); |
|
779 |
||
780 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); |
|
781 |
delete db; |
|
782 |
||
783 |
||
784 |
CLiwServiceHandler* ServiceHandler; |
|
785 |
CLiwGenericParamList* iInList,*iOutList; |
|
786 |
MLiwInterface* iLandmarkIf; |
|
787 |
||
788 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
789 |
CleanupStack::PushL(ServiceHandler); |
|
790 |
CleanupClosePushL(*iLandmarkIf); |
|
791 |
||
792 |
iInList = &(ServiceHandler->InParamListL()); |
|
793 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
794 |
||
795 |
iInList->Reset(); |
|
796 |
iOutList->Reset(); |
|
797 |
||
798 |
HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewL(KDb1); |
|
799 |
CleanupStack::PushL(info); |
|
800 |
iDatabaseManager->CreateDatabaseL (*info); |
|
801 |
CleanupStack::PopAndDestroy(info); |
|
802 |
||
803 |
info = HPosLmDatabaseInfo::NewL(KDb2); |
|
804 |
CleanupStack::PushL(info); |
|
805 |
iDatabaseManager->CreateDatabaseL (*info); |
|
806 |
CleanupStack::PopAndDestroy(info); |
|
807 |
||
808 |
info = HPosLmDatabaseInfo::NewL(KDb3); |
|
809 |
CleanupStack::PushL(info); |
|
810 |
iDatabaseManager->CreateDatabaseL (*info); |
|
811 |
CleanupStack::PopAndDestroy(info); |
|
812 |
||
813 |
info = HPosLmDatabaseInfo::NewL(KDb4); |
|
814 |
CleanupStack::PushL(info); |
|
815 |
iDatabaseManager->CreateDatabaseL (*info); |
|
816 |
CleanupStack::PopAndDestroy(info); |
|
817 |
||
818 |
||
819 |
TLiwGenericParam content(KContentType,TLiwVariant(KDatabase)); |
|
820 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
821 |
||
822 |
dbinfo->InsertL(KDbProtocol,TLiwVariant(_L("file"))); |
|
823 |
iInList->AppendL(content); |
|
824 |
iInList->AppendL(TLiwGenericParam(KFilter,TLiwVariant(dbinfo))); |
|
825 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList); |
|
826 |
ret |= CheckErrorCode (*iOutList,err); |
|
827 |
if ( err != KErrNone ) |
|
828 |
{ |
|
829 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
830 |
ret |= FAIL; |
|
831 |
} |
|
832 |
||
833 |
TInt Index = 0; |
|
834 |
const TLiwGenericParam* param = iOutList->FindFirst(Index,KReturnValue); |
|
835 |
if ( KErrNotFound == Index ) |
|
836 |
{ |
|
837 |
iLog->Log( _L("Database iterator not found in output ArgList") ); |
|
838 |
ret |= FAIL; |
|
839 |
} |
|
840 |
CLiwIterable* dbiterator = param->Value().AsIterable(); |
|
841 |
||
842 |
if ( !dbiterator ) |
|
843 |
{ |
|
844 |
iLog->Log( _L("Database iterator not set") ); |
|
845 |
ret |= FAIL; |
|
846 |
} |
|
847 |
||
848 |
TLiwVariant item; |
|
849 |
while ( dbiterator->NextL(item) ) |
|
850 |
{ |
|
851 |
const CLiwMap* db = item.AsMap(); |
|
852 |
if (db) |
|
853 |
{ |
|
854 |
TLiwVariant dburi; |
|
855 |
db->FindL(KDbUri,dburi); |
|
856 |
TPtrC URI = dburi.AsDes(); |
|
857 |
iLog->Log( _L("Database URI: %s"), URI.Ptr()); |
|
858 |
dburi.Reset(); |
|
859 |
||
860 |
TLiwVariant drive; |
|
861 |
db->FindL(KDbDrive,drive); |
|
862 |
TPtrC drv = drive.AsDes(); |
|
863 |
iLog->Log( _L("Drive: %s"), drv.Ptr()); |
|
864 |
drive.Reset(); |
|
865 |
||
866 |
TLiwVariant protocol; |
|
867 |
db->FindL(KDbProtocol,protocol); |
|
868 |
TPtrC pro = protocol.AsDes(); |
|
869 |
iLog->Log( _L("Protocal: %s"), pro.Ptr()); |
|
870 |
protocol.Reset(); |
|
871 |
||
872 |
TLiwVariant sizev; |
|
873 |
db->FindL(KDbSize,sizev); |
|
874 |
TInt32 size; |
|
875 |
sizev.Get(size); |
|
876 |
iLog->Log( _L("Size: %d"), size); |
|
877 |
||
878 |
TLiwVariant activev; |
|
879 |
db->FindL(KDbActive,activev); |
|
880 |
TBool active; |
|
881 |
activev.Get(active); |
|
882 |
iLog->Log( _L("Active: %d"), active); |
|
883 |
} |
|
884 |
else |
|
885 |
{ |
|
886 |
iLog->Log(_L(" ITEM NOT FOUND...")); |
|
887 |
} |
|
888 |
item.Reset(); |
|
889 |
} |
|
890 |
||
891 |
dbiterator->DecRef(); |
|
892 |
dbinfo->DecRef(); |
|
893 |
||
894 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
895 |
ReleaseLandmarkResources(); |
|
896 |
__UHEAP_MARKEND; |
|
897 |
||
898 |
return ret; |
|
899 |
} |
|
900 |
||
901 |
||
902 |
// ----------------------------------------------------------------------------- |
|
903 |
// CTLmDbTests::GetDbList |
|
904 |
// test method function. |
|
905 |
// ----------------------------------------------------------------------------- |
|
906 |
// |
|
907 |
TInt CTLmDbTests ::GetDbListPos(CStifItemParser& /*aItem*/) |
|
908 |
{ |
|
909 |
_LIT(KDb1, "file://c:lmdb1.ldb"); |
|
910 |
_LIT(KDb2, "file://c:lmdb2.ldb"); |
|
911 |
_LIT(KDb3, "file://c:lmdb3.ldb"); |
|
912 |
_LIT(KDb4, "file://c:lmdb4.ldb"); |
|
913 |
||
914 |
_LIT( KExample, "GetDbList" ); |
|
915 |
iLog->Log( KExample ); |
|
916 |
TInt32 err; |
|
917 |
TInt ret=0; |
|
918 |
||
919 |
DeleteAllLocalDatabasesL(); |
|
920 |
||
921 |
CLiwServiceHandler* ServiceHandler; |
|
922 |
CLiwGenericParamList* iInList,*iOutList; |
|
923 |
MLiwInterface* iLandmarkIf; |
|
924 |
||
925 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
926 |
CleanupStack::PushL(ServiceHandler); |
|
927 |
CleanupClosePushL(*iLandmarkIf); |
|
928 |
||
929 |
iInList = &(ServiceHandler->InParamListL()); |
|
930 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
931 |
||
932 |
iInList->Reset(); |
|
933 |
iOutList->Reset(); |
|
934 |
||
935 |
HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewL(KDb1); |
|
936 |
CleanupStack::PushL(info); |
|
937 |
iDatabaseManager->CreateDatabaseL (*info); |
|
938 |
CleanupStack::PopAndDestroy(info); |
|
939 |
||
940 |
info = HPosLmDatabaseInfo::NewL(KDb2); |
|
941 |
CleanupStack::PushL(info); |
|
942 |
iDatabaseManager->CreateDatabaseL (*info); |
|
943 |
CleanupStack::PopAndDestroy(info); |
|
944 |
||
945 |
info = HPosLmDatabaseInfo::NewL(KDb3); |
|
946 |
CleanupStack::PushL(info); |
|
947 |
iDatabaseManager->CreateDatabaseL (*info); |
|
948 |
CleanupStack::PopAndDestroy(info); |
|
949 |
||
950 |
info = HPosLmDatabaseInfo::NewL(KDb4); |
|
951 |
CleanupStack::PushL(info); |
|
952 |
iDatabaseManager->CreateDatabaseL (*info); |
|
953 |
CleanupStack::PopAndDestroy(info); |
|
954 |
||
955 |
||
956 |
TLiwGenericParam content(KNullDesC8,TLiwVariant(KDatabase)); |
|
957 |
CLiwMap* dbinfo = CLiwDefaultMap::NewL(); |
|
958 |
||
959 |
dbinfo->InsertL(KDbProtocol,TLiwVariant(_L("file"))); |
|
960 |
||
961 |
iInList->AppendL(content); |
|
962 |
iInList->AppendL(TLiwGenericParam(KNullDesC8,TLiwVariant(dbinfo))); |
|
963 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList); |
|
964 |
ret |= CheckErrorCode (*iOutList,err); |
|
965 |
if ( err != KErrNone ) |
|
966 |
{ |
|
967 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
968 |
ret |= FAIL; |
|
969 |
} |
|
970 |
||
971 |
TInt Index = 0; |
|
972 |
const TLiwGenericParam* param = iOutList->FindFirst(Index,KReturnValue); |
|
973 |
if ( KErrNotFound == Index ) |
|
974 |
{ |
|
975 |
iLog->Log( _L("Database iterator not found in output ArgList") ); |
|
976 |
ret |= FAIL; |
|
977 |
} |
|
978 |
CLiwIterable* dbiterator = param->Value().AsIterable(); |
|
979 |
||
980 |
if ( !dbiterator ) |
|
981 |
{ |
|
982 |
iLog->Log( _L("Database iterator not set") ); |
|
983 |
ret |= FAIL; |
|
984 |
} |
|
985 |
||
986 |
TLiwVariant item; |
|
987 |
while ( dbiterator->NextL(item) ) |
|
988 |
{ |
|
989 |
const CLiwMap* db = item.AsMap(); |
|
990 |
if (db) |
|
991 |
{ |
|
992 |
TLiwVariant dburi; |
|
993 |
db->FindL(KDbUri,dburi); |
|
994 |
TPtrC URI = dburi.AsDes(); |
|
995 |
iLog->Log( _L("Database URI: %s"), URI.Ptr()); |
|
996 |
dburi.Reset(); |
|
997 |
||
998 |
TLiwVariant drive; |
|
999 |
db->FindL(KDbDrive,drive); |
|
1000 |
TPtrC drv = drive.AsDes(); |
|
1001 |
iLog->Log( _L("Drive: %s"), drv.Ptr()); |
|
1002 |
drive.Reset(); |
|
1003 |
||
1004 |
TLiwVariant protocol; |
|
1005 |
db->FindL(KDbProtocol,protocol); |
|
1006 |
TPtrC pro = protocol.AsDes(); |
|
1007 |
iLog->Log( _L("Protocal: %s"), pro.Ptr()); |
|
1008 |
protocol.Reset(); |
|
1009 |
||
1010 |
TLiwVariant media; |
|
1011 |
db->FindL(KDbMedia,media); |
|
1012 |
TInt32 mediatype; |
|
1013 |
media.Get(mediatype); |
|
1014 |
iLog->Log( _L("MediaType: %d"), mediatype); |
|
1015 |
||
1016 |
TLiwVariant sizev; |
|
1017 |
db->FindL(KDbSize,sizev); |
|
1018 |
TInt32 size; |
|
1019 |
sizev.Get(size); |
|
1020 |
iLog->Log( _L("Size: %d"), size); |
|
1021 |
||
1022 |
TLiwVariant activev; |
|
1023 |
db->FindL(KDbActive,activev); |
|
1024 |
TBool active; |
|
1025 |
activev.Get(active); |
|
1026 |
iLog->Log( _L("Active: %d"), active); |
|
1027 |
} |
|
1028 |
else |
|
1029 |
{ |
|
1030 |
iLog->Log(_L(" ITEM NOT FOUND...")); |
|
1031 |
} |
|
1032 |
item.Reset(); |
|
1033 |
} |
|
1034 |
||
1035 |
dbiterator->DecRef(); |
|
1036 |
dbinfo->DecRef(); |
|
1037 |
||
1038 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1039 |
ReleaseLandmarkResources(); |
|
1040 |
__UHEAP_MARKEND; |
|
1041 |
return ret; |
|
1042 |
} |
|
1043 |
||
1044 |
// ----------------------------------------------------------------------------- |
|
1045 |
// CTLmDbTests::DeleteAllDatabases |
|
1046 |
// removes all local databases from the terminal |
|
1047 |
// called by all testcases. |
|
1048 |
// ----------------------------------------------------------------------------- |
|
1049 |
// |
|
1050 |
void CTLmDbTests::DeleteAllLocalDatabasesL() |
|
1051 |
{ |
|
1052 |
TInt count; |
|
1053 |
||
1054 |
CDesCArray* dbList = iDatabaseManager->ListDatabasesLC(_L("file")); |
|
1055 |
count = dbList->Count(); |
|
1056 |
||
1057 |
for ( TInt i = 0; i < count; i++ ) |
|
1058 |
{ |
|
1059 |
TPtrC db = (*dbList)[i]; |
|
1060 |
iDatabaseManager->DeleteDatabaseL ( db ); |
|
1061 |
} |
|
1062 |
CleanupStack::PopAndDestroy (1); |
|
1063 |
} |
|
1064 |
// ----------------------------------------------------------------------------- |
|
1065 |
// CTLmDbTests::CheckErrorCode |
|
1066 |
// checks error code e |
|
1067 |
// called by all testcases. |
|
1068 |
// ----------------------------------------------------------------------------- |
|
1069 |
// |
|
1070 |
TInt CTLmDbTests::CheckErrorCode( const CLiwGenericParamList& aOutList, TInt32 &aError ) |
|
1071 |
{ |
|
1072 |
TInt Index = 0; |
|
1073 |
const TLiwGenericParam* errcode = aOutList.FindFirst(Index,KErrorCode); |
|
1074 |
if ( KErrNotFound == Index ) |
|
1075 |
{ |
|
1076 |
iLog->Log( _L("ErrorCode not found in output ArgList") ); |
|
1077 |
return FAIL; |
|
1078 |
} |
|
1079 |
else |
|
1080 |
errcode->Value().Get(aError); |
|
1081 |
return PASS; |
|
1082 |
} |
|
1083 |
||
1084 |
void CTLmDbTests::CreateInterfaceL(CLiwServiceHandler*& aHandler, |
|
1085 |
MLiwInterface*& aInterface) |
|
1086 |
{ |
|
1087 |
iLog->Log( _L("In CreateInterfaceL") ); |
|
1088 |
CLiwGenericParamList* InParamList,*OutParamList; |
|
1089 |
||
1090 |
TRAPD(Err,aHandler = CLiwServiceHandler::NewL()); |
|
1091 |
if(Err) |
|
1092 |
{ |
|
1093 |
iLog->Log( _L("CLiwServiceHandler Created %d"),Err ); |
|
1094 |
User::Leave(Err); |
|
1095 |
} |
|
1096 |
||
1097 |
CleanupStack::PushL(aHandler); |
|
1098 |
||
1099 |
InParamList = &(aHandler->InParamListL()); |
|
1100 |
OutParamList = &(aHandler->OutParamListL()); |
|
1101 |
||
1102 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIDataSource,KService); |
|
1103 |
CleanupStack::PushL(crit); |
|
1104 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
1105 |
RCriteriaArray a; |
|
1106 |
CleanupClosePushL(a); |
|
1107 |
a.AppendL(crit); |
|
1108 |
||
1109 |
aHandler->AttachL(a); |
|
1110 |
||
1111 |
aHandler->ExecuteServiceCmdL(*crit,*InParamList,*OutParamList); |
|
1112 |
||
1113 |
TInt Index = 0; |
|
1114 |
const TLiwGenericParam* param = OutParamList->FindFirst(Index,KIDataSource); |
|
1115 |
if(!param) |
|
1116 |
{ |
|
1117 |
iLog->Log( _L("Interface Not found ")); |
|
1118 |
User::Leave(KErrGeneral); |
|
1119 |
} |
|
1120 |
||
1121 |
aInterface = param->Value().AsInterface(); |
|
1122 |
CleanupStack::PopAndDestroy(&a); |
|
1123 |
CleanupStack::PopAndDestroy (crit); |
|
1124 |
||
1125 |
CleanupStack::Pop (aHandler); |
|
1126 |
iLog->Log( _L("End of CreateInterfaceL") ); |
|
1127 |
} |
|
1128 |
||
1129 |
||
1130 |
//end of file |