author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
22 |
#include <e32svr.h> |
|
23 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
24 |
#include <StifTestInterface.h> |
19 | 25 |
#include <EPos_CPosLmTextCriteria.h> |
26 |
#include <lbsposition.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#include <EPos_CPosLmItemIterator.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
28 |
#include <EPos_CPosLmCategoryManager.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
29 |
#include <EPos_CPosLandmarkDatabase.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include "clmcategoriestest.h" |
19 | 31 |
#include "landmarkservice.h" |
32 |
#include "clandmarkfilter.h" |
|
33 |
||
34 |
||
35 |
// CONSTANTS |
|
36 |
_LIT(KCatName1, "lc1"); |
|
37 |
_LIT(KCatName2, "lc2"); |
|
38 |
_LIT(KCatName3, "lc3"); |
|
39 |
_LIT(KCatName4, "category1"); |
|
40 |
_LIT(KCatName5, "category2"); |
|
41 |
_LIT(KCatName6, "category3"); |
|
42 |
||
43 |
_LIT(KCatSearchString, "lc*"); |
|
44 |
||
45 |
// ----------------------------------------------------------------------------- |
|
46 |
// CTLmAsyncTest::HandleLandmarkItemsL |
|
47 |
// MLmObserver observer callback method for async getlist of landmarks request. |
|
48 |
// ----------------------------------------------------------------------------- |
|
49 |
void CClmcategoriestest::HandleLandmarkItemsL( CPosLmItemIterator* /*aIterator*/, |
|
50 |
TInt32 /*aTransactionId*/, |
|
51 |
TInt /*aError*/, const TDesC& /*aDatabaseUri*/) |
|
52 |
{ |
|
53 |
; |
|
54 |
} |
|
55 |
||
56 |
// ----------------------------------------------------------------------------- |
|
57 |
// CTLmAsyncTest::HandleCategoryItemsL |
|
58 |
// MLmObserver observer callback method for async getlist of categories request. |
|
59 |
// ----------------------------------------------------------------------------- |
|
60 |
// |
|
61 |
void CClmcategoriestest::HandleCategoryItemsL( CPosLmItemIterator* aIterator, |
|
62 |
TInt32 /*aTransactionId*/, |
|
63 |
TInt /*aError*/, const TDesC& /*aDatabaseUri*/) |
|
64 |
{ |
|
65 |
TPosLmItemId catID; |
|
66 |
TInt count = 0; |
|
67 |
switch (iTestCaseId) |
|
68 |
{ |
|
69 |
case ECategoryGetlist1: |
|
70 |
while ((catID = aIterator->NextL()) != KPosLmNullItemId) |
|
71 |
{ |
|
72 |
CPosLandmarkCategory* cat = iDefaultCategoryHandle->ReadCategoryLC(catID); |
|
73 |
TPtrC lcname; |
|
74 |
if ( !cat-> GetCategoryName (lcname) ) |
|
75 |
{ |
|
76 |
if ( lcname.Compare(KCatName1) || lcname.Compare(KCatName2) || lcname.Compare(KCatName3) ) |
|
77 |
count++; |
|
78 |
} |
|
79 |
else |
|
80 |
{ |
|
81 |
break; |
|
82 |
} |
|
83 |
CleanupStack::PopAndDestroy(cat); |
|
84 |
} |
|
85 |
if ( count != 3 ) |
|
86 |
{ |
|
87 |
iLog->Log( _L("added categories doesn't match with in getlist iterator..") ); |
|
88 |
iResult = 1; |
|
89 |
} |
|
90 |
break; |
|
91 |
||
92 |
case ECategoryGetlist2: |
|
93 |
while ((catID = aIterator->NextL()) != KPosLmNullItemId) |
|
94 |
{ |
|
95 |
CPosLandmarkCategory* cat = iDefaultCategoryHandle->ReadCategoryLC(catID); |
|
96 |
TPtrC lcname; |
|
97 |
if ( !cat-> GetCategoryName (lcname) ) |
|
98 |
{ |
|
99 |
if ( !lcname.Compare(KCatName1) || !lcname.Compare(KCatName2) || !lcname.Compare(KCatName3) ) |
|
100 |
count++; |
|
101 |
if ( !lcname.Compare(KCatName4) || !lcname.Compare(KCatName5) || !lcname.Compare(KCatName6) ) |
|
102 |
count++; |
|
103 |
} |
|
104 |
else |
|
105 |
{ |
|
106 |
break; |
|
107 |
} |
|
108 |
CleanupStack::PopAndDestroy(cat); |
|
109 |
} |
|
110 |
if ( count != 6 ) |
|
111 |
{ |
|
112 |
iLog->Log( _L("added categories doesn't match with in getlist iterator..") ); |
|
113 |
iResult = 1; |
|
114 |
} |
|
115 |
break; |
|
116 |
||
117 |
default: |
|
118 |
iResult = 1; |
|
119 |
} |
|
120 |
||
121 |
delete aIterator; |
|
122 |
CActiveScheduler::Stop(); |
|
123 |
} |
|
124 |
||
125 |
||
126 |
// ============================ MEMBER FUNCTIONS =============================== |
|
127 |
||
128 |
// ----------------------------------------------------------------------------- |
|
129 |
// CClmcategoriestest::Delete |
|
130 |
// Delete here all resources allocated and opened from test methods. |
|
131 |
// Called from destructor. |
|
132 |
// ----------------------------------------------------------------------------- |
|
133 |
// |
|
134 |
void CClmcategoriestest::Delete() |
|
135 |
{ |
|
136 |
} |
|
137 |
||
138 |
// ----------------------------------------------------------------------------- |
|
139 |
// CClmcategoriestest::RunMethodL |
|
140 |
// Run specified method. Contains also table of test mothods and their names. |
|
141 |
// ----------------------------------------------------------------------------- |
|
142 |
// |
|
143 |
TInt CClmcategoriestest::RunMethodL( |
|
144 |
CStifItemParser& aItem ) |
|
145 |
{ |
|
146 |
static TStifFunctionInfo const KFunctions[] = |
|
147 |
{ |
|
148 |
ENTRY( "getlistasynctest1", CClmcategoriestest::GetlistAsyncTest1), |
|
149 |
ENTRY( "getlistasynctest2", CClmcategoriestest::GetlistAsyncTest2), |
|
150 |
ENTRY( "categorygetlistsync", CClmcategoriestest::CategoryGetlistSync), |
|
151 |
ENTRY( "AddCategory", CClmcategoriestest::AddCategoryL ), |
|
152 |
ENTRY( "UpdateCategory", CClmcategoriestest::UpdateCategoryL), |
|
153 |
ENTRY( "RemoveCategory" , CClmcategoriestest :: RemoveCategoryL), |
|
154 |
ENTRY("LinkCategory", CClmcategoriestest :: LinkCategoryL ), |
|
155 |
ENTRY("UnLinkCategory", CClmcategoriestest :: UnLinkCategoryL ), |
|
156 |
||
157 |
}; |
|
158 |
||
159 |
const TInt count = sizeof( KFunctions ) / |
|
160 |
sizeof( TStifFunctionInfo ); |
|
161 |
||
162 |
return RunInternalL( KFunctions, count, aItem ); |
|
163 |
} |
|
164 |
||
165 |
||
166 |
TInt CClmcategoriestest::AddCategoryL( CStifItemParser& /*aItem*/ ) |
|
167 |
{ |
|
168 |
_LIT(KOffice,"Nokia"); |
|
169 |
||
170 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); |
|
171 |
CleanupStack::PushL(db); |
|
172 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
173 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
174 |
CleanupStack::PushL(catManager); |
|
175 |
RemoveAllCategories(catManager); |
|
176 |
||
177 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
178 |
category->SetCategoryNameL(KOffice); |
|
179 |
CLandmarkService* service = CLandmarkService::NewL(); |
|
180 |
CleanupStack::PushL(service); |
|
181 |
service->AddItemL(*category); |
|
182 |
CleanupStack::PopAndDestroy(4,db); |
|
183 |
return KErrNone; |
|
184 |
} |
|
185 |
||
186 |
TInt CClmcategoriestest::UpdateCategoryL( CStifItemParser& /*aItem*/ ) |
|
187 |
{ |
|
188 |
_LIT(KOffice1,"NokiaPrevious"); |
|
189 |
_LIT(KOffice,"NokiaUpdate"); |
|
190 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); |
|
191 |
CleanupStack::PushL(db); |
|
192 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
193 |
||
194 |
||
195 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
196 |
CleanupStack::PushL(catManager); |
|
197 |
RemoveAllCategories(catManager); |
|
198 |
||
199 |
TPosLmItemId catId; |
|
200 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
201 |
category->SetCategoryNameL(KOffice1); |
|
202 |
catId=catManager->AddCategoryL(*category); |
|
203 |
||
204 |
category = catManager->ReadCategoryLC(catId); |
|
205 |
category->SetCategoryNameL(KOffice); |
|
206 |
CLandmarkService* service = CLandmarkService::NewL(); |
|
207 |
CleanupStack::PushL(service); |
|
208 |
service->UpdateItemL(*category); |
|
209 |
CleanupStack::PopAndDestroy(2,category); |
|
210 |
CleanupStack::PopAndDestroy(3,db); |
|
211 |
ReleaseLandmarkResources(); |
|
212 |
return KErrNone; |
|
213 |
} |
|
214 |
||
215 |
TInt CClmcategoriestest::RemoveCategoryL( CStifItemParser& /*aItem*/ ) |
|
216 |
{ |
|
217 |
_LIT(KOffice1,"NokiaPrevious"); |
|
218 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); |
|
219 |
CleanupStack::PushL(db); |
|
220 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
221 |
||
222 |
||
223 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
224 |
CleanupStack::PushL(catManager); |
|
225 |
RemoveAllCategories(catManager); |
|
226 |
||
227 |
TPosLmItemId catId; |
|
228 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
229 |
category->SetCategoryNameL(KOffice1); |
|
230 |
catId=catManager->AddCategoryL(*category); |
|
231 |
||
232 |
//CPosLmItemIterator* iter = catManager->CategoryIteratorL(); |
|
233 |
//CleanupStack::PushL(iter); |
|
234 |
||
235 |
CLandmarkService* service = CLandmarkService::NewL(); |
|
236 |
CleanupStack::PushL(service); |
|
237 |
||
238 |
// while ((catId = iter->NextL()) != KPosLmNullItemId) |
|
239 |
//{ |
|
240 |
service->RemoveItemL(catId,CLandmarkService::ECategory); |
|
241 |
||
242 |
//} |
|
243 |
CleanupStack::PopAndDestroy(4,db); |
|
244 |
ReleaseLandmarkResources(); |
|
245 |
return KErrNone; |
|
246 |
} |
|
247 |
||
248 |
TInt CClmcategoriestest::LinkCategoryL( CStifItemParser& /*aItem*/ ) |
|
249 |
{ |
|
250 |
_LIT(KOffice1,"NokiaPrevious"); |
|
251 |
_LIT(KName1,"Mainland China"); |
|
252 |
_LIT(KName2,"Chung Wah"); |
|
253 |
_LIT(KName3,"Aromas of China"); |
|
254 |
||
255 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); |
|
256 |
CleanupStack::PushL(db); |
|
257 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
258 |
||
259 |
TPosLmItemId lmId; |
|
260 |
RArray<TPosLmItemId> landmarks; |
|
261 |
CleanupClosePushL(landmarks); |
|
262 |
||
263 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
264 |
lm->SetLandmarkNameL(KName1); |
|
265 |
lmId = db->AddLandmarkL(*lm); |
|
266 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
267 |
lm->SetLandmarkNameL(KName2); |
|
268 |
lmId = db->AddLandmarkL(*lm); |
|
269 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
270 |
lm->SetLandmarkNameL(KName3); |
|
271 |
lmId = db->AddLandmarkL(*lm); |
|
272 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
273 |
||
274 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
275 |
CleanupStack::PushL(catManager); |
|
276 |
RemoveAllCategories(catManager); |
|
277 |
||
278 |
TPosLmItemId catId; |
|
279 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
280 |
category->SetCategoryNameL(KOffice1); |
|
281 |
catId = catManager->AddCategoryL(*category); |
|
282 |
||
283 |
CLandmarkService* service = CLandmarkService::NewL(); |
|
284 |
CleanupStack::PushL(service); |
|
285 |
service->LinkCategoryToLandmarksL(catId,landmarks); |
|
286 |
||
287 |
CleanupStack::PopAndDestroy(6,db); |
|
288 |
ReleaseLandmarkResources(); |
|
289 |
||
290 |
return KErrNone; |
|
291 |
} |
|
292 |
||
293 |
TInt CClmcategoriestest::UnLinkCategoryL( CStifItemParser& /*aItem*/ ) |
|
294 |
{ |
|
295 |
_LIT(KOffice1,"NokiaPrevious"); |
|
296 |
_LIT(KName1,"Mainland China"); |
|
297 |
_LIT(KName2,"Chung Wah"); |
|
298 |
_LIT(KName3,"Aromas of China"); |
|
299 |
||
300 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); |
|
301 |
CleanupStack::PushL(db); |
|
302 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
303 |
||
304 |
TPosLmItemId lmId; |
|
305 |
RArray<TPosLmItemId> landmarks; |
|
306 |
CleanupClosePushL(landmarks); |
|
307 |
||
308 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
309 |
lm->SetLandmarkNameL(KName1); |
|
310 |
lmId = db->AddLandmarkL(*lm); |
|
311 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
312 |
lm->SetLandmarkNameL(KName2); |
|
313 |
lmId = db->AddLandmarkL(*lm); |
|
314 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
315 |
lm->SetLandmarkNameL(KName3); |
|
316 |
lmId = db->AddLandmarkL(*lm); |
|
317 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
318 |
||
319 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
320 |
CleanupStack::PushL(catManager); |
|
321 |
RemoveAllCategories(catManager); |
|
322 |
||
323 |
TPosLmItemId catId; |
|
324 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
325 |
category->SetCategoryNameL(KOffice1); |
|
326 |
catId = catManager->AddCategoryL(*category); |
|
327 |
ExecuteAndDeleteLD(catManager->AddCategoryToLandmarksL(catId,landmarks)); |
|
328 |
||
329 |
CLandmarkService* service = CLandmarkService::NewL(); |
|
330 |
CleanupStack::PushL(service); |
|
331 |
service->UnlinkCategoryToLandmarksL(catId,landmarks); |
|
332 |
||
333 |
CleanupStack::PopAndDestroy(6,db); |
|
334 |
ReleaseLandmarkResources(); |
|
335 |
return KErrNone; |
|
336 |
} |
|
337 |
||
338 |
TInt CClmcategoriestest::GetlistAsyncTest1( CStifItemParser& /*aItem*/ ) |
|
339 |
{ |
|
340 |
||
341 |
_LIT( KExample, "GetlistAsyncTest1 Async" ); |
|
342 |
iLog->Log( KExample ); |
|
343 |
||
344 |
TInt err=0; |
|
345 |
iTestCaseId = ECategoryGetlist1; |
|
346 |
CPosLmCategoryManager::TCategorySortPref SortPref(CPosLmCategoryManager::ECategorySortOrderNone); |
|
347 |
||
348 |
iTestCaseId = ECategoryGetlist1; |
|
349 |
||
350 |
RemoveAllCategories(iDefaultCategoryHandle); |
|
351 |
CreateCategories (); |
|
352 |
||
353 |
CLandmarkService *obj = CLandmarkService::NewL (); |
|
354 |
CleanupStack::PushL(obj); |
|
355 |
obj->RegisterObserver(this); |
|
356 |
||
357 |
CLandmarkFilter* filter = CLandmarkFilter::NewLC(CLandmarkFilter::ECategory); |
|
358 |
CPosLmCatNameCriteria* crit = CPosLmCatNameCriteria ::NewLC(); |
|
359 |
crit->SetSearchPatternL (KCatSearchString); |
|
360 |
filter->SetCriteria(crit); |
|
361 |
CleanupStack::Pop(crit); |
|
362 |
filter->SetCatSortPref(SortPref); |
|
363 |
TInt32 tranId = 0; |
|
364 |
TRAP (err,obj->GetListL (tranId,*filter)); |
|
365 |
if ( !err ) |
|
366 |
CActiveScheduler::Start(); |
|
367 |
else |
|
368 |
{ |
|
369 |
CleanupStack::PopAndDestroy(2,obj); |
|
370 |
return err; |
|
371 |
} |
|
372 |
User::After(5000); |
|
373 |
CleanupStack::PopAndDestroy(2,obj); |
|
374 |
||
375 |
RemoveAllCategories(iDefaultCategoryHandle); |
|
376 |
||
377 |
return iResult; |
|
378 |
} |
|
379 |
||
380 |
TInt CClmcategoriestest::GetlistAsyncTest2( CStifItemParser& /*aItem*/ ) |
|
381 |
{ |
|
382 |
_LIT( KExample, "GetlistAsyncTest2" ); |
|
383 |
iLog->Log( KExample ); |
|
384 |
||
385 |
TInt err=0; |
|
386 |
iTestCaseId = ECategoryGetlist2; |
|
387 |
||
388 |
CPosLmCategoryManager::TCategorySortPref SortPref(CPosLmCategoryManager::ECategorySortOrderNone); |
|
389 |
||
390 |
RemoveAllCategories(iDefaultCategoryHandle); |
|
391 |
CreateCategories (); |
|
392 |
||
393 |
CLandmarkService *obj = CLandmarkService::NewL (); |
|
394 |
CleanupStack::PushL(obj); |
|
395 |
obj->RegisterObserver(this); |
|
396 |
||
397 |
CPosLmCatNameCriteria* crit = CPosLmCatNameCriteria ::NewLC(); |
|
398 |
crit->SetSearchPatternL (KCatSearchString); |
|
399 |
||
400 |
CLandmarkFilter* filter = CLandmarkFilter::NewLC(CLandmarkFilter::ECategory); |
|
401 |
// filter->SetCriteria(crit); |
|
402 |
filter->SetCatSortPref(SortPref); |
|
403 |
TInt32 tranId = 0; |
|
404 |
TRAP (err,obj->GetListL (tranId,*filter)); |
|
405 |
if ( !err ) |
|
406 |
CActiveScheduler::Start(); |
|
407 |
else |
|
408 |
{ |
|
409 |
CleanupStack::PopAndDestroy(3,obj); |
|
410 |
return err; |
|
411 |
} |
|
412 |
||
413 |
CleanupStack::PopAndDestroy(3,obj); |
|
414 |
||
415 |
RemoveAllCategories(iDefaultCategoryHandle); |
|
416 |
||
417 |
return iResult; |
|
418 |
} |
|
419 |
||
420 |
||
421 |
// ----------------------------------------------------------------------------- |
|
422 |
// CClmcategoriestest::CategoryGetlist |
|
423 |
// Test method for testing syncronous implimentation of getlist categories. |
|
424 |
// ----------------------------------------------------------------------------- |
|
425 |
// |
|
426 |
TInt CClmcategoriestest::CategoryGetlistSync( CStifItemParser& /*aItem*/ ) |
|
427 |
{ |
|
428 |
_LIT( KExample, "CategoryGetlist Sync" ); |
|
429 |
iLog->Log( KExample ); |
|
430 |
||
431 |
TInt err=0; |
|
432 |
TInt ret=0; |
|
433 |
||
434 |
CPosLmCategoryManager::TCategorySortPref SortPref(CPosLmCategoryManager::ECategorySortOrderNone); |
|
435 |
RemoveAllCategories(iDefaultCategoryHandle); |
|
436 |
||
437 |
CLandmarkService *obj = CLandmarkService::NewL (); |
|
438 |
CleanupStack::PushL(obj); |
|
439 |
||
440 |
CPosLandmarkCategory * lc = CPosLandmarkCategory::NewLC (); |
|
441 |
||
442 |
lc->SetCategoryNameL (KCatName1); |
|
443 |
TRAP(err,iDefaultCategoryHandle->AddCategoryL (*lc)); |
|
444 |
||
445 |
lc->SetCategoryNameL (KCatName2); |
|
446 |
TRAP(err,iDefaultCategoryHandle->AddCategoryL (*lc)); |
|
447 |
||
448 |
lc->SetCategoryNameL (KCatName3); |
|
449 |
TRAP(err,iDefaultCategoryHandle->AddCategoryL (*lc)); |
|
450 |
||
451 |
CleanupStack::PopAndDestroy(lc); |
|
452 |
||
453 |
||
454 |
CLandmarkFilter* filter = CLandmarkFilter::NewLC(CLandmarkFilter::ECategory); |
|
455 |
CPosLmCatNameCriteria* crit = CPosLmCatNameCriteria ::NewLC(); |
|
456 |
crit->SetSearchPatternL (KCatSearchString); |
|
457 |
filter->SetCriteria(crit); |
|
458 |
CleanupStack::Pop(crit); |
|
459 |
filter->SetCatSortPref(SortPref); |
|
460 |
||
461 |
CPosLmItemIterator* iterator; |
|
462 |
TRAP (err, obj->GetListL (iterator,*filter) ); |
|
463 |
if ( !err && ret == KErrNone ) |
|
464 |
{ |
|
465 |
TPosLmItemId catID; |
|
466 |
TInt count = 0; |
|
467 |
while ((catID = iterator->NextL()) != KPosLmNullItemId) |
|
468 |
{ |
|
469 |
CPosLandmarkCategory* cat = iDefaultCategoryHandle->ReadCategoryLC(catID); |
|
470 |
TPtrC lcname; |
|
471 |
if ( !cat-> GetCategoryName (lcname) ) |
|
472 |
{ |
|
473 |
if ( lcname.Compare(KCatName1) || lcname.Compare(KCatName2) || lcname.Compare(KCatName3) ) |
|
474 |
count++; |
|
475 |
} |
|
476 |
else |
|
477 |
{ |
|
478 |
break; |
|
479 |
} |
|
480 |
CleanupStack::PopAndDestroy(cat); |
|
481 |
} |
|
482 |
if ( 3 != count ) |
|
483 |
{ |
|
484 |
iLog->Log( _L("added categories doesn't match with in getlist iterator..") ); |
|
485 |
err = 1; |
|
486 |
} |
|
487 |
} |
|
488 |
else |
|
489 |
{ |
|
490 |
CleanupStack::PopAndDestroy(2,obj); |
|
491 |
return err; |
|
492 |
} |
|
493 |
||
494 |
delete iterator; |
|
495 |
CleanupStack::PopAndDestroy(2,obj); |
|
496 |
||
497 |
RemoveAllCategories(iDefaultCategoryHandle); |
|
498 |
return err; |
|
499 |
} |
|
500 |
// ----------------------------------------------------------------------------- |
|
501 |
// CTLmAsyncTest::CreateCategories |
|
502 |
// Helper method to add categories to a default database. |
|
503 |
// ----------------------------------------------------------------------------- |
|
504 |
// |
|
505 |
void CClmcategoriestest::CreateCategories () |
|
506 |
{ |
|
507 |
CPosLandmarkCategory * lc = CPosLandmarkCategory::NewLC (); |
|
508 |
||
509 |
lc->SetCategoryNameL (KCatName1); |
|
510 |
iDefaultCategoryHandle->AddCategoryL (*lc); |
|
511 |
||
512 |
lc->SetCategoryNameL (KCatName2); |
|
513 |
iDefaultCategoryHandle->AddCategoryL (*lc); |
|
514 |
||
515 |
lc->SetCategoryNameL (KCatName3); |
|
516 |
iDefaultCategoryHandle->AddCategoryL (*lc); |
|
517 |
||
518 |
lc->SetCategoryNameL (KCatName4); |
|
519 |
iDefaultCategoryHandle->AddCategoryL (*lc); |
|
520 |
||
521 |
lc->SetCategoryNameL (KCatName5); |
|
522 |
iDefaultCategoryHandle->AddCategoryL (*lc); |
|
523 |
||
524 |
lc->SetCategoryNameL (KCatName6); |
|
525 |
iDefaultCategoryHandle->AddCategoryL (*lc); |
|
526 |
||
527 |
CleanupStack::PopAndDestroy(lc); |
|
528 |
} |
|
529 |
// ----------------------------------------------------------------------------- |
|
530 |
// CTLmAsyncTest::RemoveAllLandmarks |
|
531 |
// Helper method to remove all categories for preconditional tests. |
|
532 |
// ----------------------------------------------------------------------------- |
|
533 |
// |
|
534 |
void CClmcategoriestest::RemoveAllCategories (CPosLmCategoryManager* aHandle) |
|
535 |
{ |
|
536 |
TPosLmItemId catID; |
|
537 |
CPosLmItemIterator*iterator = aHandle->CategoryIteratorL(); |
|
538 |
CleanupStack::PushL(iterator); |
|
539 |
||
540 |
while ((catID = iterator->NextL()) != KPosLmNullItemId) |
|
541 |
{ |
|
542 |
TRAP_IGNORE(ExecuteAndDeleteLD(aHandle->RemoveCategoryL( catID ))); |
|
543 |
} |
|
544 |
CleanupStack::PopAndDestroy(iterator); |
|
545 |
} |
|
546 |
// End of File |