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) 2009 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
19 |
#include <StifTestInterface.h> |
19 | 20 |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
21 |
#include <liwservicehandler.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
22 |
#include <liwcommon.h> |
19 | 23 |
|
24 |
||
25 |
#include "tconstants.h" |
|
26 |
#include "tprovidertest.h" |
|
27 |
#include "tprovidercallback.h" |
|
28 |
#include "serviceerrno.h" |
|
29 |
||
30 |
void Ctprovidertest :: tdeleteTestL(TInt aExpected) |
|
31 |
{ |
|
32 |
if(aExpected != KErrNone) |
|
33 |
{ |
|
34 |
_LIT(KLog , "Negative test case for delete api") ; |
|
35 |
iLog->Log(KLog) ; |
|
36 |
tdeleteNegativeL(); |
|
37 |
||
38 |
} |
|
39 |
||
40 |
else |
|
41 |
{ |
|
42 |
_LIT(KLog , "Functional test for the delete api") ; |
|
43 |
iLog->Log(KLog) ; |
|
44 |
tdeleteFunctionalL() ; |
|
45 |
} |
|
46 |
} |
|
47 |
||
48 |
||
49 |
//---------------------------------------------------------------------- |
|
50 |
// internal utility function which tests the functionality of delete api |
|
51 |
// |
|
52 |
//---------------------------------------------------------------------- |
|
53 |
||
54 |
void Ctprovidertest :: tdeleteFunctionalL() |
|
55 |
{ |
|
56 |
||
57 |
_LIT(KOwnEventSubject, "RandomLogEvent"); |
|
58 |
_LIT(KOwnEventRemoteParty, "OwnContact"); |
|
59 |
||
60 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
61 |
// Input and output parameter list |
|
62 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
63 |
||
64 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
65 |
||
66 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
67 |
||
68 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
69 |
||
70 |
RCriteriaArray a; |
|
71 |
||
72 |
a.AppendL(crit); |
|
73 |
||
74 |
ServiceHandler->AttachL(a) ; |
|
75 |
||
76 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
77 |
||
78 |
TInt pos = 0; |
|
79 |
||
80 |
||
81 |
||
82 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
83 |
||
84 |
if(!genericparm) |
|
85 |
{ |
|
86 |
_LIT(KLog , "Logging interface not found") ; |
|
87 |
iLog->Log(KLog) ; |
|
88 |
||
89 |
User :: Leave(KErrArgument) ; |
|
90 |
} |
|
91 |
||
92 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
93 |
||
94 |
//Add an event and then delete this added event ; |
|
95 |
||
96 |
CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ; |
|
97 |
||
98 |
EventDetails->InsertL(KEventTypeKey ,TLiwVariant((TInt32)KLogShortMessageEvent)) ; |
|
99 |
||
100 |
||
101 |
TBufC16<10> contentType(KContentType) ; |
|
102 |
||
103 |
//Insert the contenttype to inputlist |
|
104 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
105 |
||
106 |
||
107 |
inputlist->AppendL(TLiwGenericParam(KEventDetails , TLiwVariant(EventDetails))) ; |
|
108 |
||
109 |
EventDetails->DecRef(); |
|
110 |
TBufC8<20>CmdBuf(KCmdAdd) ; |
|
111 |
||
112 |
LogInterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist) ; |
|
113 |
||
114 |
//Now get the id to deleted |
|
115 |
||
116 |
pos = 0 ; |
|
117 |
||
118 |
const TLiwGenericParam *outparm1 = outputlist->FindFirst(pos , KResponse) ; |
|
119 |
||
120 |
if(!outparm1) |
|
121 |
{ |
|
122 |
_LIT8(KLog , "Log id of the delete item not found") ; |
|
123 |
iLog->Log(KLog) ; |
|
124 |
User :: Leave(KErrArgument) ; |
|
125 |
} |
|
126 |
||
127 |
//Now delete the added item |
|
128 |
||
129 |
// TInt itemid = (outparm1->Value()).AsTInt32() ; |
|
130 |
||
131 |
TBufC<20> itemid = (outparm1->Value()).AsDes() ; |
|
132 |
||
133 |
/* if(itemid < 0 ) |
|
134 |
{ |
|
135 |
_LIT(KLog , "Invalid item id ") ; |
|
136 |
iLog->Log(KLog) ; |
|
137 |
User :: Leave(KErrArgument) ; |
|
138 |
}*/ |
|
139 |
||
140 |
inputlist->Reset() ; outputlist->Reset() ; |
|
141 |
||
142 |
CLiwDefaultMap *Idmap = CLiwDefaultMap :: NewL() ; |
|
143 |
Idmap->InsertL(KLogId ,TLiwVariant(itemid)) ; |
|
144 |
||
145 |
//Insert the contenttype to inputlist |
|
146 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
147 |
||
148 |
||
149 |
// inputlist->AppendL(TLiwGenericParam(KLogId , TLiwVariant((TInt32)itemid))) ; |
|
150 |
inputlist->AppendL(TLiwGenericParam(KData , TLiwVariant(Idmap))) ; |
|
151 |
Idmap->DecRef(); |
|
152 |
CmdBuf = KCmdDelete ; |
|
153 |
LogInterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist) ; |
|
154 |
||
155 |
pos = 0 ; |
|
156 |
const TLiwGenericParam *Errprm = outputlist->FindFirst(pos , KErrCode ) ; |
|
157 |
||
158 |
if(!Errprm) |
|
159 |
{ |
|
160 |
_LIT(KLog , "Generic error param missing form the outputlist of delete" ) ; |
|
161 |
iLog->Log(KLog) ; |
|
162 |
User :: Leave(KErrArgument) ; |
|
163 |
} |
|
164 |
||
165 |
TInt retval = Errprm->Value().AsTInt32() ; |
|
166 |
||
167 |
if(retval != SErrNone ) |
|
168 |
{ |
|
169 |
_LIT(KLog , "Functionality test of delete call failed ") ; |
|
170 |
iLog->Log(KLog) ; |
|
171 |
User :: Leave(KErrArgument) ; |
|
172 |
} |
|
173 |
LogInterface->Close() ; |
|
174 |
delete ServiceHandler; |
|
175 |
||
176 |
||
177 |
a.ResetAndDestroy(); |
|
178 |
a.Close(); |
|
179 |
||
180 |
||
181 |
||
182 |
||
183 |
} |
|
184 |
||
185 |
||
186 |
//---------------------------------------------------------------------- |
|
187 |
// Negative testcase for delete api |
|
188 |
// |
|
189 |
//---------------------------------------------------------------------- |
|
190 |
||
191 |
void Ctprovidertest :: tdeleteNegativeL() |
|
192 |
{ |
|
193 |
||
194 |
||
195 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
196 |
// Input and output parameter list |
|
197 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
198 |
||
199 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
200 |
||
201 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
202 |
||
203 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
204 |
||
205 |
RCriteriaArray a; |
|
206 |
||
207 |
a.AppendL(crit); |
|
208 |
||
209 |
ServiceHandler->AttachL(a) ; |
|
210 |
||
211 |
TBufC16<10> contentType(KContentType) ; |
|
212 |
||
213 |
//Insert the contenttype to inputlist |
|
214 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
215 |
||
216 |
||
217 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
218 |
||
219 |
TInt pos = 0; |
|
220 |
||
221 |
||
222 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
223 |
||
224 |
if(!genericparm) |
|
225 |
{ |
|
226 |
_LIT(KLog , "Logging interface not found") ; |
|
227 |
iLog->Log(KLog) ; |
|
228 |
||
229 |
User :: Leave(KErrArgument) ; |
|
230 |
} |
|
231 |
||
232 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
233 |
||
234 |
||
235 |
||
236 |
||
237 |
||
238 |
||
239 |
TInt itemid = -1; |
|
240 |
TBuf<8> des; |
|
241 |
des.Num(itemid); |
|
242 |
||
243 |
||
244 |
inputlist->Reset() ; |
|
245 |
outputlist->Reset() ; |
|
246 |
||
247 |
CLiwDefaultMap *Idmap = CLiwDefaultMap :: NewL() ; |
|
248 |
Idmap->InsertL(KLogId ,TLiwVariant(des)) ; |
|
249 |
||
250 |
inputlist->AppendL(TLiwGenericParam(KData , TLiwVariant(Idmap))) ; |
|
251 |
Idmap->DecRef(); |
|
252 |
TBufC8<20>CmdBuf(KCmdDelete) ; |
|
253 |
//CmdBuf = KCmdDelete ; |
|
254 |
LogInterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist) ; |
|
255 |
||
256 |
pos = 0 ; |
|
257 |
const TLiwGenericParam *Errprm = outputlist->FindFirst(pos , KErrCode ) ; |
|
258 |
||
259 |
if(!Errprm) |
|
260 |
{ |
|
261 |
_LIT(KLog , "Generic error param missing form the outputlist of delete" ) ; |
|
262 |
iLog->Log(KLog) ; |
|
263 |
User :: Leave(KErrArgument) ; |
|
264 |
} |
|
265 |
||
266 |
TInt retval = Errprm->Value().AsTInt32() ; |
|
267 |
||
268 |
if(retval != SErrNone ) |
|
269 |
{ |
|
270 |
LogInterface->Close() ; |
|
271 |
delete ServiceHandler; |
|
272 |
||
273 |
||
274 |
a.ResetAndDestroy(); |
|
275 |
a.Close(); |
|
276 |
||
277 |
||
278 |
||
279 |
_LIT(KLog , "Functionality test of delete call failed ") ; |
|
280 |
iLog->Log(KLog) ; |
|
281 |
User :: Leave(KErrArgument) ; |
|
282 |
} |
|
283 |
||
284 |
LogInterface->Close() ; |
|
285 |
delete ServiceHandler; |
|
286 |
||
287 |
||
288 |
a.ResetAndDestroy(); |
|
289 |
a.Close(); |
|
290 |
||
291 |
||
292 |
} |
|
293 |
||
294 |
||
295 |
//----------------------------------------------------------------------------- |
|
296 |
// Functionality test for delete async call |
|
297 |
//----------------------------------------------------------------------------- |
|
298 |
void Ctprovidertest :: tdeleteTestasyncL(TInt aExpected) |
|
299 |
{ |
|
300 |
if(aExpected != KErrNone) |
|
301 |
{ |
|
302 |
_LIT(KLog , "Negative test case for delete api") ; |
|
303 |
iLog->Log(KLog) ; |
|
304 |
tdeleteNegativeasyncL(); |
|
305 |
||
306 |
} |
|
307 |
||
308 |
else |
|
309 |
{ |
|
310 |
_LIT(KLog , "Functional test for the delete async api") ; |
|
311 |
iLog->Log(KLog) ; |
|
312 |
tdeleteFunctionalAsyncL() ; |
|
313 |
} |
|
314 |
} |
|
315 |
||
316 |
//---------------------------------------------------------------------- |
|
317 |
// positive test case for delete async |
|
318 |
// |
|
319 |
//---------------------------------------------------------------------- |
|
320 |
||
321 |
||
322 |
void Ctprovidertest :: tdeleteFunctionalAsyncL(void) |
|
323 |
{ |
|
324 |
||
325 |
NotifyCB Callback ; |
|
326 |
||
327 |
_LIT(KOwnEventSubject, "RandomLogEvent"); |
|
328 |
_LIT(KOwnEventRemoteParty, "OwnContact"); |
|
329 |
||
330 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
331 |
// Input and output parameter list |
|
332 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
333 |
||
334 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
335 |
||
336 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
337 |
||
338 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
339 |
||
340 |
RCriteriaArray a; |
|
341 |
||
342 |
a.AppendL(crit); |
|
343 |
||
344 |
ServiceHandler->AttachL(a) ; |
|
345 |
||
346 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
347 |
||
348 |
TInt pos = 0; |
|
349 |
||
350 |
||
351 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
352 |
||
353 |
if(!genericparm) |
|
354 |
{ |
|
355 |
_LIT(KLog , "Logging interface not found") ; |
|
356 |
iLog->Log(KLog) ; |
|
357 |
||
358 |
User :: Leave(KErrArgument) ; |
|
359 |
} |
|
360 |
||
361 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
362 |
||
363 |
//Add an event and then delete this added event ; |
|
364 |
||
365 |
CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ; |
|
366 |
||
367 |
EventDetails->InsertL(KEventTypeKey ,TLiwVariant((TInt32)KLogShortMessageEvent)) ; |
|
368 |
||
369 |
||
370 |
/** |
|
371 |
* First append content type |
|
372 |
*/ |
|
373 |
||
374 |
TBufC16<10> contentType(KContentType) ; |
|
375 |
||
376 |
//Insert the contenttype to inputlist |
|
377 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
378 |
||
379 |
||
380 |
inputlist->AppendL(TLiwGenericParam(KEventDetails , TLiwVariant(EventDetails))) ; |
|
381 |
||
382 |
EventDetails->DecRef(); |
|
383 |
TBufC8<20>CmdBuf(KCmdAdd) ; |
|
384 |
||
385 |
LogInterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist) ; |
|
386 |
||
387 |
//Now get the id to deleted |
|
388 |
||
389 |
pos = 0 ; |
|
390 |
||
391 |
const TLiwGenericParam *outparm1 = outputlist->FindFirst(pos , KResponse) ; |
|
392 |
||
393 |
if(!outparm1) |
|
394 |
{ |
|
395 |
_LIT8(KLog , "Log id of the delete item not found") ; |
|
396 |
iLog->Log(KLog) ; |
|
397 |
User :: Leave(KErrArgument) ; |
|
398 |
} |
|
399 |
||
400 |
//Now delete the added item |
|
401 |
||
402 |
TBufC<20> itemid = (outparm1->Value()).AsDes(); |
|
403 |
// TInt itemid = (outparm1->Value()).AsTInt32() ; |
|
404 |
||
405 |
/*if(itemid < 0 ) |
|
406 |
{ |
|
407 |
_LIT(KLog , "Invalid item id ") ; |
|
408 |
iLog->Log(KLog) ; |
|
409 |
User :: Leave(KErrArgument) ; |
|
410 |
}*/ |
|
411 |
||
412 |
inputlist->Reset() ; outputlist->Reset() ; |
|
413 |
CLiwDefaultMap *Idmap = CLiwDefaultMap :: NewL() ; |
|
414 |
Idmap->InsertL(KLogId ,TLiwVariant(itemid)) ; |
|
415 |
||
416 |
//Insert the contenttype to inputlist |
|
417 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
418 |
||
419 |
||
420 |
inputlist->AppendL(TLiwGenericParam(KData , TLiwVariant(Idmap))) ; |
|
421 |
Idmap->DecRef(); |
|
422 |
CmdBuf = KCmdDelete ; |
|
423 |
LogInterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist ,KLiwOptASyncronous, &Callback) ; |
|
424 |
||
425 |
pos = 0 ; |
|
426 |
const TLiwGenericParam *Errprm = outputlist->FindFirst(pos , KErrCode ) ; |
|
427 |
||
428 |
if(!Errprm) |
|
429 |
{ |
|
430 |
_LIT(KLog , "Generic error param missing form the outputlist of delete" ) ; |
|
431 |
iLog->Log(KLog) ; |
|
432 |
User :: Leave(KErrArgument) ; |
|
433 |
} |
|
434 |
||
435 |
TInt retval = Errprm->Value().AsTInt32() ; |
|
436 |
||
437 |
if(retval != SErrNone ) |
|
438 |
{ |
|
439 |
_LIT(KLog , "Functionality test of delete call failed ") ; |
|
440 |
iLog->Log(KLog) ; |
|
441 |
User :: Leave(KErrArgument) ; |
|
442 |
} |
|
443 |
||
444 |
Callback.Start() ; |
|
445 |
||
446 |
if(Callback.Status() != KErrNone) |
|
447 |
{ |
|
448 |
_LIT(KLog , "Async status error ") ; |
|
449 |
iLog->Log(KLog) ; |
|
450 |
User :: Leave (Callback.Status()) ; |
|
451 |
} |
|
452 |
LogInterface->Close() ; |
|
453 |
delete ServiceHandler; |
|
454 |
||
455 |
||
456 |
a.ResetAndDestroy(); |
|
457 |
a.Close(); |
|
458 |
||
459 |
||
460 |
} |
|
461 |
||
462 |
//---------------------------------------------------------------------- |
|
463 |
// negative test case for delete async |
|
464 |
// |
|
465 |
//---------------------------------------------------------------------- |
|
466 |
||
467 |
||
468 |
||
469 |
void Ctprovidertest :: tdeleteNegativeasyncL(void) |
|
470 |
{ |
|
471 |
||
472 |
NotifyCB Callback ; |
|
473 |
||
474 |
||
475 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
476 |
// Input and output parameter list |
|
477 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
478 |
||
479 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
480 |
||
481 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
482 |
||
483 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
484 |
||
485 |
RCriteriaArray a; |
|
486 |
||
487 |
a.AppendL(crit); |
|
488 |
||
489 |
ServiceHandler->AttachL(a) ; |
|
490 |
||
491 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
492 |
||
493 |
TInt pos = 0; |
|
494 |
||
495 |
||
496 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
497 |
||
498 |
if(!genericparm) |
|
499 |
{ |
|
500 |
_LIT(KLog , "Logging interface not found") ; |
|
501 |
iLog->Log(KLog) ; |
|
502 |
||
503 |
User :: Leave(KErrArgument) ; |
|
504 |
} |
|
505 |
||
506 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
507 |
||
508 |
||
509 |
||
510 |
||
511 |
TInt itemid = -1; |
|
512 |
TBuf<8> des; |
|
513 |
des.Num(itemid); |
|
514 |
||
515 |
inputlist->Reset() ; |
|
516 |
outputlist->Reset() ; |
|
517 |
||
518 |
CLiwDefaultMap *Idmap = CLiwDefaultMap :: NewL() ; |
|
519 |
Idmap->InsertL(KLogId ,TLiwVariant(des)) ; |
|
520 |
||
521 |
TBufC16<10> contentType(KContentType) ; |
|
522 |
||
523 |
//Insert the contenttype to inputlist |
|
524 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
525 |
||
526 |
inputlist->AppendL(TLiwGenericParam(KData , TLiwVariant(Idmap))) ; |
|
527 |
TBufC8<20>CmdBuf(KCmdDelete) ; |
|
528 |
Idmap->DecRef(); |
|
529 |
//CmdBuf = KCmdDelete ; |
|
530 |
LogInterface->ExecuteCmdL(CmdBuf , *inputlist , *outputlist ,KLiwOptASyncronous , &Callback) ; |
|
531 |
||
532 |
pos = 0 ; |
|
533 |
const TLiwGenericParam *Errprm = outputlist->FindFirst(pos , KErrCode ) ; |
|
534 |
||
535 |
if(!Errprm) |
|
536 |
{ |
|
537 |
_LIT(KLog , "Generic error param missing form the outputlist of delete" ) ; |
|
538 |
iLog->Log(KLog) ; |
|
539 |
User :: Leave(KErrArgument) ; |
|
540 |
} |
|
541 |
||
542 |
TInt retval = Errprm->Value().AsTInt32() ; |
|
543 |
||
544 |
if(retval != SErrNone ) |
|
545 |
{ |
|
546 |
_LIT(KLog , "Functionality test of delete call failed ") ; |
|
547 |
iLog->Log(KLog) ; |
|
548 |
User :: Leave(KErrArgument) ; |
|
549 |
} |
|
550 |
||
551 |
Callback.Start() ; |
|
552 |
||
553 |
if(Callback.Status() != KErrNone) |
|
554 |
{ |
|
555 |
_LIT(KLog , "Async status error ") ; |
|
556 |
iLog->Log(KLog) ; |
|
557 |
User :: Leave (Callback.Status()) ; |
|
558 |
} |
|
559 |
LogInterface->Close() ; |
|
560 |
delete ServiceHandler; |
|
561 |
||
562 |
||
563 |
a.ResetAndDestroy(); |
|
564 |
a.Close(); |
|
565 |
||
566 |
||
567 |
} |
|
568 |
||
569 |
/** |
|
570 |
* Delete testcase for deleting all events |
|
571 |
*/ |
|
572 |
||
573 |
void Ctprovidertest :: tdeleteAllEventsL(TInt aSync) |
|
574 |
{ |
|
575 |
if(aSync) |
|
576 |
{ |
|
577 |
tdeleteAllEventsAsyncL() ; |
|
578 |
} |
|
579 |
else |
|
580 |
{ |
|
581 |
tdeleteAllEventsSyncL() ; |
|
582 |
} |
|
583 |
} |
|
584 |
||
585 |
||
586 |
/** |
|
587 |
* Synchronously delete all events |
|
588 |
*/ |
|
589 |
||
590 |
void Ctprovidertest :: tdeleteAllEventsSyncL() |
|
591 |
{ |
|
592 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
593 |
// Input and output parameter list |
|
594 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
595 |
||
596 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
597 |
||
598 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
599 |
||
600 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
601 |
||
602 |
RCriteriaArray a; |
|
603 |
||
604 |
a.AppendL(crit); |
|
605 |
||
606 |
ServiceHandler->AttachL(a) ; |
|
607 |
||
608 |
||
609 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
610 |
||
611 |
TInt pos = 0; |
|
612 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
613 |
||
614 |
if(!genericparm) |
|
615 |
{ |
|
616 |
_LIT(KLog , "Logging interface not found") ; |
|
617 |
iLog->Log(KLog) ; |
|
618 |
||
619 |
User :: Leave(KErrArgument) ; |
|
620 |
} |
|
621 |
||
622 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
623 |
||
624 |
||
625 |
||
626 |
// set the identity information |
|
627 |
TBufC8<20>CmdBufSet(KCmdGetList) ; |
|
628 |
||
629 |
outputlist->Reset() ; |
|
630 |
||
631 |
inputlist->Reset() ; |
|
632 |
||
633 |
CLiwDefaultMap *EventFilter = CLiwDefaultMap :: NewL() ; |
|
634 |
||
635 |
//if(aDetails->GetEventId()!=0) |
|
636 |
||
637 |
EventFilter->InsertL(KAllEvents , TLiwVariant(TRUE)) ; |
|
638 |
||
639 |
||
640 |
TBufC16<10> contentType(KContentType) ; |
|
641 |
||
642 |
//Insert the contenttype to inputlist |
|
643 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
644 |
inputlist->AppendL(TLiwGenericParam(KFilter , TLiwVariant(EventFilter))) ; |
|
645 |
EventFilter->DecRef() ; |
|
646 |
||
647 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); |
|
648 |
||
649 |
||
650 |
||
651 |
/** |
|
652 |
* Extract the error param, and check the status of the call |
|
653 |
*/ |
|
654 |
TInt index = 0 ; |
|
655 |
||
656 |
const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
657 |
||
658 |
if(!ErrCode ) |
|
659 |
{ |
|
660 |
_LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
661 |
iLog->Log(KLog) ; |
|
662 |
User :: Leave(KErrArgument) ; |
|
663 |
} |
|
664 |
||
665 |
TInt retval = ErrCode->Value().AsTInt32() ; |
|
666 |
||
667 |
if(retval != SErrNone ) |
|
668 |
{ |
|
669 |
_LIT(KLog , "Functionality test of add call failed ") ; |
|
670 |
iLog->Log(KLog) ; |
|
671 |
User :: Leave(KErrArgument) ; |
|
672 |
} |
|
673 |
||
674 |
||
675 |
||
676 |
pos = 0 ; |
|
677 |
||
678 |
const TLiwGenericParam *LogIterParam = outputlist->FindFirst(pos , KLogIter) ; |
|
679 |
||
680 |
||
681 |
||
682 |
CLiwIterable *LogIter = (LogIterParam->Value()).AsIterable() ; |
|
683 |
||
684 |
if(!LogIter) |
|
685 |
{ |
|
686 |
_LIT(KLog , "LogIterator not found \n") ; |
|
687 |
iLog->Log(KLog) ; |
|
688 |
User :: Leave (KErrGeneral) ; |
|
689 |
} |
|
690 |
TLiwVariant Events ; |
|
691 |
TLiwVariant EventDetails ; |
|
692 |
||
693 |
||
694 |
||
695 |
CmdBufSet = KCmdDelete ; |
|
696 |
||
697 |
while(LogIter->NextL(EventDetails)) |
|
698 |
{ |
|
699 |
const CLiwMap *eventDetails = EventDetails.AsMap() ; |
|
700 |
||
701 |
if(eventDetails->FindL(KLogId , Events) == KErrNotFound) |
|
702 |
{ |
|
703 |
_LIT(KLog , "Item_id not found") ; |
|
704 |
iLog->Log(KLog) ; |
|
705 |
User :: Leave(KErrArgument) ; |
|
706 |
} |
|
707 |
||
708 |
||
709 |
||
710 |
TInt32 eventid = Events.AsTInt32() ; |
|
711 |
||
712 |
inputlist->Reset() ; |
|
713 |
||
714 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(KContentType))) ; |
|
715 |
inputlist->AppendL(TLiwGenericParam(KLogId , TLiwVariant(eventid))) ; |
|
716 |
||
717 |
||
718 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ) ; |
|
719 |
||
720 |
(const_cast<CLiwMap *>(eventDetails))->DecRef() ; |
|
721 |
} |
|
722 |
||
723 |
EventDetails.Reset() ; |
|
724 |
Events.Reset() ; |
|
725 |
||
726 |
CmdBufSet = KCmdGetList ; |
|
727 |
||
728 |
||
729 |
inputlist->Reset() ; |
|
730 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(KContentType))) ; |
|
731 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); |
|
732 |
||
733 |
||
734 |
index = 0 ; |
|
735 |
ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
736 |
||
737 |
if(!ErrCode ) |
|
738 |
{ |
|
739 |
_LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
740 |
iLog->Log(KLog) ; |
|
741 |
User :: Leave(KErrArgument) ; |
|
742 |
} |
|
743 |
||
744 |
retval = ErrCode->Value().AsTInt32() ; |
|
745 |
||
746 |
if(retval != SErrNone ) |
|
747 |
{ |
|
748 |
_LIT(KLog , "Functionality test of add call failed ") ; |
|
749 |
iLog->Log(KLog) ; |
|
750 |
User :: Leave(KErrArgument) ; |
|
751 |
} |
|
752 |
||
753 |
||
754 |
LogIterParam = outputlist->FindFirst(pos , KLogIter) ; |
|
755 |
LogIter = (LogIterParam->Value()).AsIterable() ; |
|
756 |
||
757 |
TInt totalCnt ; |
|
758 |
||
759 |
for( totalCnt = 0 ; LogIter->NextL(EventDetails) ; ++totalCnt) |
|
760 |
{ |
|
761 |
const CLiwMap *eventDetails = EventDetails.AsMap() ; |
|
762 |
||
763 |
if(eventDetails->FindL(KLogId , Events) == KErrNotFound) |
|
764 |
{ |
|
765 |
_LIT(KLog , "Item_id not found") ; |
|
766 |
iLog->Log(KLog) ; |
|
767 |
User :: Leave(KErrArgument) ; |
|
768 |
} |
|
769 |
||
770 |
||
771 |
||
772 |
TInt32 eventid = Events.AsTInt32() ; |
|
773 |
||
774 |
inputlist->Reset() ; |
|
775 |
||
776 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(KContentType))) ; |
|
777 |
inputlist->AppendL(TLiwGenericParam(KLogId , TLiwVariant(eventid))) ; |
|
778 |
||
779 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ) ; |
|
780 |
||
781 |
(const_cast<CLiwMap *>(eventDetails))->DecRef() ; |
|
782 |
} |
|
783 |
||
784 |
Events.Reset() ; |
|
785 |
EventDetails.Reset() ; |
|
786 |
LogInterface->Close() ; |
|
787 |
delete ServiceHandler ; |
|
788 |
a.ResetAndDestroy() ; |
|
789 |
a.Close() ; |
|
790 |
||
791 |
if(totalCnt > 0) |
|
792 |
{ |
|
793 |
_LIT(KLog , "Total count is still greater than zero") ; |
|
794 |
iLog->Log(KLog) ; |
|
795 |
User :: Leave (KErrGeneral) ; |
|
796 |
} |
|
797 |
||
798 |
} |
|
799 |
||
800 |
/** |
|
801 |
* Synchronously delete all events |
|
802 |
*/ |
|
803 |
||
804 |
void Ctprovidertest :: tdeleteAllEventsAsyncL(void) |
|
805 |
{ |
|
806 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
807 |
// Input and output parameter list |
|
808 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
809 |
||
810 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
811 |
||
812 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
813 |
||
814 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
815 |
||
816 |
RCriteriaArray a; |
|
817 |
||
818 |
a.AppendL(crit); |
|
819 |
||
820 |
ServiceHandler->AttachL(a) ; |
|
821 |
||
822 |
||
823 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
824 |
||
825 |
TInt pos = 0; |
|
826 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
827 |
||
828 |
if(!genericparm) |
|
829 |
{ |
|
830 |
_LIT(KLog , "Logging interface not found") ; |
|
831 |
iLog->Log(KLog) ; |
|
832 |
||
833 |
User :: Leave(KErrArgument) ; |
|
834 |
} |
|
835 |
||
836 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
837 |
||
838 |
||
839 |
||
840 |
// set the identity information |
|
841 |
TBufC8<20>CmdBufSet(KCmdGetList) ; |
|
842 |
||
843 |
outputlist->Reset() ; |
|
844 |
||
845 |
inputlist->Reset() ; |
|
846 |
||
847 |
CLiwDefaultMap *EventFilter = CLiwDefaultMap :: NewL() ; |
|
848 |
||
849 |
//if(aDetails->GetEventId()!=0) |
|
850 |
||
851 |
EventFilter->InsertL(KAllEvents , TLiwVariant(TRUE)) ; |
|
852 |
||
853 |
||
854 |
TBufC16<10> contentType(KContentType) ; |
|
855 |
||
856 |
//Insert the contenttype to inputlist |
|
857 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
858 |
inputlist->AppendL(TLiwGenericParam(KFilter , TLiwVariant(EventFilter))) ; |
|
859 |
EventFilter->DecRef() ; |
|
860 |
||
861 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); |
|
862 |
||
863 |
||
864 |
||
865 |
/** |
|
866 |
* Extract the error param, and check the status of the call |
|
867 |
*/ |
|
868 |
TInt index = 0 ; |
|
869 |
||
870 |
const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
871 |
||
872 |
if(!ErrCode ) |
|
873 |
{ |
|
874 |
_LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
875 |
iLog->Log(KLog) ; |
|
876 |
User :: Leave(KErrArgument) ; |
|
877 |
} |
|
878 |
||
879 |
TInt retval = ErrCode->Value().AsTInt32() ; |
|
880 |
||
881 |
if(retval != SErrNone ) |
|
882 |
{ |
|
883 |
_LIT(KLog , "Functionality test of add call failed ") ; |
|
884 |
iLog->Log(KLog) ; |
|
885 |
User :: Leave(KErrArgument) ; |
|
886 |
} |
|
887 |
||
888 |
||
889 |
||
890 |
pos = 0 ; |
|
891 |
||
892 |
const TLiwGenericParam *LogIterParam = outputlist->FindFirst(pos , KLogIter) ; |
|
893 |
||
894 |
||
895 |
||
896 |
CLiwIterable *LogIter = (LogIterParam->Value()).AsIterable() ; |
|
897 |
TLiwVariant Events ; |
|
898 |
TLiwVariant EventDetails ; |
|
899 |
||
900 |
||
901 |
||
902 |
CmdBufSet = KCmdDelete ; |
|
903 |
NotifyCB Callback ; |
|
904 |
||
905 |
while(LogIter->NextL(EventDetails)) |
|
906 |
{ |
|
907 |
const CLiwMap *eventDetails = EventDetails.AsMap() ; |
|
908 |
||
909 |
if(eventDetails->FindL(KLogId , Events) == KErrNotFound) |
|
910 |
{ |
|
911 |
_LIT(KLog , "Item_id not found") ; |
|
912 |
iLog->Log(KLog) ; |
|
913 |
User :: Leave(KErrArgument) ; |
|
914 |
} |
|
915 |
||
916 |
||
917 |
||
918 |
TUid eventid = Events.AsTUid() ; |
|
919 |
||
920 |
inputlist->Reset() ; |
|
921 |
||
922 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(KContentType))) ; |
|
923 |
inputlist->AppendL(TLiwGenericParam(KLogId , TLiwVariant(eventid))) ; |
|
924 |
||
925 |
||
926 |
||
927 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist , 0 , &Callback ) ; |
|
928 |
Callback.Start() ; |
|
929 |
||
930 |
(const_cast<CLiwMap *>(eventDetails))->DecRef() ; |
|
931 |
||
932 |
if(Callback.Status() != KErrNone) |
|
933 |
{ |
|
934 |
_LIT(KLog , "Callback status not KErrNone") ; |
|
935 |
iLog->Log(KLog) ; |
|
936 |
User :: Leave(KErrArgument) ; |
|
937 |
} |
|
938 |
||
939 |
} |
|
940 |
||
941 |
Events.Reset() ; |
|
942 |
EventDetails.Reset() ; |
|
943 |
||
944 |
LogIterParam = outputlist->FindFirst(pos , KLogIter) ; |
|
945 |
LogIter = (LogIterParam->Value()).AsIterable() ; |
|
946 |
||
947 |
TInt totalCnt ; |
|
948 |
||
949 |
for( totalCnt = 0 ; LogIter->NextL(EventDetails) ; ++totalCnt) |
|
950 |
{ |
|
951 |
const CLiwMap *eventDetails = EventDetails.AsMap() ; |
|
952 |
||
953 |
if(eventDetails->FindL(KLogId , Events) == KErrNotFound) |
|
954 |
{ |
|
955 |
_LIT(KLog , "Item_id not found") ; |
|
956 |
iLog->Log(KLog) ; |
|
957 |
User :: Leave(KErrArgument) ; |
|
958 |
} |
|
959 |
||
960 |
||
961 |
||
962 |
TInt32 eventid = Events.AsTInt32() ; |
|
963 |
||
964 |
inputlist->Reset() ; |
|
965 |
||
966 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(KContentType))) ; |
|
967 |
inputlist->AppendL(TLiwGenericParam(KLogId , TLiwVariant(eventid))) ; |
|
968 |
||
969 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ) ; |
|
970 |
||
971 |
(const_cast<CLiwMap *>(eventDetails))->DecRef() ; |
|
972 |
} |
|
973 |
||
974 |
Events.Reset() ; |
|
975 |
EventDetails.Reset() ; |
|
976 |
LogInterface->Close() ; |
|
977 |
delete ServiceHandler ; |
|
978 |
a.ResetAndDestroy() ; |
|
979 |
a.Close() ; |
|
980 |
||
981 |
if(totalCnt > 0) |
|
982 |
{ |
|
983 |
_LIT(KLog , "Total count is still greater than zero") ; |
|
984 |
iLog->Log(KLog) ; |
|
985 |
User :: Leave (KErrGeneral) ; |
|
986 |
} |
|
987 |
||
988 |
||
989 |
||
990 |
||
991 |
||
992 |
LogInterface->Close() ; |
|
993 |
delete ServiceHandler ; |
|
994 |
a.ResetAndDestroy() ; |
|
995 |
a.Close() ; |
|
996 |
||
997 |
} |
|
998 |