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