|
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 #include "FT_CPosTp123.h" |
|
22 #include "FT_LandmarkConstants.h" |
|
23 #include <EPos_CPosLandmarkDatabase.h> |
|
24 #include <EPos_CPosLmCategoryCriteria.h> |
|
25 #include <EPos_CPosLmCatNameCriteria.h> |
|
26 #include <EPos_CPosLmTextCriteria.h> |
|
27 #include <EPos_CPosLmMultiDbSearch.h> |
|
28 #include <EPos_CPosLmDatabaseManager.h> |
|
29 #include <EPos_CPosLmDisplayData.h> |
|
30 #include <EPos_CPosLmDisplayItem.h> |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================= |
|
33 |
|
34 // --------------------------------------------------------- |
|
35 // CPosTp123::GetName |
|
36 // |
|
37 // (other items were commented in a header). |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 /*void CPosTp123::GetName(TDes& aName) const |
|
41 { |
|
42 _LIT(KTestName, "Tp123 - Uncategorized LM MultiDb Search"); |
|
43 aName = KTestName; |
|
44 } |
|
45 */ |
|
46 // --------------------------------------------------------- |
|
47 // CPosTp123::CloseTest |
|
48 // |
|
49 // (other items were commented in a header). |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 void CPosTp123::CloseTest() |
|
53 { |
|
54 delete iDatabases; |
|
55 delete iLandmarkSearch; |
|
56 for (TInt i = 0; i < iIdArrays.Count(); i++) |
|
57 { |
|
58 iIdArrays[i].Close(); |
|
59 } |
|
60 iIdArrays.Close(); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CPosTp123::InitTestL |
|
65 // |
|
66 // (other items were commented in a header). |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 void CPosTp123::InitTestL() |
|
70 { |
|
71 CLandmarkTestProcedureBase::InitTestL(); |
|
72 |
|
73 // PrepareDatabases |
|
74 RemoveAllLmDatabasesL(); |
|
75 CopyTestDbFileL(KDb20); |
|
76 CopyTestDbFileL(KDb40); |
|
77 CopyTestDbFileL(KDb60); |
|
78 CopyTestDbFileL(KDb80); |
|
79 CopyTestDbFileL(KDb105); |
|
80 iNrOfDatabases = 5; |
|
81 |
|
82 // Initialize data members |
|
83 CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); |
|
84 CleanupStack::PushL(dbManager); |
|
85 iDatabases = dbManager->ListDatabasesLC(); |
|
86 CleanupStack::Pop(iDatabases); |
|
87 iDatabases->Sort(); |
|
88 AssertTrueSecL((iDatabases->Count() == iNrOfDatabases), _L("Wrong number of databases")); |
|
89 iLandmarkSearch = CPosLmMultiDbSearch::NewL(*iDatabases); |
|
90 CleanupStack::PopAndDestroy(dbManager); |
|
91 |
|
92 iLog->Log( _L("Multi db search created")); |
|
93 |
|
94 // Enable use of global categories |
|
95 // CPosLandmarkDatabase* database = UseGlobalCategoriesL(); |
|
96 // delete database; |
|
97 CPosLandmarkDatabase* database = NULL; |
|
98 // Reset Global categories for all databases but EPOSLM_105.LDB and add the global category |
|
99 // "Hotel" to the 5 first landmarks in the databases. |
|
100 for (TInt i = 0; i < iNrOfDatabases - 1; i++) // Do not use global categories in |
|
101 { |
|
102 database = CPosLandmarkDatabase::OpenL((*iDatabases)[i]); |
|
103 CleanupStack::PushL(database); |
|
104 if ( database->IsInitializingNeeded() ) |
|
105 { |
|
106 TRAPD( err, ExecuteAndDeleteLD( database->InitializeL() ) ); |
|
107 AssertTrueSecL( err == KErrNone, _L("Init db failed")); |
|
108 } |
|
109 CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*database); |
|
110 CleanupStack::PushL(catMan); |
|
111 ExecuteAndDeleteLD(catMan->ResetGlobalCategoriesL()); |
|
112 CPosLmItemIterator* lmIter = database->LandmarkIteratorL(); |
|
113 CleanupStack::PushL(lmIter); |
|
114 RIdArray idArray; |
|
115 CleanupClosePushL(idArray); |
|
116 lmIter->GetItemIdsL(idArray, 0, 5); |
|
117 |
|
118 // Remove all existing categories from the 5 first landmarks |
|
119 for (TInt i = 0; i < idArray.Count(); i++) |
|
120 { |
|
121 CPosLandmark* lm = database->ReadLandmarkLC(idArray[i]); |
|
122 lm->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo); |
|
123 TInt err = KErrLocked; |
|
124 while (err==KErrLocked) |
|
125 { |
|
126 TRAP(err, database->UpdateLandmarkL(*lm)); |
|
127 } |
|
128 CleanupStack::PopAndDestroy(lm); |
|
129 } |
|
130 |
|
131 // Add global category hotel to 5 first LMs |
|
132 TPosLmGlobalCategory accommodation(3000); // 27 == Global category id for accommodation according to .the global ids added for BC testing |
|
133 User::After(200000); |
|
134 ExecuteAndDeleteLD(catMan->AddCategoryToLandmarksL(catMan->GetGlobalCategoryL(accommodation), idArray)); |
|
135 |
|
136 CleanupStack::PopAndDestroy(4, database); |
|
137 } |
|
138 |
|
139 // Initialize arrays that will contain expected search results |
|
140 RIdArray array20; |
|
141 User::LeaveIfError(iIdArrays.Append(array20)); |
|
142 RIdArray array40; |
|
143 User::LeaveIfError(iIdArrays.Append(array40)); |
|
144 RIdArray array60; |
|
145 User::LeaveIfError(iIdArrays.Append(array60)); |
|
146 RIdArray array80; |
|
147 User::LeaveIfError(iIdArrays.Append(array80)); |
|
148 RIdArray array105; |
|
149 User::LeaveIfError(iIdArrays.Append(array105)); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CPosTp123::StartL |
|
154 // |
|
155 // (other items were commented in a header). |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 void CPosTp123::StartL() |
|
159 { |
|
160 // 1. Verify KErrArgument is returned from API |
|
161 iLog->Log(_L("<<< 1. Verify KErrArgument is returned from API >>>")); |
|
162 for (TBool runSynch = EFalse; runSynch <= ETrue; runSynch++) |
|
163 { |
|
164 iLog->Log(_L("Should leave with KErrArgument...")); |
|
165 TRAPD(err, TestSearchCategoriesL(runSynch)); |
|
166 AssertTrueSecL(err == KErrArgument, _L("Should have left with KErrArgument but failed with %d"), err); |
|
167 iLog->Log(_L("Function left correctly with KErrArgument")); |
|
168 } |
|
169 |
|
170 // 2. We should not find any uncategorized landmarks since every landmark in the db |
|
171 // belongs to a category |
|
172 iLog->Log(_L("<<< 2. Search uncategorized LMs (none exist) >>>")); |
|
173 SearchForUncategorizedLMsL(0); |
|
174 |
|
175 // 3. Remove all categories from M landmarks in each database |
|
176 iLog->Log(_L("<<< 3. Remove all categories from M landmarks in each database >>>")); |
|
177 const TInt M = 2; |
|
178 RemoveCategoriesFromLandmarksL(M); |
|
179 // Check that correct number of uncategorized landmarks are found |
|
180 SearchForUncategorizedLMsL(M * iNrOfDatabases); |
|
181 |
|
182 // 4. Remove a local category that Q LMs belong to and add an uncategorized lm |
|
183 iLog->Log(_L("<<< 4. Remove a local category that Q LMs belong to and add an uncategorized lm >>>")); |
|
184 const TInt Q = 6; |
|
185 TInt dbIndex = 3; |
|
186 TPosLmItemId localCatId = 26; // Läkare |
|
187 RemoveCategoryFromDbL(localCatId, (*iDatabases)[dbIndex]); |
|
188 // Landmark 72-77 should now be uncategorized. |
|
189 for (TInt i = 72; i <= 77; i++) |
|
190 { |
|
191 iIdArrays[dbIndex].Append(i); |
|
192 } |
|
193 |
|
194 // Add a lm |
|
195 CPosLandmark* lm = CPosLandmark::NewLC(); |
|
196 lm->SetLandmarkNameL(_L("Guru")); |
|
197 CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL((*iDatabases)[dbIndex]); |
|
198 CleanupStack::PushL(database); |
|
199 TPosLmItemId id = database->AddLandmarkL(*lm); |
|
200 iIdArrays[dbIndex].Append(id); |
|
201 CleanupStack::PopAndDestroy(2, lm); |
|
202 |
|
203 // Check that correct number of uncategorized landmarks are found |
|
204 SearchForUncategorizedLMsL(Q + 1 + M*iNrOfDatabases); |
|
205 |
|
206 // 5. Associate an uncategorized landmark with a category, e.g. lm with id 76 |
|
207 iLog->Log(_L("<<< 5. Associate an uncategorized landmark with a category >>>")); |
|
208 id = 76; |
|
209 database = CPosLandmarkDatabase::OpenL((*iDatabases)[dbIndex]); |
|
210 CleanupStack::PushL(database); |
|
211 lm = database->ReadLandmarkLC(id); |
|
212 lm->AddCategoryL(localCatId - 1); // Sjukhus |
|
213 database->UpdateLandmarkL(*lm); |
|
214 TInt index = iIdArrays[dbIndex].Find(id); |
|
215 AssertTrueSecL(index > 0, _L("Unable to find landmark in array")); |
|
216 iIdArrays[dbIndex].Remove(index); |
|
217 CleanupStack::PopAndDestroy(2, database); |
|
218 |
|
219 // Check that correct number of uncategorized landmarks are found |
|
220 SearchForUncategorizedLMsL(Q + M*iNrOfDatabases); |
|
221 |
|
222 // 6. Remove the global category Hotel, that K LMs belong to, from 2 databases |
|
223 iLog->Log(_L("<<< 6. Remove the global category Hotel, that K LMs belong to, from 2 databases >>>")); |
|
224 //const TPosLmGlobalCategory KHotel = 4; |
|
225 const TPosLmGlobalCategory KAccommodation = 3000; |
|
226 const TInt K = 2*3; // 2 dbs and three in each have hotel as category |
|
227 for (TInt dbIndex = 0; dbIndex <= 1; dbIndex++) |
|
228 { |
|
229 CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[dbIndex]); |
|
230 CleanupStack::PushL(db); |
|
231 CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*db); |
|
232 CleanupStack::PushL(catMan); |
|
233 TPosLmItemId itemId = catMan->GetGlobalCategoryL(KAccommodation); |
|
234 RemoveCategoryFromDbL(itemId, (*iDatabases)[dbIndex]); |
|
235 CleanupStack::PopAndDestroy(2, db); |
|
236 } |
|
237 |
|
238 // Landmarks 3-5 and 23-25 should now be uncategorized. |
|
239 dbIndex = 0; |
|
240 for (TInt i = 3; i <= 5; i++) |
|
241 { |
|
242 iIdArrays[dbIndex].Append(i); |
|
243 } |
|
244 for (TInt i = 23; i <= 25; i++) |
|
245 { |
|
246 iIdArrays[dbIndex + 1].Append(i); |
|
247 } |
|
248 |
|
249 // Check that correct number of uncategorized landmarks are found |
|
250 SearchForUncategorizedLMsL(K + Q + M*iNrOfDatabases); |
|
251 |
|
252 // 7. Exclude one database (the last) |
|
253 iLog->Log(_L("<<< 7. Exclude one database >>>")); |
|
254 iDatabases->Delete(4); |
|
255 iNrOfDatabases--; |
|
256 iLandmarkSearch->SetDatabasesToSearchL(*iDatabases); |
|
257 SearchForUncategorizedLMsL(K + Q + M*iNrOfDatabases); |
|
258 |
|
259 // 8. Test maximum nr of matches |
|
260 iLog->Log(_L("<<< 8. Test maximum nr of matches >>>")); |
|
261 const TInt P = 1; |
|
262 iLandmarkSearch->SetMaxNumOfMatches(P); |
|
263 SearchForUncategorizedLMsL(P * iNrOfDatabases); |
|
264 |
|
265 // 9. Test maximum nr of matches and sort |
|
266 iLog->Log(_L("<<< 9. Test maximum nr of matches and sort >>>")); |
|
267 iLandmarkSearch->SetMaxNumOfMatches(2); |
|
268 SearchForUncategorizedLMsL(2 * iNrOfDatabases, ETrue); |
|
269 |
|
270 // 10. Test on-the-fly sorting |
|
271 iLog->Log(_L("<<< 10. Test on-the-fly sorting >>>")); |
|
272 iLandmarkSearch->SetMaxNumOfMatches(KPosLmMaxNumOfMatchesUnlimited); |
|
273 |
|
274 // Create one big array with all expected matches |
|
275 RIdArray expectedMatches; |
|
276 CleanupClosePushL(expectedMatches); |
|
277 for (TInt i = 0; i < iNrOfDatabases; i++) |
|
278 { |
|
279 for (TInt j = 0; j < iIdArrays[i].Count(); j++) |
|
280 { |
|
281 User::LeaveIfError(expectedMatches.Append(iIdArrays[i][j])); |
|
282 } |
|
283 } |
|
284 |
|
285 CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); |
|
286 COnTheFlyTester* onTheFlyTester = COnTheFlyTester::NewLC(); |
|
287 onTheFlyTester->StartSearchCampaignL(iLandmarkSearch, expectedMatches, catSearchCriteria); |
|
288 TInt result = onTheFlyTester->Err(); |
|
289 if (result != KErrNone) |
|
290 { |
|
291 TPtrC msg; |
|
292 onTheFlyTester->GetErrMsg(msg); |
|
293 iLog->Log(msg); |
|
294 User::Leave(result); |
|
295 } |
|
296 CleanupStack::PopAndDestroy(3, &expectedMatches); |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------- |
|
300 // CPosTp123::TestSearchL |
|
301 // |
|
302 // (other items were commented in a header). |
|
303 // --------------------------------------------------------- |
|
304 // |
|
305 void CPosTp123::TestSearchL( |
|
306 TBool aExecuteSync, |
|
307 TSearchCriterion aCriterion, |
|
308 TInt aNrOfHits, |
|
309 TBool aSorted) |
|
310 { |
|
311 CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); |
|
312 |
|
313 // Specified in header file EPos_CPosLmCategoryCriteria.h says that |
|
314 // specifying no criteria should return uncategorized landmarks |
|
315 // SetCategoryItemId(KPosLmNullItemId) should return uncategorized landmarks and that |
|
316 // SetGlobalCategory(KPosLmNullGlobalCategory) should return uncategorized landmarks and that |
|
317 // SetCategoryNameL(KNullDesC) should return uncategorized landmarks |
|
318 switch (aCriterion) |
|
319 { |
|
320 case ENoCriterion: |
|
321 // Do nothing. Default initialized CPosLmCategoryCriteria is fine. |
|
322 break; |
|
323 case ELocalCategoryId: |
|
324 catSearchCriteria->SetCategoryItemId(KPosLmNullItemId); |
|
325 break; |
|
326 case EGlobalCategoryId: |
|
327 catSearchCriteria->SetGlobalCategory(KPosLmNullGlobalCategory); |
|
328 break; |
|
329 case ECategoryName: |
|
330 catSearchCriteria->SetCategoryNameL(KNullDesC); |
|
331 break; |
|
332 } |
|
333 |
|
334 if (aSorted) |
|
335 { |
|
336 TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
337 iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria, sortPref); |
|
338 } |
|
339 else |
|
340 { |
|
341 iOperation = iLandmarkSearch->StartLandmarkSearchL(*catSearchCriteria); |
|
342 } |
|
343 |
|
344 if (aExecuteSync) |
|
345 { |
|
346 ExecuteAndDeleteLD(iOperation); |
|
347 } |
|
348 else |
|
349 { |
|
350 RunAsyncOperationLD(iOperation); |
|
351 } |
|
352 |
|
353 VerifySearchResultL(aNrOfHits, aSorted); |
|
354 |
|
355 CleanupStack::PopAndDestroy(catSearchCriteria); |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------- |
|
359 // CPosTp123::TestSearchCategoriesL |
|
360 // |
|
361 // (other items were commented in a header). |
|
362 // --------------------------------------------------------- |
|
363 // |
|
364 void CPosTp123::TestSearchCategoriesL(TBool aExecuteSync) |
|
365 { |
|
366 CPosLmCategoryCriteria* catSearchCriteria = CPosLmCategoryCriteria::NewLC(); |
|
367 |
|
368 // This method should leave according to EPos_CPosLmCategoryCriteria.h |
|
369 iOperation = iLandmarkSearch->StartCategorySearchL( |
|
370 *catSearchCriteria, CPosLmCategoryManager::ECategorySortOrderNone); |
|
371 |
|
372 if (aExecuteSync) |
|
373 { |
|
374 ExecuteAndDeleteLD(iOperation); |
|
375 } |
|
376 else |
|
377 { |
|
378 RunAsyncOperationLD(iOperation); |
|
379 } |
|
380 |
|
381 CleanupStack::PopAndDestroy(catSearchCriteria); |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------- |
|
385 // CPosTp123::RemoveCategoriesFromLandmarksL |
|
386 // Use this method to remove the category from a specified number of landmarks |
|
387 // (other items were commented in a header). |
|
388 // --------------------------------------------------------- |
|
389 // |
|
390 void CPosTp123::RemoveCategoriesFromLandmarksL(TInt aNrOfLandmarks) |
|
391 { |
|
392 for (TInt i = 0; i < iNrOfDatabases; i++) |
|
393 { |
|
394 CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL((*iDatabases)[i]); |
|
395 CleanupStack::PushL(database); |
|
396 ExecuteAndDeleteLD(database->CompactL()); |
|
397 CPosLmItemIterator* iter = database->LandmarkIteratorL(); |
|
398 CleanupStack::PushL(iter); |
|
399 |
|
400 TPosLmItemId id = iter->NextL(); |
|
401 TInt counter=0; |
|
402 |
|
403 // Remove the categories from aNrOfLandmarks nr of landmarks |
|
404 while ((id != KPosLmNullItemId) && (counter < aNrOfLandmarks)) |
|
405 { |
|
406 CPosLandmark* landmark = database->ReadLandmarkLC(id); |
|
407 landmark->RemoveLandmarkAttributes(CPosLandmark::ECategoryInfo); |
|
408 TInt err = KErrLocked; |
|
409 while (err == KErrLocked) |
|
410 { |
|
411 TRAP(err, database->UpdateLandmarkL(*landmark)); |
|
412 } |
|
413 CleanupStack::PopAndDestroy(landmark); |
|
414 User::LeaveIfError(iIdArrays[i].Append(id)); |
|
415 |
|
416 id = iter->NextL(); |
|
417 if (id == KPosLmNullItemId) |
|
418 { |
|
419 iLog->Log(_L("KPosLmNullItemId")); |
|
420 } |
|
421 counter++; |
|
422 } |
|
423 |
|
424 CleanupStack::PopAndDestroy(2, database); |
|
425 } |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------- |
|
429 // CPosTp123::SearchForUncategorizedLMsL |
|
430 // |
|
431 // (other items were commented in a header). |
|
432 // --------------------------------------------------------- |
|
433 // |
|
434 void CPosTp123::SearchForUncategorizedLMsL(TInt aNrOfHits, TBool aSorted) |
|
435 { |
|
436 for (TBool runSynch = EFalse; runSynch < 2; runSynch++) |
|
437 { |
|
438 for (TSearchCriterion searchCriterion = ENoCriterion; |
|
439 searchCriterion <= ECategoryName; |
|
440 searchCriterion = (TSearchCriterion)((TInt)searchCriterion + 1)) |
|
441 { |
|
442 TestSearchL(runSynch, searchCriterion, aNrOfHits, aSorted); |
|
443 } |
|
444 } |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------- |
|
448 // CPosTp123::RemoveCategoryFromDbL |
|
449 // |
|
450 // (other items were commented in a header). |
|
451 // --------------------------------------------------------- |
|
452 // |
|
453 void CPosTp123::RemoveCategoryFromDbL( |
|
454 TPosLmItemId aCategoryId, |
|
455 const TDesC& aDbUri) |
|
456 { |
|
457 CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(aDbUri); |
|
458 CleanupStack::PushL(database); |
|
459 CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*database); |
|
460 CleanupStack::PushL(catMan); |
|
461 |
|
462 ExecuteAndDeleteLD(catMan->RemoveCategoryL(aCategoryId)); |
|
463 |
|
464 CleanupStack::PopAndDestroy(2, database); |
|
465 } |
|
466 |
|
467 // --------------------------------------------------------- |
|
468 // CPosTp123::VerifySearchResultL |
|
469 // |
|
470 // (other items were commented in a header). |
|
471 // --------------------------------------------------------- |
|
472 // |
|
473 void CPosTp123::VerifySearchResultL( |
|
474 TInt aNrOfHits, |
|
475 TBool aSorted) |
|
476 { |
|
477 AssertTrueSecL(iLandmarkSearch->NumOfSearchErrors() == 0, _L("Found search errors!")); |
|
478 |
|
479 // Verify total number of matches is correct |
|
480 TInt totNrOfMatches = iLandmarkSearch->TotalNumOfMatches(); |
|
481 if (totNrOfMatches != aNrOfHits) |
|
482 { |
|
483 iBuf.Format(_L("Wrong number of landmarks returned when searching for uncategorized landmarks, found: %d expected %d"), totNrOfMatches, aNrOfHits); |
|
484 iLog->Log(iBuf); |
|
485 User::Leave(-1); |
|
486 } |
|
487 |
|
488 |
|
489 for (TUint i = 0; i < iNrOfDatabases; i++) |
|
490 { |
|
491 CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL((*iDatabases)[i]); |
|
492 CleanupStack::PushL(database); |
|
493 CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(i); |
|
494 CleanupStack::PushL(iter); |
|
495 |
|
496 // Verify number of matches in each database is correct |
|
497 TInt nrInIter = iter->NumOfItemsL(); |
|
498 AssertTrueSecL(nrInIter == iLandmarkSearch->NumOfMatches(i), _L("wrong number of items returned in a specific iterator!")); |
|
499 |
|
500 // Verify that correct landmarks were found |
|
501 TPosLmItemId id = iter->NextL(); |
|
502 TInt index = 0; |
|
503 while (id != KPosLmNullItemId) |
|
504 { |
|
505 TInt found = iIdArrays[i].Find(id); |
|
506 if (found == KErrNotFound) |
|
507 { |
|
508 iLog->Log(_L("Not found")); |
|
509 User::Leave(KErrNotFound); |
|
510 } |
|
511 else |
|
512 { |
|
513 index++; |
|
514 CPosLandmark* landmark = database->ReadLandmarkLC(id); |
|
515 CPosLandmark* landmark2 = database->ReadLandmarkLC(iIdArrays[i][found]); |
|
516 |
|
517 CompareLandmarksL(*landmark, *landmark2); |
|
518 |
|
519 CleanupStack::PopAndDestroy(landmark2); |
|
520 CleanupStack::PopAndDestroy(landmark); |
|
521 } |
|
522 id = iter->NextL(); |
|
523 } |
|
524 |
|
525 if (index != nrInIter) |
|
526 { |
|
527 iLog->Log(_L("The correct landmark was never found")); |
|
528 User::Leave(-1); |
|
529 |
|
530 } |
|
531 if (aSorted) |
|
532 { |
|
533 VerifySortOrderL(iter, database); |
|
534 } |
|
535 CleanupStack::PopAndDestroy(2, database); |
|
536 } |
|
537 } |
|
538 |
|
539 // --------------------------------------------------------- |
|
540 // CPosTp123::VerifySortOrderL |
|
541 // |
|
542 // (other items were commented in a header). |
|
543 // --------------------------------------------------------- |
|
544 // |
|
545 void CPosTp123::VerifySortOrderL( |
|
546 CPosLmItemIterator* aIter, |
|
547 CPosLandmarkDatabase* aDb) |
|
548 { |
|
549 RIdArray idArray; |
|
550 CleanupClosePushL(idArray); |
|
551 TInt nrOfItems = aIter->NumOfItemsL(); |
|
552 aIter->GetItemIdsL(idArray, 0, nrOfItems); |
|
553 |
|
554 for (TInt i = 0; i < nrOfItems; i++) |
|
555 { |
|
556 if (i < nrOfItems - 1) |
|
557 { |
|
558 CPosLandmark* lm1 = aDb->ReadLandmarkLC(idArray[i]); |
|
559 CPosLandmark* lm2 = aDb->ReadLandmarkLC(idArray[i + 1]); |
|
560 TPtrC name1, name2; |
|
561 lm1->GetLandmarkName(name1); |
|
562 lm2->GetLandmarkName(name2); |
|
563 AssertTrueSecL(name1.CompareC(name2) <= 0, _L("lm1 is greater than lm2 - should not be the case since ascending order is used.")); |
|
564 CleanupStack::PopAndDestroy(2, lm1); |
|
565 } |
|
566 } |
|
567 CleanupStack::PopAndDestroy(&idArray); |
|
568 } |
|
569 |
|
570 // End of File |