|
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 the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-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_CPosTp124.h" |
|
22 #include <EPos_CPosLandmarkDatabase.h> |
|
23 #include <EPos_CPosLmCompositeCriteria.h> |
|
24 #include <EPos_CPosLmCategoryCriteria.h> |
|
25 #include <EPos_CPosLmCatNameCriteria.h> |
|
26 #include <EPos_CPosLmNearestCriteria.h> |
|
27 #include <EPos_CPosLmAreaCriteria.h> |
|
28 #include <EPos_CPosLmTextCriteria.h> |
|
29 #include <EPos_CPosLmIdListCriteria.h> |
|
30 #include "FT_LandmarkConstants.h" |
|
31 |
|
32 #include "FT_CCompositeSearchResult.h" |
|
33 |
|
34 #include <EPos_CPosLmDisplayData.h> |
|
35 #include <EPos_CPosLmDisplayItem.h> |
|
36 |
|
37 #include <EPos_CPosLMItemIterator.h> |
|
38 #include <EPos_CPosLmMultiDbSearch.h> |
|
39 #include <EPos_CPosLmDatabaseManager.h> |
|
40 |
|
41 #include <e32math.h> |
|
42 |
|
43 // CONSTANTS |
|
44 _LIT(KLMDB1, "COMPOSITELMDB_1.LDB"); |
|
45 _LIT(KLMDB2, "COMPOSITELMDB_2.LDB"); |
|
46 _LIT(KLMDB3, "COMPOSITELMDB_3.LDB"); |
|
47 _LIT(KLMDB4, "COMPOSITELMDB_4.LDB"); |
|
48 _LIT(KLMDB5, "COMPOSITELMDB_5.LDB"); |
|
49 _LIT(KLMDB1Path,"file://C:COMPOSITELMDB_1.LDB"); |
|
50 _LIT(KLMDB2Path,"file://C:COMPOSITELMDB_2.LDB"); |
|
51 _LIT(KLMDB3Path,"file://C:COMPOSITELMDB_3.LDB"); |
|
52 _LIT(KLMDB4Path,"file://C:COMPOSITELMDB_4.LDB"); |
|
53 _LIT(KLMDB5Path,"file://C:COMPOSITELMDB_5.LDB"); |
|
54 |
|
55 //_LIT(KCOMPOSITELMDB, "compositeeposlm.ldb"); |
|
56 |
|
57 // ================= MEMBER FUNCTIONS ======================= |
|
58 |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CPosTp124::CloseTest |
|
62 // |
|
63 // (other items were commented in a header). |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 void CPosTp124::CloseTest() |
|
67 { |
|
68 iLog->Log(_L("CloseTest")); |
|
69 delete iDatabase; |
|
70 iDatabase=NULL; |
|
71 |
|
72 delete iDatabases; |
|
73 |
|
74 if (iMultiDbSearch) iMultiDbSearch->UnsetDisplayData(); |
|
75 delete iDisplayData; |
|
76 iDisplayData = NULL; |
|
77 |
|
78 delete iMultiDbSearch; |
|
79 |
|
80 TRAPD(err, RemoveAllLmDatabasesL()); |
|
81 if (err != KErrNone) iLog->Log(_L("Error when RemoveAllLmDatabasesL")); |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------- |
|
85 // CPosTp124::InitTestL |
|
86 // |
|
87 // (other items were commented in a header). |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 void CPosTp124::InitTestL() |
|
91 { |
|
92 CLandmarkTestProcedureBase::InitTestL(); |
|
93 |
|
94 iLog->Log(_L("InitTestL")); |
|
95 RemoveAllLmDatabasesL(); |
|
96 CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); |
|
97 CleanupStack::PushL(dbManager); |
|
98 // check the count of databases that could not be delted since they were in use |
|
99 iDatabases = dbManager->ListDatabasesLC(); |
|
100 CleanupStack::Pop(iDatabases); |
|
101 iDbCount = iDatabases->Count(); |
|
102 |
|
103 |
|
104 // PrepareDatabases |
|
105 PrepareDatabasesL(); |
|
106 |
|
107 SetupLimits(); |
|
108 |
|
109 |
|
110 |
|
111 iDatabases = dbManager->ListDatabasesLC(); |
|
112 CleanupStack::Pop(iDatabases); |
|
113 iDatabases->Sort(); // Not really necessary... |
|
114 // database count is equal to ones added plus ones not been able to delte since they were in use |
|
115 TInt dbCount = iDatabases->Count(); |
|
116 iNrOfDatabases = iDbCount + 5; |
|
117 |
|
118 iMultiDbSearch = CPosLmMultiDbSearch::NewL(*iDatabases); |
|
119 CleanupStack::PopAndDestroy(dbManager); |
|
120 |
|
121 iDisplayData = CPosLmDisplayData::NewL(); |
|
122 iMultiDbSearch->SetDisplayData(*iDisplayData); |
|
123 |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------- |
|
127 // CPosTp124::StartL |
|
128 // |
|
129 // (other items were commented in a header). |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 void CPosTp124::StartL() |
|
133 { |
|
134 TTime startTime; |
|
135 TTime stopTime; |
|
136 startTime.UniversalTime(); |
|
137 |
|
138 MakeSurePanicDebugFileExistsL(); |
|
139 |
|
140 iDatabase = UseCompositeLandmarksDbFileL(); |
|
141 |
|
142 if (iDatabase->IsInitializingNeeded()) |
|
143 { |
|
144 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
145 } |
|
146 |
|
147 // TC_Part 1 |
|
148 // ASynchronous, Sort ascending |
|
149 StartLandmarksCompositeTestL(EAsynchronous, ESortAscending); |
|
150 // Synchronous, Sort descending |
|
151 StartLandmarksCompositeTestL(EAsynchronous, ESortDescending); |
|
152 // ASynchronous, Sort ascending |
|
153 TestWithSortOrderLandmarksL(EAsynchronous, ESortAscending); |
|
154 |
|
155 TestWithSortOrderNearestL(EAsynchronous, ESortAscending); |
|
156 TestWithSortOrderNearestL(ESynchronous, ESortNone); |
|
157 TestWithSortOrderNearestL(EAsynchronous, ESortDescending); |
|
158 TestWithSortOrderNearestL(EAsynchronous, ESortDistance); |
|
159 |
|
160 // TC Part 2_3 Test with several text criterias |
|
161 TestSeveralTextArgumentsL(); |
|
162 |
|
163 // TC Part 4-5 Test add and remove from composite object |
|
164 TestAddAndRemoveL(); |
|
165 |
|
166 // TC Part 6 |
|
167 // Cancel immediately |
|
168 CancelTestL(EFalse); |
|
169 |
|
170 // Cancel in callback |
|
171 CancelTestL(ETrue); |
|
172 |
|
173 // TC Part 7 |
|
174 TestOnTheFlySearchL(); |
|
175 |
|
176 // Since TestOnTheFlySearchL is changing displadata |
|
177 iMultiDbSearch->UnsetDisplayData(); |
|
178 delete iDisplayData; |
|
179 iDisplayData = NULL; |
|
180 iDisplayData = CPosLmDisplayData::NewL(); |
|
181 iMultiDbSearch->SetDisplayData(*iDisplayData); |
|
182 |
|
183 // TC Part 8-11 |
|
184 // TestLessDbsToSearchL(); |
|
185 |
|
186 // TC Part 12 |
|
187 // It is not possible to use Composite in a composite object in multi search |
|
188 TestCompositeInCompositeL(); |
|
189 |
|
190 // TC Part 13 |
|
191 // It is not possible to use IdList in a composite object in multi search |
|
192 TestWithIdListAndCompositeL(); |
|
193 |
|
194 // TC Part 14 |
|
195 // It is not possible to use CPosLmCatNameCriteria in a composite object in multi search |
|
196 TestCategoryCompositeSearchL(); |
|
197 |
|
198 // TC Part 15 |
|
199 // Test with no previous result but try to refine search anyway |
|
200 TestWithNoPreviousResultL(); |
|
201 |
|
202 TInt KNrOfObjectsInComposite = 100; |
|
203 TInt KStartIndex = 90; |
|
204 CompositeStressTestL(KStartIndex, KNrOfObjectsInComposite); |
|
205 |
|
206 stopTime.UniversalTime(); |
|
207 TTimeIntervalMicroSeconds executionTime = |
|
208 stopTime.MicroSecondsFrom(startTime); |
|
209 |
|
210 TInt resse = executionTime.Int64()/1000000; |
|
211 TBuf<100> buf; |
|
212 buf.Format(_L("TP124 took %d seconds"), resse); |
|
213 iLog->Log(buf); |
|
214 |
|
215 if (iErrorsFound != KErrNone) |
|
216 { |
|
217 iLog->Log(_L("Errors found in TP124")); |
|
218 User::Leave(-1); |
|
219 } |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------- |
|
223 // CPosTp124::SetupLimits() |
|
224 // |
|
225 // (other items were commented in a header). |
|
226 // --------------------------------------------------------- |
|
227 void CPosTp124::SetupLimits() |
|
228 { |
|
229 // First db-> Keep landmarks 1-20 |
|
230 // Second db-> Keep landmarks 21-40 |
|
231 // Third db-> Keep landmarks 41-60 |
|
232 // Fourth db-> Keep landmarks 61-80 |
|
233 // Fifth db-> Keep landmarks 81-105 |
|
234 |
|
235 iIdDb1Min = 1; |
|
236 iIdDb1Max = 20; |
|
237 |
|
238 iIdDb2Min = 21; |
|
239 iIdDb2Max = 40; |
|
240 |
|
241 iIdDb3Min = 41; |
|
242 iIdDb3Max = 60; |
|
243 |
|
244 iIdDb4Min = 61; |
|
245 iIdDb4Max = 80; |
|
246 |
|
247 iIdDb5Min = 81; |
|
248 iIdDb5Max = 105; |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------- |
|
252 // CPosTp124::ValidateIdL |
|
253 // |
|
254 // (other items were commented in a header). |
|
255 // --------------------------------------------------------- |
|
256 // |
|
257 void CPosTp124::ValidateIdL(TPosLmItemId aId, TInt aDbIndex) |
|
258 { |
|
259 TBool condition = EFalse; |
|
260 switch (aDbIndex) |
|
261 { |
|
262 case 0: |
|
263 // Db 1 contains landmarks with id = 1-20 |
|
264 condition = aId >= iIdDb1Min && aId <= iIdDb1Max; |
|
265 break; |
|
266 case 1: |
|
267 // Db 2 contains landmarks with id = 21-40 |
|
268 condition = aId >= iIdDb2Min && aId <= iIdDb2Max; |
|
269 break; |
|
270 case 2: |
|
271 // Db 3 contains landmarks with id = 41-60 |
|
272 condition = aId >= iIdDb3Min && aId <= iIdDb3Max; |
|
273 break; |
|
274 case 3: |
|
275 // Db 4 contains landmarks with id = 61-80 |
|
276 condition = aId >= iIdDb4Min && aId <= iIdDb4Max; |
|
277 break; |
|
278 case 4: |
|
279 // Db 5 contains landmarks with id = 81-105 |
|
280 condition = aId >= iIdDb5Min && aId <= iIdDb5Max; |
|
281 break; |
|
282 } |
|
283 |
|
284 if (!condition) |
|
285 { |
|
286 iErrorsFound++; |
|
287 TBuf<150> buf; |
|
288 buf.Format(_L("ERROR: Invalid match from database reported, index %d in db %d"), aId, aDbIndex); |
|
289 iLog->Log(buf); |
|
290 } |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------- |
|
294 // CPosTp124::PrepareDatabasesL |
|
295 // |
|
296 // (other items were commented in a header). |
|
297 // --------------------------------------------------------- |
|
298 // |
|
299 void CPosTp124::PrepareDatabasesL() |
|
300 { |
|
301 iLog->Log(_L("PrepareDatabasesL")); |
|
302 // Copy eposlmnearestsearch.ldb into five dbs |
|
303 _LIT(KDbFile, "c:\\system\\test\\testdata\\compositeeposlm.ldb"); |
|
304 |
|
305 CFileMan* fileMan = CFileMan::NewL(iFileSession); |
|
306 CleanupStack::PushL(fileMan); |
|
307 |
|
308 // Create five copies of testdata\\compositeeposlm.ldb |
|
309 TBuf<100> path; |
|
310 path.Zero(); |
|
311 path.Append(KLmDbPath); |
|
312 path.Append(KLMDB1); |
|
313 User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); |
|
314 |
|
315 path.Zero(); |
|
316 path.Append(KLmDbPath); |
|
317 path.Append(KLMDB2); |
|
318 User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); |
|
319 |
|
320 path.Zero(); |
|
321 path.Append(KLmDbPath); |
|
322 path.Append(KLMDB3); |
|
323 User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); |
|
324 |
|
325 path.Zero(); |
|
326 path.Append(KLmDbPath); |
|
327 path.Append(KLMDB4); |
|
328 User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); |
|
329 |
|
330 path.Zero(); |
|
331 path.Append(KLmDbPath); |
|
332 path.Append(KLMDB5); |
|
333 User::LeaveIfError(fileMan->Copy(KDbFile, path, CFileMan::EOverWrite)); |
|
334 |
|
335 CleanupStack::PopAndDestroy(fileMan); |
|
336 |
|
337 // Now adjust dbs according to following: |
|
338 // First db-> Keep landmarks 1-20 |
|
339 // Second db-> Keep landmarks 21-40 |
|
340 // Third db-> Keep landmarks 41-60 |
|
341 // Fourth db-> Keep landmarks 61-80 |
|
342 // Fifth db-> Keep landmarks 81-105 |
|
343 |
|
344 RArray<TPosLmItemId> array; |
|
345 CleanupClosePushL(array); |
|
346 |
|
347 CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(KLMDB1); |
|
348 CleanupStack::PushL(lmd); |
|
349 |
|
350 TBool debug = EFalse; |
|
351 TInt index=0; |
|
352 TInt max=105; |
|
353 for (index=20;index<max;index++) array.Append(index+1); |
|
354 if (lmd->IsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); |
|
355 ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); |
|
356 User::After(200000); |
|
357 ExecuteAndDeleteLD(lmd->CompactL()); |
|
358 array.Reset(); |
|
359 if (debug) PrintLm(lmd); |
|
360 CleanupStack::PopAndDestroy(lmd); |
|
361 |
|
362 lmd = CPosLandmarkDatabase::OpenL(KLMDB2); |
|
363 CleanupStack::PushL(lmd); |
|
364 |
|
365 for (index=0;index<20;index++) array.Append(index+1); |
|
366 for (index=40;index<max;index++) array.Append(index+1); |
|
367 if (lmd->IsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); |
|
368 ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); |
|
369 User::After(200000); |
|
370 ExecuteAndDeleteLD(lmd->CompactL()); |
|
371 array.Reset(); |
|
372 if (debug) PrintLm(lmd); |
|
373 CleanupStack::PopAndDestroy(lmd); |
|
374 |
|
375 lmd = CPosLandmarkDatabase::OpenL(KLMDB3); |
|
376 CleanupStack::PushL(lmd); |
|
377 |
|
378 for (index=0;index<40;index++) array.Append(index+1); |
|
379 for (index=60;index<max;index++) array.Append(index+1); |
|
380 if (lmd->IsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); |
|
381 ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); |
|
382 User::After(200000); |
|
383 ExecuteAndDeleteLD(lmd->CompactL()); |
|
384 array.Reset(); |
|
385 if (debug) PrintLm(lmd); |
|
386 CleanupStack::PopAndDestroy(lmd); |
|
387 |
|
388 lmd = CPosLandmarkDatabase::OpenL(KLMDB4); |
|
389 CleanupStack::PushL(lmd); |
|
390 |
|
391 for (index=0;index<60;index++) array.Append(index+1); |
|
392 for (index=80;index<max;index++) array.Append(index+1); |
|
393 if (lmd->IsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); |
|
394 ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); |
|
395 User::After(200000); |
|
396 ExecuteAndDeleteLD(lmd->CompactL()); |
|
397 array.Reset(); |
|
398 if (debug) PrintLm(lmd); |
|
399 CleanupStack::PopAndDestroy(lmd); |
|
400 |
|
401 lmd = CPosLandmarkDatabase::OpenL(KLMDB5); |
|
402 CleanupStack::PushL(lmd); |
|
403 |
|
404 for (index=0;index<80;index++) array.Append(index+1); |
|
405 if (lmd->IsInitializingNeeded()) ExecuteAndDeleteLD(lmd->InitializeL()); |
|
406 ExecuteAndDeleteLD(lmd->RemoveLandmarksL(array)); |
|
407 User::After(200000); |
|
408 ExecuteAndDeleteLD(lmd->CompactL()); |
|
409 array.Reset(); |
|
410 if (debug) PrintLm(lmd); |
|
411 |
|
412 CleanupStack::PopAndDestroy(lmd); |
|
413 |
|
414 CleanupStack::PopAndDestroy(&array); |
|
415 iLog->Log(_L("PrepareDatabasesL Done")); |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------- |
|
419 // CPosTp124::PrintLm |
|
420 // |
|
421 // (other items were commented in a header). |
|
422 // --------------------------------------------------------- |
|
423 // |
|
424 void CPosTp124::PrintLm(CPosLandmarkDatabase* db) |
|
425 { |
|
426 CPosLmItemIterator* iter = db->LandmarkIteratorL(); |
|
427 CleanupStack::PushL(iter); |
|
428 iLog->Log(_L("PrintLm")); |
|
429 |
|
430 TPosLmItemId id = iter->NextL(); |
|
431 TBuf<100> buf; |
|
432 |
|
433 while (id != KPosLmNullItemId) |
|
434 { |
|
435 CPosLandmark* lm = db->ReadLandmarkLC(id); |
|
436 TPtrC name; |
|
437 lm->GetLandmarkName(name); |
|
438 iLog->Log(_L("Found LM: ")); |
|
439 iLog->Log(name); |
|
440 TInt idde = lm->LandmarkId(); |
|
441 |
|
442 id = iter->NextL(); |
|
443 CleanupStack::PopAndDestroy(lm); |
|
444 } |
|
445 |
|
446 CleanupStack::PopAndDestroy(iter); |
|
447 iLog->Log(_L("PrintLm Done")); |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------- |
|
451 // CPosTp124::TestOnTheFlySearchL |
|
452 // |
|
453 // (other items were commented in a header). |
|
454 // --------------------------------------------------------- |
|
455 // |
|
456 void CPosTp124::TestOnTheFlySearchL() |
|
457 { |
|
458 iLog->Log(_L("TestOnTheFlySearchL")); |
|
459 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
460 |
|
461 CCompositeSearchResult* res = CCompositeSearchResult::NewL(iLog); |
|
462 CleanupStack::PushL(res); |
|
463 |
|
464 while (!res->GetCompositeSearchResultsL(*composite)) |
|
465 { |
|
466 // Check if IdList is included in composite, if so dont |
|
467 // use this search since IdList is not possible to use in multiple db seach |
|
468 if (!CheckCompositeForIdListL(composite)) |
|
469 { |
|
470 PrintCompositeInfo(composite); |
|
471 iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); |
|
472 TBuf<150> buf; |
|
473 COnTheFlyTester* onTheFlyTester = COnTheFlyTester::NewLC(); |
|
474 onTheFlyTester->StartSearchCampaignL(iMultiDbSearch, res->iResultIds, composite); |
|
475 |
|
476 TInt result = onTheFlyTester->Err(); |
|
477 if (result != KErrNone) |
|
478 { |
|
479 TPtrC msg; |
|
480 onTheFlyTester->GetErrMsg(msg); |
|
481 iLog->Log(msg); |
|
482 User::Leave(result); |
|
483 } |
|
484 CleanupStack::PopAndDestroy(onTheFlyTester); |
|
485 } |
|
486 } |
|
487 |
|
488 CleanupStack::PopAndDestroy(res); |
|
489 CleanupStack::PopAndDestroy(composite); |
|
490 iLog->Log(_L("TestOnTheFlySearchL Done")); |
|
491 |
|
492 } |
|
493 |
|
494 // --------------------------------------------------------- |
|
495 // CPosTp124::TestLessDbsToSearchL |
|
496 // |
|
497 // (other items were commented in a header). |
|
498 // --------------------------------------------------------- |
|
499 // |
|
500 void CPosTp124::TestLessDbsToSearchL() |
|
501 { |
|
502 iLog->Log(_L("TestLessDbsToSearchL")); |
|
503 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
504 |
|
505 TBuf<100> buf; |
|
506 |
|
507 // First create a textcriteria |
|
508 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
509 textCriteria->SetTextL(_L("LO*")); |
|
510 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
511 CleanupStack::Pop(textCriteria); |
|
512 |
|
513 // Create search result |
|
514 RArray<TPosLmItemId> searchResults; |
|
515 CleanupClosePushL(searchResults); |
|
516 |
|
517 // Will find: |
|
518 searchResults.Append(1); |
|
519 searchResults.Append(2); |
|
520 searchResults.Append(20); |
|
521 searchResults.Append(21); |
|
522 searchResults.Append(22); |
|
523 searchResults.Append(23); |
|
524 searchResults.Append(24); |
|
525 searchResults.Append(26); |
|
526 searchResults.Append(27); |
|
527 searchResults.Append(28); |
|
528 |
|
529 iLog->Log(_L("Search in all dbs")); |
|
530 |
|
531 SearchL(composite, ESynchronous, EFalse, ESortNone); |
|
532 ValidateSearchResultsL(searchResults, ESortNone); |
|
533 |
|
534 // delete the COMPOSITELMDB_1 & COMPOSITELMDB_3 |
|
535 TInt count = iDatabases->Count(); |
|
536 for(TInt i =0;i<count;i++) |
|
537 { |
|
538 TPtrC16 dbName((*iDatabases)[i]); |
|
539 if(dbName.Compare(KLMDB1Path) == KErrNone || dbName.Compare(KLMDB4Path) == KErrNone ) |
|
540 { |
|
541 iDatabases->Delete(i); |
|
542 } |
|
543 } |
|
544 // iDatabases->Delete(0); |
|
545 // iDatabases->Delete(3); |
|
546 |
|
547 iNrOfDatabases-=2; |
|
548 |
|
549 iIdDb1Min = 21; |
|
550 iIdDb1Max = 40; |
|
551 |
|
552 iIdDb2Min = 41; |
|
553 iIdDb2Max = 60; |
|
554 |
|
555 iIdDb3Min = 81; |
|
556 iIdDb3Max = 105; |
|
557 |
|
558 iMultiDbSearch->SetDatabasesToSearchL(*iDatabases); |
|
559 |
|
560 iLog->Log(_L("Search in all dbs but db0 and db3")); |
|
561 // Remove three first items, found in db0 |
|
562 searchResults.Remove(0); // id 1 |
|
563 searchResults.Remove(0); // id 2 |
|
564 searchResults.Remove(0); // id 20 |
|
565 SearchL(composite, ESynchronous, EFalse, ESortNone); |
|
566 ValidateSearchResultsL(searchResults, ESortNone); |
|
567 |
|
568 // Open DB last in list and add a new landmark |
|
569 CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KLMDB3); |
|
570 CleanupStack::PushL(db); |
|
571 CPosLandmark* lm1 = CPosLandmark::NewLC(); |
|
572 lm1->SetLandmarkNameL(_L("LOOOPIA Landmark")); |
|
573 lm1->SetLandmarkDescriptionL(_L("Some Description")); |
|
574 |
|
575 iLog->Log(_L("Add new Landmark to db nr 0")); |
|
576 TPosLmItemId newLmId = db->AddLandmarkL(*lm1); |
|
577 CleanupStack::PopAndDestroy(lm1); |
|
578 |
|
579 iLog->Log(_L("Search in all dbs but db0 and db3")); |
|
580 //Refine search. new landmark should not be included |
|
581 SearchL(composite, ESynchronous, ETrue, ESortNone); |
|
582 ValidateSearchResultsL(searchResults, ESortNone); |
|
583 |
|
584 CPosLmCategoryCriteria* catSearchCriteria1 = CPosLmCategoryCriteria::NewLC(); |
|
585 CPosLmCategoryCriteria* catSearchCriteria2 = CPosLmCategoryCriteria::NewLC(); |
|
586 |
|
587 catSearchCriteria1->SetCategoryNameL(_L("Stadsbibliotek")); |
|
588 catSearchCriteria2->SetCategoryNameL(_L("Systembolag")); |
|
589 |
|
590 User::LeaveIfError(composite->AddArgument(catSearchCriteria1)); |
|
591 User::LeaveIfError(composite->AddArgument(catSearchCriteria2)); |
|
592 CleanupStack::Pop(catSearchCriteria2); |
|
593 CleanupStack::Pop(catSearchCriteria1); |
|
594 |
|
595 iLog->Log(_L("Search in all dbs but db0 and db3")); |
|
596 //Refine search with more specific composite search object |
|
597 // new landmark should not be included |
|
598 |
|
599 searchResults.Reset(); |
|
600 searchResults.Append(27); |
|
601 |
|
602 SearchL(composite, ESynchronous, ETrue, ESortNone); |
|
603 ValidateSearchResultsL(searchResults, ESortNone); |
|
604 |
|
605 // Remove some criterias from composite and do a new search, |
|
606 iLog->Log(_L("Search in all dbs but db0 and db3, remove last argument from composite")); |
|
607 // Remove last added argument |
|
608 CPosLmSearchCriteria* obj1 = composite->RemoveArgument(composite->NumOfArguments()-1); |
|
609 delete obj1; |
|
610 obj1 = NULL; |
|
611 |
|
612 //Refine search. new landmark should not be included |
|
613 SearchL(composite, ESynchronous, ETrue, ESortNone); |
|
614 ValidateSearchResultsL(searchResults, ESortNone); |
|
615 |
|
616 // Remove last added argument |
|
617 obj1 = composite->RemoveArgument(composite->NumOfArguments()-1); |
|
618 delete obj1; |
|
619 obj1 = NULL; |
|
620 |
|
621 //Do a new search (not more refined). new landmark should be included |
|
622 searchResults.Append(newLmId); |
|
623 iIdDb3Max = newLmId; |
|
624 searchResults.Reset(); |
|
625 searchResults.Append(21); |
|
626 searchResults.Append(22); |
|
627 searchResults.Append(23); |
|
628 searchResults.Append(24); |
|
629 searchResults.Append(26); |
|
630 searchResults.Append(27); |
|
631 searchResults.Append(28); |
|
632 searchResults.Append(newLmId); |
|
633 iLog->Log(_L("Search in all dbs but db0 and db3, without refined")); |
|
634 SearchL(composite, ESynchronous, EFalse, ESortNone); |
|
635 ValidateSearchResultsL(searchResults, ESortNone); |
|
636 |
|
637 // Remove the added landmark |
|
638 db->RemoveLandmarkL(newLmId); |
|
639 CleanupStack::PopAndDestroy(db); |
|
640 |
|
641 CleanupStack::PopAndDestroy(&searchResults); |
|
642 CleanupStack::PopAndDestroy(composite); |
|
643 // Correct limits if more testing after this part |
|
644 SetupLimits(); |
|
645 |
|
646 CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); |
|
647 CleanupStack::PushL(dbManager); |
|
648 delete iDatabases; |
|
649 iDatabases = NULL; |
|
650 iDatabases = dbManager->ListDatabasesLC(); |
|
651 CleanupStack::Pop(iDatabases); |
|
652 iDatabases->Sort(); // Not really necessary... |
|
653 // Remove compositeeposlm.ldb that should not be searched |
|
654 iNrOfDatabases = iDbCount + 5; |
|
655 iDatabases->Delete(0); |
|
656 AssertTrueSecL((iDatabases->Count() == iNrOfDatabases), _L("Wrong number of databases")); |
|
657 |
|
658 iMultiDbSearch->UnsetDisplayData(); |
|
659 delete iDisplayData; |
|
660 iDisplayData = NULL; |
|
661 |
|
662 delete iMultiDbSearch; |
|
663 iMultiDbSearch = NULL; |
|
664 |
|
665 iMultiDbSearch = CPosLmMultiDbSearch::NewL(*iDatabases); |
|
666 iDisplayData = CPosLmDisplayData::NewL(); |
|
667 iMultiDbSearch->SetDisplayData(*iDisplayData); |
|
668 |
|
669 CleanupStack::PopAndDestroy(dbManager); |
|
670 |
|
671 } |
|
672 |
|
673 // --------------------------------------------------------- |
|
674 // CPosTp124::TestWithSortOrderNearestL |
|
675 // |
|
676 // (other items were commented in a header). |
|
677 // --------------------------------------------------------- |
|
678 // |
|
679 void CPosTp124::TestWithSortOrderNearestL(TExecutionMode aExecutionMode, |
|
680 TTp124SortOrder aSortOrder) |
|
681 { |
|
682 iLog->Log(_L("TestWithSortOrderNearestL")); |
|
683 |
|
684 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
685 |
|
686 // First create a textcriteria |
|
687 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
688 textCriteria->SetTextL(_L("*")); |
|
689 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
690 CleanupStack::Pop(textCriteria); |
|
691 |
|
692 // Then create a nearest criteria same coordinate as landmark itemid=31 Text1 |
|
693 TCoordinate coord(45.5, 0.5); |
|
694 iCoord = coord; |
|
695 CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, ETrue); |
|
696 nearestCriteria->SetMaxDistance(80000); |
|
697 |
|
698 |
|
699 User::LeaveIfError(composite->AddArgument(nearestCriteria)); |
|
700 CleanupStack::Pop(nearestCriteria); |
|
701 |
|
702 // Create search result |
|
703 RArray<TPosLmItemId> searchResults; |
|
704 CleanupClosePushL(searchResults); |
|
705 |
|
706 // Will find Unique, Text'1 and Text1 |
|
707 searchResults.Append(29); |
|
708 searchResults.Append(31); |
|
709 searchResults.Append(30); |
|
710 |
|
711 iLog->Log(_L("Innan search")); |
|
712 SearchL(composite, aExecutionMode, EFalse, aSortOrder); |
|
713 iLog->Log(_L("Innan validate")); |
|
714 ValidateSearchResultsL(searchResults, aSortOrder); |
|
715 |
|
716 CleanupStack::PopAndDestroy(&searchResults); |
|
717 CleanupStack::PopAndDestroy(composite); |
|
718 } |
|
719 |
|
720 // --------------------------------------------------------- |
|
721 // CPosTp124::CheckCompositeForIdListL |
|
722 // |
|
723 // (other items were commented in a header). |
|
724 // --------------------------------------------------------- |
|
725 // |
|
726 TBool CPosTp124::CheckCompositeForIdListL(CPosLmCompositeCriteria* aComposite) |
|
727 { |
|
728 iLog->Log(_L("CheckCompositeForIdListL")); |
|
729 TBool res = EFalse; |
|
730 for (TUint i=0;i<aComposite->NumOfArguments();i++) |
|
731 { |
|
732 CPosLmSearchCriteria& comp = aComposite->Argument(i); |
|
733 TInt type = comp.CriteriaType(); |
|
734 if (type == CPosLmSearchCriteria::ECriteriaIdList) |
|
735 { |
|
736 res = ETrue; |
|
737 } |
|
738 } |
|
739 return res; |
|
740 } |
|
741 |
|
742 // --------------------------------------------------------- |
|
743 // CPosTp124::StartLandmarksCompositeTestL |
|
744 // |
|
745 // (other items were commented in a header). |
|
746 // --------------------------------------------------------- |
|
747 // |
|
748 void CPosTp124::StartLandmarksCompositeTestL(TExecutionMode aExecutionMode, |
|
749 TTp124SortOrder aSortOrder) |
|
750 { |
|
751 iLog->Log(_L("StartLandmarksCompositeTestL")); |
|
752 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
753 |
|
754 CCompositeSearchResult* res = CCompositeSearchResult::NewL(iLog); |
|
755 CleanupStack::PushL(res); |
|
756 |
|
757 |
|
758 |
|
759 while (!res->GetCompositeSearchResultsL(*composite)) |
|
760 { |
|
761 // Check if IdList is included in composite, if so dont |
|
762 // use this search since IdList is not possible to use in multiple db seach |
|
763 if (!CheckCompositeForIdListL(composite)) |
|
764 { |
|
765 PrintCompositeInfo(composite); |
|
766 iLog->Log(_L("iLandmarkSearch->StartLandmarkSearchL")); |
|
767 SearchL(composite, aExecutionMode, res->Redefined(), aSortOrder); |
|
768 ValidateSearchResultsL(res->iResultIds, aSortOrder); |
|
769 } |
|
770 } |
|
771 |
|
772 CleanupStack::PopAndDestroy(res); |
|
773 CleanupStack::PopAndDestroy(composite); |
|
774 iLog->Log(_L("StartLandmarksCompositeTestL Done")); |
|
775 } |
|
776 |
|
777 // --------------------------------------------------------- |
|
778 // CPosTp124::TestWithSortOrderLandmarksL |
|
779 // |
|
780 // (other items were commented in a header). |
|
781 // --------------------------------------------------------- |
|
782 // |
|
783 void CPosTp124::TestWithSortOrderLandmarksL(TExecutionMode aExecutionMode, |
|
784 TTp124SortOrder aSortOrder) |
|
785 { |
|
786 iLog->Log(_L("TestWithSortOrderLandmarksL")); |
|
787 |
|
788 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
789 TInt i=0; |
|
790 |
|
791 TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
792 |
|
793 // First create a textcriteria |
|
794 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
795 textCriteria->SetTextL(_L("*")); |
|
796 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
797 CleanupStack::Pop(textCriteria); |
|
798 |
|
799 // Then create a nearest criteria |
|
800 TCoordinate coord(12.123, -20,123); |
|
801 CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(coord, EFalse); |
|
802 User::LeaveIfError(composite->AddArgument(nearestCriteria)); |
|
803 CleanupStack::Pop(nearestCriteria); |
|
804 |
|
805 // Create search result of all landmark ids: 1-105 |
|
806 RArray<TPosLmItemId> searchResults; |
|
807 CleanupClosePushL(searchResults); |
|
808 for (i=1;i<106;i++) {searchResults.Append(i);} |
|
809 |
|
810 SearchL(composite, aExecutionMode, EFalse, aSortOrder); |
|
811 ValidateSearchResultsL(searchResults, aSortOrder); |
|
812 |
|
813 CleanupStack::PopAndDestroy(&searchResults); |
|
814 CleanupStack::PopAndDestroy(composite); |
|
815 |
|
816 } |
|
817 |
|
818 // --------------------------------------------------------- |
|
819 // CPosTp124::SearchL |
|
820 // |
|
821 // (other items were commented in a header). |
|
822 // --------------------------------------------------------- |
|
823 // |
|
824 void CPosTp124::SearchL( |
|
825 CPosLmCompositeCriteria* aCompositeSearchCriteria, |
|
826 TExecutionMode aExecutionMode, |
|
827 TBool aRefinedSearch, |
|
828 TTp124SortOrder aSortOrder) |
|
829 { |
|
830 switch (aSortOrder) |
|
831 { |
|
832 case ESortNone: |
|
833 { |
|
834 iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCompositeSearchCriteria, aRefinedSearch); |
|
835 break; |
|
836 } |
|
837 case ESortAscending: |
|
838 { |
|
839 TPosLmSortPref ascending(CPosLandmark::ELandmarkName); |
|
840 iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCompositeSearchCriteria, ascending, aRefinedSearch); |
|
841 break; |
|
842 } |
|
843 case ESortDescending: |
|
844 { |
|
845 TPosLmSortPref descending(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); |
|
846 iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCompositeSearchCriteria, descending, aRefinedSearch); |
|
847 break; |
|
848 } |
|
849 case ESortDistance: |
|
850 { |
|
851 iOperation = iMultiDbSearch->StartLandmarkSearchL(*aCompositeSearchCriteria, aRefinedSearch); |
|
852 break; |
|
853 } |
|
854 default: |
|
855 { |
|
856 User::Leave(KErrArgument); |
|
857 break; |
|
858 } |
|
859 } |
|
860 |
|
861 switch (aExecutionMode) |
|
862 { |
|
863 case ESynchronous: |
|
864 ExecuteAndDeleteLD(iOperation); |
|
865 break; |
|
866 case EAsynchronous: |
|
867 RunAsyncOperationLD(iOperation); |
|
868 break; |
|
869 default: |
|
870 User::Leave(KErrArgument); |
|
871 break; |
|
872 } |
|
873 } |
|
874 |
|
875 // --------------------------------------------------------- |
|
876 // CPosTp124::TestSeveralTextArgumentsL |
|
877 // |
|
878 // (other items were commented in a header). |
|
879 // --------------------------------------------------------- |
|
880 // |
|
881 void CPosTp124::TestSeveralTextArgumentsL() |
|
882 { |
|
883 iLog->Log(_L("TestSeveralTextArgumentsL")); |
|
884 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
885 |
|
886 // >>>>>>> Test different text criterias <<<<<<<<<< |
|
887 // First create a textcriteria |
|
888 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
889 textCriteria->SetTextL(_L("Nokia*")); |
|
890 TInt err = composite->AddArgument(textCriteria); |
|
891 if (err != KErrNone) |
|
892 { |
|
893 iLog->Log(_L("Error when adding argument1")); |
|
894 User::Leave(err); |
|
895 } |
|
896 CleanupStack::Pop(textCriteria); |
|
897 |
|
898 // First create a textcriteria |
|
899 CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); |
|
900 textCriteria2->SetTextL(_L("*Stockholm")); |
|
901 err = composite->AddArgument(textCriteria2); |
|
902 if (err != KErrNone) |
|
903 { |
|
904 iLog->Log(_L("Error when adding argument2")); |
|
905 User::Leave(err); |
|
906 } |
|
907 CleanupStack::Pop(textCriteria2); |
|
908 |
|
909 // Should find landmark id: 63 name: "Nokia, Stockholm" |
|
910 iLog->Log(_L("iMultiDbSearch->StartLandmarkSearchL")); |
|
911 RIdArray expectedIds; |
|
912 CleanupClosePushL(expectedIds); |
|
913 User::LeaveIfError(expectedIds.Append(63)); |
|
914 |
|
915 SearchL(composite, EAsynchronous, EFalse, ESortAscending); |
|
916 ValidateSearchResultsL(expectedIds, ESortAscending); |
|
917 composite->ClearArguments(); |
|
918 |
|
919 // >>>>>>> Test same text as criterias in composite <<<<<<< |
|
920 textCriteria = CPosLmTextCriteria::NewLC(); |
|
921 textCriteria->SetTextL(_L("Text9")); |
|
922 err = composite->AddArgument(textCriteria); |
|
923 if (err != KErrNone) |
|
924 { |
|
925 iLog->Log(_L("Error when adding argument1")); |
|
926 User::Leave(err); |
|
927 } |
|
928 CleanupStack::Pop(textCriteria); |
|
929 |
|
930 // First create a textcriteria |
|
931 textCriteria2 = CPosLmTextCriteria::NewLC(); |
|
932 textCriteria2->SetTextL(_L("Text9")); |
|
933 err = composite->AddArgument(textCriteria2); |
|
934 if (err != KErrNone) |
|
935 { |
|
936 iLog->Log(_L("Error when adding argument2")); |
|
937 User::Leave(err); |
|
938 } |
|
939 CleanupStack::Pop(textCriteria2); |
|
940 expectedIds.Reset(); |
|
941 // Should find landmark id: 39 name: Text9 |
|
942 iLog->Log(_L("iMultiDbSearch->StartLandmarkSearchL")); |
|
943 User::LeaveIfError(expectedIds.Append(39)); |
|
944 |
|
945 SearchL(composite, EAsynchronous, EFalse, ESortDescending); |
|
946 ValidateSearchResultsL(expectedIds, ESortDescending); |
|
947 |
|
948 CleanupStack::PopAndDestroy(&expectedIds); |
|
949 CleanupStack::PopAndDestroy(composite); |
|
950 iDisplayData->Reset(); |
|
951 } |
|
952 |
|
953 // --------------------------------------------------------- |
|
954 // CPosTp124::TestAddAndRemoveL |
|
955 // |
|
956 // (other items were commented in a header). |
|
957 // --------------------------------------------------------- |
|
958 // |
|
959 void CPosTp124::TestAddAndRemoveL() |
|
960 { |
|
961 iLog->Log(_L("TestAddAndRemoveL")); |
|
962 |
|
963 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
964 |
|
965 // Add a text criteria |
|
966 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
967 textCriteria->SetTextL(_L("PELLE")); |
|
968 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
969 CleanupStack::Pop(textCriteria); |
|
970 |
|
971 // Test that ClearArguments is correct |
|
972 composite->ClearArguments(); |
|
973 |
|
974 if (composite->NumOfArguments() != 0) |
|
975 { |
|
976 iLog->Log(_L("Wrong number of arguments")); |
|
977 User::Leave(-1); |
|
978 } |
|
979 |
|
980 // 1) Add a text criteria |
|
981 textCriteria = CPosLmTextCriteria::NewLC(); |
|
982 textCriteria->SetTextL(_L("*")); |
|
983 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
984 CleanupStack::Pop(textCriteria); |
|
985 |
|
986 // 2) Add a text criteria |
|
987 textCriteria = CPosLmTextCriteria::NewLC(); |
|
988 textCriteria->SetTextL(_L("Natur*")); |
|
989 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
990 CleanupStack::Pop(textCriteria); |
|
991 |
|
992 // 3) Add an area criteria |
|
993 CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(-12.23, 34.4, -2.05, 45.5); |
|
994 User::LeaveIfError(composite->AddArgument(areaCriteria)); |
|
995 CleanupStack::Pop(areaCriteria); |
|
996 |
|
997 // 4) Add a category criteria |
|
998 CPosLmCategoryCriteria* catCriteria = CPosLmCategoryCriteria::NewLC(); |
|
999 catCriteria->SetCategoryNameL(_L("Museum")); |
|
1000 User::LeaveIfError(composite->AddArgument(catCriteria)); |
|
1001 CleanupStack::Pop(catCriteria); |
|
1002 |
|
1003 // 5) Add a nearest criteria |
|
1004 TCoordinate cord(12.23, 12); |
|
1005 CPosLmNearestCriteria* nearestCriteria = CPosLmNearestCriteria::NewLC(cord, ETrue); |
|
1006 User::LeaveIfError(composite->AddArgument(nearestCriteria)); |
|
1007 CleanupStack::Pop(nearestCriteria); |
|
1008 |
|
1009 if (composite->NumOfArguments() != 5) |
|
1010 { |
|
1011 iLog->Log(_L("Wrong number of arguments")); |
|
1012 User::Leave(-1); |
|
1013 } |
|
1014 |
|
1015 // Remove (3) area criteria |
|
1016 CPosLmSearchCriteria* obj1 = composite->RemoveArgument(2); |
|
1017 delete obj1;obj1 = NULL; |
|
1018 |
|
1019 // Remove (5) nearest criteria (after 3 removed it has id 4) |
|
1020 CPosLmSearchCriteria* obj2 = composite->RemoveArgument(3); |
|
1021 delete obj2;obj2 = NULL; |
|
1022 |
|
1023 RIdArray expectedIds; |
|
1024 CleanupClosePushL(expectedIds); |
|
1025 |
|
1026 // Should find landmark with id: 87 name: "Naturhistoriska" |
|
1027 User::LeaveIfError(expectedIds.Append(87)); |
|
1028 SearchL(composite, EAsynchronous, EFalse, ESortAscending); |
|
1029 ValidateSearchResultsL(expectedIds, ESortAscending); |
|
1030 |
|
1031 // Remove (1) first text criteria |
|
1032 CPosLmSearchCriteria* obj4 = composite->RemoveArgument(0); |
|
1033 delete obj4; obj4 = NULL; |
|
1034 |
|
1035 // Remove (2) the second text criteria |
|
1036 CPosLmSearchCriteria* obj3 = composite->RemoveArgument(0); |
|
1037 delete obj3; obj3 = NULL; |
|
1038 |
|
1039 expectedIds.Reset(); |
|
1040 // Should find six landmarks belonging to category "museum", |
|
1041 User::LeaveIfError(expectedIds.Append(22)); |
|
1042 User::LeaveIfError(expectedIds.Append(84)); |
|
1043 User::LeaveIfError(expectedIds.Append(85)); |
|
1044 User::LeaveIfError(expectedIds.Append(86)); |
|
1045 User::LeaveIfError(expectedIds.Append(87)); |
|
1046 User::LeaveIfError(expectedIds.Append(89)); |
|
1047 |
|
1048 SearchL(composite, EAsynchronous, EFalse, ESortNone); |
|
1049 ValidateSearchResultsL(expectedIds, ESortNone); |
|
1050 |
|
1051 CleanupStack::PopAndDestroy(&expectedIds); |
|
1052 CleanupStack::PopAndDestroy(composite); |
|
1053 |
|
1054 iLog->Log(_L("TestAddAndRemoveL Done")); |
|
1055 } |
|
1056 |
|
1057 // --------------------------------------------------------- |
|
1058 // CPosTp124::ValidateSearchResultsL |
|
1059 // |
|
1060 // (other items were commented in a header). |
|
1061 // --------------------------------------------------------- |
|
1062 // |
|
1063 void CPosTp124::ValidateSearchResultsL( |
|
1064 RIdArray& aExpectedIds, TTp124SortOrder aSortOrder, |
|
1065 TInt aNrOfExpectedErrors) |
|
1066 { |
|
1067 iLog->Log(_L("ValidateSearchResultsL")); |
|
1068 |
|
1069 _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results"); |
|
1070 _LIT(KNotFoundErr2, "Id %d not found in search result from displaydata"); |
|
1071 _LIT(KNrOfMatchError, "Nr of matches from DisplayData is not correct"); |
|
1072 _LIT(KNrOfMatchError2, "Expected matches is not correct"); |
|
1073 |
|
1074 TBuf<100> buf; |
|
1075 |
|
1076 TInt nrOfMatches = 0; |
|
1077 // list of databases to search in |
|
1078 CDesCArray* dbList = new (ELeave) CDesCArrayFlat(5); |
|
1079 CleanupStack::PushL(dbList); |
|
1080 dbList->AppendL(KLMDB1); |
|
1081 dbList->AppendL(KLMDB2); |
|
1082 dbList->AppendL(KLMDB3); |
|
1083 dbList->AppendL(KLMDB4); |
|
1084 dbList->AppendL(KLMDB5); |
|
1085 TInt dbListCount = dbList->Count(); |
|
1086 for (TInt j = 0; j < dbListCount; j++) |
|
1087 { |
|
1088 // CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*iDatabases)[j]); |
|
1089 CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL((*dbList)[j]); |
|
1090 CleanupStack::PushL(db); |
|
1091 CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); |
|
1092 CleanupStack::PushL(iter); |
|
1093 |
|
1094 nrOfMatches += iter->NumOfItemsL(); |
|
1095 TPosLmItemId id = iter->NextL(); |
|
1096 while (id != KPosLmNullItemId) |
|
1097 { |
|
1098 buf.Format(_L("Found idde %d in db %d"), id, j); |
|
1099 //iLog->Log(buf); |
|
1100 ValidateIdL(id, j); |
|
1101 AssertTrueSecL(aExpectedIds.Find(id) != KErrNotFound, KNotFoundErr, id); |
|
1102 |
|
1103 CPosLandmark* lm1 = db->ReadLandmarkLC(id); |
|
1104 id = iter->NextL(); |
|
1105 // Check sort order in every iterator |
|
1106 if (aSortOrder != ESortNone && aSortOrder != ESortDistance && id != KPosLmNullItemId) |
|
1107 { |
|
1108 CPosLandmark* lm2 = db->ReadLandmarkLC(id); |
|
1109 TPtrC name1, name2; |
|
1110 lm1->GetLandmarkName(name1); |
|
1111 lm2->GetLandmarkName(name2); |
|
1112 |
|
1113 if (aSortOrder == ESortAscending) |
|
1114 { |
|
1115 AssertTrueSecL(name1.CompareC(name2) <= 0, _L("Not sorted ascending as expected")); |
|
1116 } |
|
1117 else if (aSortOrder == ESortDescending) |
|
1118 { |
|
1119 AssertTrueSecL(name1.CompareC(name2) >= 0, _L("Not sorted descending as expected")); |
|
1120 } |
|
1121 CleanupStack::PopAndDestroy(lm2); |
|
1122 } |
|
1123 CleanupStack::PopAndDestroy(lm1); |
|
1124 } |
|
1125 |
|
1126 // Now check that iterator is sorted on distance |
|
1127 if (aSortOrder == ESortDistance) |
|
1128 { |
|
1129 iter->Reset(); |
|
1130 RArray<TPosLmItemId> result; |
|
1131 CleanupClosePushL(result); |
|
1132 |
|
1133 if (iter->NumOfItemsL() > 0) |
|
1134 { |
|
1135 iter->GetItemIdsL(result,0, iter->NumOfItemsL()); |
|
1136 LandmarksSortL(result, aSortOrder); |
|
1137 TPosLmItemId idde = iter->NextL(); |
|
1138 TInt index=0; |
|
1139 while (idde != KPosLmNullItemId) |
|
1140 { |
|
1141 iLog->Log(_L("##### Check iterator sorted on distance")); |
|
1142 AssertTrueSecL(idde == result[index], _L("Iterator is not sorted on distance")); |
|
1143 index++; |
|
1144 idde = iter->NextL(); |
|
1145 } |
|
1146 } |
|
1147 CleanupStack::PopAndDestroy(&result); |
|
1148 } |
|
1149 |
|
1150 CleanupStack::PopAndDestroy(iter); |
|
1151 CleanupStack::PopAndDestroy(db); |
|
1152 } |
|
1153 |
|
1154 AssertTrueSecL(nrOfMatches == iMultiDbSearch->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators")); |
|
1155 AssertTrueSecL(NrOfSearchErrors(iMultiDbSearch) == aNrOfExpectedErrors, _L("Found search errors!")); |
|
1156 AssertTrueSecL(nrOfMatches == iDisplayData->Count(), KNrOfMatchError); |
|
1157 AssertTrueSecL(aExpectedIds.Count() == iDisplayData->Count(), KNrOfMatchError2); |
|
1158 |
|
1159 TInt itemId = iDisplayData->NewItemIndex(); |
|
1160 while (itemId != KPosLmNoNewItems) |
|
1161 { |
|
1162 CPosLmDisplayItem& item1 = iDisplayData->DisplayItem(itemId); |
|
1163 TInt lmId = item1.Landmark().LandmarkId(); |
|
1164 TPtrC name1; |
|
1165 item1.Landmark().GetLandmarkName(name1); |
|
1166 TInt dbIndex = item1.DatabaseIndex(); |
|
1167 // Validate lm from correct db |
|
1168 ValidateIdL(lmId, dbIndex); |
|
1169 |
|
1170 buf.Format(_L("LM id: %d"), lmId); |
|
1171 //iLog->Log(buf); |
|
1172 AssertTrueSecL(aExpectedIds.Find(lmId) != KErrNotFound, KNotFoundErr2, lmId); |
|
1173 itemId = iDisplayData->NewItemIndex(); |
|
1174 if (itemId != KPosLmNoNewItems) |
|
1175 { |
|
1176 CPosLmDisplayItem& item2 = iDisplayData->DisplayItem(itemId); |
|
1177 lmId = item2.Landmark().LandmarkId(); |
|
1178 TPtrC name2; |
|
1179 lmId = item2.Landmark().LandmarkId(); |
|
1180 dbIndex = item2.DatabaseIndex(); |
|
1181 // Validate lm from correct db |
|
1182 ValidateIdL(lmId, dbIndex); |
|
1183 |
|
1184 item2.Landmark().GetLandmarkName(name2); |
|
1185 AssertTrueSecL(aExpectedIds.Find(lmId) != KErrNotFound, KNotFoundErr2, lmId); |
|
1186 |
|
1187 // Check sort order for display data items |
|
1188 if (aSortOrder == ESortAscending) |
|
1189 { |
|
1190 AssertTrueSecL(name1.CompareC(name2) <= 0, _L("Not sorted ascending as expected")); |
|
1191 } |
|
1192 else if (aSortOrder == ESortDescending) |
|
1193 { |
|
1194 AssertTrueSecL(name1.CompareC(name2) >= 0, _L("Not sorted descending as expected")); |
|
1195 } |
|
1196 } |
|
1197 } |
|
1198 |
|
1199 if (aSortOrder == ESortDistance) |
|
1200 { |
|
1201 iLog->Log(_L("##### Check sorted on distance")); |
|
1202 LandmarksSortL(aExpectedIds, aSortOrder); |
|
1203 for (TInt i=0;i<aExpectedIds.Count();i++) |
|
1204 { |
|
1205 CPosLmDisplayItem& item1 = iDisplayData->DisplayItem(i); |
|
1206 TInt lmId = item1.Landmark().LandmarkId(); |
|
1207 if (aExpectedIds[i] != lmId) |
|
1208 { |
|
1209 buf.Format(_L("Incorrect distance sorting Id1 %d Id2 %d"),aExpectedIds[i], lmId ); |
|
1210 //iLog->Log(buf); |
|
1211 iLog->Log(buf); |
|
1212 User::Leave(-1); |
|
1213 } |
|
1214 } |
|
1215 } |
|
1216 CleanupStack::PopAndDestroy(dbList); |
|
1217 } |
|
1218 |
|
1219 // --------------------------------------------------------- |
|
1220 // CPosTp124::NrOfSearchErrors |
|
1221 // |
|
1222 // (other items were commented in a header). |
|
1223 // --------------------------------------------------------- |
|
1224 // |
|
1225 TInt CPosTp124::NrOfSearchErrors(CPosLmMultiDbSearch* aMultiDbSearcher) |
|
1226 { |
|
1227 TInt nrOfSearchErrors = aMultiDbSearcher->NumOfSearchErrors(); |
|
1228 if (nrOfSearchErrors != 0) |
|
1229 { |
|
1230 for (TInt i = 0; i < nrOfSearchErrors; i++) |
|
1231 { |
|
1232 CPosLmMultiDbSearch::TSearchError error; |
|
1233 aMultiDbSearcher->GetSearchError(i, error); |
|
1234 TBuf<100> msg; |
|
1235 msg.Format(_L("Found error %d in database %d"), error.iErrorCode, error.iDatabaseIndex); |
|
1236 iLog->Log(msg); |
|
1237 } |
|
1238 } |
|
1239 return nrOfSearchErrors; |
|
1240 } |
|
1241 |
|
1242 // --------------------------------------------------------- |
|
1243 // Tp124InternalLandmarksSortL |
|
1244 // |
|
1245 // (other items were commented in a header). |
|
1246 // --------------------------------------------------------- |
|
1247 // |
|
1248 TInt Tp124InternalLandmarksSortL(const CPosLandmark& aSource, const CPosLandmark& aTarget) |
|
1249 { |
|
1250 // NOTE: Always sorted on distance to TCoordinate iCoord(45.5, 0.5); |
|
1251 TLocality loc1; |
|
1252 TLocality loc2; |
|
1253 |
|
1254 aSource.GetPosition(loc1); |
|
1255 aTarget.GetPosition(loc2); |
|
1256 TReal32 distance1, distance2; |
|
1257 // Not nice, ugly hardcoded |
|
1258 TCoordinate iCoord(45.5, 0.5); |
|
1259 loc1.Distance(iCoord, distance1); |
|
1260 loc2.Distance(iCoord, distance2); |
|
1261 |
|
1262 iCoord.Distance(loc1, distance1); |
|
1263 iCoord.Distance(loc2, distance2); |
|
1264 |
|
1265 TInt res = distance1-distance2; |
|
1266 |
|
1267 return res; |
|
1268 } |
|
1269 |
|
1270 // --------------------------------------------------------- |
|
1271 // CPosTp124::LandmarksSortL |
|
1272 // |
|
1273 // (other items were commented in a header). |
|
1274 // --------------------------------------------------------- |
|
1275 // |
|
1276 void CPosTp124::LandmarksSortL(RArray<TPosLmItemId>& aArray, TTp124SortOrder aSortOrder) |
|
1277 { |
|
1278 iLog->Log(_L("LandmarksSortL")); |
|
1279 |
|
1280 RPointerArray<CPosLandmark> landmarks; |
|
1281 CleanupClosePushL(landmarks); |
|
1282 |
|
1283 for (TInt i=0; i<aArray.Count(); i++) |
|
1284 { |
|
1285 CPosLandmark* lm = iDatabase->ReadLandmarkLC(aArray[i]); |
|
1286 landmarks.Append(lm); |
|
1287 CleanupStack::Pop(lm); |
|
1288 } |
|
1289 |
|
1290 // Sort on distance, possible to add a ascending and descending sort here as well |
|
1291 // if needed |
|
1292 TLinearOrder<CPosLandmark> order(Tp124InternalLandmarksSortL); |
|
1293 landmarks.Sort(order); |
|
1294 aArray.Reset(); |
|
1295 if (aSortOrder == ESortDistance) |
|
1296 { |
|
1297 for (TInt j=0; j<landmarks.Count(); j++) |
|
1298 { |
|
1299 aArray.Append(landmarks[j]->LandmarkId()); |
|
1300 } |
|
1301 } |
|
1302 |
|
1303 |
|
1304 landmarks.ResetAndDestroy(); |
|
1305 CleanupStack::PopAndDestroy(&landmarks); |
|
1306 } |
|
1307 |
|
1308 // --------------------------------------------------------- |
|
1309 // CPosTp124::CancelTestL |
|
1310 // |
|
1311 // (other items were commented in a header). |
|
1312 // --------------------------------------------------------- |
|
1313 // |
|
1314 void CPosTp124::CancelTestL(const TBool& aCancelInCallback) |
|
1315 { |
|
1316 iLog->Log(_L("CancelTestL")); |
|
1317 |
|
1318 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
1319 |
|
1320 CCompositeSearchResult* res = CCompositeSearchResult::NewL(iLog); |
|
1321 CleanupStack::PushL(res); |
|
1322 |
|
1323 // Get first composite search from lmDbCompositeSearchResult.txt |
|
1324 res->GetCompositeSearchResultsL(*composite); |
|
1325 |
|
1326 // Cancel in callback, cancel in every progress step phase |
|
1327 // when progress has increased with 0.09 |
|
1328 if (aCancelInCallback) |
|
1329 { |
|
1330 iLog->Log(_L("Cancel in Callback")); |
|
1331 TReal32 progress(0); |
|
1332 while (progress < 1.0) |
|
1333 { |
|
1334 RunAsyncOperationAndCancelInCallbackLD( |
|
1335 iMultiDbSearch->StartLandmarkSearchL( |
|
1336 *composite, |
|
1337 EFalse), |
|
1338 progress); |
|
1339 |
|
1340 TInt nrOfMatches = 0; |
|
1341 for (TInt j = 0; j < iNrOfDatabases; j++) |
|
1342 { |
|
1343 CPosLmItemIterator* iter = iMultiDbSearch->MatchIteratorL(j); |
|
1344 CleanupStack::PushL(iter); |
|
1345 nrOfMatches += iter->NumOfItemsL(); |
|
1346 CleanupStack::PopAndDestroy(iter); |
|
1347 } |
|
1348 AssertTrueSecL(nrOfMatches == iMultiDbSearch->TotalNumOfMatches(), _L("Total nr of matches doesn't match sum of matches in iterators when cancelling")); |
|
1349 //AssertTrueSecL(iMultiDbSearch->TotalNumOfMatches() == iDisplayData->Count(),_L("Wrong number of matches after cancel")); |
|
1350 |
|
1351 progress = progress + 0.09; |
|
1352 } |
|
1353 } |
|
1354 else |
|
1355 { |
|
1356 // Cancel immediately |
|
1357 iLog->Log(_L("Cancel immediately")); |
|
1358 RunAsyncOperationAndCancelLD( |
|
1359 iMultiDbSearch->StartLandmarkSearchL( |
|
1360 *composite, |
|
1361 EFalse)); |
|
1362 |
|
1363 AssertTrueSecL(iMultiDbSearch->TotalNumOfMatches() == iDisplayData->Count(),_L("Wrong number of matches after cancel")); |
|
1364 } |
|
1365 |
|
1366 if (iMultiDbSearch->NumOfSearchErrors() != 0) iLog->Log(_L("Errors after search")); |
|
1367 for (TInt i=0;i<iMultiDbSearch->NumOfSearchErrors(); i++) |
|
1368 { |
|
1369 CPosLmMultiDbSearch::TSearchError searchErr; |
|
1370 iMultiDbSearch->GetSearchError(i, searchErr); |
|
1371 TBuf<150> buf; |
|
1372 buf.Format(_L("ErrorCode %d returned from db nr %d"),searchErr.iErrorCode, searchErr.iDatabaseIndex); |
|
1373 iLog->Log(buf); |
|
1374 } |
|
1375 |
|
1376 CleanupStack::PopAndDestroy(res); |
|
1377 CleanupStack::PopAndDestroy(composite); |
|
1378 } |
|
1379 |
|
1380 // --------------------------------------------------------- |
|
1381 // CPosTp124::CompositeStressTestL |
|
1382 // |
|
1383 // (other items were commented in a header). |
|
1384 // --------------------------------------------------------- |
|
1385 // |
|
1386 void CPosTp124::CompositeStressTestL(TInt aStartNr, TInt aTotalNr) |
|
1387 { |
|
1388 iLog->Log(_L("CompositeStressTestL")); |
|
1389 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
1390 TInt i=0; |
|
1391 |
|
1392 for (i=0;i<aTotalNr;i++) |
|
1393 { |
|
1394 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
1395 textCriteria->SetTextL(_L("*")); |
|
1396 |
|
1397 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
1398 CleanupStack::Pop(textCriteria); |
|
1399 |
|
1400 if (i>aStartNr) |
|
1401 { |
|
1402 SearchL(composite, EAsynchronous, EFalse, ESortAscending); |
|
1403 TBuf<100> buf; |
|
1404 buf.Format(_L("Found %d nr of matches"), iDisplayData->Count()); |
|
1405 iLog->Log(buf); |
|
1406 } |
|
1407 } |
|
1408 |
|
1409 TInt antal = composite->NumOfArguments(); |
|
1410 if (antal != aTotalNr) iLog->Log(_L("nr of composite arguments is incorrect")); |
|
1411 |
|
1412 TBuf<100> buf; |
|
1413 buf.Format(_L("Found %d nr of matches"), iDisplayData->Count()); |
|
1414 iLog->Log(buf); |
|
1415 |
|
1416 TInt itemId = iDisplayData->NewItemIndex(); |
|
1417 while (itemId != KPosLmNoNewItems) |
|
1418 { |
|
1419 CPosLmDisplayItem& item1 = iDisplayData->DisplayItem(itemId); |
|
1420 TInt lmId = item1.Landmark().LandmarkId(); |
|
1421 TPtrC name1; |
|
1422 item1.Landmark().GetLandmarkName(name1); |
|
1423 TInt dbIndex = item1.DatabaseIndex(); |
|
1424 // Validate lm from correct db |
|
1425 ValidateIdL(lmId, dbIndex); |
|
1426 buf.Format(_L("LM id: %d from DB %d"), lmId, dbIndex); |
|
1427 iLog->Log(buf); |
|
1428 itemId = iDisplayData->NewItemIndex(); |
|
1429 } |
|
1430 |
|
1431 // 105 is the total number of landmarks in the five dbs |
|
1432 if (iDisplayData->Count() != 105) |
|
1433 { |
|
1434 iLog->Log(_L("Wrong number of matches found")); |
|
1435 User::Leave(-1); |
|
1436 } |
|
1437 |
|
1438 CleanupStack::PopAndDestroy(composite); |
|
1439 } |
|
1440 |
|
1441 // --------------------------------------------------------- |
|
1442 // CPosTp124::TestWithNoPreviousResultL |
|
1443 // |
|
1444 // (other items were commented in a header). |
|
1445 // --------------------------------------------------------- |
|
1446 // |
|
1447 void CPosTp124::TestWithNoPreviousResultL() |
|
1448 { |
|
1449 iLog->Log(_L("TestWithNoPreviousResultL")); |
|
1450 |
|
1451 if (iMultiDbSearch) iMultiDbSearch->UnsetDisplayData(); |
|
1452 delete iDisplayData; |
|
1453 iDisplayData = NULL; |
|
1454 delete iMultiDbSearch; |
|
1455 iMultiDbSearch = CPosLmMultiDbSearch::NewL(*iDatabases); |
|
1456 |
|
1457 iDisplayData = CPosLmDisplayData::NewL(); |
|
1458 iMultiDbSearch->SetDisplayData(*iDisplayData); |
|
1459 |
|
1460 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
1461 |
|
1462 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
1463 textCriteria->SetTextL(_L("*")); |
|
1464 |
|
1465 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
1466 CleanupStack::Pop(textCriteria); |
|
1467 |
|
1468 // No previous result-> should leave with KErrArgument |
|
1469 TRAPD(err, SearchL(composite, EAsynchronous, ETrue, ESortAscending)); |
|
1470 if (err != KErrArgument) |
|
1471 { |
|
1472 iLog->Log(_L("It should not be possible to search when no previous result has been retrieved")); |
|
1473 User::Leave(err); |
|
1474 } |
|
1475 |
|
1476 CleanupStack::PopAndDestroy(composite); |
|
1477 } |
|
1478 |
|
1479 // --------------------------------------------------------- |
|
1480 // CPosTp124::TestWithIdListAndCompositeL |
|
1481 // |
|
1482 // (other items were commented in a header). |
|
1483 // --------------------------------------------------------- |
|
1484 // |
|
1485 void CPosTp124::TestWithIdListAndCompositeL() |
|
1486 { |
|
1487 iLog->Log(_L("TestWithIdListAndCompositeL")); |
|
1488 |
|
1489 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
1490 |
|
1491 // First create a textcriteria |
|
1492 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
1493 textCriteria->SetTextL(_L("Nokia*")); |
|
1494 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
1495 CleanupStack::Pop(textCriteria); |
|
1496 |
|
1497 // Then create an IdList |
|
1498 CPosLmIdListCriteria* idList = CPosLmIdListCriteria::NewLC(); |
|
1499 RIdArray ids; |
|
1500 CleanupClosePushL(ids); |
|
1501 User::LeaveIfError(ids.Append(63)); |
|
1502 User::LeaveIfError(ids.Append(33)); |
|
1503 idList->SetLandmarkIdsL(ids); |
|
1504 CleanupStack::PopAndDestroy(&ids); |
|
1505 |
|
1506 User::LeaveIfError(composite->AddArgument(idList)); |
|
1507 CleanupStack::Pop(idList); |
|
1508 |
|
1509 // It is not possible to use IdList in combination with composite in multiple db search |
|
1510 TRAPD(err, SearchL(composite, EAsynchronous, EFalse, ESortAscending)); |
|
1511 if (err != KErrArgument) |
|
1512 { |
|
1513 iLog->Log(_L("It should not be possible to use CPosLmIdListCriteria in a composite search")); |
|
1514 User::Leave(err); |
|
1515 |
|
1516 } |
|
1517 |
|
1518 CleanupStack::PopAndDestroy(composite); |
|
1519 iDisplayData->Reset(); |
|
1520 } |
|
1521 |
|
1522 // --------------------------------------------------------- |
|
1523 // CPosTp124::TestCategoryCompositeSearchL |
|
1524 // |
|
1525 // (other items were commented in a header). |
|
1526 // --------------------------------------------------------- |
|
1527 // |
|
1528 void CPosTp124::TestCategoryCompositeSearchL() |
|
1529 { |
|
1530 iLog->Log(_L("TestCategoryCompositeSearchL")); |
|
1531 |
|
1532 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
1533 |
|
1534 // It should not be possible to add a CPosLmCatNameCriteria to composite |
|
1535 CPosLmCatNameCriteria* nameCriteria = CPosLmCatNameCriteria::NewLC(); |
|
1536 nameCriteria->SetSearchPatternL(_L("*")); |
|
1537 TInt err = composite->AddArgument(nameCriteria); |
|
1538 if (err != KErrNotSupported) |
|
1539 { |
|
1540 iLog->Log(_L("It should not be possible to use CPosLmIdListCriteria in a composite search")); |
|
1541 User::Leave(err); |
|
1542 |
|
1543 } |
|
1544 CleanupStack::PopAndDestroy(nameCriteria); |
|
1545 |
|
1546 // Test once more |
|
1547 CPosLmCatNameCriteria* nameCriteria2 = CPosLmCatNameCriteria::NewLC(); |
|
1548 nameCriteria2->SetSearchPatternL(_L("*kontor")); |
|
1549 err = composite->AddArgument(nameCriteria2); |
|
1550 if (err != KErrNotSupported) |
|
1551 { |
|
1552 iLog->Log(_L("It should not be possible to use CPosLmIdListCriteria in a composite search")); |
|
1553 User::Leave(err); |
|
1554 |
|
1555 } |
|
1556 CleanupStack::PopAndDestroy(nameCriteria2); |
|
1557 |
|
1558 CleanupStack::PopAndDestroy(composite); |
|
1559 } |
|
1560 |
|
1561 // --------------------------------------------------------- |
|
1562 // CPosTp124::TestCompositeInCompositeL |
|
1563 // |
|
1564 // (other items were commented in a header). |
|
1565 // --------------------------------------------------------- |
|
1566 // |
|
1567 void CPosTp124::TestCompositeInCompositeL() |
|
1568 { |
|
1569 iLog->Log(_L("TestCompositeInCompositeL")); |
|
1570 CPosLmCompositeCriteria* composite = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
1571 |
|
1572 // First create a textcriteria |
|
1573 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
1574 |
|
1575 textCriteria->SetTextL(_L("*")); |
|
1576 |
|
1577 User::LeaveIfError(composite->AddArgument(textCriteria)); |
|
1578 CleanupStack::Pop(textCriteria); |
|
1579 |
|
1580 CPosLmAreaCriteria* areaCriteria = CPosLmAreaCriteria::NewLC(-48, 5, -5, 20); |
|
1581 |
|
1582 User::LeaveIfError(composite->AddArgument(areaCriteria)); |
|
1583 CleanupStack::Pop(areaCriteria); |
|
1584 |
|
1585 //Create composite object that should be used as argument to the first composite object |
|
1586 CPosLmCompositeCriteria* composite2 = CPosLmCompositeCriteria::NewLC(CPosLmCompositeCriteria::ECompositionAND); |
|
1587 |
|
1588 CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); |
|
1589 textCriteria2->SetTextL(_L("TE,*")); |
|
1590 |
|
1591 User::LeaveIfError(composite2->AddArgument(textCriteria2)); |
|
1592 CleanupStack::Pop(textCriteria2); |
|
1593 |
|
1594 //User::LeaveIfError(composite->AddArgument(composite2)); |
|
1595 TInt res = composite->AddArgument(composite2); |
|
1596 if (res != KErrNotSupported) |
|
1597 { |
|
1598 iLog->Log(_L("It should not be possible to add to a composite ")); |
|
1599 User::Leave(-1); |
|
1600 |
|
1601 } |
|
1602 |
|
1603 CleanupStack::PopAndDestroy(composite2); |
|
1604 |
|
1605 |
|
1606 CleanupStack::PopAndDestroy(composite); |
|
1607 |
|
1608 iLog->Log(_L("TestCompositeInCompositeL Done")); |
|
1609 |
|
1610 } |
|
1611 |
|
1612 // --------------------------------------------------------- |
|
1613 // CPosTp124::PrintCompositeInfo |
|
1614 // |
|
1615 // (other items were commented in a header). |
|
1616 // --------------------------------------------------------- |
|
1617 // |
|
1618 void CPosTp124::PrintCompositeInfo(CPosLmCompositeCriteria* aComposite) |
|
1619 { |
|
1620 TBuf<100> buf; |
|
1621 buf.Format(_L("PrintCompositeInfo() NrOfArg %d"), aComposite->NumOfArguments()); |
|
1622 iLog->Log(buf); |
|
1623 |
|
1624 for (TUint i=0;i<aComposite->NumOfArguments();i++) |
|
1625 { |
|
1626 |
|
1627 CPosLmSearchCriteria& comp = aComposite->Argument(i); |
|
1628 TInt type = comp.CriteriaType(); |
|
1629 |
|
1630 if (type == CPosLmSearchCriteria::ECriteriaArea) |
|
1631 { |
|
1632 iLog->Log(_L("Arg Area found")); |
|
1633 |
|
1634 CPosLmAreaCriteria& tt = static_cast<CPosLmAreaCriteria&>(comp); |
|
1635 |
|
1636 TReal64 southLat; |
|
1637 TReal64 northLat; |
|
1638 TReal64 westLong; |
|
1639 TReal64 eastLong; |
|
1640 |
|
1641 tt.GetSearchArea(southLat, northLat, westLong, eastLong); |
|
1642 |
|
1643 buf.Format(_L("SouthL %f NorthL: %f WestL :%f EastL: %f"), (TReal)southLat, (TReal)northLat, (TReal)westLong, (TReal)eastLong); |
|
1644 iLog->Log(buf); |
|
1645 |
|
1646 } |
|
1647 else if (type == CPosLmSearchCriteria::ECriteriaText) |
|
1648 { |
|
1649 iLog->Log(_L("Arg Text found:")); |
|
1650 CPosLmTextCriteria& tt = static_cast<CPosLmTextCriteria&>(comp); |
|
1651 iLog->Log(tt.Text()); |
|
1652 } |
|
1653 else if (type == CPosLmSearchCriteria::ECriteriaComposite) |
|
1654 { |
|
1655 iLog->Log(_L("Arg Composite found")); |
|
1656 } |
|
1657 else if (type == CPosLmSearchCriteria::ECriteriaCategory) |
|
1658 { |
|
1659 iLog->Log(_L("Arg Category found")); |
|
1660 |
|
1661 CPosLmCategoryCriteria& tt = static_cast<CPosLmCategoryCriteria&>(comp); |
|
1662 iLog->Log(tt.CategoryName()); |
|
1663 } |
|
1664 else if (type == CPosLmSearchCriteria::ECriteriaFindNearest) |
|
1665 { |
|
1666 CPosLmNearestCriteria& tt = static_cast<CPosLmNearestCriteria&>(comp); |
|
1667 TCoordinate cord; |
|
1668 tt.GetCoordinate(cord); |
|
1669 iLog->Log(_L("Arg Nearest found")); |
|
1670 buf.Format(_L("Latitude %f Longitude: %f MaxDist:%f"), (TReal)cord.Latitude(), (TReal)cord.Longitude(), (TReal)tt.MaxDistance()); |
|
1671 iLog->Log(buf); |
|
1672 } |
|
1673 else if (type == CPosLmSearchCriteria::ECriteriaIdList) |
|
1674 { |
|
1675 iLog->Log(_L("Arg Idlist found")); |
|
1676 CPosLmIdListCriteria& tt = static_cast<CPosLmIdListCriteria&>(comp); |
|
1677 |
|
1678 RArray<TPosLmItemId> result; |
|
1679 CleanupClosePushL(result); |
|
1680 tt.GetLandmarkIdsL(result); |
|
1681 |
|
1682 buf.Format(_L("Nr of Ids: %d"), result.Count()); |
|
1683 iLog->Log(buf); |
|
1684 |
|
1685 for (TInt i=0;i<result.Count();i++) |
|
1686 { |
|
1687 buf.Format(_L("ID%d: %d"), i, result[i]); |
|
1688 |
|
1689 } |
|
1690 CleanupStack::PopAndDestroy(&result); |
|
1691 |
|
1692 } |
|
1693 else if (type == CPosLmSearchCriteria::ECriteriaCategoryByName) |
|
1694 { |
|
1695 // Should never come here, ECriteriaCategoryByName not supported in composite objects |
|
1696 iLog->Log(_L("Arg Categorybyname found")); |
|
1697 } |
|
1698 } |
|
1699 } |
|
1700 |
|
1701 // End of File |