author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:06:03 +0300 | |
branch | RCL_3 |
changeset 44 | 0b68a1b0c15e |
parent 38 | ea43c23d28d2 |
child 45 | a9c0808a1095 |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2002 - 2007 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 FILES] - do not remove |
|
21 |
#include <e32svr.h> |
|
22 |
#include <StifParser.h> |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
23 |
#include <StifTestInterface.h> |
5 | 24 |
#include <hal.h> |
25 |
||
26 |
#include "tserviceregistrytest.h" |
|
27 |
#include "serviceerrno.h" |
|
28 |
||
29 |
||
30 |
// Other generated constants |
|
31 |
_LIT8(KService, "IService"); |
|
32 |
_LIT8(KCmdCancel, "Cancel"); |
|
33 |
||
34 |
||
35 |
_LIT8( KParamFilter, "Filter" ); |
|
36 |
_LIT8( KServiceName, "ServiceName" ); |
|
37 |
_LIT8( KInterfaceName, "InterfaceName" ); |
|
38 |
_LIT8( KVersionList, "VersionList" ); |
|
39 |
||
40 |
||
41 |
||
42 |
||
43 |
// Constants for supported Operations |
|
44 |
_LIT8(KGetList, "GetList"); |
|
45 |
||
46 |
_LIT8(KBadCmd, "BadCmd"); |
|
47 |
||
48 |
||
49 |
// Constants for error messages |
|
50 |
_LIT8(KErrorMessage, "ErrorMessage"); |
|
51 |
_LIT(KMessageSeparator, ": "); |
|
52 |
_LIT(KInterfaceErrorMessage, "Invalid Interface"); |
|
53 |
_LIT(KMissingArgument, "Input argument was not found."); |
|
54 |
_LIT(KBadArgumentType, "Input argument type was wrong."); |
|
55 |
_LIT(KInvalidCMD, "Command not supported."); |
|
56 |
_LIT(KInvalidCMDOptions, "Invalid command options."); |
|
57 |
_LIT(KCallbackNotFound, "Callback was not found for asynchronous method."); |
|
58 |
_LIT(KSyncRequestNotSupported, "Synchronous request not supported."); |
|
59 |
_LIT(KAsyncRequestNotSupported, "Asynchronous request not supported."); |
|
60 |
_LIT(KGeneralErrorMessage, "Error occured during runtime."); |
|
61 |
_LIT(KTransactionCancelFailed, "Canceling transaction failed."); |
|
62 |
_LIT(KMissingCancelOption, "Cancel option was not set."); |
|
63 |
||
64 |
_LIT8(KWild, "*"); |
|
65 |
||
66 |
_LIT8(KErrorCode , "ErrorCode"); |
|
67 |
||
68 |
/* |
|
69 |
* Return Value Identifier in output parameter list. |
|
70 |
*/ |
|
71 |
_LIT8(KReturnValue , "ReturnValue"); |
|
72 |
||
73 |
/** |
|
74 |
* Command identifier in input parameter list |
|
75 |
*/ |
|
76 |
_LIT8(KCommand, "cmd"); |
|
77 |
||
78 |
/** |
|
79 |
* Transaction id in output parameter list needed for asynchronous request |
|
80 |
*/ |
|
81 |
_LIT8(KTransactionId, "TransactionID"); |
|
82 |
||
83 |
||
84 |
_LIT(KInputStart, "InputStart"); |
|
85 |
_LIT(KInputEnd, "InputEnd"); |
|
86 |
||
87 |
_LIT(KExpectedStart,"ExpectedStart"); |
|
88 |
_LIT(KExpectedEnd,"ExpectedEnd"); |
|
89 |
||
90 |
_LIT(KMapStart,"StartMap"); |
|
91 |
_LIT(KMapEnd,"EndMap"); |
|
92 |
||
93 |
// ============================ MEMBER FUNCTIONS =============================== |
|
94 |
||
95 |
// ----------------------------------------------------------------------------- |
|
96 |
// CIServiceTestModule::Delete |
|
97 |
// Delete here all resources allocated and opened from test methods. |
|
98 |
// Called from destructor. |
|
99 |
// ----------------------------------------------------------------------------- |
|
100 |
// |
|
101 |
void CIServiceTestModule::Delete() |
|
102 |
{ |
|
103 |
iIface->Close(); |
|
104 |
iCriteriaArray.Close(); |
|
105 |
delete iServiceHandler; |
|
106 |
delete iCriteria; |
|
107 |
for(TInt i=0; i<iExpectedOutPutArray.Count(); i++) |
|
108 |
{ |
|
109 |
iExpectedOutPutArray[i]->DecRef(); |
|
110 |
} |
|
111 |
iExpectedOutPutArray.Reset(); |
|
112 |
} |
|
113 |
||
114 |
||
115 |
TInt CIServiceTestModule :: HandleNotifyL(TInt /*aCmdId*/, |
|
116 |
TInt /*aEventId*/, |
|
117 |
CLiwGenericParamList& aEventParamList, |
|
118 |
const CLiwGenericParamList& /*aInParamList*/) |
|
119 |
{ |
|
120 |
TInt pos = 0 ; |
|
121 |
||
122 |
const TLiwGenericParam* param = NULL; |
|
123 |
const TLiwGenericParam* paramIter = NULL; |
|
124 |
const CLiwList* pList = NULL; |
|
125 |
CLiwIterable* iter = NULL; |
|
126 |
||
127 |
CActiveScheduler::Stop(); |
|
128 |
param = aEventParamList.FindFirst(pos, KErrorCode); |
|
129 |
||
130 |
if(param) |
|
131 |
{ |
|
132 |
TLiwVariant err = param->Value(); |
|
133 |
TInt code = err.AsTInt32(); |
|
134 |
err.Reset(); |
|
135 |
if(code != iExpectedError) |
|
136 |
{ |
|
137 |
iResult = KErrGeneral; |
|
44
0b68a1b0c15e
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
38
diff
changeset
|
138 |
return; |
5 | 139 |
} |
140 |
} |
|
141 |
||
142 |
pos = 0; |
|
143 |
paramIter = aEventParamList.FindFirst(pos, KReturnValue); |
|
144 |
||
145 |
iter = paramIter->Value().AsIterable(); |
|
146 |
||
147 |
if(iter) |
|
148 |
{ |
|
149 |
if(IsExpectedResult(iter)) |
|
150 |
{ |
|
151 |
iResult = KErrNone; |
|
152 |
} |
|
153 |
} |
|
44
0b68a1b0c15e
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
38
diff
changeset
|
154 |
|
5 | 155 |
} |
156 |
||
157 |
TInt CIServiceTestModule::LoadProviderTest(CStifItemParser& aItem) |
|
158 |
{ |
|
159 |
__UHEAP_MARK; |
|
160 |
if(iIface) |
|
161 |
{ |
|
162 |
iResult = KErrNone; |
|
163 |
} |
|
164 |
else |
|
165 |
{ |
|
166 |
iResult = KErrNotFound; |
|
167 |
} |
|
168 |
iInparams->Reset(); |
|
169 |
iOutparams->Reset(); |
|
170 |
Delete(); |
|
171 |
__UHEAP_MARKEND; |
|
172 |
return iResult; |
|
173 |
} |
|
174 |
||
175 |
TInt CIServiceTestModule::InvalidServiceValue(CStifItemParser& aItem) |
|
176 |
{ |
|
177 |
__UHEAP_MARK; |
|
178 |
TInt pos = 0; |
|
179 |
TReal serviceName = 1.0; |
|
180 |
CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
181 |
pMap->InsertL(KServiceName,TLiwVariant(serviceName)); |
|
182 |
iInparams->AppendL(TLiwGenericParam(KParamFilter, TLiwVariant(pMap))); |
|
183 |
pMap->DecRef(); |
|
184 |
||
185 |
iIface->ExecuteCmdL(KGetList, |
|
186 |
*iInparams, |
|
187 |
*iOutparams, |
|
188 |
KLiwOptASyncronous, |
|
189 |
this); |
|
190 |
||
191 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
192 |
||
193 |
TInt code = KErrGeneral; |
|
194 |
if(param) |
|
195 |
{ |
|
196 |
TLiwVariant err = param->Value(); |
|
197 |
code = err.AsTInt32(); |
|
198 |
err.Reset(); |
|
199 |
} |
|
200 |
if(SErrInvalidServiceArgument == code) |
|
201 |
{ |
|
202 |
iResult = KErrNone; |
|
203 |
} |
|
204 |
else |
|
205 |
{ |
|
206 |
iResult = KErrGeneral; |
|
207 |
} |
|
208 |
iInparams->Reset(); |
|
209 |
iOutparams->Reset(); |
|
210 |
Delete(); |
|
211 |
__UHEAP_MARKEND; |
|
212 |
return iResult; |
|
213 |
} |
|
214 |
TInt CIServiceTestModule::InvalidInterfaceValue(CStifItemParser& aItem) |
|
215 |
{ |
|
216 |
__UHEAP_MARK; |
|
217 |
TInt pos = 0; |
|
218 |
TReal interfacename = 1.0; |
|
219 |
CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
220 |
pMap->InsertL(KInterfaceName,TLiwVariant(interfacename)); |
|
221 |
iInparams->AppendL(TLiwGenericParam(KParamFilter, TLiwVariant(pMap))); |
|
222 |
pMap->DecRef(); |
|
223 |
||
224 |
iIface->ExecuteCmdL(KGetList, |
|
225 |
*iInparams, |
|
226 |
*iOutparams, |
|
227 |
KLiwOptASyncronous, |
|
228 |
this); |
|
229 |
||
230 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
231 |
||
232 |
TInt code = KErrGeneral; |
|
233 |
if(param) |
|
234 |
{ |
|
235 |
TLiwVariant err = param->Value(); |
|
236 |
code = err.AsTInt32(); |
|
237 |
err.Reset(); |
|
238 |
} |
|
239 |
if(SErrInvalidServiceArgument == code) |
|
240 |
{ |
|
241 |
iResult = KErrNone; |
|
242 |
} |
|
243 |
else |
|
244 |
{ |
|
245 |
iResult = KErrGeneral; |
|
246 |
} |
|
247 |
iInparams->Reset(); |
|
248 |
iOutparams->Reset(); |
|
249 |
Delete(); |
|
250 |
__UHEAP_MARKEND; |
|
251 |
return iResult; |
|
252 |
} |
|
253 |
||
254 |
TInt CIServiceTestModule::InvalidMinVerValue(CStifItemParser& aItem) |
|
255 |
{ |
|
256 |
__UHEAP_MARK; |
|
257 |
TInt pos = 0; |
|
258 |
TBuf<25> Minver(_L("InvalidVer")); |
|
259 |
CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
260 |
pMap->InsertL(_L8("MinimumVersion"),TLiwVariant(Minver)); |
|
261 |
iInparams->AppendL(TLiwGenericParam(KParamFilter, TLiwVariant(pMap))); |
|
262 |
pMap->DecRef(); |
|
263 |
||
264 |
iIface->ExecuteCmdL(KGetList, |
|
265 |
*iInparams, |
|
266 |
*iOutparams, |
|
267 |
KLiwOptASyncronous, |
|
268 |
this); |
|
269 |
||
270 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
271 |
||
272 |
TInt code = KErrGeneral; |
|
273 |
if(param) |
|
274 |
{ |
|
275 |
TLiwVariant err = param->Value(); |
|
276 |
code = err.AsTInt32(); |
|
277 |
err.Reset(); |
|
278 |
} |
|
279 |
if(SErrInvalidServiceArgument == code) |
|
280 |
{ |
|
281 |
iResult = KErrNone; |
|
282 |
} |
|
283 |
else |
|
284 |
{ |
|
285 |
iResult = KErrGeneral; |
|
286 |
} |
|
287 |
iInparams->Reset(); |
|
288 |
iOutparams->Reset(); |
|
289 |
Delete(); |
|
290 |
__UHEAP_MARKEND; |
|
291 |
return iResult; |
|
292 |
} |
|
293 |
TInt CIServiceTestModule::InvalidMaxVerValue(CStifItemParser& aItem) |
|
294 |
{ |
|
295 |
__UHEAP_MARK; |
|
296 |
TInt pos = 0; |
|
297 |
TBuf<25> Maxver(_L("InvalidVer")); |
|
298 |
CLiwDefaultMap* pMap = CLiwDefaultMap::NewL(); |
|
299 |
pMap->InsertL(_L8("MaximumVersion"),TLiwVariant(Maxver)); |
|
300 |
iInparams->AppendL(TLiwGenericParam(KParamFilter, TLiwVariant(pMap))); |
|
301 |
pMap->DecRef(); |
|
302 |
||
303 |
iIface->ExecuteCmdL(KGetList, |
|
304 |
*iInparams, |
|
305 |
*iOutparams, |
|
306 |
KLiwOptASyncronous, |
|
307 |
this); |
|
308 |
||
309 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
310 |
||
311 |
TInt code = KErrGeneral; |
|
312 |
if(param) |
|
313 |
{ |
|
314 |
TLiwVariant err = param->Value(); |
|
315 |
code = err.AsTInt32(); |
|
316 |
err.Reset(); |
|
317 |
} |
|
318 |
if(SErrInvalidServiceArgument == code) |
|
319 |
{ |
|
320 |
iResult = KErrNone; |
|
321 |
} |
|
322 |
else |
|
323 |
{ |
|
324 |
iResult = KErrGeneral; |
|
325 |
} |
|
326 |
iInparams->Reset(); |
|
327 |
iOutparams->Reset(); |
|
328 |
Delete(); |
|
329 |
__UHEAP_MARKEND; |
|
330 |
return iResult; |
|
331 |
} |
|
332 |
||
333 |
TInt CIServiceTestModule::InvalidFilterValue(CStifItemParser& aItem) |
|
334 |
{ |
|
335 |
__UHEAP_MARK; |
|
336 |
TInt pos = 0; |
|
337 |
CLiwDefaultList* pList= CLiwDefaultList::NewL(); |
|
338 |
iInparams->AppendL(TLiwGenericParam(KParamFilter, TLiwVariant(pList))); |
|
339 |
pList->DecRef(); |
|
340 |
||
341 |
iIface->ExecuteCmdL(KGetList, |
|
342 |
*iInparams, |
|
343 |
*iOutparams, |
|
344 |
KLiwOptASyncronous, |
|
345 |
this); |
|
346 |
||
347 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
348 |
||
349 |
TInt code = KErrGeneral; |
|
350 |
if(param) |
|
351 |
{ |
|
352 |
TLiwVariant err = param->Value(); |
|
353 |
code = err.AsTInt32(); |
|
354 |
err.Reset(); |
|
355 |
} |
|
356 |
if(SErrInvalidServiceArgument == code) |
|
357 |
{ |
|
358 |
iResult = KErrNone; |
|
359 |
} |
|
360 |
else |
|
361 |
{ |
|
362 |
iResult = KErrGeneral; |
|
363 |
} |
|
364 |
iInparams->Reset(); |
|
365 |
iOutparams->Reset(); |
|
366 |
Delete(); |
|
367 |
__UHEAP_MARKEND; |
|
368 |
return iResult; |
|
369 |
} |
|
370 |
||
371 |
TInt CIServiceTestModule::GetListTwice(CStifItemParser& aItem) |
|
372 |
{ |
|
373 |
__UHEAP_MARK; |
|
374 |
TInt pos =0; |
|
375 |
iIface->ExecuteCmdL(KGetList, |
|
376 |
*iInparams, |
|
377 |
*iOutparams, |
|
378 |
KLiwOptASyncronous, |
|
379 |
this); |
|
380 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
381 |
||
382 |
TInt code = KErrGeneral; |
|
383 |
if(param) |
|
384 |
{ |
|
385 |
TLiwVariant err = param->Value(); |
|
386 |
code = err.AsTInt32(); |
|
387 |
err.Reset(); |
|
388 |
} |
|
389 |
if(code == KErrNone) |
|
390 |
{ |
|
391 |
iInparams->Reset(); |
|
392 |
iOutparams->Reset(); |
|
393 |
iIface->ExecuteCmdL(KGetList, |
|
394 |
*iInparams, |
|
395 |
*iOutparams, |
|
396 |
KLiwOptASyncronous, |
|
397 |
this); |
|
398 |
} |
|
399 |
pos =0; |
|
400 |
const TLiwGenericParam* param1 = iOutparams->FindFirst(pos, KErrorCode); |
|
401 |
||
402 |
TInt code1 = KErrGeneral; |
|
403 |
if(param1) |
|
404 |
{ |
|
405 |
TLiwVariant err1 = param1->Value(); |
|
406 |
code1 = err1.AsTInt32(); |
|
407 |
err1.Reset(); |
|
408 |
} |
|
409 |
||
410 |
if(code1 == SErrServiceInUse) |
|
411 |
{ |
|
412 |
iResult = KErrNone; |
|
413 |
} |
|
414 |
else |
|
415 |
{ |
|
416 |
iResult = KErrGeneral; |
|
417 |
} |
|
418 |
iInparams->Reset(); |
|
419 |
iOutparams->Reset(); |
|
420 |
||
421 |
Delete(); |
|
422 |
__UHEAP_MARKEND; |
|
423 |
return iResult; |
|
424 |
} |
|
425 |
||
426 |
TInt CIServiceTestModule::InvalidCommand(CStifItemParser& aItem) |
|
427 |
{ |
|
428 |
__UHEAP_MARK; |
|
429 |
TInt pos = 0; |
|
430 |
iIface->ExecuteCmdL(_L8("Dummy"), |
|
431 |
*iInparams, |
|
432 |
*iOutparams, |
|
433 |
KLiwOptASyncronous, |
|
434 |
this); |
|
435 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
436 |
||
437 |
TInt code = KErrGeneral; |
|
438 |
if(param) |
|
439 |
{ |
|
440 |
TLiwVariant err = param->Value(); |
|
441 |
code = err.AsTInt32(); |
|
442 |
err.Reset(); |
|
443 |
} |
|
444 |
if(SErrServiceNotSupported == code) |
|
445 |
{ |
|
446 |
iResult = KErrNone; |
|
447 |
} |
|
448 |
else |
|
449 |
{ |
|
450 |
iResult = KErrNotFound; |
|
451 |
} |
|
452 |
iInparams->Reset(); |
|
453 |
iOutparams->Reset(); |
|
454 |
Delete(); |
|
455 |
__UHEAP_MARKEND; |
|
456 |
return iResult; |
|
457 |
} |
|
458 |
||
459 |
||
460 |
||
461 |
TInt CIServiceTestModule::CancelInvalidTransID(CStifItemParser& aItem) |
|
462 |
{ |
|
463 |
__UHEAP_MARK; |
|
464 |
TInt pos =0 ; |
|
465 |
iIface->ExecuteCmdL(KGetList, |
|
466 |
*iInparams, |
|
467 |
*iOutparams, |
|
468 |
KLiwOptASyncronous, |
|
469 |
this); |
|
470 |
||
471 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
472 |
||
473 |
TInt code = KErrGeneral; |
|
474 |
if(param) |
|
475 |
{ |
|
476 |
TLiwVariant err = param->Value(); |
|
477 |
code = err.AsTInt32(); |
|
478 |
err.Reset(); |
|
479 |
} |
|
480 |
||
481 |
if(code == KErrNone) |
|
482 |
{ |
|
483 |
pos = 0; |
|
484 |
||
485 |
iInparams->Reset(); |
|
486 |
iOutparams->Reset(); |
|
487 |
||
488 |
iInparams->AppendL(TLiwGenericParam(KTransactionId, TLiwVariant(TInt32(12345)))); |
|
489 |
||
490 |
iIface->ExecuteCmdL(KCmdCancel, |
|
491 |
*iInparams, |
|
492 |
*iOutparams, |
|
493 |
KLiwOptCancel, |
|
494 |
this); |
|
495 |
pos =0; |
|
496 |
const TLiwGenericParam* paramerr = iOutparams->FindFirst(pos, KErrorCode); |
|
497 |
||
498 |
TLiwVariant error = paramerr->Value(); |
|
499 |
code = error.AsTInt32(); |
|
500 |
error.Reset(); |
|
501 |
||
502 |
if(code == SErrNotFound) |
|
503 |
{ |
|
504 |
iResult = KErrNone; |
|
505 |
} |
|
506 |
else |
|
507 |
{ |
|
508 |
iResult = KErrGeneral; |
|
509 |
} |
|
510 |
} |
|
511 |
iInparams->Reset(); |
|
512 |
iOutparams->Reset(); |
|
513 |
||
514 |
Delete(); |
|
515 |
__UHEAP_MARKEND; |
|
516 |
} |
|
517 |
||
518 |
||
519 |
// ----------------------------------------------------------------------------- |
|
520 |
// CIServiceTestModule::GetListL |
|
521 |
// Test method function. |
|
522 |
// (other items were commented in a header). |
|
523 |
// ----------------------------------------------------------------------------- |
|
524 |
// |
|
525 |
TInt CIServiceTestModule::GetMetaDataListL(CStifItemParser& aItem) |
|
526 |
{ |
|
527 |
||
528 |
TInt pos = 0; |
|
529 |
iResult = KErrGeneral; |
|
530 |
TInt cancelbit = -1; |
|
531 |
TPtrC nextString; |
|
532 |
CLiwDefaultMap* pMap = NULL; |
|
533 |
||
534 |
__UHEAP_MARK; |
|
535 |
||
536 |
aItem.GetNextInt(iExpectedError); |
|
537 |
aItem.GetNextInt(cancelbit); |
|
538 |
aItem.GetNextString(nextString); |
|
539 |
||
540 |
if(nextString.CompareF(KInputStart) == 0) |
|
541 |
{ |
|
542 |
pMap = SetInputFilterL(aItem); |
|
543 |
aItem.GetNextString(nextString); |
|
544 |
} |
|
545 |
if(nextString.CompareF(KExpectedStart) == 0) |
|
546 |
{ |
|
547 |
SetExpectedOutputMap(aItem); |
|
548 |
} |
|
549 |
if(pMap) |
|
550 |
{ |
|
551 |
iInparams->AppendL(TLiwGenericParam(KParamFilter, TLiwVariant(pMap))); |
|
552 |
pMap->DecRef(); |
|
553 |
} |
|
554 |
||
555 |
iIface->ExecuteCmdL(KGetList, |
|
556 |
*iInparams, |
|
557 |
*iOutparams, |
|
558 |
KLiwOptASyncronous, |
|
559 |
this); |
|
560 |
||
561 |
const TLiwGenericParam* param = iOutparams->FindFirst(pos, KErrorCode); |
|
562 |
||
563 |
TInt code = KErrGeneral; |
|
564 |
if(param) |
|
565 |
{ |
|
566 |
TLiwVariant err = param->Value(); |
|
567 |
code = err.AsTInt32(); |
|
568 |
err.Reset(); |
|
569 |
} |
|
570 |
||
571 |
if(code == KErrNone) |
|
572 |
{ |
|
573 |
if(cancelbit == 1) |
|
574 |
{ |
|
575 |
pos = 0; |
|
576 |
const TLiwGenericParam* paramtransid = iOutparams->FindFirst(pos, KTransactionId); |
|
577 |
if(paramtransid) |
|
578 |
{ |
|
579 |
TLiwVariant trID = paramtransid->Value(); |
|
580 |
TInt32 transID = trID.AsTInt32(); |
|
581 |
trID.Reset(); |
|
582 |
iInparams->Reset(); |
|
583 |
iOutparams->Reset(); |
|
584 |
||
585 |
iInparams->AppendL(TLiwGenericParam(KTransactionId, TLiwVariant(transID))); |
|
586 |
||
587 |
iIface->ExecuteCmdL(KCmdCancel, |
|
588 |
*iInparams, |
|
589 |
*iOutparams, |
|
590 |
KLiwOptCancel, |
|
591 |
this); |
|
592 |
pos =0; |
|
593 |
const TLiwGenericParam* paramerr = iOutparams->FindFirst(pos, KErrorCode); |
|
594 |
||
595 |
TLiwVariant error = paramerr->Value(); |
|
596 |
code = error.AsTInt32(); |
|
597 |
error.Reset(); |
|
598 |
||
599 |
if(iExpectedError == code) |
|
600 |
{ |
|
601 |
iResult = KErrNone; |
|
602 |
} |
|
603 |
} |
|
604 |
} |
|
605 |
else |
|
606 |
CActiveScheduler::Start(); |
|
607 |
} |
|
608 |
else |
|
609 |
{ |
|
610 |
if(iExpectedError == code) |
|
611 |
{ |
|
612 |
iResult = KErrNone; |
|
613 |
} |
|
614 |
} |
|
615 |
||
616 |
iInparams->Reset(); |
|
617 |
iOutparams->Reset(); |
|
618 |
||
619 |
Delete(); |
|
620 |
||
621 |
__UHEAP_MARKEND; |
|
622 |
return iResult; |
|
623 |
} |
|
624 |
||
625 |
||
626 |
CLiwDefaultMap* CIServiceTestModule::SetInputFilterL(CStifItemParser& aItem) |
|
627 |
{ |
|
628 |
TPtrC nextString(KNullDesC); |
|
629 |
||
630 |
CLiwDefaultMap* pMap = CLiwDefaultMap :: NewL(); |
|
631 |
||
632 |
aItem.GetNextString(nextString); |
|
633 |
||
634 |
while(nextString.CompareF(KInputEnd) != 0) |
|
635 |
{ |
|
636 |
TPtrC value(KNullDesC); |
|
637 |
||
638 |
aItem.GetNextString(value); |
|
639 |
||
640 |
TBuf8<255> key8bit; |
|
641 |
key8bit.Copy(nextString); |
|
642 |
||
643 |
if(key8bit.CompareF(_L8("MinimumVersion"))==0) |
|
644 |
{ |
|
645 |
TReal version; |
|
646 |
TLex lex(value); |
|
647 |
lex.Val(version,'.'); |
|
648 |
aItem.GetNextString(nextString); |
|
649 |
pMap->InsertL(key8bit, version); |
|
650 |
continue; |
|
651 |
} |
|
652 |
if(key8bit.CompareF(_L8("MaximumVersion"))==0) |
|
653 |
{ |
|
654 |
TReal version; |
|
655 |
TLex lex(value); |
|
656 |
lex.Val(version,'.'); |
|
657 |
aItem.GetNextString(nextString); |
|
658 |
pMap->InsertL(key8bit, version); |
|
659 |
continue; |
|
660 |
} |
|
661 |
aItem.GetNextString(nextString); |
|
662 |
||
663 |
pMap->InsertL(key8bit, value); |
|
664 |
} |
|
665 |
||
666 |
return pMap; |
|
667 |
} |
|
668 |
||
669 |
||
670 |
void CIServiceTestModule :: SetExpectedOutputMap(CStifItemParser& aItem) |
|
671 |
{ |
|
672 |
TPtrC16 nextString(KNullDesC); |
|
673 |
||
674 |
iLog->Log(_L("Inside SetExpectedOutputMap")); |
|
675 |
||
676 |
//aItem.GetNextString(nextString); |
|
677 |
/* |
|
678 |
* The expected output is in the format. |
|
679 |
* [ExpectredStart StartMap Key Value[...]EndMap[...]ExpectedEnd]. |
|
680 |
*/ |
|
681 |
||
682 |
while(nextString.CompareF(KExpectedEnd)!=0) |
|
683 |
{ |
|
684 |
if(nextString.CompareF(KMapStart) == 0) |
|
685 |
{ |
|
686 |
CLiwDefaultMap* expectedOutPutMap = CLiwDefaultMap::NewL(); |
|
687 |
CleanupStack::PushL(expectedOutPutMap); |
|
688 |
aItem.GetNextString(nextString); |
|
689 |
||
690 |
while(nextString.CompareF(KMapEnd)!= 0) |
|
691 |
{ |
|
692 |
TPtrC key; |
|
693 |
TPtrC value; |
|
694 |
TBuf8<255> insertKey; |
|
695 |
||
696 |
key.Set(nextString); |
|
697 |
insertKey.Copy(key); |
|
698 |
||
699 |
if(key.CompareF(_L("Version"))==0) |
|
700 |
{ |
|
701 |
TPtrC ver(KNullDesC); |
|
702 |
TReal version; |
|
703 |
aItem.GetNextString(ver); |
|
704 |
TLex lex(ver); |
|
705 |
lex.Val(version,'.'); |
|
706 |
expectedOutPutMap->InsertL(insertKey, version); |
|
707 |
} |
|
708 |
else |
|
709 |
{ |
|
710 |
aItem.GetNextString(nextString); |
|
711 |
value.Set(nextString); |
|
712 |
expectedOutPutMap->InsertL(insertKey, value); |
|
713 |
} |
|
714 |
aItem.GetNextString(nextString); |
|
715 |
} |
|
716 |
||
717 |
iExpectedOutPutArray.Append(expectedOutPutMap); |
|
718 |
CleanupStack::Pop(expectedOutPutMap); |
|
719 |
} |
|
720 |
aItem.GetNextString(nextString); |
|
721 |
} |
|
722 |
} |
|
723 |
||
724 |
||
725 |
||
726 |
TBool CIServiceTestModule::IsExpectedResult(CLiwIterable* aResultlist) |
|
727 |
{ |
|
728 |
TLiwVariant metadata; |
|
729 |
TBool foundMap = EFalse; |
|
730 |
iLog->Log(_L("Inside IsExpectedResult")); |
|
731 |
||
732 |
for(TInt i = 0; i<iExpectedOutPutArray.Count(); i++) |
|
733 |
||
734 |
{ |
|
735 |
while(aResultlist->NextL(metadata)) |
|
736 |
{ |
|
737 |
const CLiwMap* map = metadata.AsMap(); |
|
738 |
if(map) |
|
739 |
{ |
|
740 |
iLog->Log(_L("Map found from iterator")); |
|
741 |
//compare the two maps the result and the expected one. |
|
742 |
if(CompareMaps(iExpectedOutPutArray[i], map)) |
|
743 |
{ |
|
744 |
aResultlist->Reset(); |
|
745 |
metadata.Reset(); |
|
746 |
foundMap = ETrue; |
|
747 |
break; |
|
748 |
} |
|
749 |
} |
|
750 |
metadata.Reset(); |
|
751 |
} |
|
752 |
if(foundMap) |
|
753 |
{ |
|
754 |
foundMap = EFalse; |
|
755 |
} |
|
756 |
else |
|
757 |
{ |
|
758 |
iLog->Log(_L("Expected map not found in the result list")); |
|
759 |
return EFalse; |
|
760 |
} |
|
761 |
} |
|
762 |
return ETrue; |
|
763 |
} |
|
764 |
||
765 |
||
766 |
||
767 |
||
768 |
TBool CIServiceTestModule::CompareMaps(CLiwMap* aExpectedMap, |
|
769 |
const CLiwMap* aResultMap) |
|
770 |
{ |
|
771 |
||
772 |
iLog->Log(_L("Inside CompareMaps")); |
|
773 |
||
774 |
if(!CompareStringResult(KServiceName, aExpectedMap, aResultMap)) |
|
775 |
{ |
|
776 |
return EFalse; |
|
777 |
} |
|
778 |
if(!CompareStringResult(KInterfaceName, aExpectedMap, aResultMap)) |
|
779 |
{ |
|
780 |
return EFalse; |
|
781 |
} |
|
782 |
if(!CompareTRealResult(KVersionList, aExpectedMap, aResultMap)) |
|
783 |
{ |
|
784 |
return EFalse; |
|
785 |
} |
|
786 |
||
787 |
return ETrue; |
|
788 |
} |
|
789 |
||
790 |
||
791 |
||
792 |
||
793 |
/* -------------------------------------------------------------------------- |
|
794 |
Ctmediaprovidertesting :: CompareStringResult. |
|
795 |
A static method which compares two string results from the maps. |
|
796 |
----------------------------------------------------------------------------- |
|
797 |
*/ |
|
798 |
TBool CIServiceTestModule::CompareStringResult(const TDesC8& aKey, |
|
799 |
CLiwMap* aExpectedMap, |
|
800 |
const CLiwMap* aResultMap) |
|
801 |
{ |
|
802 |
TLiwVariant expValue; |
|
803 |
TLiwVariant resValue; |
|
804 |
TBool equal = EFalse; |
|
805 |
||
806 |
iLog->Log(_L("Inside CompareStringResult")); |
|
807 |
||
808 |
if(!aExpectedMap->FindL(aKey, expValue)) |
|
809 |
{ |
|
810 |
expValue.Reset(); |
|
811 |
return ETrue; |
|
812 |
} |
|
813 |
aResultMap->FindL(aKey, resValue); |
|
814 |
||
815 |
TPtrC expPtr = expValue.AsDes(); |
|
816 |
TPtrC resPtr = resValue.AsDes(); |
|
817 |
||
818 |
iLog->Log(_L("Expected Value")); |
|
819 |
iLog->Log(expPtr); |
|
820 |
||
821 |
iLog->Log(_L("Result Value")); |
|
822 |
iLog->Log(resPtr); |
|
823 |
||
824 |
if(expPtr.CompareF(_L("NULL"))!=0) |
|
825 |
{ |
|
826 |
if(expPtr.CompareF(resPtr) == 0) |
|
827 |
{ |
|
828 |
equal = ETrue; |
|
829 |
} |
|
830 |
} |
|
831 |
expValue.Reset(); |
|
832 |
resValue.Reset(); |
|
833 |
||
834 |
return equal; |
|
835 |
} |
|
836 |
||
837 |
||
838 |
TBool CIServiceTestModule::CompareTRealResult(const TDesC8& aKey, |
|
839 |
CLiwMap* aExpectedMap, |
|
840 |
const CLiwMap* aResultMap) |
|
841 |
{ |
|
842 |
TLiwVariant expValue; |
|
843 |
TLiwVariant resValue; |
|
844 |
||
845 |
TBool equal = EFalse; |
|
44
0b68a1b0c15e
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
38
diff
changeset
|
846 |
TReal expValueReal; |
0b68a1b0c15e
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
38
diff
changeset
|
847 |
TReal resValueReal; |
5 | 848 |
|
849 |
if(!aExpectedMap->FindL(aKey, expValue)) |
|
850 |
{ |
|
851 |
expValue.Reset(); |
|
852 |
return ETrue; |
|
853 |
} |
|
854 |
else |
|
855 |
{ |
|
856 |
expValueReal = expValue.AsTReal(); |
|
857 |
} |
|
858 |
||
859 |
if(aResultMap->FindL(KVersionList,resValue)) |
|
860 |
{ |
|
861 |
TLiwVariant ver; |
|
862 |
const CLiwList* verList = resValue.AsList(); |
|
863 |
if(verList->Count() == 0) |
|
864 |
{ |
|
865 |
expValue.Reset(); |
|
866 |
resValue.Reset(); |
|
867 |
return ETrue; |
|
868 |
} |
|
869 |
for(TInt i = 0; i < verList->Count(); ++i) |
|
870 |
{ |
|
871 |
verList->AtL(i,ver); |
|
872 |
resValueReal = ver.AsTReal(); |
|
873 |
} |
|
874 |
ver.Reset(); |
|
875 |
} |
|
876 |
else |
|
877 |
{ |
|
878 |
return ETrue; |
|
879 |
} |
|
880 |
||
881 |
//iLog->Log(_L("Expected Value")); |
|
882 |
//iLog->Log(expValueReal); |
|
883 |
||
884 |
//iLog->Log(_L("Result Value")); |
|
885 |
//iLog->Log(resValueReal); |
|
886 |
||
887 |
if(expValueReal == resValueReal) |
|
888 |
{ |
|
889 |
equal = ETrue; |
|
890 |
} |
|
891 |
||
892 |
expValue.Reset(); |
|
893 |
resValue.Reset(); |
|
894 |
return equal; |
|
895 |
} |
|
896 |
||
897 |
||
898 |