1 /* |
1 /* |
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Symbian Foundation License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
73 CLandmarkTestProcedureBase::InitTestL(); |
73 CLandmarkTestProcedureBase::InitTestL(); |
74 |
74 |
75 // PrepareDatabases |
75 // PrepareDatabases |
76 const TInt KNrOfDatabases = 5; |
76 const TInt KNrOfDatabases = 5; |
77 RemoveAllLmDatabasesL(); |
77 RemoveAllLmDatabasesL(); |
|
78 // Get the list of Dbs remaining after removing the possible ones. |
|
79 CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); |
|
80 CleanupStack::PushL(dbMan); |
|
81 iDbUris = dbMan->ListDatabasesLC(); |
|
82 iInitialDbCount = iDbUris->Count(); |
|
83 CleanupStack::PopAndDestroy(iDbUris); |
78 CopyTestDbFileL(KDb20); |
84 CopyTestDbFileL(KDb20); |
79 CopyTestDbFileL(KDb40); |
85 CopyTestDbFileL(KDb40); |
80 CopyTestDbFileL(KDb60); |
86 CopyTestDbFileL(KDb60); |
81 CopyTestDbFileL(KDb80); |
87 CopyTestDbFileL(KDb80); |
82 CopyTestDbFileL(KDb105); |
88 CopyTestDbFileL(KDb105); |
83 |
89 |
84 // List databases |
90 // List databases |
85 CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); |
91 |
86 CleanupStack::PushL(dbMan); |
|
87 iDbUris = dbMan->ListDatabasesLC(); |
92 iDbUris = dbMan->ListDatabasesLC(); |
88 CleanupStack::Pop(iDbUris); |
93 CleanupStack::Pop(iDbUris); |
89 AssertTrueSecL(iDbUris->Count() == KNrOfDatabases, _L("Wrong number of test databases!")); |
94 AssertTrueSecL(iDbUris->Count() == iInitialDbCount+KNrOfDatabases, _L("Wrong number of test databases!")); |
90 CleanupStack::PopAndDestroy(dbMan); |
95 CleanupStack::PopAndDestroy(dbMan); |
|
96 |
|
97 // Get only the list of dburi in which this test case operations need to be performed |
|
98 TInt dbUriCount = iDbUris->Count(); |
|
99 |
|
100 for ( TInt i= 0;i < dbUriCount;i++) |
|
101 { |
|
102 iLog->Log((*iDbUris)[i]); |
|
103 // Action to be performed only on the newly added dbs in this test case, therefore remove any other |
|
104 // db apart from the ones added in this test case from the iDbUris list |
|
105 TPtrC dbUri((*iDbUris)[i]); |
|
106 if ( (dbUri != KDb20Uri) && (dbUri != KDb40Uri) && (dbUri != KDb60Uri) && |
|
107 ( dbUri != KDb80Uri) && (dbUri != KDb105Uri) ) |
|
108 { |
|
109 iDbUris->Delete(i); |
|
110 } |
|
111 |
|
112 } |
91 |
113 |
92 iDbSearcher = CPosLmMultiDbSearch::NewL(*iDbUris); |
114 iDbSearcher = CPosLmMultiDbSearch::NewL(*iDbUris); |
93 |
115 |
94 // Initialize expected landmark search result |
116 // Initialize expected landmark search result |
95 |
117 |
227 RPointerArray<CPosLmItemIterator> iterators; |
249 RPointerArray<CPosLmItemIterator> iterators; |
228 CleanupClosePushL(iterators); |
250 CleanupClosePushL(iterators); |
229 CleanupStack::PushL(TCleanupItem(ResetAndDestroy, &iterators)); |
251 CleanupStack::PushL(TCleanupItem(ResetAndDestroy, &iterators)); |
230 |
252 |
231 TInt totalNrOfMatches(0), totalNrOfExpectedMatches(0); |
253 TInt totalNrOfMatches(0), totalNrOfExpectedMatches(0); |
232 for (TInt i = 0; i < KNrOfDatabases; i++) |
254 for (TInt i = 0; i < iDbUris->Count(); i++) |
233 { |
255 { |
234 // 2. Ask for the iterator for each database |
256 // 2. Ask for the iterator for each database |
235 iterators.AppendL(iDbSearcher->MatchIteratorL(i)); |
257 iterators.AppendL(iDbSearcher->MatchIteratorL(i)); |
236 |
258 |
237 // 3. Verify that the number of each iterator equals to the expected result |
259 // 3. Verify that the number of each iterator equals to the expected result |
244 |
266 |
245 // 4. Verify that the total number of matches equals the sum of expected |
267 // 4. Verify that the total number of matches equals the sum of expected |
246 AssertTrueSecL(totalNrOfMatches == totalNrOfExpectedMatches, _L("totalNrOfMatches != totalNrOfExpectedMatches")); |
268 AssertTrueSecL(totalNrOfMatches == totalNrOfExpectedMatches, _L("totalNrOfMatches != totalNrOfExpectedMatches")); |
247 AssertTrueSecL(totalNrOfMatches == iDbSearcher->TotalNumOfMatches(), _L("totalNrOfMatches != iDbSearcher->TotalNumOfMatches()")); |
269 AssertTrueSecL(totalNrOfMatches == iDbSearcher->TotalNumOfMatches(), _L("totalNrOfMatches != iDbSearcher->TotalNumOfMatches()")); |
248 |
270 |
249 for (TInt dbIndex = 0; dbIndex < KNrOfDatabases; dbIndex++) |
271 for (TInt dbIndex = 0; dbIndex < iDbUris->Count(); dbIndex++) |
250 { |
272 { |
251 // 5. Ask for the first item in each iterator |
273 // 5. Ask for the first item in each iterator |
252 TPosLmItemId id1 = iterators[dbIndex]->NextL(); |
274 TPosLmItemId id1 = iterators[dbIndex]->NextL(); |
253 |
275 |
254 // 6. Perform an operation on the first item, e.g. read it from db |
276 // 6. Perform an operation on the first item, e.g. read it from db |