author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:06:03 +0300 | |
branch | RCL_3 |
changeset 65 | 0b68a1b0c15e |
parent 58 | ea43c23d28d2 |
child 66 | a9c0808a1095 |
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 |
#include <e32std.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
21 |
#include <StifTestInterface.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
22 |
#include <liwservicehandler.h> |
19 | 23 |
#include <StifLogger.h> |
24 |
#include "getlist.h" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
25 |
#include<liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include<liwvariant.h> |
19 | 27 |
#include "landmarkliwparams.hrh" |
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
28 |
#include <EPos_CPosLandmarkDatabase.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
29 |
#include <EPos_CPosLandmark.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include <EPos_CPosLandmarkEncoder.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
31 |
#include <EPos_CPosLmCategoryManager.h> |
19 | 32 |
#include "tlandmark_provider.h" |
33 |
#include <EPos_HPosLmDatabaseInfo.h> |
|
34 |
#include <EPos_CPosLmDatabaseManager.h> |
|
35 |
#include <lbsposition.h> |
|
36 |
#include "serviceerrno.h" |
|
37 |
#include "tlandmark_provider.h" |
|
38 |
||
39 |
using namespace LIW ; |
|
40 |
||
41 |
_LIT8(KTestInterface, "IDataSource"); |
|
42 |
_LIT8(KTestContent, "Service.Calendar"); |
|
43 |
_LIT8(KCmd, "RequestNotification"); |
|
44 |
_LIT(KTestCalendar, "CalChangeNotify"); |
|
45 |
_LIT8(KErrCode , "ErrorCode") ; |
|
46 |
_LIT(KLmName1, "lm1"); |
|
47 |
_LIT(KLmName2, "lma2"); |
|
48 |
_LIT(KLmName3, "lma3"); |
|
49 |
_LIT(KLmName4, "landmark1"); |
|
50 |
_LIT(KLmName5, "landmark2"); |
|
51 |
_LIT(KLmName6, "landmark3"); |
|
52 |
||
53 |
_LIT(KLmSearchString, "lm*"); |
|
54 |
_LIT(KLmSearchString1, "lma*"); |
|
55 |
||
56 |
#define PASS TInt(0) |
|
57 |
#define FAIL (!PASS) |
|
58 |
||
59 |
CCalCallback* CCalCallback::NewL(CActiveSchedulerWait* aWaitSchedular, TInt32& aResult) |
|
60 |
{ |
|
61 |
return new (ELeave) CCalCallback(aWaitSchedular, aResult); |
|
62 |
} |
|
63 |
||
64 |
TInt CCalCallback::HandleNotifyL(TInt aCmdId, |
|
65 |
TInt aEventId, |
|
66 |
CLiwGenericParamList& aEventParamList, |
|
67 |
const CLiwGenericParamList& aInParamList) |
|
68 |
{ |
|
69 |
TInt pos = 0; |
|
70 |
TInt32 result = KErrNone; |
|
71 |
||
72 |
const TLiwGenericParam* err = aEventParamList.FindFirst(pos,KErrCode); |
|
73 |
if(err) |
|
74 |
result = err->Value().AsTInt32(); |
|
75 |
||
76 |
if(!result && aEventId != KLiwEventCanceled) |
|
77 |
{ |
|
78 |
iResult = result; |
|
79 |
pos=0; |
|
80 |
const TLiwGenericParam* output = aEventParamList.FindFirst( pos,_L8("ReturnValue")); |
|
81 |
||
82 |
if(output) |
|
83 |
{ |
|
84 |
||
85 |
} |
|
86 |
} |
|
87 |
||
88 |
else if(!result && aEventId == KLiwEventCanceled) |
|
89 |
iResult = KErrNone; |
|
90 |
else |
|
91 |
iResult = result; |
|
92 |
||
93 |
if ( iWaitSchedular && iWaitSchedular->IsStarted()) |
|
94 |
{ |
|
95 |
iWaitSchedular->AsyncStop(); |
|
96 |
} |
|
97 |
} |
|
98 |
||
99 |
CTestAsync* CTestAsync::NewL(TInt type) |
|
100 |
{ |
|
101 |
CTestAsync* self = new (ELeave) CTestAsync(); |
|
102 |
self->ConstructL(type); |
|
103 |
return self; |
|
104 |
} |
|
105 |
||
106 |
CTestAsync::~CTestAsync() |
|
107 |
{ |
|
108 |
Cancel(); |
|
109 |
delete gLog; |
|
110 |
inparam->Reset(); |
|
111 |
outparam->Reset(); |
|
112 |
||
113 |
interface->Close(); |
|
114 |
||
115 |
delete iServiceHandler; |
|
116 |
||
117 |
delete iCallback; |
|
118 |
||
119 |
if(iWaitSchedular->IsStarted()) |
|
120 |
iWaitSchedular->AsyncStop(); |
|
121 |
||
122 |
delete iWaitSchedular; |
|
123 |
} |
|
124 |
||
125 |
||
126 |
void CTestAsync::ConstructL(TInt case_type) |
|
127 |
{ |
|
128 |
TFileName glogFileName; |
|
129 |
gLog = CStifLogger::NewL( Ktlandmark_providerLogPath, |
|
130 |
glogFileName, |
|
131 |
CStifLogger::ETxt, |
|
132 |
CStifLogger::EFile, |
|
133 |
EFalse ); |
|
134 |
||
135 |
iTestCaseType = case_type; |
|
136 |
interface = CreateInterface(); |
|
137 |
CActiveScheduler::Add(this); |
|
138 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
139 |
} |
|
140 |
||
141 |
MLiwInterface* CTestAsync::CreateInterface() |
|
142 |
{ |
|
143 |
||
144 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
145 |
||
146 |
inparam = &(iServiceHandler->InParamListL()); |
|
147 |
outparam = &(iServiceHandler->OutParamListL()); |
|
148 |
||
149 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
150 |
||
151 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
152 |
||
153 |
RCriteriaArray a; |
|
154 |
a.AppendL(crit); |
|
155 |
||
156 |
iServiceHandler->AttachL(a); |
|
157 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
158 |
||
159 |
a.Reset(); |
|
160 |
delete crit; |
|
161 |
||
162 |
TInt pos = 0; |
|
163 |
||
164 |
outparam->FindFirst( pos, KIDataSource ); |
|
165 |
if(pos != KErrNotFound) |
|
166 |
{ |
|
167 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
168 |
} |
|
169 |
||
170 |
outparam->Reset(); |
|
171 |
inparam->Reset(); |
|
172 |
||
173 |
return interface; |
|
174 |
} |
|
175 |
||
176 |
CTestAsync::CTestAsync() : |
|
177 |
CActive(EPriorityStandard) |
|
178 |
{ |
|
179 |
interface = NULL ; |
|
180 |
iResult = KErrGeneral; |
|
181 |
} |
|
182 |
||
183 |
void CTestAsync::DoCancel() |
|
184 |
{ |
|
185 |
||
186 |
} |
|
187 |
||
188 |
void CTestAsync::RunL() |
|
189 |
{ |
|
190 |
switch(iTestCaseType) |
|
191 |
{ |
|
192 |
case 1 : TestFunc(); |
|
193 |
break; |
|
194 |
case 2 : GetListInvalidCase(); |
|
195 |
break; |
|
196 |
case 3 : AddGetListCancel(); |
|
197 |
break; |
|
198 |
case 4 : CancelWithInvalidTid(); |
|
199 |
break; |
|
200 |
case 5 : CallGetListMultipleTimes(); |
|
201 |
break; |
|
202 |
case 6 : CancelKeyBasedTid(); |
|
203 |
break; |
|
204 |
case 7 : CancelPosBasedTid(); |
|
205 |
break; |
|
206 |
case 8 : CancelLargeTid(); |
|
207 |
break; |
|
208 |
case 9 : CancelInvalidTidType(); |
|
209 |
break; |
|
210 |
case 10 : CancelInvalidCmd(); |
|
211 |
break; |
|
212 |
} |
|
213 |
} |
|
214 |
||
215 |
||
216 |
TInt32 CTestAsync::Result() |
|
217 |
{ |
|
218 |
return iResult; |
|
219 |
} |
|
220 |
||
221 |
void CTestAsync::Start() |
|
222 |
{ |
|
223 |
SetActive(); |
|
224 |
TRequestStatus* temp = &iStatus; |
|
225 |
User::RequestComplete(temp, KErrNone); |
|
226 |
iWaitSchedular->Start(); |
|
227 |
} |
|
228 |
||
229 |
void CTestAsync::CancelInvalidCmd() |
|
230 |
{ |
|
231 |
TLiwGenericParam param; |
|
232 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
233 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
234 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
235 |
inparam->AppendL(param); |
|
236 |
param.Reset(); |
|
237 |
||
238 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
239 |
getlistlandmark_map->DecRef(); |
|
240 |
||
241 |
TInt pos=0; |
|
242 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
243 |
||
244 |
if(output) |
|
245 |
{ |
|
246 |
iTransactionId = output->Value().AsTInt32(); |
|
247 |
CancelNotification_InvalidCmd(); //Call cancel |
|
248 |
} |
|
249 |
else |
|
250 |
{ |
|
251 |
if(iWaitSchedular->IsStarted()) |
|
252 |
iWaitSchedular->AsyncStop(); |
|
253 |
iResult = SErrBadArgumentType; |
|
254 |
} |
|
255 |
||
256 |
inparam->Reset(); |
|
257 |
outparam->Reset(); |
|
258 |
||
259 |
} |
|
260 |
||
261 |
void CTestAsync::CancelNotification_InvalidCmd() |
|
262 |
{ |
|
263 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
264 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
265 |
||
266 |
TLiwGenericParam param; |
|
267 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant((TReal32)44.55)); |
|
268 |
inparam->AppendL(param); |
|
269 |
param.Reset(); |
|
270 |
||
271 |
TRAPD(err_cancel,interface->ExecuteCmdL(KCancel, *inparam, *outparam,KLiwOptASyncronous,iCallback )); |
|
272 |
||
273 |
TInt pos=0; |
|
274 |
const TLiwGenericParam* err = outparam->FindFirst(pos,KErrCode); |
|
275 |
if(err) |
|
276 |
{ |
|
277 |
if(iWaitSchedular->IsStarted()) |
|
278 |
iWaitSchedular->AsyncStop(); |
|
279 |
if(iResult == KErrGeneral) |
|
280 |
iResult = err->Value().AsTInt32(); |
|
281 |
} |
|
282 |
||
283 |
inparam->Reset(); |
|
284 |
outparam->Reset(); |
|
285 |
||
286 |
} |
|
287 |
||
288 |
void CTestAsync::CancelInvalidTidType() |
|
289 |
{ |
|
290 |
TLiwGenericParam param; |
|
291 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
292 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
293 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
294 |
inparam->AppendL(param); |
|
295 |
param.Reset(); |
|
296 |
||
297 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
298 |
getlistlandmark_map->DecRef(); |
|
299 |
||
300 |
TInt pos=0; |
|
301 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
302 |
||
303 |
if(output) |
|
304 |
{ |
|
305 |
iTransactionId = output->Value().AsTInt32(); |
|
306 |
CancelNotification_InvalidTidType(); //Call cancel |
|
307 |
} |
|
308 |
else |
|
309 |
{ |
|
310 |
if(iWaitSchedular->IsStarted()) |
|
311 |
iWaitSchedular->AsyncStop(); |
|
312 |
iResult = SErrBadArgumentType; |
|
313 |
} |
|
314 |
||
315 |
inparam->Reset(); |
|
316 |
outparam->Reset(); |
|
317 |
||
318 |
} |
|
319 |
||
320 |
void CTestAsync::CancelNotification_InvalidTidType() |
|
321 |
{ |
|
322 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
323 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
324 |
||
325 |
TLiwGenericParam param; |
|
326 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant((TReal32)44.55)); |
|
327 |
inparam->AppendL(param); |
|
328 |
param.Reset(); |
|
329 |
||
330 |
TRAPD(err_cancel,interface->ExecuteCmdL(KCancel, *inparam, *outparam,KLiwOptCancel,0 )); |
|
331 |
||
332 |
TInt pos=0; |
|
333 |
const TLiwGenericParam* err = outparam->FindFirst(pos,KErrCode); |
|
334 |
if(err) |
|
335 |
{ |
|
336 |
if(iWaitSchedular->IsStarted()) |
|
337 |
iWaitSchedular->AsyncStop(); |
|
338 |
if(iResult == KErrGeneral) |
|
339 |
iResult = err->Value().AsTInt32(); |
|
340 |
} |
|
341 |
||
342 |
inparam->Reset(); |
|
343 |
outparam->Reset(); |
|
344 |
||
345 |
} |
|
346 |
||
347 |
void CTestAsync::CancelLargeTid() |
|
348 |
{ |
|
349 |
TLiwGenericParam param; |
|
350 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
351 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
352 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
353 |
inparam->AppendL(param); |
|
354 |
param.Reset(); |
|
355 |
||
356 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
357 |
getlistlandmark_map->DecRef(); |
|
358 |
||
359 |
TInt pos=0; |
|
360 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
361 |
||
362 |
if(output) |
|
363 |
{ |
|
364 |
iTransactionId = output->Value().AsTInt32(); |
|
365 |
CancelNotification(1,534); //Call cancel |
|
366 |
} |
|
367 |
else |
|
368 |
{ |
|
369 |
if(iWaitSchedular->IsStarted()) |
|
370 |
iWaitSchedular->AsyncStop(); |
|
371 |
iResult = SErrBadArgumentType; |
|
372 |
} |
|
373 |
||
374 |
inparam->Reset(); |
|
375 |
outparam->Reset(); |
|
376 |
||
377 |
} |
|
378 |
||
379 |
||
380 |
void CTestAsync::CancelPosBasedTid() |
|
381 |
{ |
|
382 |
TLiwGenericParam param; |
|
383 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
384 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
385 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
386 |
inparam->AppendL(param); |
|
387 |
param.Reset(); |
|
388 |
||
389 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
390 |
getlistlandmark_map->DecRef(); |
|
391 |
||
392 |
TInt pos=0; |
|
393 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
394 |
||
395 |
if(output) |
|
396 |
{ |
|
397 |
iTransactionId = output->Value().AsTInt32(); |
|
398 |
CancelNotification_PosBased(); //Call cancel |
|
399 |
} |
|
400 |
else |
|
401 |
{ |
|
402 |
if(iWaitSchedular->IsStarted()) |
|
403 |
iWaitSchedular->AsyncStop(); |
|
404 |
iResult = SErrBadArgumentType; |
|
405 |
} |
|
406 |
||
407 |
inparam->Reset(); |
|
408 |
outparam->Reset(); |
|
409 |
||
410 |
} |
|
411 |
||
412 |
void CTestAsync::CancelNotification_PosBased() |
|
413 |
{ |
|
414 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
415 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
416 |
||
417 |
TLiwGenericParam param; |
|
418 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(iTransactionId)); |
|
419 |
inparam->AppendL(param); |
|
420 |
param.Reset(); |
|
421 |
||
422 |
TRAPD(err_cancel,interface->ExecuteCmdL(KCancel, *inparam, *outparam,KLiwOptCancel,0 )); |
|
423 |
||
424 |
TInt pos=0; |
|
425 |
const TLiwGenericParam* err = outparam->FindFirst(pos,KErrCode); |
|
426 |
if(err) |
|
427 |
{ |
|
428 |
if(iWaitSchedular->IsStarted()) |
|
429 |
iWaitSchedular->AsyncStop(); |
|
430 |
if(iResult == KErrGeneral) |
|
431 |
iResult = err->Value().AsTInt32(); |
|
432 |
} |
|
433 |
||
434 |
inparam->Reset(); |
|
435 |
outparam->Reset(); |
|
436 |
} |
|
437 |
||
438 |
||
439 |
void CTestAsync::CancelKeyBasedTid() |
|
440 |
{ |
|
441 |
TLiwGenericParam param; |
|
442 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
443 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
444 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
445 |
inparam->AppendL(param); |
|
446 |
param.Reset(); |
|
447 |
||
448 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
449 |
getlistlandmark_map->DecRef(); |
|
450 |
||
451 |
TInt pos=0; |
|
452 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
453 |
||
454 |
if(output) |
|
455 |
{ |
|
456 |
iTransactionId = output->Value().AsTInt32(); |
|
457 |
CancelNotification_KeyBased(); //Call cancel |
|
458 |
} |
|
459 |
else |
|
460 |
{ |
|
461 |
if(iWaitSchedular->IsStarted()) |
|
462 |
iWaitSchedular->AsyncStop(); |
|
463 |
iResult = SErrBadArgumentType; |
|
464 |
} |
|
465 |
||
466 |
inparam->Reset(); |
|
467 |
outparam->Reset(); |
|
468 |
||
469 |
} |
|
470 |
||
471 |
void CTestAsync::CancelNotification_KeyBased() |
|
472 |
{ |
|
473 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
474 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
475 |
||
476 |
TLiwGenericParam param; |
|
477 |
param.SetNameAndValueL(KTransactionId,TLiwVariant(iTransactionId)); |
|
478 |
inparam->AppendL(param); |
|
479 |
param.Reset(); |
|
480 |
||
481 |
TRAPD(err_cancel,interface->ExecuteCmdL(KCancel, *inparam, *outparam,KLiwOptCancel,0 )); |
|
482 |
||
483 |
TInt pos=0; |
|
484 |
const TLiwGenericParam* err = outparam->FindFirst(pos,KErrCode); |
|
485 |
if(err) |
|
486 |
{ |
|
487 |
if(iWaitSchedular->IsStarted()) |
|
488 |
iWaitSchedular->AsyncStop(); |
|
489 |
if(iResult == KErrGeneral) |
|
490 |
iResult = err->Value().AsTInt32(); |
|
491 |
} |
|
492 |
||
493 |
inparam->Reset(); |
|
494 |
outparam->Reset(); |
|
495 |
} |
|
496 |
||
497 |
||
498 |
void CTestAsync::CallGetListMultipleTimes() |
|
499 |
{ |
|
500 |
// Add landmark |
|
501 |
_LIT(KName,"GetListstress"); |
|
502 |
_LIT(KDescription,"stress on getlist Api"); |
|
503 |
||
504 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
505 |
TLiwGenericParam param; |
|
506 |
TInt32 res = KErrGeneral; |
|
507 |
||
508 |
//name |
|
509 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KName)); |
|
510 |
||
511 |
//description |
|
512 |
landmarkMap->InsertL(KLandmarkDesc,TLiwVariant(KDescription)); |
|
513 |
||
514 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
515 |
inparam->AppendL(param); |
|
516 |
param.Reset(); |
|
517 |
||
518 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
519 |
inparam->AppendL(param); |
|
520 |
param.Reset(); |
|
521 |
||
522 |
interface->ExecuteCmdL(KAdd,*inparam,*outparam,0,0); |
|
523 |
landmarkMap->DecRef(); |
|
524 |
||
525 |
TInt index = 0; |
|
526 |
||
527 |
const TLiwGenericParam* err = outparam->FindFirst(index,KErrorCode); |
|
528 |
if(err) |
|
529 |
res = err->Value().AsTInt32(); |
|
530 |
||
531 |
if(!res) |
|
532 |
{ |
|
533 |
inparam->Reset(); |
|
534 |
outparam->Reset(); |
|
535 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
536 |
TLiwGenericParam param; |
|
537 |
||
538 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
539 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
540 |
inparam->AppendL(param); |
|
541 |
param.Reset(); |
|
542 |
||
543 |
||
544 |
param.SetNameAndValueL(KFilter,TLiwVariant(getlistlandmark_map)); |
|
545 |
inparam->AppendL(param); |
|
546 |
param.Reset(); |
|
547 |
||
548 |
||
549 |
interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback); |
|
550 |
outparam->Reset(); |
|
551 |
User::After(10); |
|
552 |
interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback); |
|
553 |
getlistlandmark_map->DecRef(); |
|
554 |
||
555 |
index=0; |
|
556 |
const TLiwGenericParam* getlist_err = outparam->FindFirst(index,KErrCode); |
|
557 |
if(getlist_err) |
|
558 |
{ |
|
559 |
iResult = getlist_err->Value().AsTInt32(); |
|
560 |
if(iResult) |
|
561 |
{ |
|
562 |
if(iWaitSchedular->IsStarted()) |
|
563 |
iWaitSchedular->AsyncStop(); |
|
564 |
} |
|
565 |
} |
|
566 |
||
567 |
inparam->Reset(); |
|
568 |
||
569 |
} |
|
570 |
||
571 |
inparam->Reset(); |
|
572 |
outparam->Reset(); |
|
573 |
} |
|
574 |
||
575 |
void CTestAsync::CancelNotification(TBool include_tid, TInt32 tid) |
|
576 |
{ |
|
577 |
gLog->Log(_L("inside cancel notification function")); |
|
578 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
579 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
580 |
||
581 |
if(include_tid) |
|
582 |
{ |
|
583 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
584 |
CleanupStack::PushL(map); |
|
585 |
||
586 |
TLiwGenericParam element; |
|
587 |
if(tid > 0) |
|
588 |
tid = tid * 20000000000000; |
|
589 |
element.SetNameAndValueL(_L8("TransactionID"), TLiwVariant(tid)); |
|
590 |
inparam->AppendL(element); |
|
591 |
element.Reset(); |
|
592 |
||
593 |
map->DecRef(); |
|
594 |
CleanupStack::Pop(map); |
|
595 |
} |
|
596 |
||
597 |
TRAPD(err_cancel,interface->ExecuteCmdL(KCancel, *inparam, *outparam,KLiwOptCancel,0 )); |
|
598 |
||
599 |
TInt pos=0; |
|
600 |
const TLiwGenericParam* err = outparam->FindFirst(pos,KErrCode); |
|
601 |
if(err) |
|
602 |
{ |
|
603 |
gLog->Log(_L("after call to cancel function")); |
|
604 |
if(iWaitSchedular->IsStarted()) |
|
605 |
iWaitSchedular->AsyncStop(); |
|
606 |
if(iResult == KErrGeneral) |
|
607 |
iResult = err->Value().AsTInt32(); |
|
608 |
} |
|
609 |
||
610 |
inparam->Reset(); |
|
611 |
outparam->Reset(); |
|
612 |
} |
|
613 |
||
614 |
void CTestAsync::AddGetListCancel() |
|
615 |
{ |
|
616 |
// Add landmark |
|
617 |
_LIT(KName,"ktaka"); |
|
618 |
_LIT(KDescription,"Indian state"); |
|
619 |
||
620 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
621 |
TLiwGenericParam param; |
|
622 |
TInt32 res = KErrGeneral; |
|
623 |
||
624 |
//name |
|
625 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KName)); |
|
626 |
||
627 |
//description |
|
628 |
landmarkMap->InsertL(KLandmarkDesc,TLiwVariant(KDescription)); |
|
629 |
||
630 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
631 |
inparam->AppendL(param); |
|
632 |
param.Reset(); |
|
633 |
||
634 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
635 |
inparam->AppendL(param); |
|
636 |
param.Reset(); |
|
637 |
||
638 |
interface->ExecuteCmdL(KAdd,*inparam,*outparam,0,0); |
|
639 |
landmarkMap->DecRef(); |
|
640 |
||
641 |
TInt index = 0; |
|
642 |
||
643 |
const TLiwGenericParam* err = outparam->FindFirst(index,KErrorCode); |
|
644 |
if(err) |
|
645 |
res = err->Value().AsTInt32(); |
|
646 |
||
647 |
if(!res) |
|
648 |
{ |
|
649 |
inparam->Reset(); |
|
650 |
outparam->Reset(); |
|
651 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
652 |
TLiwGenericParam param; |
|
653 |
||
654 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
655 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
656 |
inparam->AppendL(param); |
|
657 |
param.Reset(); |
|
658 |
||
659 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
660 |
getlistlandmark_map->DecRef(); |
|
661 |
||
662 |
TInt pos=0; |
|
663 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
664 |
||
665 |
if(output) |
|
666 |
{ |
|
667 |
iTransactionId = output->Value().AsTInt32(); |
|
668 |
CancelNotification(1,iTransactionId); //Call cancel |
|
669 |
} |
|
670 |
else |
|
671 |
{ |
|
672 |
if(iWaitSchedular->IsStarted()) |
|
673 |
iWaitSchedular->AsyncStop(); |
|
674 |
if(iResult == KErrGeneral) |
|
675 |
iResult = SErrBadArgumentType; |
|
676 |
} |
|
677 |
||
678 |
} |
|
679 |
||
680 |
inparam->Reset(); |
|
681 |
outparam->Reset(); |
|
682 |
||
683 |
} |
|
684 |
||
685 |
||
686 |
void CTestAsync::CancelWithInvalidTid() |
|
687 |
{ |
|
688 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
689 |
TLiwGenericParam param; |
|
690 |
||
691 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
692 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
693 |
inparam->AppendL(param); |
|
694 |
param.Reset(); |
|
695 |
||
696 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
697 |
getlistlandmark_map->DecRef(); |
|
698 |
||
699 |
TInt pos=0; |
|
700 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
701 |
||
702 |
if(output) |
|
703 |
{ |
|
704 |
iTransactionId = output->Value().AsTInt32(); |
|
705 |
CancelNotification(1,-25); //Call cancel |
|
706 |
} |
|
707 |
else |
|
708 |
{ |
|
709 |
if(iWaitSchedular->IsStarted()) |
|
710 |
iWaitSchedular->AsyncStop(); |
|
711 |
iResult = SErrBadArgumentType; |
|
712 |
} |
|
713 |
||
714 |
inparam->Reset(); |
|
715 |
outparam->Reset(); |
|
716 |
||
717 |
} |
|
718 |
||
719 |
||
720 |
void CTestAsync::GetListInvalidCase() |
|
721 |
{ |
|
722 |
||
723 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
724 |
TLiwGenericParam param; |
|
725 |
||
726 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
727 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
728 |
inparam->AppendL(param); |
|
729 |
param.Reset(); |
|
730 |
||
731 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, NULL)); |
|
732 |
getlistlandmark_map->DecRef(); |
|
733 |
||
734 |
TInt pos=0; |
|
735 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
736 |
||
737 |
if(output) |
|
738 |
{ |
|
739 |
iTransactionId = output->Value().AsTInt32(); |
|
740 |
} |
|
741 |
else |
|
742 |
{ |
|
743 |
if(iWaitSchedular->IsStarted()) |
|
744 |
iWaitSchedular->AsyncStop(); |
|
745 |
iResult = SErrBadArgumentType; |
|
746 |
} |
|
747 |
} |
|
748 |
||
749 |
void CTestAsync::TestFunc() |
|
750 |
{ |
|
751 |
/* iServiceHandler = CLiwServiceHandler::NewL(); |
|
752 |
||
753 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
754 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
755 |
||
756 |
TInt err; |
|
757 |
||
758 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
759 |
||
760 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
761 |
||
762 |
RCriteriaArray a; |
|
763 |
a.AppendL(crit); |
|
764 |
||
765 |
iServiceHandler->AttachL(a); |
|
766 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
767 |
||
768 |
a.Reset(); |
|
769 |
delete crit; |
|
770 |
||
771 |
TInt pos = 0; |
|
772 |
||
773 |
outparam->FindFirst( pos, KIDataSource ); |
|
774 |
if(pos != KErrNotFound) |
|
775 |
{ |
|
776 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
777 |
} |
|
778 |
||
779 |
outparam->Reset(); |
|
780 |
inparam->Reset();*/ |
|
781 |
||
782 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
783 |
||
784 |
/* CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
785 |
CleanupStack::PushL(db); |
|
786 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
787 |
RemoveAllLandmarks(db); |
|
788 |
CreateLandmarksL(db); |
|
789 |
CleanupStack::PopAndDestroy(db); |
|
790 |
||
791 |
TLiwGenericParam param; |
|
792 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
793 |
inparam->AppendL(param); |
|
794 |
param.Reset(); |
|
795 |
||
796 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback));*/ |
|
797 |
||
798 |
TLiwGenericParam param; |
|
799 |
||
800 |
CLiwMap* getlistlandmark_map = CLiwDefaultMap::NewL(); |
|
801 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
802 |
inparam->AppendL(param); |
|
803 |
param.Reset(); |
|
804 |
||
805 |
TRAPD(err_getlist, interface->ExecuteCmdL(KGetList, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
806 |
getlistlandmark_map->DecRef(); |
|
807 |
||
808 |
TInt pos=0; |
|
809 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
810 |
||
811 |
if(output) |
|
812 |
{ |
|
813 |
iTransactionId = output->Value().AsTInt32(); |
|
814 |
gLog->Log(_L("calling cancel function from testfunc")); |
|
815 |
CancelNotification(0,iTransactionId); //Call cancel with no trans Id |
|
816 |
} |
|
817 |
else |
|
818 |
{ |
|
819 |
if(iWaitSchedular->IsStarted()) |
|
820 |
iWaitSchedular->AsyncStop(); |
|
821 |
} |
|
822 |
||
823 |
inparam->Reset(); |
|
824 |
outparam->Reset(); |
|
825 |
} |
|
826 |
||
827 |
||
828 |
//Helper functions |
|
829 |
||
830 |
// ----------------------------------------------------------------------------- |
|
831 |
// CreateLandmarksL |
|
832 |
// Helper method to add landmarks to a default database. |
|
833 |
// ----------------------------------------------------------------------------- |
|
834 |
// |
|
835 |
void CreateLandmarksL (CPosLandmarkDatabase* aLandmarkHandle) |
|
836 |
{ |
|
837 |
CPosLandmark* lm = CPosLandmark::NewLC (); |
|
838 |
_LIT(KStreet,"broadway"); |
|
839 |
// _LIT(KIconFile,"//s60//icons//qgn_graf_s60_logo.svg"); |
|
840 |
_LIT(KDesc,"welcome to galactica"); |
|
841 |
TPosition locale; |
|
842 |
locale.SetCoordinate(12.345,67.89); |
|
843 |
lm->SetLandmarkNameL(KLmName1); |
|
844 |
lm->SetPositionL(locale); |
|
845 |
lm->SetCoverageRadius(12.345); |
|
846 |
lm->SetPositionFieldL(EPositionFieldStreet,KStreet); |
|
847 |
lm->SetLandmarkDescriptionL(KDesc); |
|
848 |
aLandmarkHandle->AddLandmarkL(*lm); |
|
849 |
CleanupStack::PopAndDestroy(lm); |
|
850 |
lm = CPosLandmark::NewLC (); |
|
851 |
lm->SetLandmarkNameL (KLmName2); |
|
852 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
853 |
||
854 |
lm->SetLandmarkNameL (KLmName3); |
|
855 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
856 |
||
857 |
lm->SetLandmarkNameL (KLmName4); |
|
858 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
859 |
||
860 |
lm->SetLandmarkNameL (KLmName5); |
|
861 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
862 |
||
863 |
lm->SetLandmarkNameL (KLmName6); |
|
864 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
865 |
||
866 |
CleanupStack::PopAndDestroy(lm); |
|
867 |
} |
|
868 |
||
869 |
// ----------------------------------------------------------------------------- |
|
870 |
// CheckErrorCode |
|
871 |
// checks error code e |
|
872 |
// called by all testcases. |
|
873 |
// ----------------------------------------------------------------------------- |
|
874 |
// |
|
875 |
TInt CheckErrorCode( const CLiwGenericParamList& aOutList, TInt32& aError ) |
|
876 |
{ |
|
877 |
TInt Index = 0; |
|
878 |
const TLiwGenericParam* errcode = aOutList.FindFirst(Index,KErrorCode); |
|
879 |
if ( KErrNotFound == Index ) |
|
880 |
{ |
|
881 |
// iLog->Log( _L("ErrorCode not found in output ArgList") ); |
|
882 |
return FAIL; |
|
883 |
} |
|
884 |
else |
|
885 |
{ |
|
886 |
aError = errcode->Value().AsTInt32(); |
|
887 |
return PASS; |
|
888 |
} |
|
889 |
||
890 |
} |
|
891 |
||
892 |
// ----------------------------------------------------------------------------- |
|
893 |
// RemoveAllLandmarks |
|
894 |
// Helper method to remove all landmarks for preconditional tests. |
|
895 |
// ----------------------------------------------------------------------------- |
|
896 |
// |
|
897 |
||
898 |
void RemoveAllLandmarks (CPosLandmarkDatabase* aLandmarkHandle) |
|
899 |
{ |
|
900 |
ExecuteAndDeleteLD(aLandmarkHandle->RemoveAllLandmarksL()); |
|
901 |
} |
|
902 |
// ----------------------------------------------------------------------------- |
|
903 |
// RemoveAllLandmarks |
|
904 |
// Helper method to remove all categories for preconditional tests. |
|
905 |
// ----------------------------------------------------------------------------- |
|
906 |
// |
|
907 |
void RemoveAllCategories (CPosLmCategoryManager* aHandle) |
|
908 |
{ |
|
909 |
TPosLmItemId catID; |
|
910 |
CPosLmItemIterator*iterator = aHandle->CategoryIteratorL(); |
|
911 |
CleanupStack::PushL(iterator); |
|
912 |
||
913 |
while ((catID = iterator->NextL()) != KPosLmNullItemId) |
|
914 |
{ |
|
915 |
TRAPD(err,ExecuteAndDeleteLD(aHandle->RemoveCategoryL( catID ))); |
|
916 |
TBuf8<50> error; |
|
917 |
TRealFormat format; |
|
918 |
error.Num(err,format) ; |
|
919 |
// iLog->Log( error ); |
|
920 |
} |
|
921 |
CleanupStack::PopAndDestroy(iterator); |
|
922 |
} |
|
923 |
||
924 |
||
925 |
// ----------------------------------------------------------------------------- |
|
926 |
// DeleteAllDatabases |
|
927 |
// removes all local databases from the terminal |
|
928 |
// called by all testcases. |
|
929 |
// ----------------------------------------------------------------------------- |
|
930 |
// |
|
931 |
/*void DeleteAllLocalDatabasesL() |
|
932 |
{ |
|
933 |
TInt count; |
|
934 |
||
935 |
CDesCArray* dbList = iDatabaseManager->ListDatabasesLC(_L("file")); |
|
936 |
count = dbList->Count(); |
|
937 |
||
938 |
for ( TInt i = 0; i < count; i++ ) |
|
939 |
{ |
|
940 |
TPtrC db = (*dbList)[i]; |
|
941 |
iDatabaseManager->DeleteDatabaseL ( db ); |
|
942 |
} |
|
943 |
CleanupStack::PopAndDestroy (1); |
|
944 |
}*/ |
|
945 |