|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * ?description_line |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 |
|
22 #include "FT_CPosTp135.h" |
|
23 #include <EPos_CPosLandmarkDatabase.h> |
|
24 #include <EPos_CPosLmDatabaseManager.h> |
|
25 |
|
26 |
|
27 // ================= CONSTANTS ======================= |
|
28 |
|
29 _LIT(KRemoteDb1, "test://RemoteDb1.ldb"); |
|
30 _LIT(KRemoteDb2, "test://RemoteDb2.ldb"); |
|
31 _LIT(KLocalDb1, "file://C:SOMEDB.LDB"); |
|
32 _LIT(KLocalDbName1, "SOMEDB"); |
|
33 _LIT(KRemoteDbName1, "RemoteDb1"); |
|
34 _LIT(KRemoteDbName2, "RemoteDb2"); |
|
35 _LIT(KRemoteDb3, "test://RemoteDb3.ldb"); |
|
36 _LIT(KRemoteDb4, "test://RemoteDb4.ldb"); |
|
37 _LIT(KRemoteDb5, "RemoteDb5.ldb"); |
|
38 _LIT(KLocalDb2, "file://C:SOMELOCALDB.LDB"); |
|
39 _LIT(KRemoteNonExistingDb, "test://NonExistingDb.ldb"); |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 |
|
43 // Cleanup for RPointerArray<HPosLmDatabaseInfo> objects |
|
44 void CleanupTestPointerArray(TAny* aArray) |
|
45 |
|
46 { |
|
47 (static_cast<RPointerArray<HPosLmDatabaseInfo>*>(aArray))->ResetAndDestroy(); |
|
48 } |
|
49 |
|
50 // Cleanup for RPointerArray<HPosLmDatabaseInfo> objects |
|
51 void CleanupTestPointerArray2(TAny* aArray) |
|
52 |
|
53 { |
|
54 |
|
55 (static_cast<RPointerArray<HPosLmDatabaseInfo>*>(aArray))->Reset(); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // CPosTp135::CloseTest |
|
60 // |
|
61 // (other items were commented in a header). |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 void CPosTp135::CloseTest() |
|
65 { |
|
66 iLog->Log(_L("CloseTest")); |
|
67 |
|
68 iDbArray->Reset(); |
|
69 delete iDbArray; |
|
70 iDbArray = NULL; |
|
71 |
|
72 TRAPD(err, RemoveAllLmDatabasesL()); |
|
73 if (err != KErrNone) iLog->Log(_L("RemoveAllLmDatabasesL() leaved")); |
|
74 |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------- |
|
78 // CPosTp135::StartL |
|
79 // |
|
80 // (other items were commented in a header). |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 void CPosTp135::StartL() |
|
84 { |
|
85 _LIT(KEmptyProtocol, ""); |
|
86 _LIT(KRemoteProtocol, "test"); |
|
87 |
|
88 TInt err=KErrNone; |
|
89 iErrorsFound = KErrNone; |
|
90 |
|
91 RemoveAllLmDatabasesL(); |
|
92 |
|
93 iDbArray = NULL; |
|
94 iDbArray = new (ELeave) CDesCArrayFlat(5); |
|
95 |
|
96 // Create defaultdb |
|
97 CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); |
|
98 CleanupStack::PushL(dbManager); |
|
99 |
|
100 // TC Step 1 Create a remote database (uses the test provider implementation, using test as identifier |
|
101 // (compare with file) |
|
102 HPosLmDatabaseInfo* db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb1); |
|
103 dbManager->CreateDatabaseL(*db1); |
|
104 |
|
105 // TC Step 2 Register db |
|
106 dbManager->RegisterDatabaseL(*db1); |
|
107 TPosLmDatabaseSettings settings = db1->Settings(); |
|
108 TPosLmDatabaseName bufName(KRemoteDbName1); |
|
109 settings.SetDatabaseName(bufName); |
|
110 dbManager->ModifyDatabaseSettingsL(KRemoteDb1, settings); |
|
111 CleanupStack::PopAndDestroy(db1); |
|
112 |
|
113 // TC Step 3 Create local db and try to register it |
|
114 HPosLmDatabaseInfo* localDb1 = HPosLmDatabaseInfo::NewLC(KLocalDb1); |
|
115 dbManager->CreateDatabaseL(*localDb1); |
|
116 |
|
117 settings = db1->Settings(); |
|
118 TPosLmDatabaseName bufName2(KLocalDbName1); |
|
119 settings.SetDatabaseName(bufName2); |
|
120 dbManager->ModifyDatabaseSettingsL(KLocalDb1, settings); |
|
121 |
|
122 TRAP(err, dbManager->RegisterDatabaseL(*localDb1)); |
|
123 if (err != KErrNotSupported) |
|
124 { |
|
125 iLog->Log(_L("Register a local db should leave with KErrNotSupported")) ; |
|
126 User::Leave(err); |
|
127 } |
|
128 CleanupStack::PopAndDestroy(localDb1); |
|
129 |
|
130 // TC Step 4 Create another remote database and register it |
|
131 db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb2); |
|
132 dbManager->CreateDatabaseL(*db1); |
|
133 // Register db, |
|
134 dbManager->RegisterDatabaseL(*db1); |
|
135 settings = db1->Settings(); |
|
136 TPosLmDatabaseName bufName3(KRemoteDbName2); |
|
137 settings.SetDatabaseName(bufName3); |
|
138 dbManager->ModifyDatabaseSettingsL(KRemoteDb2, settings); |
|
139 CleanupStack::PopAndDestroy(db1); |
|
140 |
|
141 // TC Step 5 List all dbs without specifying protocol |
|
142 CDesCArray* list = dbManager->ListDatabasesLC(); |
|
143 // Verify list should contain two remote and one local database |
|
144 iDbArray->AppendL(KLocalDb1); |
|
145 iDbArray->AppendL(KRemoteDb1); |
|
146 iDbArray->AppendL(KRemoteDb2); |
|
147 VerifyDbListL(list); |
|
148 CleanupStack::PopAndDestroy(list); |
|
149 |
|
150 // TC Step 6 List all dbs but specify protocol (protocol "local") |
|
151 list = dbManager->ListDatabasesLC(_L("file")); |
|
152 iDbArray->Delete(0, iDbArray->Count()); |
|
153 iDbArray->AppendL(KLocalDb1); |
|
154 //Verify list should contain one local database |
|
155 VerifyDbListL(list); |
|
156 CleanupStack::PopAndDestroy(list); |
|
157 |
|
158 // TC Step 7 List all dbs but specify protocol (protocol "test") |
|
159 list = dbManager->ListDatabasesLC(KRemoteProtocol); |
|
160 //Verify list should contain two remote databases |
|
161 iDbArray->Reset(); |
|
162 iDbArray->AppendL(KRemoteDb1); |
|
163 iDbArray->AppendL(KRemoteDb2); |
|
164 //Verify list should contain one local database |
|
165 VerifyDbListL(list); |
|
166 CleanupStack::PopAndDestroy(list); |
|
167 |
|
168 // TC Step 8 Also test with empty protocol, All existing dbs will be returned |
|
169 list = dbManager->ListDatabasesLC(_L("")); |
|
170 iDbArray->Reset(); |
|
171 iDbArray->AppendL(KLocalDb1); |
|
172 iDbArray->AppendL(KRemoteDb1); |
|
173 iDbArray->AppendL(KRemoteDb2); |
|
174 //Verify list |
|
175 VerifyDbListL(list); |
|
176 CleanupStack::PopAndDestroy(list); |
|
177 |
|
178 // TC Step 9 Retrive info about all dbs without specifying protocol |
|
179 HPosLmDatabaseInfo* dbInfo01 = HPosLmDatabaseInfo::NewLC(KLocalDb1); |
|
180 HPosLmDatabaseInfo* dbInfo02 = HPosLmDatabaseInfo::NewLC(KRemoteDb1); |
|
181 HPosLmDatabaseInfo* dbInfo03 = HPosLmDatabaseInfo::NewLC(KRemoteDb2); |
|
182 |
|
183 RPointerArray<HPosLmDatabaseInfo> myDbInfoList; |
|
184 CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray2, &myDbInfoList)); |
|
185 |
|
186 RPointerArray<HPosLmDatabaseInfo> infoList; |
|
187 CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); |
|
188 |
|
189 dbManager->ListDatabasesL(infoList); |
|
190 // Verify list should contain all dbs |
|
191 |
|
192 myDbInfoList.Append(dbInfo01); |
|
193 myDbInfoList.Append(dbInfo02); |
|
194 myDbInfoList.Append(dbInfo03); |
|
195 |
|
196 VerifyDbInfoListL(infoList, myDbInfoList); |
|
197 CleanupStack::PopAndDestroy(&infoList); |
|
198 myDbInfoList.Reset(); |
|
199 CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); |
|
200 |
|
201 // TC Step 10 Retrive info about dbs specifying remote protocol |
|
202 dbManager->ListDatabasesL(infoList, KRemoteProtocol); |
|
203 // Verify list should contain two remote databases |
|
204 myDbInfoList.Append(dbInfo03); myDbInfoList.Append(dbInfo02); |
|
205 VerifyDbInfoListL(infoList, myDbInfoList); |
|
206 CleanupStack::PopAndDestroy(&infoList); |
|
207 myDbInfoList.Reset(); |
|
208 CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); |
|
209 |
|
210 // TC Step 11 Retrive info but specify empty protocol, |
|
211 dbManager->ListDatabasesL(infoList, KEmptyProtocol); |
|
212 // Verify list should contain all databases |
|
213 myDbInfoList.Append(dbInfo01);myDbInfoList.Append(dbInfo02);myDbInfoList.Append(dbInfo03); |
|
214 VerifyDbInfoListL(infoList, myDbInfoList); |
|
215 CleanupStack::PopAndDestroy(&infoList); |
|
216 CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); |
|
217 myDbInfoList.Reset(); |
|
218 |
|
219 // TC Step 12 Also test when specifying KNullDesC |
|
220 dbManager->ListDatabasesL(infoList, KEmptyProtocol); |
|
221 // Verify list should contain all databases |
|
222 myDbInfoList.Append(dbInfo01);myDbInfoList.Append(dbInfo02);myDbInfoList.Append(dbInfo03); |
|
223 VerifyDbInfoListL(infoList, myDbInfoList); |
|
224 CleanupStack::PopAndDestroy(&infoList); |
|
225 CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); |
|
226 myDbInfoList.Reset(); |
|
227 |
|
228 // TC Step 13 Unregister one remote db and list dbs |
|
229 dbManager->UnregisterDatabaseL(KRemoteDb1); |
|
230 |
|
231 list = dbManager->ListDatabasesLC(KRemoteProtocol); |
|
232 // Verify list should contain one remote databases |
|
233 iDbArray->Delete(0, iDbArray->Count()); |
|
234 iDbArray->AppendL(KRemoteDb2); |
|
235 VerifyDbListL(list); |
|
236 CleanupStack::PopAndDestroy(list); |
|
237 |
|
238 // TC Step 14 Retrieves info about dbs, specify remote protocol |
|
239 dbManager->ListDatabasesL(infoList, KRemoteProtocol); |
|
240 // Verify list, should contain one remote |
|
241 myDbInfoList.Append(dbInfo03); |
|
242 VerifyDbInfoListL(infoList, myDbInfoList); |
|
243 CleanupStack::PopAndDestroy(&infoList); |
|
244 myDbInfoList.Reset(); |
|
245 CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); |
|
246 |
|
247 // TC Step 15 Unregisters all remote dbs |
|
248 dbManager->UnregisterAllDatabasesL(KRemoteProtocol); |
|
249 // Retrieves info about all dbs without specifying protocol |
|
250 CleanupStack::PopAndDestroy(&infoList); |
|
251 CleanupStack::PushL(TCleanupItem(CleanupTestPointerArray, &infoList)); |
|
252 dbManager->ListDatabasesL(infoList); |
|
253 // Verify list should contain one local database |
|
254 myDbInfoList.Append(dbInfo01); |
|
255 VerifyDbInfoListL(infoList, myDbInfoList); |
|
256 myDbInfoList.Reset(); |
|
257 |
|
258 CleanupStack::PopAndDestroy(&infoList); |
|
259 CleanupStack::PopAndDestroy(&myDbInfoList); |
|
260 CleanupStack::PopAndDestroy(dbInfo03); |
|
261 CleanupStack::PopAndDestroy(dbInfo02); |
|
262 CleanupStack::PopAndDestroy(dbInfo01); |
|
263 |
|
264 // TC Step 16 set the default database to a remote database |
|
265 TRAP(err, dbManager->SetDefaultDatabaseUriL(KRemoteDb1)); |
|
266 if (err != KErrNotSupported) |
|
267 { |
|
268 iLog->Log(_L("ERROR: SetDefaultDatabaseUriL to a remote db should leave with KErrNotSupported")) ; |
|
269 User::Leave(err); |
|
270 } |
|
271 |
|
272 // TC Step 17 Try to register a landmark database with an incorrect URI |
|
273 db1 = HPosLmDatabaseInfo::NewLC(_L("test:/awd/C:Pelle.ldb")); |
|
274 TRAP(err, dbManager->RegisterDatabaseL(*db1)); |
|
275 if (err != KErrNotSupported) |
|
276 { |
|
277 iLog->Log(_L("ERROR: RegisterDatabaseL with incorrect URI should leave with KErrNotSupported (1)")) ; |
|
278 User::Leave(err); |
|
279 |
|
280 } |
|
281 CleanupStack::PopAndDestroy(db1); |
|
282 |
|
283 // TC Step 18 Try to register a landmark database with an incorrect URI |
|
284 db1 = HPosLmDatabaseInfo::NewLC(_L("test:/\"/C:Pelle.ldb")); |
|
285 TRAP(err, dbManager->RegisterDatabaseL(*db1)); |
|
286 if (err != KErrNotSupported) |
|
287 { |
|
288 iLog->Log(_L("ERROR: RegisterDatabaseL with incorrect URI should leave with KErrNotSupported (2)")) ; |
|
289 User::Leave(err); |
|
290 |
|
291 } |
|
292 CleanupStack::PopAndDestroy(db1); |
|
293 |
|
294 // TC Step 19 Try to register a landmark database with an incorrect URI |
|
295 db1 = HPosLmDatabaseInfo::NewLC(_L("file:/awd/C:C:Pelle.ldb")); |
|
296 TRAP(err, dbManager->RegisterDatabaseL(*db1)); |
|
297 if (err != KErrNotSupported) |
|
298 { |
|
299 iLog->Log(_L("ERROR: RegisterDatabaseL with incorrect URI should leave with KErrNotSupported (3)")) ; |
|
300 User::Leave(err); |
|
301 |
|
302 } |
|
303 CleanupStack::PopAndDestroy(db1); |
|
304 |
|
305 // TC Step 20 Try to register a landmark database with an incorrect URI |
|
306 db1 = HPosLmDatabaseInfo::NewLC(_L("file:/ /C:C:Pelle.ldb")); |
|
307 TRAP(err, dbManager->RegisterDatabaseL(*db1)); |
|
308 if (err != KErrNotSupported) |
|
309 { |
|
310 iLog->Log(_L("ERROR: RegisterDatabaseL with incorrect URI should leave with KErrNotSupported (4)")) ; |
|
311 User::Leave(err); |
|
312 |
|
313 } |
|
314 CleanupStack::PopAndDestroy(db1); |
|
315 |
|
316 // TC Step 21 Try to un-register a landmark database with an incorrect URI |
|
317 TRAP(err, dbManager->UnregisterDatabaseL(_L("test:/ /C:Pelle.ldb"))); |
|
318 if (err != KErrNotSupported) |
|
319 { |
|
320 iLog->Log(_L("ERROR: UnregisterDatabaseL with incorrect URI should leave with KErrArgument (1)")) ; |
|
321 User::Leave(err); |
|
322 |
|
323 } |
|
324 |
|
325 // TC Step 22 Try to un-register a landmark database with an incorrect URI |
|
326 TRAP(err, dbManager->UnregisterDatabaseL(_L("file: //C:C:Pelle.ldb"))); |
|
327 if (err != KErrNotSupported) |
|
328 { |
|
329 iLog->Log(_L("ERROR: UnregisterDatabaseL with incorrect URI should leave with KErrArgument (2)")) ; |
|
330 User::Leave(err); |
|
331 |
|
332 } |
|
333 |
|
334 // TC Step 23 Try to register a local landmark database |
|
335 db1 = HPosLmDatabaseInfo::NewLC(KLocalDb1); |
|
336 TRAP(err, dbManager->RegisterDatabaseL(*db1)); |
|
337 if (err != KErrNotSupported) |
|
338 { |
|
339 iLog->Log(_L("ERROR: RegisterDatabaseL a local db should leave with KErrNotSupported")) ; |
|
340 User::Leave(err); |
|
341 |
|
342 } |
|
343 CleanupStack::PopAndDestroy(db1); |
|
344 |
|
345 // TC Step 24 Try to unregister a local landmark database |
|
346 TRAP(err, dbManager->UnregisterDatabaseL(KLocalDb1)); |
|
347 if (err != KErrNotSupported) |
|
348 { |
|
349 iLog->Log(_L("ERROR:UnRegisterDatabaseL a local db should leave with KErrNotSupported")) ; |
|
350 User::Leave(err); |
|
351 |
|
352 } |
|
353 |
|
354 // TC Step 25 Unregisters all dbs using empty protocol |
|
355 // make sure that one is registered |
|
356 db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb1); |
|
357 dbManager->RegisterDatabaseL(*db1); |
|
358 TRAP(err, dbManager->UnregisterAllDatabasesL(_L(""))); |
|
359 if (err != KErrArgument) |
|
360 { |
|
361 iLog->Log(_L("ERROR: UnregisterAllDatabasesL with empty protocol should leave with KErrArgument")) ; |
|
362 User::Leave(err); |
|
363 |
|
364 } |
|
365 |
|
366 // TC Step 26 Unregisters all dbs using KNullDesC |
|
367 // make sure that one is registered |
|
368 |
|
369 TRAP(err, dbManager->UnregisterAllDatabasesL(KNullDesC)); |
|
370 if (err != KErrArgument) |
|
371 { |
|
372 iLog->Log(_L("ERROR: UnregisterAllDatabasesL with KNullDesc protocol should leave with KErrArgument")) ; |
|
373 User::Leave(err); |
|
374 |
|
375 } |
|
376 |
|
377 // TC Step 27 Unregisters all dbs using local protocol |
|
378 // make sure that one is registered |
|
379 |
|
380 TRAP(err, dbManager->UnregisterAllDatabasesL(_L("file"))); |
|
381 if (err != KErrNotSupported) |
|
382 { |
|
383 iLog->Log(_L("ERROR: UnregisterAllDatabasesL with file protocol should leave with KErrArgument(1)")) ; |
|
384 User::Leave(err); |
|
385 |
|
386 } |
|
387 |
|
388 // TC Step 28 Unregisters all dbs using local protocol |
|
389 // make sure that one is registered |
|
390 TRAP(err, dbManager->UnregisterAllDatabasesL(_L("file://"))); |
|
391 if (err != KErrNotSupported) |
|
392 { |
|
393 iLog->Log(_L("ERROR: UnregisterAllDatabasesL with file protocol should leave with KErrNotSupported(2)")) ; |
|
394 User::Leave(err); |
|
395 |
|
396 } |
|
397 |
|
398 // TC 29 try to register again, should leave with KErrAlreadyExists |
|
399 |
|
400 TRAP(err, dbManager->RegisterDatabaseL(*db1)); |
|
401 if (err != KErrAlreadyExists) |
|
402 { |
|
403 iLog->Log(_L("ERROR: RegisterDatabaseL already registered db should leave with KErrAlreadyExists")) ; |
|
404 User::Leave(err); |
|
405 |
|
406 } |
|
407 |
|
408 CleanupStack::PopAndDestroy(db1); |
|
409 |
|
410 // TC Step 30 Copy database and verify that it is registered |
|
411 dbManager->UnregisterAllDatabasesL(_L("test")); |
|
412 db1 = HPosLmDatabaseInfo::NewLC(KRemoteDb3); |
|
413 dbManager->CreateDatabaseL(*db1); |
|
414 // Register db, |
|
415 dbManager->RegisterDatabaseL(*db1); |
|
416 CleanupStack::PopAndDestroy(db1); |
|
417 dbManager->CopyDatabaseL(KRemoteDb3, KRemoteDb4); |
|
418 // Only list "remote" dbs |
|
419 list = dbManager->ListDatabasesLC(_L("test")); |
|
420 iDbArray->Reset(); |
|
421 iDbArray->AppendL(KRemoteDb3); |
|
422 iDbArray->AppendL(KRemoteDb4); |
|
423 |
|
424 VerifyDbListL(list); |
|
425 CleanupStack::PopAndDestroy(list); |
|
426 |
|
427 // TC Step 31) Check DatabaseExistsL method |
|
428 TBool result = dbManager->DatabaseExistsL(KRemoteDb3); |
|
429 if (!result) |
|
430 { |
|
431 iLog->Log(_L("DatabaseExistsL should return ETrue")) ; |
|
432 User::Leave(-1); |
|
433 |
|
434 } |
|
435 result = dbManager->DatabaseExistsL(KRemoteNonExistingDb); |
|
436 if (result) |
|
437 { |
|
438 iLog->Log(_L("DatabaseExistsL should return EFalse")) ; |
|
439 User::Leave(-1); |
|
440 } |
|
441 |
|
442 // TC Step 32) Try to copy remote db to local |
|
443 TRAP(err, dbManager->CopyDatabaseL(KRemoteDb3, KLocalDb2)); |
|
444 if (err != KErrArgument) |
|
445 { |
|
446 iLog->Log(_L("Copy from remote to local should leave with KErrArgument")) ; |
|
447 User::Leave(err); |
|
448 } |
|
449 |
|
450 // TC Step 33) Try to copy remote db to local |
|
451 TRAP(err, dbManager->CopyDatabaseL(KRemoteDb3, KRemoteDb5)); |
|
452 if (err != KErrArgument) |
|
453 { |
|
454 iLog->Log(_L("Copy from remote to unspecified should leave with KErrArgument")) ; |
|
455 User::Leave(err); |
|
456 |
|
457 } |
|
458 |
|
459 CleanupStack::PopAndDestroy(dbManager); |
|
460 if (iErrorsFound != KErrNone) |
|
461 { |
|
462 iLog->Log(_L("Errors found in TP135")) ; |
|
463 User::Leave(-1); |
|
464 |
|
465 } |
|
466 else iLog->Log(_L("CPosTp135 Passed")); |
|
467 } |
|
468 |
|
469 // --------------------------------------------------------- |
|
470 // CPosTp135::VerifyDbListL |
|
471 // |
|
472 // (other items were commented in a header). |
|
473 // --------------------------------------------------------- |
|
474 // |
|
475 void CPosTp135::VerifyDbListL(CDesCArray* aDbArray) |
|
476 { |
|
477 iLog->Log(_L("VerifyDbListL")); |
|
478 if (aDbArray->Count() != iDbArray->Count()) |
|
479 { |
|
480 TBuf<100> buf; |
|
481 buf.Format(_L("List was %d should be %d "), aDbArray->Count(), iDbArray->Count()); |
|
482 |
|
483 iLog->Log(buf); |
|
484 User::Leave(KErrNone); |
|
485 } |
|
486 |
|
487 TInt found = 0; |
|
488 TInt count = aDbArray->Count(); |
|
489 TInt i = 0; |
|
490 |
|
491 for (i = 0; i<count; i++) |
|
492 { |
|
493 // Below for debug purposes |
|
494 |
|
495 TInt pos; |
|
496 if (aDbArray->Find(iDbArray->MdcaPoint(i), pos) != KErrNone) |
|
497 { |
|
498 iLog->Log(_L("Did Not Found:")); |
|
499 iLog->Log(iDbArray->MdcaPoint(i)); |
|
500 iLog->Log(_L("------------------")); |
|
501 } |
|
502 else |
|
503 { |
|
504 iLog->Log(iDbArray->MdcaPoint(i)); |
|
505 found++; |
|
506 } |
|
507 } |
|
508 |
|
509 if (found != count) |
|
510 { |
|
511 |
|
512 iLog->Log(_L("List was not correct")); |
|
513 User::Leave(-1); |
|
514 |
|
515 } |
|
516 |
|
517 } |
|
518 |
|
519 // --------------------------------------------------------- |
|
520 // CPosTp135::VerifyDbInfoListL |
|
521 // |
|
522 // (other items were commented in a header). |
|
523 // --------------------------------------------------------- |
|
524 // |
|
525 void CPosTp135::VerifyDbInfoListL(RPointerArray<HPosLmDatabaseInfo> aDbInfoList, |
|
526 RPointerArray<HPosLmDatabaseInfo> aDbInfoList2) |
|
527 { |
|
528 iLog->Log(_L("VerifyDbInfoListL")); |
|
529 |
|
530 TBuf<100> debug; |
|
531 |
|
532 if (aDbInfoList.Count() != aDbInfoList2.Count()) |
|
533 { |
|
534 TBuf<100> buf; |
|
535 buf.Format(_L("List was %d should be %d "), aDbInfoList.Count(), aDbInfoList2.Count()); |
|
536 |
|
537 iLog->Log(buf); |
|
538 User::Leave(KErrNone); |
|
539 |
|
540 } |
|
541 |
|
542 TBool found = EFalse; |
|
543 TInt count = aDbInfoList.Count(); |
|
544 TInt j=0; |
|
545 |
|
546 for (j = 0; j<count; j++) |
|
547 { |
|
548 TInt i = 0; |
|
549 found = EFalse; |
|
550 iLog->Log(_L("Looking for: ")); |
|
551 iLog->Log(aDbInfoList[j]->DatabaseUri()); |
|
552 |
|
553 for (i = 0; i<count && !found; i++) |
|
554 { |
|
555 if (((aDbInfoList[j])->DatabaseUri()).CompareC((aDbInfoList2[i])->DatabaseUri()) == KErrNone) |
|
556 { |
|
557 iLog->Log(_L("Found:")); |
|
558 iLog->Log(aDbInfoList2[i]->DatabaseUri()); |
|
559 found = ETrue; |
|
560 TPosLmDatabaseSettings settings = aDbInfoList[j]->Settings(); |
|
561 |
|
562 if (aDbInfoList[j]->IsDefault()) |
|
563 { |
|
564 iLog->Log(_L("Db should never be default")); |
|
565 User::Leave(KErrNone); |
|
566 } |
|
567 |
|
568 if (aDbInfoList[j]->DatabaseUri() == KRemoteDb1) |
|
569 { |
|
570 if (settings.DatabaseName() != KRemoteDbName1) |
|
571 { |
|
572 iLog->Log(_L("Incorrect Databasename for remote db1")); |
|
573 User::Leave(-1); |
|
574 } |
|
575 if (aDbInfoList[j]->Protocol() != _L("test")) |
|
576 { |
|
577 iLog->Log(_L("Incorrect protocol for remote db1")); |
|
578 User::Leave(-1); |
|
579 } |
|
580 if (aDbInfoList[j]->DatabaseMedia() != EMediaRemote) |
|
581 { |
|
582 iLog->Log(_L("Incorrect media for remote db1")); |
|
583 User::Leave(-1); |
|
584 } |
|
585 if (aDbInfoList[j]->DatabaseDrive() != 'U') |
|
586 { |
|
587 iLog->Log(_L("Incorrect drive for remote db1")); |
|
588 User::Leave(-1); |
|
589 } |
|
590 } |
|
591 else if (aDbInfoList[j]->DatabaseUri() == KRemoteDb2) |
|
592 { |
|
593 if (settings.DatabaseName() != KRemoteDbName2) |
|
594 { |
|
595 iLog->Log(_L("Incorrect Databasename for remote db2")); |
|
596 User::Leave(-1); |
|
597 } |
|
598 if (aDbInfoList[j]->Protocol() != _L("test")) |
|
599 { |
|
600 iLog->Log(_L("Incorrect protocol for remote db2")); |
|
601 User::Leave(-1); |
|
602 } |
|
603 if (aDbInfoList[j]->DatabaseMedia() != EMediaRemote) |
|
604 { |
|
605 iLog->Log(_L("Incorrect media for remote db2")); |
|
606 User::Leave(-1); |
|
607 } |
|
608 if (aDbInfoList[j]->DatabaseDrive() != 'U') |
|
609 { |
|
610 iLog->Log(_L("Incorrect drive for remote db2")); |
|
611 User::Leave(-1); |
|
612 } |
|
613 } |
|
614 else |
|
615 { |
|
616 // Local db |
|
617 if (aDbInfoList[j]->Protocol() != _L("file")) |
|
618 { |
|
619 iLog->Log(_L("Incorrect protocol for local db")); |
|
620 User::Leave(-1); |
|
621 } |
|
622 if (settings.DatabaseName() != KLocalDbName1) |
|
623 { |
|
624 iLog->Log(_L("Incorrect Databasename for local db")); |
|
625 User::Leave(-1); |
|
626 } |
|
627 |
|
628 |
|
629 |
|
630 if (aDbInfoList[j]->DatabaseDrive() != 'C') |
|
631 { |
|
632 iLog->Log(_L("Incorrect drive for remote db1")); |
|
633 User::Leave(-1); |
|
634 } |
|
635 |
|
636 } |
|
637 |
|
638 if (aDbInfoList[j]->Size() <1) |
|
639 { |
|
640 iLog->Log(_L("Size should have a value")); |
|
641 User::Leave(-1); |
|
642 } |
|
643 if (!settings.IsAttributeSet(TPosLmDatabaseSettings::EName)) |
|
644 { |
|
645 iLog->Log(_L("Name attribute should be set")); |
|
646 User::Leave(-1); |
|
647 } |
|
648 |
|
649 } |
|
650 } |
|
651 if (!found) |
|
652 { |
|
653 |
|
654 iLog->Log(_L("List was not correct")); |
|
655 User::Leave(-1); |
|
656 } |
|
657 } |
|
658 } |
|
659 |
|
660 // End of File |