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 |
#include <e32svr.h> |
|
20 |
#include <f32file.h> |
|
21 |
#include <StifParser.h> |
|
22 |
#include <e32std.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
23 |
#include <StifTestInterface.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
24 |
#include <liwgenericparam.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
25 |
#include <liwservicehandler.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include <EPos_CPosLandmarkDatabase.h> |
19 | 27 |
#include <EPos_CPosLmDatabaseManager.h> |
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
28 |
#include <EPos_CPosLandmark.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
29 |
#include <EPos_CPosLandmarkEncoder.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include <EPos_CPosLmCategoryManager.h> |
19 | 31 |
#include "tlmprovidercategorytests.h" |
32 |
#include "landmarkliwparams.hrh" |
|
33 |
||
34 |
#define PASS TInt(0) |
|
35 |
#define FAIL (!PASS) |
|
36 |
||
37 |
_LIT(KDefaultDatabase,"c:default.ldb"); |
|
38 |
// CONSTANTS |
|
39 |
_LIT(KCatName1, "lc1"); |
|
40 |
_LIT(KCatName2, "lca2"); |
|
41 |
_LIT(KCatName3, "lca3"); |
|
42 |
_LIT(KCatName4, "category1"); |
|
43 |
_LIT(KCatName5, "category2"); |
|
44 |
_LIT(KCatName6, "category3"); |
|
45 |
||
46 |
_LIT(KOtherCatName1, "loc1"); |
|
47 |
_LIT(KOtherCatName2, "loc2"); |
|
48 |
_LIT(KOtherCatName3, "loc3"); |
|
49 |
_LIT(KOtherCatName4, "othercategory1"); |
|
50 |
_LIT(KOtherCatName5, "othercategory2"); |
|
51 |
_LIT(KOtherCatName6, "othercategory3"); |
|
52 |
||
53 |
_LIT(KCatSearchString, "lc*"); |
|
54 |
_LIT(KCatSearchString1, "lo*"); |
|
55 |
_LIT(KCatSearchString2, "lca*"); |
|
56 |
_LIT(KOtherDatabase,"c:database1.ldb"); |
|
57 |
||
58 |
// ============================ MEMBER FUNCTIONS =============================== |
|
59 |
// ----------------------------------------------------------------------------- |
|
60 |
// CTLmCategoryTests::RunMethodL |
|
61 |
// Run specified method. Contains also table of test mothods and their names. |
|
62 |
// ----------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
TInt CTLmCategoryTests::RunMethodL( |
|
65 |
CStifItemParser& aItem ) |
|
66 |
{ |
|
67 |
static TStifFunctionInfo const KFunctions[] = |
|
68 |
{ |
|
69 |
ENTRY( "AddCategory", CTLmCategoryTests::AddCategoryL ), |
|
70 |
ENTRY( "AddCategory1", CTLmCategoryTests::AddCategory1L ), |
|
71 |
ENTRY( "UpdateCategory", CTLmCategoryTests::UpdateCategoryL), |
|
72 |
ENTRY( "UpdateCategory1", CTLmCategoryTests::UpdateCategory1L), |
|
73 |
ENTRY( "CategoryAsyncTest1", CTLmCategoryTests::CategoryAsyncTest1), |
|
74 |
ENTRY( "CategoryAsyncTest2", CTLmCategoryTests::CategoryAsyncTest2), |
|
75 |
ENTRY( "CategorySyncTest1", CTLmCategoryTests::CategorySyncTest1), |
|
76 |
ENTRY( "CategorySyncTest2", CTLmCategoryTests::CategorySyncTest2), |
|
77 |
ENTRY( "RemoveCategory", CTLmCategoryTests::RemoveCategoryL), |
|
78 |
ENTRY( "RemoveCategory1", CTLmCategoryTests::RemoveCategory1L), |
|
79 |
ENTRY( "CancelAsyncTest1", CTLmCategoryTests::CancelAsyncTest1), |
|
80 |
ENTRY( "AddCategoryPos", CTLmCategoryTests::AddCategoryL ), |
|
81 |
ENTRY( "UpdateCategoryPos", CTLmCategoryTests::UpdateCategoryL), |
|
82 |
ENTRY( "CategoryAsyncTestPos1", CTLmCategoryTests::CategoryAsyncTest1), |
|
83 |
ENTRY( "CategorySyncTestPos1", CTLmCategoryTests::CategorySyncTest1), |
|
84 |
ENTRY( "RemoveCategoryPos", CTLmCategoryTests::RemoveCategoryL), |
|
85 |
}; |
|
86 |
||
87 |
const TInt count = sizeof( KFunctions ) / |
|
88 |
sizeof( TStifFunctionInfo ); |
|
89 |
||
90 |
return RunInternalL( KFunctions, count, aItem ); |
|
91 |
||
92 |
} |
|
93 |
||
94 |
||
95 |
// ----------------------------------------------------------------------------- |
|
96 |
// CTLmCategoryTests::CategorySyncTest1 |
|
97 |
// Example test method function. |
|
98 |
// (other items were commented in a header). |
|
99 |
// ----------------------------------------------------------------------------- |
|
100 |
// |
|
101 |
TInt CTLmCategoryTests::CategorySyncTest1 ( CStifItemParser& /*aItem */ ) |
|
102 |
{ |
|
103 |
_LIT( KExample, "CategorySyncTest1" ); |
|
104 |
iLog->Log( KExample ); |
|
105 |
||
106 |
__UHEAP_MARK; |
|
107 |
CLiwServiceHandler* ServiceHandler; |
|
108 |
||
109 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
110 |
CleanupStack::PushL(ServiceHandler); |
|
111 |
CleanupClosePushL(*iLandmarkIf); |
|
112 |
||
113 |
iInList = &(ServiceHandler->InParamListL()); |
|
114 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
115 |
||
116 |
ResetParams(); |
|
117 |
||
118 |
TInt32 err; |
|
119 |
TInt ret = 0; |
|
120 |
/*Preconditions*/ |
|
121 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
122 |
CleanupStack::PushL(db); |
|
123 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
124 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
125 |
CleanupStack::PushL(catManager); |
|
126 |
CreateCategoriesL(catManager); |
|
127 |
CleanupStack::PopAndDestroy(2,db); |
|
128 |
||
129 |
TLiwGenericParam param; |
|
130 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
131 |
iInList->AppendL(param); |
|
132 |
param.Reset(); |
|
133 |
||
134 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
135 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString)); |
|
136 |
param.SetNameAndValueL(KFilter,TLiwVariant(categoryMap)); |
|
137 |
iInList->AppendL(param); |
|
138 |
categoryMap->DecRef(); |
|
139 |
param.Reset(); |
|
140 |
||
141 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,0,0); |
|
142 |
ret |= CheckErrorCode (*iOutList,err); |
|
143 |
if ( err != KErrNone ) |
|
144 |
{ |
|
145 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
146 |
ret |= FAIL; |
|
147 |
} |
|
148 |
||
149 |
TInt Index = 0; |
|
150 |
const TLiwGenericParam* itrparm = iOutList->FindFirst(Index,KReturnValue); |
|
151 |
if ( !itrparm ) |
|
152 |
{ |
|
153 |
iLog->Log( _L("Database iterator not found in output ArgList") ); |
|
154 |
ret |= FAIL; |
|
155 |
} |
|
156 |
else |
|
157 |
{ |
|
158 |
TLiwVariant cat; |
|
159 |
CLiwIterable* iter = itrparm->Value().AsIterable(); |
|
160 |
TInt cnt = 0; |
|
161 |
while ( iter->NextL(cat) ) |
|
162 |
{ |
|
163 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
164 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
165 |
TPtrC categoryName = category->Des(); |
|
166 |
||
167 |
if (categoryName == KCatName1 || |
|
168 |
categoryName == KCatName2 || |
|
169 |
categoryName == KCatName3) |
|
170 |
{ |
|
171 |
cnt++; |
|
172 |
CleanupStack::PopAndDestroy(category); |
|
173 |
} |
|
174 |
||
175 |
cat.Reset(); |
|
176 |
} |
|
177 |
if ( 3 != cnt ) |
|
178 |
{ |
|
179 |
iLog->Log( _L("All expected categories not listed") ); |
|
180 |
ret |= FAIL; |
|
181 |
} |
|
182 |
||
183 |
iter->Reset(); |
|
184 |
cnt = 0; |
|
185 |
while ( iter->NextL(cat) ) |
|
186 |
{ |
|
187 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
188 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
189 |
TPtrC categoryName = category->Des(); |
|
190 |
||
191 |
if (categoryName == KCatName1 || |
|
192 |
categoryName == KCatName2 || |
|
193 |
categoryName == KCatName3) |
|
194 |
{ |
|
195 |
cnt++; |
|
196 |
CleanupStack::PopAndDestroy(category); |
|
197 |
} |
|
198 |
||
199 |
cat.Reset(); |
|
200 |
} |
|
201 |
if ( 3 != cnt ) |
|
202 |
{ |
|
203 |
iLog->Log( _L("All expected categories not listed after reset") ); |
|
204 |
ret |= FAIL; |
|
205 |
} |
|
206 |
} |
|
207 |
||
208 |
//prev matches |
|
209 |
iInList->Reset(); |
|
210 |
iOutList->Reset(); |
|
211 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
212 |
iInList->AppendL(param); |
|
213 |
param.Reset(); |
|
214 |
||
215 |
categoryMap = CLiwDefaultMap::NewL(); |
|
216 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString2)); |
|
217 |
categoryMap->InsertL(KPrevMatchesOnly,TLiwVariant((TBool)ETrue)); |
|
218 |
param.SetNameAndValueL(KFilter,TLiwVariant(categoryMap)); |
|
219 |
iInList->AppendL(param); |
|
220 |
categoryMap->DecRef(); |
|
221 |
param.Reset(); |
|
222 |
||
223 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,0,0); |
|
224 |
ret |= CheckErrorCode (*iOutList,err); |
|
225 |
if ( err != KErrNone ) |
|
226 |
{ |
|
227 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
228 |
ret |= FAIL; |
|
229 |
} |
|
230 |
||
231 |
Index = 0; |
|
232 |
itrparm = iOutList->FindFirst(Index,KReturnValue); |
|
233 |
if ( !itrparm ) |
|
234 |
{ |
|
235 |
iLog->Log( _L("Database iterator not found in output ArgList") ); |
|
236 |
ret |= FAIL; |
|
237 |
} |
|
238 |
else |
|
239 |
{ |
|
240 |
TLiwVariant cat; |
|
241 |
CLiwIterable* iter = itrparm->Value().AsIterable(); |
|
242 |
TInt cnt = 0; |
|
243 |
while ( iter->NextL(cat) ) |
|
244 |
{ |
|
245 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
246 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
247 |
TPtrC categoryName = category->Des(); |
|
248 |
||
249 |
if (categoryName == KCatName2 || |
|
250 |
categoryName == KCatName3) |
|
251 |
{ |
|
252 |
cnt++; |
|
253 |
CleanupStack::PopAndDestroy(category); |
|
254 |
} |
|
255 |
||
256 |
cat.Reset(); |
|
257 |
} |
|
258 |
if ( 2 != cnt ) |
|
259 |
{ |
|
260 |
iLog->Log( _L("All expected categories not listed") ); |
|
261 |
ret |= FAIL; |
|
262 |
} |
|
263 |
} |
|
264 |
iInList->Reset(); |
|
265 |
iOutList->Reset(); |
|
266 |
||
267 |
iLog->Log( _L("End of CategorySyncTest1") ); |
|
268 |
||
269 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
270 |
ReleaseLandmarkResources(); |
|
271 |
__UHEAP_MARKEND; |
|
272 |
||
273 |
return ret; |
|
274 |
} |
|
275 |
||
276 |
// ----------------------------------------------------------------------------- |
|
277 |
// CTLmCategoryTests::CategorySyncTest1 |
|
278 |
// Example test method function. |
|
279 |
// (other items were commented in a header). |
|
280 |
// ----------------------------------------------------------------------------- |
|
281 |
// |
|
282 |
TInt CTLmCategoryTests::CategorySyncTestPos1 ( CStifItemParser& /*aItem */ ) |
|
283 |
{ |
|
284 |
_LIT( KExample, "CategorySyncTestPos1" ); |
|
285 |
iLog->Log( KExample ); |
|
286 |
||
287 |
TInt32 err; |
|
288 |
TInt ret = 0; |
|
289 |
__UHEAP_MARK; |
|
290 |
CLiwServiceHandler* ServiceHandler; |
|
291 |
||
292 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
293 |
CleanupStack::PushL(ServiceHandler); |
|
294 |
CleanupClosePushL(*iLandmarkIf); |
|
295 |
||
296 |
iInList = &(ServiceHandler->InParamListL()); |
|
297 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
298 |
||
299 |
ResetParams(); |
|
300 |
||
301 |
/*Preconditions*/ |
|
302 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
303 |
CleanupStack::PushL(db); |
|
304 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
305 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
306 |
CleanupStack::PushL(catManager); |
|
307 |
CreateCategoriesL(catManager); |
|
308 |
CleanupStack::PopAndDestroy(2,db); |
|
309 |
||
310 |
TLiwGenericParam param; |
|
311 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KCategory)); |
|
312 |
iInList->AppendL(param); |
|
313 |
param.Reset(); |
|
314 |
||
315 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
316 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString)); |
|
317 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(categoryMap)); |
|
318 |
iInList->AppendL(param); |
|
319 |
categoryMap->DecRef(); |
|
320 |
param.Reset(); |
|
321 |
||
322 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,0,0); |
|
323 |
ret |= CheckErrorCode (*iOutList,err); |
|
324 |
if ( err != KErrNone ) |
|
325 |
{ |
|
326 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
327 |
ret |= FAIL; |
|
328 |
} |
|
329 |
||
330 |
TInt Index = 0; |
|
331 |
const TLiwGenericParam* itrparm = iOutList->FindFirst(Index,KReturnValue); |
|
332 |
if ( !itrparm ) |
|
333 |
{ |
|
334 |
iLog->Log( _L("Database iterator not found in output ArgList") ); |
|
335 |
ret |= FAIL; |
|
336 |
} |
|
337 |
else |
|
338 |
{ |
|
339 |
TLiwVariant cat; |
|
340 |
CLiwIterable* iter = itrparm->Value().AsIterable(); |
|
341 |
TInt cnt = 0; |
|
342 |
while ( iter->NextL(cat) ) |
|
343 |
{ |
|
344 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
345 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
346 |
TPtrC categoryName = category->Des(); |
|
347 |
||
348 |
if (categoryName == KCatName1 || |
|
349 |
categoryName == KCatName2 || |
|
350 |
categoryName == KCatName3) |
|
351 |
{ |
|
352 |
cnt++; |
|
353 |
CleanupStack::PopAndDestroy(category); |
|
354 |
} |
|
355 |
||
356 |
} |
|
357 |
if ( 3 != cnt ) |
|
358 |
{ |
|
359 |
iLog->Log( _L("All expected categories not listed") ); |
|
360 |
ret |= FAIL; |
|
361 |
} |
|
362 |
||
363 |
iter->Reset(); |
|
364 |
cnt = 0; |
|
365 |
while ( iter->NextL(cat) ) |
|
366 |
{ |
|
367 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
368 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
369 |
TPtrC categoryName = category->Des(); |
|
370 |
||
371 |
if (categoryName == KCatName1 || |
|
372 |
categoryName == KCatName2 || |
|
373 |
categoryName == KCatName3) |
|
374 |
{ |
|
375 |
cnt++; |
|
376 |
CleanupStack::PopAndDestroy(category); |
|
377 |
} |
|
378 |
||
379 |
} |
|
380 |
if ( 3 != cnt ) |
|
381 |
{ |
|
382 |
iLog->Log( _L("All expected categories not listed after reset") ); |
|
383 |
ret |= FAIL; |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
iInList->Reset(); |
|
388 |
iOutList->Reset(); |
|
389 |
iLog->Log( _L("End of CategorySyncTest1") ); |
|
390 |
||
391 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
392 |
ReleaseLandmarkResources(); |
|
393 |
__UHEAP_MARKEND; |
|
394 |
||
395 |
return ret; |
|
396 |
} |
|
397 |
||
398 |
||
399 |
// ----------------------------------------------------------------------------- |
|
400 |
// CTLmCategoryTests::CategorySyncTest1 |
|
401 |
// Example test method function. |
|
402 |
// (other items were commented in a header). |
|
403 |
// ----------------------------------------------------------------------------- |
|
404 |
// |
|
405 |
TInt CTLmCategoryTests::CategorySyncTest2 ( CStifItemParser& /*aItem */ ) |
|
406 |
{ |
|
407 |
_LIT( KExample, "CategorySyncTest2" ); |
|
408 |
iLog->Log( KExample ); |
|
409 |
||
410 |
TInt32 err; |
|
411 |
TInt ret = 0; |
|
412 |
||
413 |
__UHEAP_MARK; |
|
414 |
CLiwServiceHandler* ServiceHandler; |
|
415 |
||
416 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
417 |
CleanupStack::PushL(ServiceHandler); |
|
418 |
CleanupClosePushL(*iLandmarkIf); |
|
419 |
||
420 |
iInList = &(ServiceHandler->InParamListL()); |
|
421 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
422 |
||
423 |
ResetParams(); |
|
424 |
||
425 |
/*Preconditions*/ |
|
426 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
427 |
CleanupStack::PushL(db); |
|
428 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
429 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
430 |
CleanupStack::PushL(catManager); |
|
431 |
CreateCategoriesL(catManager); |
|
432 |
CleanupStack::PopAndDestroy(2,db); |
|
433 |
||
434 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KOtherDatabase); |
|
435 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
436 |
CleanupStack::PopAndDestroy(dbInfo); |
|
437 |
||
438 |
db = CPosLandmarkDatabase::OpenL(KOtherDatabase); |
|
439 |
CleanupStack::PushL(db); |
|
440 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
441 |
catManager = CPosLmCategoryManager::NewL(*db); |
|
442 |
CleanupStack::PushL(catManager); |
|
443 |
CreateCategoriesOtherL(catManager); |
|
444 |
CleanupStack::PopAndDestroy(2,db); |
|
445 |
||
446 |
||
447 |
TLiwGenericParam param; |
|
448 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
449 |
iInList->AppendL(param); |
|
450 |
param.Reset(); |
|
451 |
||
452 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
453 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString)); |
|
454 |
param.SetNameAndValueL(KFilter,TLiwVariant(categoryMap)); |
|
455 |
iInList->AppendL(param); |
|
456 |
categoryMap->DecRef(); |
|
457 |
param.Reset(); |
|
458 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,0,0); |
|
459 |
ret |= CheckErrorCode (*iOutList,err); |
|
460 |
if ( err != KErrNone ) |
|
461 |
{ |
|
462 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
463 |
ret |= FAIL; |
|
464 |
} |
|
465 |
||
466 |
TInt Index = 0; |
|
467 |
const TLiwGenericParam* itrparm = iOutList->FindFirst(Index,KReturnValue); |
|
468 |
if ( !itrparm ) |
|
469 |
{ |
|
470 |
iLog->Log( _L("Database iterator not found in output ArgList") ); |
|
471 |
ret |= FAIL; |
|
472 |
} |
|
473 |
else |
|
474 |
{ |
|
475 |
TLiwVariant cat; |
|
476 |
CLiwIterable* iter = itrparm->Value().AsIterable(); |
|
477 |
TInt cnt = 0; |
|
478 |
while ( iter->NextL(cat) ) |
|
479 |
{ |
|
480 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
481 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
482 |
TPtrC categoryName = category->Des(); |
|
483 |
||
484 |
if (categoryName == KCatName1 || |
|
485 |
categoryName == KCatName2 || |
|
486 |
categoryName == KCatName3) |
|
487 |
{ |
|
488 |
cnt++; |
|
489 |
CleanupStack::PopAndDestroy(category); |
|
490 |
} |
|
491 |
cat.Reset(); |
|
492 |
} |
|
493 |
if ( 3 != cnt ) |
|
494 |
{ |
|
495 |
iLog->Log( _L("All expected categories not listed") ); |
|
496 |
ret |= FAIL; |
|
497 |
} |
|
498 |
||
499 |
iter->Reset(); |
|
500 |
cnt = 0; |
|
501 |
while ( iter->NextL(cat) ) |
|
502 |
{ |
|
503 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
504 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
505 |
TPtrC categoryName = category->Des(); |
|
506 |
||
507 |
if (categoryName == KCatName1 || |
|
508 |
categoryName == KCatName2 || |
|
509 |
categoryName == KCatName3) |
|
510 |
{ |
|
511 |
cnt++; |
|
512 |
CleanupStack::PopAndDestroy(category); |
|
513 |
} |
|
514 |
cat.Reset(); |
|
515 |
} |
|
516 |
if ( 3 != cnt ) |
|
517 |
{ |
|
518 |
iLog->Log( _L("All expected categories not listed after reset") ); |
|
519 |
ret |= FAIL; |
|
520 |
} |
|
521 |
||
522 |
} |
|
523 |
ResetParams (); |
|
524 |
categoryMap->DecRef(); |
|
525 |
||
526 |
||
527 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
528 |
iInList->AppendL(param); |
|
529 |
param.Reset(); |
|
530 |
||
531 |
categoryMap = CLiwDefaultMap::NewL(); |
|
532 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString1)); |
|
533 |
categoryMap->InsertL(KDbUri,TLiwVariant(KOtherDatabase)); |
|
534 |
param.SetNameAndValueL(KFilter,TLiwVariant(categoryMap)); |
|
535 |
iInList->AppendL(param); |
|
536 |
categoryMap->DecRef(); |
|
537 |
param.Reset(); |
|
538 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,0,0); |
|
539 |
ret |= CheckErrorCode (*iOutList,err); |
|
540 |
if ( err != KErrNone ) |
|
541 |
{ |
|
542 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
543 |
ret |= FAIL; |
|
544 |
} |
|
545 |
||
546 |
Index = 0; |
|
547 |
itrparm = iOutList->FindFirst(Index,KReturnValue); |
|
548 |
if ( !itrparm ) |
|
549 |
{ |
|
550 |
iLog->Log( _L("Database iterator not found in output ArgList") ); |
|
551 |
ret |= FAIL; |
|
552 |
} |
|
553 |
else |
|
554 |
{ |
|
555 |
TLiwVariant cat; |
|
556 |
CLiwIterable* iter = itrparm->Value().AsIterable(); |
|
557 |
TInt cnt = 0; |
|
558 |
while ( iter->NextL(cat) ) |
|
559 |
{ |
|
560 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
561 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
562 |
TPtrC categoryName = category->Des(); |
|
563 |
||
564 |
if (categoryName == KOtherCatName1 || |
|
565 |
categoryName == KOtherCatName2 || |
|
566 |
categoryName == KOtherCatName3) |
|
567 |
{ |
|
568 |
cnt++; |
|
569 |
CleanupStack::PopAndDestroy(category); |
|
570 |
} |
|
571 |
cat.Reset(); |
|
572 |
} |
|
573 |
if ( 3 != cnt ) |
|
574 |
{ |
|
575 |
iLog->Log( _L("All expected categories not listed") ); |
|
576 |
ret |= FAIL; |
|
577 |
} |
|
578 |
||
579 |
iter->Reset(); |
|
580 |
cnt = 0; |
|
581 |
while ( iter->NextL(cat) ) |
|
582 |
{ |
|
583 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
584 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
585 |
TPtrC categoryName = category->Des(); |
|
586 |
||
587 |
if (categoryName == KOtherCatName1 || |
|
588 |
categoryName == KOtherCatName2 || |
|
589 |
categoryName == KOtherCatName3) |
|
590 |
{ |
|
591 |
cnt++; |
|
592 |
CleanupStack::PopAndDestroy(category); |
|
593 |
} |
|
594 |
cat.Reset(); |
|
595 |
} |
|
596 |
if ( 3 != cnt ) |
|
597 |
{ |
|
598 |
iLog->Log( _L("All expected categories not listed after reset") ); |
|
599 |
ret |= FAIL; |
|
600 |
} |
|
601 |
||
602 |
} |
|
603 |
categoryMap->DecRef(); |
|
604 |
iInList->Reset(); |
|
605 |
iOutList->Reset(); |
|
606 |
||
607 |
iLog->Log( _L("End of CategorySyncTest2") ); |
|
608 |
||
609 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
610 |
ReleaseLandmarkResources(); |
|
611 |
__UHEAP_MARKEND; |
|
612 |
return ret; |
|
613 |
} |
|
614 |
||
615 |
// ----------------------------------------------------------------------------- |
|
616 |
// CTLmCategoryTests::CategoryAsyncTest1 |
|
617 |
// Example test method function. |
|
618 |
// (other items were commented in a header). |
|
619 |
// ----------------------------------------------------------------------------- |
|
620 |
// |
|
621 |
TInt CTLmCategoryTests::CategoryAsyncTest1 ( CStifItemParser& /*aItem */ ) |
|
622 |
{ |
|
623 |
_LIT( KExample, "CategoryAsyncTest1" ); |
|
624 |
iLog->Log( KExample ); |
|
625 |
iTestID = ETEST1; |
|
626 |
iResult = 0; |
|
627 |
||
628 |
TInt32 err; |
|
629 |
TInt ret = 0; |
|
630 |
||
631 |
__UHEAP_MARK; |
|
632 |
CLiwServiceHandler* ServiceHandler; |
|
633 |
||
634 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
635 |
CleanupStack::PushL(ServiceHandler); |
|
636 |
CleanupClosePushL(*iLandmarkIf); |
|
637 |
||
638 |
iInList = &(ServiceHandler->InParamListL()); |
|
639 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
640 |
||
641 |
ResetParams(); |
|
642 |
||
643 |
/*Preconditions*/ |
|
644 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
645 |
CleanupStack::PushL(db); |
|
646 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
647 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
648 |
CleanupStack::PushL(catManager); |
|
649 |
CreateCategoriesL(catManager); |
|
650 |
CleanupStack::PopAndDestroy(2,db); |
|
651 |
||
652 |
TLiwGenericParam param; |
|
653 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
654 |
iInList->AppendL(param); |
|
655 |
param.Reset(); |
|
656 |
||
657 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
658 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString)); |
|
659 |
param.SetNameAndValueL(KFilter,TLiwVariant(categoryMap)); |
|
660 |
iInList->AppendL(param); |
|
661 |
categoryMap->DecRef(); |
|
662 |
param.Reset(); |
|
663 |
||
664 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,KLiwOptASyncronous,this); |
|
665 |
ret |= CheckErrorCode (*iOutList,err); |
|
666 |
if ( err != KErrNone ) |
|
667 |
{ |
|
668 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
669 |
ret |= FAIL; |
|
670 |
} |
|
671 |
||
672 |
TInt Index = -1; |
|
673 |
const TLiwGenericParam* cparam = iOutList->FindFirst(Index,KReturnValue); |
|
674 |
if ( cparam ) |
|
675 |
{ |
|
676 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
677 |
ret |= FAIL; |
|
678 |
} |
|
679 |
||
680 |
Index = 0; |
|
681 |
cparam = iOutList->FindFirst(Index,KTransactionId); |
|
682 |
if ( !cparam ) |
|
683 |
{ |
|
684 |
iLog->Log( _L("TransactionID not found in output ArgList") ); |
|
685 |
ret |= FAIL; |
|
686 |
} |
|
687 |
||
688 |
if ( !ret ) |
|
689 |
CActiveScheduler::Start(); |
|
690 |
||
691 |
iLog->Log( _L("End of CategoryAsyncTest1") ); |
|
692 |
ret |= iResult; |
|
693 |
||
694 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
695 |
ReleaseLandmarkResources(); |
|
696 |
__UHEAP_MARKEND; |
|
697 |
||
698 |
return ret; |
|
699 |
} |
|
700 |
||
701 |
// ----------------------------------------------------------------------------- |
|
702 |
// CTLmCategoryTests::CategoryAsyncTestPos1 |
|
703 |
// Example test method function. |
|
704 |
// (other items were commented in a header). |
|
705 |
// ----------------------------------------------------------------------------- |
|
706 |
// |
|
707 |
TInt CTLmCategoryTests::CategoryAsyncTestPos1 ( CStifItemParser& /*aItem */ ) |
|
708 |
{ |
|
709 |
_LIT( KExample, "CategoryAsyncTestPos1" ); |
|
710 |
iLog->Log( KExample ); |
|
711 |
iTestID = ETEST1; |
|
712 |
iResult = 0; |
|
713 |
||
714 |
TInt32 err; |
|
715 |
TInt ret = 0; |
|
716 |
||
717 |
__UHEAP_MARK; |
|
718 |
CLiwServiceHandler* ServiceHandler; |
|
719 |
||
720 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
721 |
CleanupStack::PushL(ServiceHandler); |
|
722 |
CleanupClosePushL(*iLandmarkIf); |
|
723 |
||
724 |
iInList = &(ServiceHandler->InParamListL()); |
|
725 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
726 |
||
727 |
ResetParams(); |
|
728 |
||
729 |
/*Preconditions*/ |
|
730 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
731 |
CleanupStack::PushL(db); |
|
732 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
733 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
734 |
CleanupStack::PushL(catManager); |
|
735 |
CreateCategoriesL(catManager); |
|
736 |
CleanupStack::PopAndDestroy(2,db); |
|
737 |
||
738 |
TLiwGenericParam param; |
|
739 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KCategory)); |
|
740 |
iInList->AppendL(param); |
|
741 |
param.Reset(); |
|
742 |
||
743 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
744 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString)); |
|
745 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(categoryMap)); |
|
746 |
iInList->AppendL(param); |
|
747 |
categoryMap->DecRef(); |
|
748 |
param.Reset(); |
|
749 |
||
750 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,KLiwOptASyncronous,this); |
|
751 |
ret |= CheckErrorCode (*iOutList,err); |
|
752 |
if ( err != KErrNone ) |
|
753 |
{ |
|
754 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
755 |
ret |= FAIL; |
|
756 |
} |
|
757 |
||
758 |
TInt Index = -1; |
|
759 |
const TLiwGenericParam* cparam = iOutList->FindFirst(Index,KReturnValue); |
|
760 |
if ( cparam ) |
|
761 |
{ |
|
762 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
763 |
ret |= FAIL; |
|
764 |
} |
|
765 |
||
766 |
Index = 0; |
|
767 |
cparam = iOutList->FindFirst(Index,KTransactionId); |
|
768 |
if ( !cparam ) |
|
769 |
{ |
|
770 |
iLog->Log( _L("TransactionID not found in output ArgList") ); |
|
771 |
ret |= FAIL; |
|
772 |
} |
|
773 |
||
774 |
if ( !ret ) |
|
775 |
CActiveScheduler::Start(); |
|
776 |
||
777 |
iLog->Log( _L("End of CategoryAsyncTest1") ); |
|
778 |
ret |= iResult; |
|
779 |
||
780 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
781 |
ReleaseLandmarkResources(); |
|
782 |
__UHEAP_MARKEND; |
|
783 |
||
784 |
return ret; |
|
785 |
} |
|
786 |
||
787 |
// ----------------------------------------------------------------------------- |
|
788 |
// CTLmCategoryTests::AddCategoryL |
|
789 |
// Example test method function. |
|
790 |
// (other items were commented in a header). |
|
791 |
// ----------------------------------------------------------------------------- |
|
792 |
// |
|
793 |
TInt CTLmCategoryTests::AddCategoryL( CStifItemParser& /*aItem */ ) |
|
794 |
{ |
|
795 |
_LIT( KExample, "In AddCategoryL" ); |
|
796 |
_LIT(KOffice,"NokiaUpdate"); |
|
797 |
iLog->Log( KExample ); |
|
798 |
||
799 |
TInt ret=0; |
|
800 |
TInt32 err; |
|
801 |
||
802 |
__UHEAP_MARK; |
|
803 |
CLiwServiceHandler* ServiceHandler; |
|
804 |
||
805 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
806 |
CleanupStack::PushL(ServiceHandler); |
|
807 |
CleanupClosePushL(*iLandmarkIf); |
|
808 |
||
809 |
iInList = &(ServiceHandler->InParamListL()); |
|
810 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
811 |
||
812 |
ResetParams(); |
|
813 |
||
814 |
/*Preconditions*/ |
|
815 |
||
816 |
TLiwGenericParam param; |
|
817 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
818 |
iInList->AppendL(param); |
|
819 |
param.Reset(); |
|
820 |
||
821 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
822 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
823 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
824 |
iInList->AppendL(param); |
|
825 |
categoryMap->DecRef(); |
|
826 |
param.Reset(); |
|
827 |
||
828 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
829 |
ret |= CheckErrorCode (*iOutList,err); |
|
830 |
if ( err != KErrNone ) |
|
831 |
{ |
|
832 |
iLog->Log( _L(" AddCategory on database failed with err...") ); |
|
833 |
ret |= FAIL; |
|
834 |
} |
|
835 |
||
836 |
iLog->Log( _L("End of AddCategoryL") ); |
|
837 |
||
838 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
839 |
ReleaseLandmarkResources(); |
|
840 |
__UHEAP_MARKEND; |
|
841 |
return ret; |
|
842 |
} |
|
843 |
||
844 |
// ----------------------------------------------------------------------------- |
|
845 |
// CTLmCategoryTests::AddCategoryL |
|
846 |
// Example test method function. |
|
847 |
// (other items were commented in a header). |
|
848 |
// ----------------------------------------------------------------------------- |
|
849 |
// |
|
850 |
TInt CTLmCategoryTests::AddCategoryPosL( CStifItemParser& /*aItem */ ) |
|
851 |
{ |
|
852 |
_LIT( KExample, "In AddCategoryPosL" ); |
|
853 |
_LIT(KOffice,"NokiaUpdate"); |
|
854 |
iLog->Log( KExample ); |
|
855 |
||
856 |
TInt ret=0; |
|
857 |
TInt32 err; |
|
858 |
||
859 |
__UHEAP_MARK; |
|
860 |
CLiwServiceHandler* ServiceHandler; |
|
861 |
||
862 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
863 |
CleanupStack::PushL(ServiceHandler); |
|
864 |
CleanupClosePushL(*iLandmarkIf); |
|
865 |
||
866 |
iInList = &(ServiceHandler->InParamListL()); |
|
867 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
868 |
||
869 |
ResetParams(); |
|
870 |
/*Preconditions*/ |
|
871 |
||
872 |
TLiwGenericParam param; |
|
873 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KCategory)); |
|
874 |
iInList->AppendL(param); |
|
875 |
param.Reset(); |
|
876 |
||
877 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
878 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
879 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(categoryMap)); |
|
880 |
iInList->AppendL(param); |
|
881 |
categoryMap->DecRef(); |
|
882 |
param.Reset(); |
|
883 |
||
884 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
885 |
ret |= CheckErrorCode (*iOutList,err); |
|
886 |
if ( err != KErrNone ) |
|
887 |
{ |
|
888 |
iLog->Log( _L(" AddCategory on database failed with err...") ); |
|
889 |
ret |= FAIL; |
|
890 |
} |
|
891 |
||
892 |
iLog->Log( _L("End of AddCategoryL") ); |
|
893 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
894 |
ReleaseLandmarkResources(); |
|
895 |
__UHEAP_MARKEND; |
|
896 |
return ret; |
|
897 |
} |
|
898 |
||
899 |
// ----------------------------------------------------------------------------- |
|
900 |
// CTLmCategoryTests::AddCategory1L |
|
901 |
// Example test method function. |
|
902 |
// (other items were commented in a header). |
|
903 |
// ----------------------------------------------------------------------------- |
|
904 |
// |
|
905 |
TInt CTLmCategoryTests::AddCategory1L( CStifItemParser& /*aItem */) |
|
906 |
{ |
|
907 |
_LIT( KExample, "In AddCategory1L" ); |
|
908 |
iLog->Log( KExample ); |
|
909 |
_LIT(KOffice1,"NokiaPrevious"); |
|
910 |
_LIT(KOffice,"NokiaUpdate"); |
|
911 |
TInt ret=0; |
|
912 |
TInt32 err; |
|
913 |
||
914 |
__UHEAP_MARK; |
|
915 |
CLiwServiceHandler* ServiceHandler; |
|
916 |
||
917 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
918 |
CleanupStack::PushL(ServiceHandler); |
|
919 |
CleanupClosePushL(*iLandmarkIf); |
|
920 |
||
921 |
iInList = &(ServiceHandler->InParamListL()); |
|
922 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
923 |
||
924 |
ResetParams(); |
|
925 |
||
926 |
||
927 |
/*Preconditions*/ |
|
928 |
||
929 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KOtherDatabase); |
|
930 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
931 |
CleanupStack::PopAndDestroy(dbInfo); |
|
932 |
||
933 |
TLiwGenericParam param; |
|
934 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
935 |
iInList->AppendL(param); |
|
936 |
param.Reset(); |
|
937 |
||
938 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
939 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
940 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
941 |
iInList->AppendL(param); |
|
942 |
categoryMap->DecRef(); |
|
943 |
param.Reset(); |
|
944 |
||
945 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
946 |
ret |= CheckErrorCode (*iOutList,err); |
|
947 |
if ( err != KErrNone ) |
|
948 |
{ |
|
949 |
iLog->Log( _L(" AddCategory on database failed with err...") ); |
|
950 |
ret |= FAIL; |
|
951 |
} |
|
952 |
categoryMap->DecRef(); |
|
953 |
ResetParams(); |
|
954 |
||
955 |
categoryMap = CLiwDefaultMap::NewL(); |
|
956 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
957 |
iInList->AppendL(param); |
|
958 |
param.Reset(); |
|
959 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
960 |
categoryMap->InsertL(KDbUri,TLiwVariant(KOtherDatabase)); |
|
961 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
962 |
iInList->AppendL(param); |
|
963 |
categoryMap->DecRef(); |
|
964 |
param.Reset(); |
|
965 |
||
966 |
iLog->Log( _L(" Calling ExecuteCmdL again.") ); |
|
967 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
968 |
ret |= CheckErrorCode (*iOutList,err); |
|
969 |
if ( err != KErrNone ) |
|
970 |
{ |
|
971 |
iLog->Log( _L(" AddCategory on database failed with err...") ); |
|
972 |
ret |= FAIL; |
|
973 |
} |
|
974 |
categoryMap->DecRef(); |
|
975 |
ResetParams(); |
|
976 |
||
977 |
||
978 |
categoryMap = CLiwDefaultMap::NewL(); |
|
979 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
980 |
iInList->AppendL(param); |
|
981 |
param.Reset(); |
|
982 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice1)); |
|
983 |
categoryMap->InsertL(KDbUri,TLiwVariant(KOtherDatabase)); |
|
984 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
985 |
iInList->AppendL(param); |
|
986 |
categoryMap->DecRef(); |
|
987 |
param.Reset(); |
|
988 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
989 |
ret |= CheckErrorCode (*iOutList,err); |
|
990 |
if ( err != KErrNone ) |
|
991 |
{ |
|
992 |
iLog->Log( _L(" AddCategory on database failed with err...") ); |
|
993 |
ret |= FAIL; |
|
994 |
} |
|
995 |
||
996 |
iLog->Log( _L("End of AddCategory1L") ); |
|
997 |
||
998 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
999 |
ReleaseLandmarkResources(); |
|
1000 |
__UHEAP_MARKEND; |
|
1001 |
return ret; |
|
1002 |
} |
|
1003 |
||
1004 |
// ----------------------------------------------------------------------------- |
|
1005 |
// CTLmCategoryTests::UpdateCategoryL |
|
1006 |
// Example test method function. |
|
1007 |
// (other items were commented in a header). |
|
1008 |
// ----------------------------------------------------------------------------- |
|
1009 |
// |
|
1010 |
TInt CTLmCategoryTests::UpdateCategoryL( CStifItemParser& /*aItem */) |
|
1011 |
{ |
|
1012 |
_LIT( KExample, "In UpdateCategoryL" ); |
|
1013 |
iLog->Log( KExample ); |
|
1014 |
_LIT(KOffice,"NokiaUpdate"); |
|
1015 |
TInt ret=0; |
|
1016 |
TInt32 err; |
|
1017 |
TPosLmItemId catid1; |
|
1018 |
||
1019 |
__UHEAP_MARK; |
|
1020 |
CLiwServiceHandler* ServiceHandler; |
|
1021 |
||
1022 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
1023 |
CleanupStack::PushL(ServiceHandler); |
|
1024 |
CleanupClosePushL(*iLandmarkIf); |
|
1025 |
||
1026 |
iInList = &(ServiceHandler->InParamListL()); |
|
1027 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
1028 |
||
1029 |
ResetParams(); |
|
1030 |
||
1031 |
||
1032 |
/*Preconditions*/ |
|
1033 |
||
1034 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
1035 |
CleanupStack::PushL(db); |
|
1036 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1037 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1038 |
CleanupStack::PushL(catManager); |
|
1039 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1040 |
category->SetCategoryNameL(KOffice); |
|
1041 |
catid1=catManager->AddCategoryL(*category); |
|
1042 |
CleanupStack::PopAndDestroy(3,db); |
|
1043 |
||
1044 |
TLiwGenericParam param; |
|
1045 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
1046 |
iInList->AppendL(param); |
|
1047 |
param.Reset(); |
|
1048 |
||
1049 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
1050 |
TBuf<5> catIdString1; |
|
1051 |
catIdString1.Num(catid1,EDecimal); |
|
1052 |
categoryMap->InsertL(KId,TLiwVariant(catIdString1)); |
|
1053 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
1054 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
1055 |
iInList->AppendL(param); |
|
1056 |
categoryMap->DecRef(); |
|
1057 |
param.Reset(); |
|
1058 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
1059 |
ret |= CheckErrorCode (*iOutList,err); |
|
1060 |
if ( err != KErrNone ) |
|
1061 |
{ |
|
1062 |
iLog->Log( _L(" UpdateCategory1L on database failed with err...") ); |
|
1063 |
ret |= FAIL; |
|
1064 |
} |
|
1065 |
categoryMap->DecRef(); |
|
1066 |
||
1067 |
iLog->Log( _L("End of UpdateCategoryL") ); |
|
1068 |
||
1069 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1070 |
ReleaseLandmarkResources(); |
|
1071 |
__UHEAP_MARKEND; |
|
1072 |
return ret; |
|
1073 |
} |
|
1074 |
||
1075 |
// ----------------------------------------------------------------------------- |
|
1076 |
// CTLmCategoryTests::UpdateCategoryL |
|
1077 |
// Example test method function. |
|
1078 |
// (other items were commented in a header). |
|
1079 |
// ----------------------------------------------------------------------------- |
|
1080 |
// |
|
1081 |
TInt CTLmCategoryTests::UpdateCategoryPosL( CStifItemParser& /*aItem */) |
|
1082 |
{ |
|
1083 |
_LIT( KExample, "In UpdateCategoryPosL" ); |
|
1084 |
iLog->Log( KExample ); |
|
1085 |
_LIT(KOffice,"NokiaUpdate"); |
|
1086 |
TInt ret=0; |
|
1087 |
TInt32 err; |
|
1088 |
TPosLmItemId catid1; |
|
1089 |
||
1090 |
__UHEAP_MARK; |
|
1091 |
CLiwServiceHandler* ServiceHandler; |
|
1092 |
||
1093 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
1094 |
CleanupStack::PushL(ServiceHandler); |
|
1095 |
CleanupClosePushL(*iLandmarkIf); |
|
1096 |
||
1097 |
iInList = &(ServiceHandler->InParamListL()); |
|
1098 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
1099 |
||
1100 |
ResetParams(); |
|
1101 |
||
1102 |
||
1103 |
/*Preconditions*/ |
|
1104 |
||
1105 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
1106 |
CleanupStack::PushL(db); |
|
1107 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1108 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1109 |
CleanupStack::PushL(catManager); |
|
1110 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1111 |
category->SetCategoryNameL(KOffice); |
|
1112 |
catid1=catManager->AddCategoryL(*category); |
|
1113 |
CleanupStack::PopAndDestroy(3,db); |
|
1114 |
||
1115 |
TLiwGenericParam param; |
|
1116 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KCategory)); |
|
1117 |
iInList->AppendL(param); |
|
1118 |
param.Reset(); |
|
1119 |
||
1120 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
1121 |
TBuf<5> catIdString1; |
|
1122 |
catIdString1.Num(catid1,EDecimal); |
|
1123 |
categoryMap->InsertL(KId,TLiwVariant(catIdString1)); |
|
1124 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
1125 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(categoryMap)); |
|
1126 |
iInList->AppendL(param); |
|
1127 |
categoryMap->DecRef(); |
|
1128 |
param.Reset(); |
|
1129 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
1130 |
ret |= CheckErrorCode (*iOutList,err); |
|
1131 |
if ( err != KErrNone ) |
|
1132 |
{ |
|
1133 |
iLog->Log( _L(" UpdateCategory1L on database failed with err...") ); |
|
1134 |
ret |= FAIL; |
|
1135 |
} |
|
1136 |
categoryMap->DecRef(); |
|
1137 |
||
1138 |
iLog->Log( _L("End of UpdateCategoryL") ); |
|
1139 |
||
1140 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1141 |
ReleaseLandmarkResources(); |
|
1142 |
__UHEAP_MARKEND; |
|
1143 |
return ret; |
|
1144 |
} |
|
1145 |
||
1146 |
// ----------------------------------------------------------------------------- |
|
1147 |
// CTLmCategoryTests::UpdateCategory1L |
|
1148 |
// Example test method function. |
|
1149 |
// (other items were commented in a header). |
|
1150 |
// ----------------------------------------------------------------------------- |
|
1151 |
// |
|
1152 |
TInt CTLmCategoryTests::UpdateCategory1L( CStifItemParser& /*aItem */) |
|
1153 |
{ |
|
1154 |
_LIT( KExample, "In UpdateCategory1L" ); |
|
1155 |
iLog->Log( KExample ); |
|
1156 |
_LIT(KOffice1,"NokiaPrevious"); |
|
1157 |
_LIT(KOffice,"NokiaUpdate"); |
|
1158 |
TInt ret=0; |
|
1159 |
TInt32 err; |
|
1160 |
TPosLmItemId catid1,catid2; |
|
1161 |
||
1162 |
__UHEAP_MARK; |
|
1163 |
CLiwServiceHandler* ServiceHandler; |
|
1164 |
||
1165 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
1166 |
CleanupStack::PushL(ServiceHandler); |
|
1167 |
CleanupClosePushL(*iLandmarkIf); |
|
1168 |
||
1169 |
iInList = &(ServiceHandler->InParamListL()); |
|
1170 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
1171 |
||
1172 |
ResetParams(); |
|
1173 |
||
1174 |
||
1175 |
/*Preconditions*/ |
|
1176 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
1177 |
CleanupStack::PushL(db); |
|
1178 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1179 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1180 |
CleanupStack::PushL(catManager); |
|
1181 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1182 |
category->SetCategoryNameL(KOffice); |
|
1183 |
catid1=catManager->AddCategoryL(*category); |
|
1184 |
CleanupStack::PopAndDestroy(3,db); |
|
1185 |
||
1186 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KOtherDatabase); |
|
1187 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
1188 |
CleanupStack::PopAndDestroy(dbInfo); |
|
1189 |
||
1190 |
db = CPosLandmarkDatabase::OpenL(KOtherDatabase); |
|
1191 |
CleanupStack::PushL(db); |
|
1192 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1193 |
catManager= CPosLmCategoryManager::NewL(*db); |
|
1194 |
CleanupStack::PushL(catManager); |
|
1195 |
category = CPosLandmarkCategory::NewLC(); |
|
1196 |
category->SetCategoryNameL(KOffice1); |
|
1197 |
catid2=catManager->AddCategoryL(*category); |
|
1198 |
CleanupStack::PopAndDestroy(3,db); |
|
1199 |
||
1200 |
TLiwGenericParam param; |
|
1201 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
1202 |
iInList->AppendL(param); |
|
1203 |
param.Reset(); |
|
1204 |
||
1205 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
1206 |
TBuf<5> catIdString1; |
|
1207 |
catIdString1.Num(catid1,EDecimal); |
|
1208 |
categoryMap->InsertL(KId,TLiwVariant(catIdString1)); |
|
1209 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
1210 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
1211 |
iInList->AppendL(param); |
|
1212 |
categoryMap->DecRef(); |
|
1213 |
param.Reset(); |
|
1214 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
1215 |
ret |= CheckErrorCode (*iOutList,err); |
|
1216 |
if ( err != KErrNone ) |
|
1217 |
{ |
|
1218 |
iLog->Log( _L(" UpdateCategory1L on database failed with err...") ); |
|
1219 |
ret |= FAIL; |
|
1220 |
} |
|
1221 |
categoryMap->DecRef(); |
|
1222 |
ResetParams(); |
|
1223 |
||
1224 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
1225 |
iInList->AppendL(param); |
|
1226 |
param.Reset(); |
|
1227 |
categoryMap = CLiwDefaultMap::NewL(); |
|
1228 |
TBuf<5> catIdString2; |
|
1229 |
catIdString2.Num(catid2,EDecimal); |
|
1230 |
categoryMap->InsertL(KId,TLiwVariant(catIdString2)); |
|
1231 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
1232 |
categoryMap->InsertL(KDbUri,TLiwVariant(KOtherDatabase)); |
|
1233 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
1234 |
iInList->AppendL(param); |
|
1235 |
categoryMap->DecRef(); |
|
1236 |
param.Reset(); |
|
1237 |
iLandmarkIf->ExecuteCmdL(KAdd,*iInList,*iOutList,0,0); |
|
1238 |
ret |= CheckErrorCode (*iOutList,err); |
|
1239 |
if ( err != KErrNone ) |
|
1240 |
{ |
|
1241 |
iLog->Log( _L(" UpdateCategory1L on database failed with err...") ); |
|
1242 |
ret |= FAIL; |
|
1243 |
} |
|
1244 |
categoryMap->DecRef(); |
|
1245 |
||
1246 |
iLog->Log( _L("End of UpdateCategory1L") ); |
|
1247 |
||
1248 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1249 |
ReleaseLandmarkResources(); |
|
1250 |
__UHEAP_MARKEND; |
|
1251 |
||
1252 |
return ret; |
|
1253 |
} |
|
1254 |
||
1255 |
// ----------------------------------------------------------------------------- |
|
1256 |
// CTLmCategoryTests::CheckErrorCode |
|
1257 |
// checks error code e |
|
1258 |
// called by all testcases. |
|
1259 |
// ----------------------------------------------------------------------------- |
|
1260 |
// |
|
1261 |
TInt CTLmCategoryTests::CheckErrorCode( const CLiwGenericParamList& aOutList, TInt32 &aError ) |
|
1262 |
{ |
|
1263 |
iLog->Log( _L("In CheckErrorCode") ); |
|
1264 |
TInt Index = 0; |
|
1265 |
const TLiwGenericParam* errcode = aOutList.FindFirst(Index,KErrorCode); |
|
1266 |
if ( KErrNotFound == Index ) |
|
1267 |
{ |
|
1268 |
iLog->Log( _L("ErrorCode not found in output ArgList") ); |
|
1269 |
return FAIL; |
|
1270 |
} |
|
1271 |
else |
|
1272 |
errcode->Value().Get(aError); |
|
1273 |
iLog->Log( _L("End of CheckErrorCode") ); |
|
1274 |
return PASS; |
|
1275 |
} |
|
1276 |
||
1277 |
// ----------------------------------------------------------------------------- |
|
1278 |
// CTLmCategoryTests::RemoveAllCategoriesL |
|
1279 |
// Helper method to remove all categories for preconditional tests. |
|
1280 |
// ----------------------------------------------------------------------------- |
|
1281 |
// |
|
1282 |
void CTLmCategoryTests::RemoveAllCategoriesL (CPosLmCategoryManager* aHandle) |
|
1283 |
{ |
|
1284 |
iLog->Log( _L("In RemoveAllCategoriesLL") ); |
|
1285 |
TPosLmItemId catID; |
|
1286 |
CPosLmItemIterator*iterator = aHandle->CategoryIteratorL(); |
|
1287 |
CleanupStack::PushL(iterator); |
|
1288 |
||
1289 |
while ((catID = iterator->NextL()) != KPosLmNullItemId) |
|
1290 |
{ |
|
1291 |
TRAP_IGNORE(ExecuteAndDeleteLD(aHandle->RemoveCategoryL( catID ))); |
|
1292 |
} |
|
1293 |
CleanupStack::PopAndDestroy(iterator); |
|
1294 |
iLog->Log( _L("End of RemoveAllCategoriesLL") ); |
|
1295 |
} |
|
1296 |
||
1297 |
// ----------------------------------------------------------------------------- |
|
1298 |
// CTLmCategoryTests::HandleNotifyL |
|
1299 |
// This gets called on completion of async request. |
|
1300 |
// ----------------------------------------------------------------------------- |
|
1301 |
// |
|
1302 |
TInt CTLmCategoryTests::HandleNotifyL( |
|
1303 |
TInt /*aCmdId*/, |
|
1304 |
TInt /*aEventId*/, |
|
1305 |
CLiwGenericParamList& aEventParamList, |
|
1306 |
const CLiwGenericParamList& /*aInputParam*/) |
|
1307 |
{ |
|
1308 |
iLog->Log( _L("In HandleNotifyL") ); |
|
1309 |
switch (iTestID) |
|
1310 |
{ |
|
1311 |
case ETEST1: |
|
1312 |
iResult = HandleAsyncTest1(aEventParamList); |
|
1313 |
break; |
|
1314 |
case ETEST2: |
|
1315 |
iResult = HandleAsyncTest2(aEventParamList); |
|
1316 |
break; |
|
1317 |
case ETEST3: |
|
1318 |
return KErrNone; |
|
1319 |
||
1320 |
default: |
|
1321 |
break; |
|
1322 |
} |
|
1323 |
iLog->Log( _L("Stopping Active Schduler in HandleNotifyL") ); |
|
1324 |
CActiveScheduler::Stop(); |
|
1325 |
return KErrNone; |
|
1326 |
} |
|
1327 |
||
1328 |
// ----------------------------------------------------------------------------- |
|
1329 |
// CTLmCategoryTests::CreateCategoriesL |
|
1330 |
// Helper method to add categories to a default database. |
|
1331 |
// ----------------------------------------------------------------------------- |
|
1332 |
// |
|
1333 |
void CTLmCategoryTests::CreateCategoriesL (CPosLmCategoryManager* aHandle) |
|
1334 |
{ |
|
1335 |
iLog->Log( _L("In CreateCategoriesL") ); |
|
1336 |
CPosLandmarkCategory * lc = CPosLandmarkCategory::NewLC (); |
|
1337 |
||
1338 |
lc->SetCategoryNameL (KCatName1); |
|
1339 |
aHandle->AddCategoryL (*lc); |
|
1340 |
||
1341 |
lc->SetCategoryNameL (KCatName2); |
|
1342 |
aHandle->AddCategoryL (*lc); |
|
1343 |
||
1344 |
lc->SetCategoryNameL (KCatName3); |
|
1345 |
aHandle->AddCategoryL (*lc); |
|
1346 |
||
1347 |
lc->SetCategoryNameL (KCatName4); |
|
1348 |
aHandle->AddCategoryL (*lc); |
|
1349 |
||
1350 |
lc->SetCategoryNameL (KCatName5); |
|
1351 |
aHandle->AddCategoryL (*lc); |
|
1352 |
||
1353 |
lc->SetCategoryNameL (KCatName6); |
|
1354 |
aHandle->AddCategoryL (*lc); |
|
1355 |
||
1356 |
CleanupStack::PopAndDestroy(lc); |
|
1357 |
iLog->Log( _L("End of CreateCategoriesL") ); |
|
1358 |
} |
|
1359 |
// ----------------------------------------------------------------------------- |
|
1360 |
// CTLmCategoryTests::CreateCategoriesOtherL |
|
1361 |
// Helper method to add categories to a default database. |
|
1362 |
// ----------------------------------------------------------------------------- |
|
1363 |
// |
|
1364 |
void CTLmCategoryTests::CreateCategoriesOtherL (CPosLmCategoryManager* aHandle) |
|
1365 |
{ |
|
1366 |
iLog->Log( _L("In CreateCategoriesOtherL") ); |
|
1367 |
CPosLandmarkCategory * lc = CPosLandmarkCategory::NewLC (); |
|
1368 |
||
1369 |
lc->SetCategoryNameL (KOtherCatName1); |
|
1370 |
aHandle->AddCategoryL (*lc); |
|
1371 |
||
1372 |
lc->SetCategoryNameL (KOtherCatName2); |
|
1373 |
aHandle->AddCategoryL (*lc); |
|
1374 |
||
1375 |
lc->SetCategoryNameL (KOtherCatName3); |
|
1376 |
aHandle->AddCategoryL (*lc); |
|
1377 |
||
1378 |
lc->SetCategoryNameL (KOtherCatName4); |
|
1379 |
aHandle->AddCategoryL (*lc); |
|
1380 |
||
1381 |
lc->SetCategoryNameL (KOtherCatName5); |
|
1382 |
aHandle->AddCategoryL (*lc); |
|
1383 |
||
1384 |
lc->SetCategoryNameL (KOtherCatName6); |
|
1385 |
aHandle->AddCategoryL (*lc); |
|
1386 |
||
1387 |
CleanupStack::PopAndDestroy(lc); |
|
1388 |
iLog->Log( _L("End of CreateCategoriesOtherL") ); |
|
1389 |
} |
|
1390 |
// ----------------------------------------------------------------------------- |
|
1391 |
// CTLmCategoryTests::DeleteAllDatabases |
|
1392 |
// removes all local databases from the terminal |
|
1393 |
// called by all testcases. |
|
1394 |
// ----------------------------------------------------------------------------- |
|
1395 |
// |
|
1396 |
void CTLmCategoryTests::DeleteAllLocalDatabasesL() |
|
1397 |
{ |
|
1398 |
iLog->Log( _L("In DeleteAllLocalDatabasesL") ); |
|
1399 |
TInt count; |
|
1400 |
CDesCArray* dbList = iDatabaseManager->ListDatabasesLC(_L("file")); |
|
1401 |
count = dbList->Count(); |
|
1402 |
||
1403 |
for ( TInt i = 0; i < count; i++ ) |
|
1404 |
{ |
|
1405 |
TPtrC db = (*dbList)[i]; |
|
1406 |
iDatabaseManager->DeleteDatabaseL ( db ); |
|
1407 |
} |
|
1408 |
CleanupStack::PopAndDestroy (dbList); |
|
1409 |
iLog->Log( _L("End of DeleteAllLocalDatabasesL") ); |
|
1410 |
} |
|
1411 |
// ----------------------------------------------------------------------------- |
|
1412 |
// CTLmCategoryTests::ResetParams |
|
1413 |
// Example test method function. |
|
1414 |
// (other items were commented in a header). |
|
1415 |
// ----------------------------------------------------------------------------- |
|
1416 |
// |
|
1417 |
void CTLmCategoryTests:: ResetParams () |
|
1418 |
{ |
|
1419 |
iLog->Log( _L("In ResetParams") ); |
|
1420 |
iOutList->Reset(); |
|
1421 |
iInList->Reset(); |
|
1422 |
iLog->Log( _L("End of ResetParams") ); |
|
1423 |
} |
|
1424 |
// ----------------------------------------------------------------------------- |
|
1425 |
// CTLmCategoryTests::GetCatName |
|
1426 |
// Example test method function. |
|
1427 |
// (other items were commented in a header). |
|
1428 |
// ----------------------------------------------------------------------------- |
|
1429 |
// |
|
1430 |
HBufC* CTLmCategoryTests::GetCatNameLC (const CLiwMap* aCategoryMap) |
|
1431 |
{ |
|
1432 |
iLog->Log( _L("In GetCatName") ); |
|
1433 |
TLiwVariant value; |
|
1434 |
if ( aCategoryMap->FindL(KCategoryName,value) ) |
|
1435 |
{ |
|
1436 |
TPtrC catname; |
|
1437 |
value.Get(catname); |
|
1438 |
iLog->Log( _L("End of GetCatName") ); |
|
1439 |
HBufC* temp = catname.AllocLC(); |
|
1440 |
value.Reset(); |
|
1441 |
return (temp); |
|
1442 |
} |
|
1443 |
else |
|
1444 |
{ |
|
1445 |
iLog->Log( _L("End of GetCatName") ); |
|
1446 |
return (NULL); |
|
1447 |
} |
|
1448 |
||
1449 |
} |
|
1450 |
||
1451 |
// ----------------------------------------------------------------------------- |
|
1452 |
// CTLmCategoryTests::HandleAsyncTest1 |
|
1453 |
// Example test method function. |
|
1454 |
// (other items were commented in a header). |
|
1455 |
// ----------------------------------------------------------------------------- |
|
1456 |
// |
|
1457 |
TInt CTLmCategoryTests::HandleAsyncTest1 (const CLiwGenericParamList& aEventParamList) |
|
1458 |
{ |
|
1459 |
TInt ret = 0; |
|
1460 |
TInt Index = 0; |
|
1461 |
iLog->Log( _L("In HandleAsyncTest1") ); |
|
1462 |
const TLiwGenericParam* itrparm = aEventParamList.FindFirst(Index,KReturnValue); |
|
1463 |
TLiwVariant cat; |
|
1464 |
CLiwIterable* iter = itrparm->Value().AsIterable(); |
|
1465 |
TInt cnt = 0; |
|
1466 |
while ( iter->NextL(cat) ) |
|
1467 |
{ |
|
1468 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
1469 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
1470 |
TPtrC categoryName = category->Des(); |
|
1471 |
||
1472 |
if (categoryName == KCatName1 || |
|
1473 |
categoryName == KCatName2 || |
|
1474 |
categoryName == KCatName3) |
|
1475 |
{ |
|
1476 |
cnt++; |
|
1477 |
CleanupStack::PopAndDestroy(category); |
|
1478 |
} |
|
1479 |
cat.Reset(); |
|
1480 |
} |
|
1481 |
if ( 3 != cnt ) |
|
1482 |
{ |
|
1483 |
iLog->Log( _L("All expected categories not listed") ); |
|
1484 |
ret |= FAIL; |
|
1485 |
} |
|
1486 |
||
1487 |
iter->Reset(); |
|
1488 |
cnt = 0; |
|
1489 |
while ( iter->NextL(cat) ) |
|
1490 |
{ |
|
1491 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
1492 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
1493 |
TPtrC categoryName = category->Des(); |
|
1494 |
||
1495 |
if (categoryName == KCatName1 || |
|
1496 |
categoryName == KCatName2 || |
|
1497 |
categoryName == KCatName3) |
|
1498 |
{ |
|
1499 |
cnt++; |
|
1500 |
CleanupStack::PopAndDestroy(category); |
|
1501 |
} |
|
1502 |
cat.Reset(); |
|
1503 |
} |
|
1504 |
if ( 3 != cnt ) |
|
1505 |
{ |
|
1506 |
iLog->Log( _L("All expected categories not listed after reset") ); |
|
1507 |
ret |= FAIL; |
|
1508 |
} |
|
1509 |
||
1510 |
iLog->Log( _L("End of HandleAsyncTest1") ); |
|
1511 |
return ret; |
|
1512 |
} |
|
1513 |
||
1514 |
// ----------------------------------------------------------------------------- |
|
1515 |
// CTLmCategoryTests::CategoryAsyncTest2 |
|
1516 |
// Example test method function. |
|
1517 |
// (other items were commented in a header). |
|
1518 |
// ----------------------------------------------------------------------------- |
|
1519 |
// |
|
1520 |
TInt CTLmCategoryTests::CategoryAsyncTest2 ( CStifItemParser& /*aItem */ ) |
|
1521 |
{ |
|
1522 |
_LIT( KExample, "CategoryAsyncTest2" ); |
|
1523 |
iLog->Log( KExample ); |
|
1524 |
iTestID = ETEST2; |
|
1525 |
iResult = 0; |
|
1526 |
TInt32 err; |
|
1527 |
TInt ret = 0; |
|
1528 |
||
1529 |
__UHEAP_MARK; |
|
1530 |
CLiwServiceHandler* ServiceHandler; |
|
1531 |
||
1532 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
1533 |
CleanupStack::PushL(ServiceHandler); |
|
1534 |
CleanupClosePushL(*iLandmarkIf); |
|
1535 |
||
1536 |
iInList = &(ServiceHandler->InParamListL()); |
|
1537 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
1538 |
||
1539 |
ResetParams(); |
|
1540 |
||
1541 |
/*Preconditions*/ |
|
1542 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KOtherDatabase); |
|
1543 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
1544 |
CleanupStack::PopAndDestroy(dbInfo); |
|
1545 |
||
1546 |
||
1547 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); |
|
1548 |
CleanupStack::PushL(db); |
|
1549 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1550 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1551 |
CleanupStack::PushL(catManager); |
|
1552 |
CreateCategoriesL(catManager); |
|
1553 |
CleanupStack::PopAndDestroy(2,db); |
|
1554 |
||
1555 |
db = CPosLandmarkDatabase::OpenL(KOtherDatabase); |
|
1556 |
CleanupStack::PushL(db); |
|
1557 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1558 |
catManager = CPosLmCategoryManager::NewL(*db); |
|
1559 |
CleanupStack::PushL(catManager); |
|
1560 |
CreateCategoriesOtherL(catManager); |
|
1561 |
CleanupStack::PopAndDestroy(2,db); |
|
1562 |
||
1563 |
||
1564 |
TLiwGenericParam param; |
|
1565 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
1566 |
iInList->AppendL(param); |
|
1567 |
param.Reset(); |
|
1568 |
||
1569 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
1570 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString)); |
|
1571 |
iInList->AppendL(TLiwGenericParam(KFilter,TLiwVariant(categoryMap))); |
|
1572 |
categoryMap->DecRef(); |
|
1573 |
iAsyncCallCnt = 0; |
|
1574 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,KLiwOptASyncronous,this); |
|
1575 |
ret |= CheckErrorCode (*iOutList,err); |
|
1576 |
if ( err != KErrNone ) |
|
1577 |
{ |
|
1578 |
iLog->Log( _L(" Getlist on database failed with err...") ); |
|
1579 |
ret |= FAIL; |
|
1580 |
} |
|
1581 |
||
1582 |
TInt Index = -1; |
|
1583 |
const TLiwGenericParam* cparam = iOutList->FindFirst(Index,KReturnValue); |
|
1584 |
if ( cparam ) |
|
1585 |
{ |
|
1586 |
CLiwIterable* iterable = cparam->Value().AsIterable(); |
|
1587 |
||
1588 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
1589 |
ret |= FAIL; |
|
1590 |
} |
|
1591 |
||
1592 |
Index = 0; |
|
1593 |
cparam = iOutList->FindFirst(Index,KTransactionId); |
|
1594 |
if ( !cparam ) |
|
1595 |
{ |
|
1596 |
iLog->Log( _L("TransactionID not found in output ArgList") ); |
|
1597 |
ret |= FAIL; |
|
1598 |
} |
|
1599 |
categoryMap->DecRef(); |
|
1600 |
ResetParams (); |
|
1601 |
if ( !ret ) |
|
1602 |
CActiveScheduler::Start(); |
|
1603 |
||
1604 |
||
1605 |
||
1606 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
1607 |
iInList->AppendL(param); |
|
1608 |
param.Reset(); |
|
1609 |
||
1610 |
categoryMap = CLiwDefaultMap::NewL(); |
|
1611 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString1)); |
|
1612 |
categoryMap->InsertL(KDbUri,TLiwVariant(KOtherDatabase)); |
|
1613 |
iInList->AppendL(TLiwGenericParam(KFilter,TLiwVariant(categoryMap))); |
|
1614 |
categoryMap->DecRef(); |
|
1615 |
||
1616 |
iAsyncCallCnt = 1; |
|
1617 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,KLiwOptASyncronous,this); |
|
1618 |
ret |= CheckErrorCode (*iOutList,err); |
|
1619 |
if ( err != KErrNone ) |
|
1620 |
{ |
|
1621 |
iLog->Log( _L(" Getlist on database failed with err...") ); |
|
1622 |
ret |= FAIL; |
|
1623 |
} |
|
1624 |
||
1625 |
Index = -1; |
|
1626 |
cparam = iOutList->FindFirst(Index,KReturnValue); |
|
1627 |
if ( cparam ) |
|
1628 |
{ |
|
1629 |
CLiwIterable* iterable = cparam->Value().AsIterable(); |
|
1630 |
||
1631 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
1632 |
ret |= FAIL; |
|
1633 |
} |
|
1634 |
Index = 0; |
|
1635 |
cparam = iOutList->FindFirst(Index,KTransactionId); |
|
1636 |
if ( !cparam ) |
|
1637 |
{ |
|
1638 |
iLog->Log( _L("TransactionID not found in output ArgList") ); |
|
1639 |
ret |= FAIL; |
|
1640 |
} |
|
1641 |
categoryMap->DecRef(); |
|
1642 |
ResetParams (); |
|
1643 |
if ( !ret ) |
|
1644 |
CActiveScheduler::Start(); |
|
1645 |
||
1646 |
ret |= iResult; |
|
1647 |
iLog->Log( _L("End of CategoryAsyncTest2") ); |
|
1648 |
||
1649 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1650 |
ReleaseLandmarkResources(); |
|
1651 |
__UHEAP_MARKEND; |
|
1652 |
||
1653 |
return ret; |
|
1654 |
} |
|
1655 |
// ----------------------------------------------------------------------------- |
|
1656 |
// CTLmCategoryTests::HandleAsyncTest2 |
|
1657 |
// Example test method function. |
|
1658 |
// (other items were commented in a header). |
|
1659 |
// ----------------------------------------------------------------------------- |
|
1660 |
// |
|
1661 |
TInt CTLmCategoryTests::HandleAsyncTest2 (const CLiwGenericParamList& aEventParamList) |
|
1662 |
{ |
|
1663 |
TInt ret = 0; |
|
1664 |
TInt Index = 0; |
|
1665 |
iLog->Log( _L("In HandleAsyncTest2") ); |
|
1666 |
const TLiwGenericParam* itrparm = aEventParamList.FindFirst(Index,KReturnValue); |
|
1667 |
TLiwVariant cat; |
|
1668 |
CLiwIterable* iter = itrparm->Value().AsIterable(); |
|
1669 |
if (iAsyncCallCnt == 0) |
|
1670 |
{ |
|
1671 |
TInt cnt = 0; |
|
1672 |
while ( iter->NextL(cat) ) |
|
1673 |
{ |
|
1674 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
1675 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
1676 |
TPtrC categoryName = category->Des(); |
|
1677 |
||
1678 |
if (categoryName == KCatName1 || |
|
1679 |
categoryName == KCatName2 || |
|
1680 |
categoryName == KCatName3) |
|
1681 |
{ |
|
1682 |
cnt++; |
|
1683 |
CleanupStack::PopAndDestroy(category); |
|
1684 |
} |
|
1685 |
cat.Reset(); |
|
1686 |
} |
|
1687 |
if ( 3 != cnt ) |
|
1688 |
{ |
|
1689 |
iLog->Log( _L("All expected categories not listed") ); |
|
1690 |
ret |= FAIL; |
|
1691 |
} |
|
1692 |
||
1693 |
iter->Reset(); |
|
1694 |
cnt = 0; |
|
1695 |
while ( iter->NextL(cat) ) |
|
1696 |
{ |
|
1697 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
1698 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
1699 |
TPtrC categoryName = category->Des(); |
|
1700 |
||
1701 |
if (categoryName == KCatName1 || |
|
1702 |
categoryName == KCatName2 || |
|
1703 |
categoryName == KCatName3) |
|
1704 |
{ |
|
1705 |
cnt++; |
|
1706 |
CleanupStack::PopAndDestroy(category); |
|
1707 |
} |
|
1708 |
cat.Reset(); |
|
1709 |
} |
|
1710 |
if ( 3 != cnt ) |
|
1711 |
{ |
|
1712 |
iLog->Log( _L("All expected categories not listed after reset") ); |
|
1713 |
ret |= FAIL; |
|
1714 |
} |
|
1715 |
} |
|
1716 |
else |
|
1717 |
{ |
|
1718 |
TInt cnt = 0; |
|
1719 |
while ( iter->NextL(cat) ) |
|
1720 |
{ |
|
1721 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
1722 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
1723 |
TPtrC categoryName = category->Des(); |
|
1724 |
||
1725 |
if (categoryName == KOtherCatName1 || |
|
1726 |
categoryName == KOtherCatName2 || |
|
1727 |
categoryName == KOtherCatName3) |
|
1728 |
{ |
|
1729 |
cnt++; |
|
1730 |
CleanupStack::PopAndDestroy(category); |
|
1731 |
} |
|
1732 |
cat.Reset(); |
|
1733 |
} |
|
1734 |
if ( 3 != cnt ) |
|
1735 |
{ |
|
1736 |
iLog->Log( _L("All expected categories not listed") ); |
|
1737 |
ret |= FAIL; |
|
1738 |
} |
|
1739 |
||
1740 |
iter->Reset(); |
|
1741 |
cnt = 0; |
|
1742 |
while ( iter->NextL(cat) ) |
|
1743 |
{ |
|
1744 |
const CLiwMap* CategoryMap = cat.AsMap(); |
|
1745 |
HBufC* category = GetCatNameLC (CategoryMap); |
|
1746 |
TPtrC categoryName = category->Des(); |
|
1747 |
||
1748 |
if (categoryName == KOtherCatName1 || |
|
1749 |
categoryName == KOtherCatName2 || |
|
1750 |
categoryName == KOtherCatName3) |
|
1751 |
{ |
|
1752 |
cnt++; |
|
1753 |
CleanupStack::PopAndDestroy(category); |
|
1754 |
} |
|
1755 |
cat.Reset(); |
|
1756 |
} |
|
1757 |
if ( 3 != cnt ) |
|
1758 |
{ |
|
1759 |
iLog->Log( _L("All expected categories not listed after reset") ); |
|
1760 |
ret |= FAIL; |
|
1761 |
} |
|
1762 |
} |
|
1763 |
||
1764 |
iLog->Log( _L("End of HandleAsyncTest2") ); |
|
1765 |
return ret; |
|
1766 |
} |
|
1767 |
||
1768 |
// ----------------------------------------------------------------------------- |
|
1769 |
// CTLmCategoryTests::RemoveCategoryL |
|
1770 |
// Example test method function. |
|
1771 |
// (other items were commented in a header). |
|
1772 |
// ----------------------------------------------------------------------------- |
|
1773 |
// |
|
1774 |
TInt CTLmCategoryTests::RemoveCategoryL ( CStifItemParser& /*aItem */ ) |
|
1775 |
{ |
|
1776 |
_LIT( KExample, "RemoveCategoryL" ); |
|
1777 |
_LIT(KOffice,"NokiaUpdate"); |
|
1778 |
iLog->Log( KExample ); |
|
1779 |
TInt32 err; |
|
1780 |
TInt ret = 0; |
|
1781 |
TPosLmItemId catid1; |
|
1782 |
||
1783 |
__UHEAP_MARK; |
|
1784 |
CLiwServiceHandler* ServiceHandler; |
|
1785 |
||
1786 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
1787 |
CleanupStack::PushL(ServiceHandler); |
|
1788 |
CleanupClosePushL(*iLandmarkIf); |
|
1789 |
||
1790 |
iInList = &(ServiceHandler->InParamListL()); |
|
1791 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
1792 |
||
1793 |
ResetParams(); |
|
1794 |
||
1795 |
/*Preconditions*/ |
|
1796 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
1797 |
CleanupStack::PushL(db); |
|
1798 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1799 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1800 |
CleanupStack::PushL(catManager); |
|
1801 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1802 |
category->SetCategoryNameL(KOffice); |
|
1803 |
catid1=catManager->AddCategoryL(*category); |
|
1804 |
CleanupStack::PopAndDestroy(3,db); |
|
1805 |
||
1806 |
TLiwGenericParam param; |
|
1807 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
1808 |
iInList->AppendL(param); |
|
1809 |
param.Reset(); |
|
1810 |
||
1811 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
1812 |
TBuf<5> catIdString1; |
|
1813 |
catIdString1.Num(catid1,EDecimal); |
|
1814 |
categoryMap->InsertL(KId,TLiwVariant(catIdString1)); |
|
1815 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
1816 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
1817 |
iInList->AppendL(param); |
|
1818 |
categoryMap->DecRef(); |
|
1819 |
param.Reset(); |
|
1820 |
iLandmarkIf->ExecuteCmdL(KRemove,*iInList,*iOutList,0,0); |
|
1821 |
ret |= CheckErrorCode (*iOutList,err); |
|
1822 |
if ( err != KErrNone ) |
|
1823 |
{ |
|
1824 |
iLog->Log( _L(" UpdateCategory1L on database failed with err...") ); |
|
1825 |
ret |= FAIL; |
|
1826 |
} |
|
1827 |
categoryMap->DecRef(); |
|
1828 |
||
1829 |
iLog->Log( _L("End of RemoveCategoryL") ); |
|
1830 |
||
1831 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1832 |
ReleaseLandmarkResources(); |
|
1833 |
__UHEAP_MARKEND; |
|
1834 |
||
1835 |
return ret; |
|
1836 |
} |
|
1837 |
||
1838 |
// ----------------------------------------------------------------------------- |
|
1839 |
// CTLmCategoryTests::RemoveCategoryL |
|
1840 |
// Example test method function. |
|
1841 |
// (other items were commented in a header). |
|
1842 |
// ----------------------------------------------------------------------------- |
|
1843 |
// |
|
1844 |
TInt CTLmCategoryTests::RemoveCategoryPosL ( CStifItemParser& /*aItem */ ) |
|
1845 |
{ |
|
1846 |
_LIT( KExample, "RemoveCategoryPosL" ); |
|
1847 |
_LIT(KOffice,"NokiaUpdate"); |
|
1848 |
iLog->Log( KExample ); |
|
1849 |
TInt32 err; |
|
1850 |
TInt ret = 0; |
|
1851 |
TPosLmItemId catid1; |
|
1852 |
||
1853 |
__UHEAP_MARK; |
|
1854 |
CLiwServiceHandler* ServiceHandler; |
|
1855 |
||
1856 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
1857 |
CleanupStack::PushL(ServiceHandler); |
|
1858 |
CleanupClosePushL(*iLandmarkIf); |
|
1859 |
||
1860 |
iInList = &(ServiceHandler->InParamListL()); |
|
1861 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
1862 |
||
1863 |
ResetParams(); |
|
1864 |
||
1865 |
||
1866 |
/*Preconditions*/ |
|
1867 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
1868 |
CleanupStack::PushL(db); |
|
1869 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1870 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1871 |
CleanupStack::PushL(catManager); |
|
1872 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1873 |
category->SetCategoryNameL(KOffice); |
|
1874 |
catid1=catManager->AddCategoryL(*category); |
|
1875 |
CleanupStack::PopAndDestroy(3,db); |
|
1876 |
||
1877 |
TLiwGenericParam param; |
|
1878 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KCategory)); |
|
1879 |
iInList->AppendL(param); |
|
1880 |
param.Reset(); |
|
1881 |
||
1882 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
1883 |
TBuf<5> catIdString1; |
|
1884 |
catIdString1.Num(catid1,EDecimal); |
|
1885 |
categoryMap->InsertL(KId,TLiwVariant(catIdString1)); |
|
1886 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
1887 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(categoryMap)); |
|
1888 |
iInList->AppendL(param); |
|
1889 |
categoryMap->DecRef(); |
|
1890 |
param.Reset(); |
|
1891 |
iLandmarkIf->ExecuteCmdL(KRemove,*iInList,*iOutList,0,0); |
|
1892 |
ret |= CheckErrorCode (*iOutList,err); |
|
1893 |
if ( err != KErrNone ) |
|
1894 |
{ |
|
1895 |
iLog->Log( _L(" UpdateCategory1L on database failed with err...") ); |
|
1896 |
ret |= FAIL; |
|
1897 |
} |
|
1898 |
categoryMap->DecRef(); |
|
1899 |
||
1900 |
iLog->Log( _L("End of RemoveCategoryL") ); |
|
1901 |
||
1902 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1903 |
ReleaseLandmarkResources(); |
|
1904 |
__UHEAP_MARKEND; |
|
1905 |
||
1906 |
return ret; |
|
1907 |
} |
|
1908 |
||
1909 |
// ----------------------------------------------------------------------------- |
|
1910 |
// CTLmCategoryTests::RemoveCategory1L |
|
1911 |
// Example test method function. |
|
1912 |
// (other items were commented in a header). |
|
1913 |
// ----------------------------------------------------------------------------- |
|
1914 |
// |
|
1915 |
TInt CTLmCategoryTests::RemoveCategory1L ( CStifItemParser& /*aItem */ ) |
|
1916 |
{ |
|
1917 |
_LIT(KOffice1,"NokiaPrevious"); |
|
1918 |
_LIT(KOffice,"NokiaUpdate"); |
|
1919 |
TInt ret=0; |
|
1920 |
TInt32 err; |
|
1921 |
TPosLmItemId catid1,catid2; |
|
1922 |
||
1923 |
__UHEAP_MARK; |
|
1924 |
CLiwServiceHandler* ServiceHandler; |
|
1925 |
||
1926 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
1927 |
CleanupStack::PushL(ServiceHandler); |
|
1928 |
CleanupClosePushL(*iLandmarkIf); |
|
1929 |
||
1930 |
iInList = &(ServiceHandler->InParamListL()); |
|
1931 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
1932 |
||
1933 |
ResetParams(); |
|
1934 |
||
1935 |
||
1936 |
/*Preconditions*/ |
|
1937 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
1938 |
CleanupStack::PushL(db); |
|
1939 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1940 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1941 |
CleanupStack::PushL(catManager); |
|
1942 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1943 |
category->SetCategoryNameL(KOffice); |
|
1944 |
catid1=catManager->AddCategoryL(*category); |
|
1945 |
CleanupStack::PopAndDestroy(3,db); |
|
1946 |
||
1947 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(KOtherDatabase); |
|
1948 |
iDatabaseManager-> CreateDatabaseL(*dbInfo); |
|
1949 |
CleanupStack::PopAndDestroy(dbInfo); |
|
1950 |
||
1951 |
db = CPosLandmarkDatabase::OpenL(KOtherDatabase); |
|
1952 |
CleanupStack::PushL(db); |
|
1953 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1954 |
catManager= CPosLmCategoryManager::NewL(*db); |
|
1955 |
CleanupStack::PushL(catManager); |
|
1956 |
category = CPosLandmarkCategory::NewLC(); |
|
1957 |
category->SetCategoryNameL(KOffice1); |
|
1958 |
catid2=catManager->AddCategoryL(*category); |
|
1959 |
CleanupStack::PopAndDestroy(3,db); |
|
1960 |
||
1961 |
||
1962 |
TLiwGenericParam param; |
|
1963 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
1964 |
iInList->AppendL(param); |
|
1965 |
param.Reset(); |
|
1966 |
||
1967 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
1968 |
TBuf<5> catIdString1; |
|
1969 |
catIdString1.Num(catid1,EDecimal); |
|
1970 |
categoryMap->InsertL(KId,TLiwVariant(catIdString1)); |
|
1971 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
1972 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
1973 |
iInList->AppendL(param); |
|
1974 |
categoryMap->DecRef(); |
|
1975 |
param.Reset(); |
|
1976 |
iLandmarkIf->ExecuteCmdL(KRemove,*iInList,*iOutList,0,0); |
|
1977 |
ret |= CheckErrorCode (*iOutList,err); |
|
1978 |
if ( err != KErrNone ) |
|
1979 |
{ |
|
1980 |
iLog->Log( _L(" UpdateCategory1L on database failed with err...") ); |
|
1981 |
ret |= FAIL; |
|
1982 |
} |
|
1983 |
categoryMap->DecRef(); |
|
1984 |
ResetParams(); |
|
1985 |
||
1986 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
1987 |
iInList->AppendL(param); |
|
1988 |
param.Reset(); |
|
1989 |
categoryMap = CLiwDefaultMap::NewL(); |
|
1990 |
TBuf<5> catIdString2; |
|
1991 |
catIdString2.Num(catid2,EDecimal); |
|
1992 |
categoryMap->InsertL(KId,TLiwVariant(catIdString2)); |
|
1993 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KOffice)); |
|
1994 |
categoryMap->InsertL(KDbUri,TLiwVariant(KOtherDatabase)); |
|
1995 |
param.SetNameAndValueL(KDataFields,TLiwVariant(categoryMap)); |
|
1996 |
iInList->AppendL(param); |
|
1997 |
categoryMap->DecRef(); |
|
1998 |
param.Reset(); |
|
1999 |
iLandmarkIf->ExecuteCmdL(KRemove,*iInList,*iOutList,0,0); |
|
2000 |
ret |= CheckErrorCode (*iOutList,err); |
|
2001 |
if ( err != KErrNone ) |
|
2002 |
{ |
|
2003 |
iLog->Log( _L(" UpdateCategory1L on database failed with err...") ); |
|
2004 |
ret |= FAIL; |
|
2005 |
} |
|
2006 |
categoryMap->DecRef(); |
|
2007 |
||
2008 |
iLog->Log( _L("End of RemoveCategoryL") ); |
|
2009 |
||
2010 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2011 |
ReleaseLandmarkResources(); |
|
2012 |
__UHEAP_MARKEND; |
|
2013 |
||
2014 |
return ret; |
|
2015 |
} |
|
2016 |
||
2017 |
||
2018 |
// ----------------------------------------------------------------------------- |
|
2019 |
// CTLmCategoryTests::CancelAsyncTest1 |
|
2020 |
// Example test method function. |
|
2021 |
// (other items were commented in a header). |
|
2022 |
// ----------------------------------------------------------------------------- |
|
2023 |
// |
|
2024 |
TInt CTLmCategoryTests::CancelAsyncTest1 ( CStifItemParser& /*aItem */ ) |
|
2025 |
{ |
|
2026 |
_LIT( KExample, "CancelAsyncTest1" ); |
|
2027 |
iLog->Log( KExample ); |
|
2028 |
iTestID = ETEST3; |
|
2029 |
iResult = 0; |
|
2030 |
||
2031 |
TInt32 err; |
|
2032 |
TInt ret = 0; |
|
2033 |
||
2034 |
__UHEAP_MARK; |
|
2035 |
CLiwServiceHandler* ServiceHandler; |
|
2036 |
||
2037 |
CreateInterfaceL(ServiceHandler,iLandmarkIf); |
|
2038 |
CleanupStack::PushL(ServiceHandler); |
|
2039 |
CleanupClosePushL(*iLandmarkIf); |
|
2040 |
||
2041 |
iInList = &(ServiceHandler->InParamListL()); |
|
2042 |
iOutList = &(ServiceHandler->OutParamListL()); |
|
2043 |
||
2044 |
ResetParams(); |
|
2045 |
||
2046 |
/*Preconditions*/ |
|
2047 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KDefaultDatabase); |
|
2048 |
CleanupStack::PushL(db); |
|
2049 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
2050 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
2051 |
CleanupStack::PushL(catManager); |
|
2052 |
CreateCategoriesL(catManager); |
|
2053 |
CleanupStack::PopAndDestroy(2,db); |
|
2054 |
||
2055 |
TLiwGenericParam param; |
|
2056 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
2057 |
iInList->AppendL(param); |
|
2058 |
param.Reset(); |
|
2059 |
||
2060 |
CLiwMap* categoryMap = CLiwDefaultMap::NewL(); |
|
2061 |
categoryMap->InsertL(KCategoryName,TLiwVariant(KCatSearchString)); |
|
2062 |
param.SetNameAndValueL(KFilter,TLiwVariant(categoryMap)); |
|
2063 |
iInList->AppendL(param); |
|
2064 |
categoryMap->DecRef(); |
|
2065 |
param.Reset(); |
|
2066 |
||
2067 |
iLandmarkIf->ExecuteCmdL(KGetList,*iInList,*iOutList,KLiwOptASyncronous,this); |
|
2068 |
ret |= CheckErrorCode (*iOutList,err); |
|
2069 |
if ( err != KErrNone ) |
|
2070 |
{ |
|
2071 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2072 |
ret |= FAIL; |
|
2073 |
} |
|
2074 |
||
2075 |
TInt Index = -1; |
|
2076 |
const TLiwGenericParam* cparam = iOutList->FindFirst(Index,KReturnValue); |
|
2077 |
if ( cparam ) |
|
2078 |
{ |
|
2079 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
2080 |
ret |= FAIL; |
|
2081 |
} |
|
2082 |
||
2083 |
Index = 0; |
|
2084 |
TInt32 tid; |
|
2085 |
cparam = iOutList->FindFirst(Index,KTransactionId); |
|
2086 |
if ( !cparam ) |
|
2087 |
{ |
|
2088 |
iLog->Log( _L("TransactionID not found in output ArgList") ); |
|
2089 |
ret |= FAIL; |
|
2090 |
} |
|
2091 |
else |
|
2092 |
{ |
|
2093 |
tid = cparam->Value().AsTInt32(); |
|
2094 |
ResetParams(); |
|
2095 |
||
2096 |
param.SetNameAndValueL(KContentType,TLiwVariant(KCategory)); |
|
2097 |
iInList->AppendL(param); |
|
2098 |
param.Reset(); |
|
2099 |
||
2100 |
iInList->AppendL(TLiwGenericParam(KTransactionId,TLiwVariant(TInt32(tid)))); |
|
2101 |
iLandmarkIf->ExecuteCmdL(KCancel,*iInList,*iOutList,KLiwOptCancel); |
|
2102 |
ret |= CheckErrorCode (*iOutList,err); |
|
2103 |
if ( err != KErrNone ) |
|
2104 |
{ |
|
2105 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2106 |
ret |= FAIL; |
|
2107 |
} |
|
2108 |
||
2109 |
iLog->Log( _L("End of CancelAsyncTest1") ); |
|
2110 |
ret |= iResult; |
|
2111 |
} |
|
2112 |
||
2113 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2114 |
ReleaseLandmarkResources(); |
|
2115 |
__UHEAP_MARKEND; |
|
2116 |
||
2117 |
return ret; |
|
2118 |
} |
|
2119 |
||
2120 |
void CTLmCategoryTests::CreateInterfaceL(CLiwServiceHandler*& aHandler, |
|
2121 |
MLiwInterface*& aInterface) |
|
2122 |
{ |
|
2123 |
iLog->Log( _L("In CreateInterfaceL") ); |
|
2124 |
CLiwGenericParamList* InParamList,*OutParamList; |
|
2125 |
||
2126 |
TRAPD(Err,aHandler = CLiwServiceHandler::NewL()); |
|
2127 |
if(Err) |
|
2128 |
{ |
|
2129 |
iLog->Log( _L("CLiwServiceHandler Created %d"),Err ); |
|
2130 |
User::Leave(Err); |
|
2131 |
} |
|
2132 |
||
2133 |
CleanupStack::PushL(aHandler); |
|
2134 |
||
2135 |
InParamList = &(aHandler->InParamListL()); |
|
2136 |
OutParamList = &(aHandler->OutParamListL()); |
|
2137 |
||
2138 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIDataSource,KService); |
|
2139 |
CleanupStack::PushL(crit); |
|
2140 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
2141 |
RCriteriaArray a; |
|
2142 |
CleanupClosePushL(a); |
|
2143 |
a.AppendL(crit); |
|
2144 |
||
2145 |
aHandler->AttachL(a); |
|
2146 |
||
2147 |
InParamList->AppendL(TLiwGenericParam(KDbUri,TLiwVariant(KDefaultDatabase))); |
|
2148 |
||
2149 |
aHandler->ExecuteServiceCmdL(*crit,*InParamList,*OutParamList); |
|
2150 |
||
2151 |
TInt Index = 0; |
|
2152 |
const TLiwGenericParam* param = OutParamList->FindFirst(Index,KIDataSource); |
|
2153 |
if(!param) |
|
2154 |
{ |
|
2155 |
iLog->Log( _L("Interface Not found ")); |
|
2156 |
User::Leave(KErrGeneral); |
|
2157 |
} |
|
2158 |
||
2159 |
aInterface = param->Value().AsInterface(); |
|
2160 |
CleanupStack::PopAndDestroy(&a); |
|
2161 |
CleanupStack::PopAndDestroy (crit); |
|
2162 |
||
2163 |
CleanupStack::Pop (aHandler); |
|
2164 |
iLog->Log( _L("End of CreateInterfaceL") ); |
|
2165 |
} |