|
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> |
|
19 #include <Stiftestinterface.h> |
|
20 |
|
21 #include <LiwServiceHandler.h> |
|
22 #include <LiwCommon.h> |
|
23 |
|
24 #include "tconstants.h" |
|
25 |
|
26 #include "tprovidertest.h" |
|
27 #include "teventdetails.h" |
|
28 #include "tprovidercallback.h" |
|
29 #include "serviceerrno.h" |
|
30 |
|
31 #define Sync 0 |
|
32 #define ASync 1 |
|
33 |
|
34 _LIT(KNull,"NULL"); |
|
35 |
|
36 void Ctprovidertest :: taddgenericL(CEventDetails *aDetails,TInt aParsedValue) |
|
37 |
|
38 { |
|
39 if(aParsedValue==Sync) |
|
40 { |
|
41 _LIT(KLog , "sync test case for add api") ; |
|
42 iLog->Log(KLog) ; |
|
43 taddsyncgenericL(aDetails); |
|
44 } |
|
45 |
|
46 else |
|
47 { |
|
48 _LIT(KLog , "async test case for add api") ; |
|
49 iLog->Log(KLog) ; |
|
50 taddasyncgenericL(aDetails); |
|
51 } |
|
52 |
|
53 } |
|
54 |
|
55 //----------------------------------------------------------------------------- |
|
56 // Functionality test for add sync call |
|
57 //----------------------------------------------------------------------------- |
|
58 |
|
59 //const TBuf<KLogMaxSubjectLength> NullBuf ; |
|
60 |
|
61 |
|
62 void Ctprovidertest :: taddsyncgenericL(CEventDetails *aDetails) |
|
63 { |
|
64 |
|
65 |
|
66 CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
67 // Input and output parameter list |
|
68 CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
69 |
|
70 CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
71 |
|
72 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
73 |
|
74 |
|
75 |
|
76 crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
77 |
|
78 RCriteriaArray a; |
|
79 |
|
80 |
|
81 a.AppendL(crit); |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 ServiceHandler->AttachL(a) ; |
|
87 |
|
88 |
|
89 ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 TInt pos = 0; |
|
95 |
|
96 |
|
97 const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
98 |
|
99 if(!genericparm) |
|
100 { |
|
101 _LIT(KLog , "Logging interface not found") ; |
|
102 iLog->Log(KLog) ; |
|
103 |
|
104 User :: Leave(KErrArgument) ; |
|
105 } |
|
106 |
|
107 MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
108 |
|
109 |
|
110 //First set the identity information |
|
111 TBufC8<20>CmdBufSet(KCmdAdd) ; |
|
112 |
|
113 outputlist->Reset() ; |
|
114 |
|
115 inputlist->Reset() ; |
|
116 |
|
117 CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ; |
|
118 |
|
119 |
|
120 |
|
121 EventDetails->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) ); |
|
122 |
|
123 |
|
124 if(aDetails->GetDurationType()!=0) |
|
125 { |
|
126 EventDetails->InsertL(KEventDurationKey ,TLiwVariant(aDetails->GetDurationType()) ); |
|
127 } |
|
128 |
|
129 if(aDetails->GetContactType() !=0 ) |
|
130 { |
|
131 EventDetails->InsertL(KContactidKey , TLiwVariant(aDetails->GetContactType()) ); |
|
132 } |
|
133 |
|
134 if(aDetails->GetLinkType()!=0) |
|
135 { |
|
136 EventDetails->InsertL(KLinkKey , TLiwVariant(aDetails->GetLinkType()) ); |
|
137 } |
|
138 |
|
139 if(aDetails->GetTimer() !=0 ) |
|
140 { |
|
141 EventDetails->InsertL(KEventTimeKey , TLiwVariant(aDetails->GetTimer())) ; |
|
142 } |
|
143 |
|
144 |
|
145 TBuf<10> EmptyDes ; |
|
146 |
|
147 |
|
148 //if(ptr.Compare(KNull) ) |
|
149 if(aDetails->GetSubjectType() != EmptyDes) |
|
150 { |
|
151 EventDetails->InsertL(KSubjectKey , TLiwVariant(aDetails->GetSubjectType())) ; |
|
152 } |
|
153 |
|
154 |
|
155 |
|
156 //if(aDetails->GetSubjectType().Compare(_LIT(NULL)) ) |
|
157 |
|
158 if(aDetails->GetNumberType()!= EmptyDes) |
|
159 { |
|
160 EventDetails->InsertL(KPhoneNumberKey , TLiwVariant(aDetails->GetNumberType())) ; |
|
161 } |
|
162 |
|
163 if(aDetails->GetRemotePartyType() != EmptyDes) |
|
164 { |
|
165 EventDetails->InsertL(KRemotePartyKey , TLiwVariant(aDetails->GetRemotePartyType())) ; |
|
166 } |
|
167 |
|
168 if(aDetails->GetDirectionType() >= 0) |
|
169 { |
|
170 EventDetails->InsertL(KDirectionKey , TLiwVariant(aDetails->GetDirectionType())) ; |
|
171 } |
|
172 |
|
173 if(aDetails->GetDescriptionType() != EmptyDes) |
|
174 { |
|
175 EventDetails->InsertL(KDescriptionKey , TLiwVariant(aDetails->GetDescriptionType())) ; |
|
176 } |
|
177 |
|
178 if(aDetails->GetStatusType() >= 0 ) |
|
179 { |
|
180 EventDetails->InsertL(KDeliveryStatusKey , TLiwVariant(aDetails->GetStatusType())) ; |
|
181 } |
|
182 _LIT8(KData,"1234"); |
|
183 if(aDetails->GetDataType() != EmptyDes) |
|
184 { |
|
185 EventDetails->InsertL(KEventDataKey , TLiwVariant(KData)) ; |
|
186 } |
|
187 |
|
188 TBuf16 <10> Contents(KContentType) ; |
|
189 |
|
190 inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(Contents))) ; |
|
191 |
|
192 inputlist->AppendL(TLiwGenericParam(KEventDetails , TLiwVariant(EventDetails))) ; |
|
193 EventDetails->DecRef(); |
|
194 |
|
195 LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); |
|
196 |
|
197 |
|
198 |
|
199 /** |
|
200 * Extract the error param, and check the status of the call |
|
201 */ |
|
202 TInt index = 0 ; |
|
203 |
|
204 const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
205 |
|
206 if(!ErrCode ) |
|
207 { |
|
208 _LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
209 iLog->Log(KLog) ; |
|
210 User :: Leave(KErrArgument) ; |
|
211 } |
|
212 |
|
213 TInt retval = ErrCode->Value().AsTInt32() ; |
|
214 |
|
215 if(retval != SErrNone ) |
|
216 { |
|
217 |
|
218 LogInterface->Close() ; |
|
219 delete ServiceHandler; |
|
220 a.ResetAndDestroy(); |
|
221 a.Close(); |
|
222 |
|
223 |
|
224 |
|
225 _LIT(KLog , "Functionality test of add call failed ") ; |
|
226 iLog->Log(KLog) ; |
|
227 User :: Leave(KErrArgument) ; |
|
228 } |
|
229 |
|
230 /* if((ErrCode->Value().AsTInt32()) != KErrNone ) |
|
231 { |
|
232 User :: Leave(ErrCode->Value().AsTInt32()) ; |
|
233 } */ |
|
234 |
|
235 |
|
236 /** Log the event details to a file |
|
237 */ |
|
238 |
|
239 index = 0 ; |
|
240 const TLiwGenericParam *genparm = outputlist->FindFirst(index , KResponse) ; |
|
241 |
|
242 if(!genparm) |
|
243 { |
|
244 _LIT8(KLog , "Log id of the added item not found") ; |
|
245 iLog->Log(KLog) ; |
|
246 User :: Leave(KErrArgument) ; |
|
247 } |
|
248 |
|
249 tlogresultsL(genparm , EAddEvent) ; |
|
250 |
|
251 LogInterface->Close() ; |
|
252 delete ServiceHandler; |
|
253 // delete crit; |
|
254 |
|
255 a.ResetAndDestroy(); |
|
256 a.Close(); |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 } |
|
263 |
|
264 //----------------------------------------------------------------------------- |
|
265 // Functionality test for add async call |
|
266 //----------------------------------------------------------------------------- |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 void Ctprovidertest :: taddasyncgenericL(CEventDetails *aDetails) |
|
272 { |
|
273 |
|
274 |
|
275 TBuf<6> EmptyDes ; |
|
276 NotifyCB cb ; |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
282 |
|
283 |
|
284 |
|
285 // Input and output parameter list |
|
286 CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
287 |
|
288 CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
289 |
|
290 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
291 |
|
292 |
|
293 |
|
294 crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
295 |
|
296 RCriteriaArray a; |
|
297 |
|
298 |
|
299 a.AppendL(crit); |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 ServiceHandler->AttachL(a) ; |
|
305 |
|
306 |
|
307 ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 TInt pos = 0; |
|
313 |
|
314 |
|
315 const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
316 |
|
317 if(!genericparm) |
|
318 { |
|
319 _LIT(KLog , "Logging interface not found") ; |
|
320 iLog->Log(KLog) ; |
|
321 |
|
322 User :: Leave(KErrArgument) ; |
|
323 } |
|
324 |
|
325 MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 //First set the identity information |
|
332 TBufC8<20>CmdBufSet(KCmdAdd) ; |
|
333 |
|
334 outputlist->Reset() ; |
|
335 |
|
336 inputlist->Reset() ; |
|
337 |
|
338 CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ; |
|
339 |
|
340 EventDetails->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) ); |
|
341 |
|
342 if(aDetails->GetDurationType()!=0) |
|
343 { |
|
344 EventDetails->InsertL(KEventDurationKey ,TLiwVariant(aDetails->GetDurationType()) ); |
|
345 } |
|
346 |
|
347 if(aDetails->GetContactType()!=0) |
|
348 { |
|
349 EventDetails->InsertL(KContactidKey , TLiwVariant(aDetails->GetContactType()) ); |
|
350 } |
|
351 |
|
352 if(aDetails->GetLinkType()!=0) |
|
353 { |
|
354 EventDetails->InsertL(KLinkKey , TLiwVariant(aDetails->GetLinkType()) ); |
|
355 } |
|
356 |
|
357 if(aDetails->GetTimer()!=0) |
|
358 { |
|
359 EventDetails->InsertL(KEventTimeKey , TLiwVariant(aDetails->GetTimer())) ; |
|
360 } |
|
361 |
|
362 if(aDetails->GetSubjectType() != EmptyDes) |
|
363 { |
|
364 EventDetails->InsertL(KSubjectKey , TLiwVariant(aDetails->GetSubjectType())) ; |
|
365 } |
|
366 |
|
367 if(aDetails->GetNumberType()!= EmptyDes) |
|
368 { |
|
369 EventDetails->InsertL(KPhoneNumberKey , TLiwVariant(aDetails->GetNumberType())) ; |
|
370 } |
|
371 |
|
372 if(aDetails->GetRemotePartyType() != EmptyDes) |
|
373 { |
|
374 EventDetails->InsertL(KRemotePartyKey , TLiwVariant(aDetails->GetRemotePartyType())) ; |
|
375 } |
|
376 |
|
377 if(aDetails->GetDirectionType() >= 0 ) |
|
378 { |
|
379 EventDetails->InsertL(KDirectionKey , TLiwVariant(aDetails->GetDirectionType())) ; |
|
380 } |
|
381 |
|
382 if(aDetails->GetDescriptionType() != EmptyDes) |
|
383 { |
|
384 EventDetails->InsertL(KDescriptionKey , TLiwVariant(aDetails->GetDescriptionType())) ; |
|
385 } |
|
386 |
|
387 if(aDetails->GetStatusType() >= 0) |
|
388 { |
|
389 EventDetails->InsertL(KDeliveryStatusKey , TLiwVariant(aDetails->GetStatusType())) ; |
|
390 } |
|
391 |
|
392 _LIT8(KData,"1234"); |
|
393 if(aDetails->GetDataType() != EmptyDes) |
|
394 { |
|
395 EventDetails->InsertL(KEventDataKey , TLiwVariant(KData)) ; |
|
396 } |
|
397 |
|
398 //EventDetails->InsertL(KEventDataKey , TLiwVariant(true)) ; |
|
399 TBufC16<10> contentType(KContentType) ; |
|
400 // contentType.SetLengthL(3) ; |
|
401 |
|
402 //Insert the contenttype to inputlist |
|
403 inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
404 |
|
405 |
|
406 inputlist->AppendL(TLiwGenericParam(KEventDetails , TLiwVariant(EventDetails))) ; |
|
407 EventDetails->DecRef(); |
|
408 |
|
409 |
|
410 |
|
411 LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ,KLiwOptASyncronous, &cb); |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 /** |
|
417 * Extract the error param, and check the status of the call |
|
418 */ |
|
419 TInt index = 0 ; |
|
420 |
|
421 const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
422 |
|
423 |
|
424 |
|
425 if(!ErrCode ) |
|
426 { |
|
427 _LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
428 iLog->Log(KLog) ; |
|
429 User :: Leave(KErrArgument) ; |
|
430 } |
|
431 |
|
432 TInt retval = ErrCode->Value().AsTInt32() ; |
|
433 |
|
434 if(retval != SErrNone ) |
|
435 { |
|
436 LogInterface->Close() ; |
|
437 delete ServiceHandler; |
|
438 a.ResetAndDestroy(); |
|
439 a.Close(); |
|
440 |
|
441 |
|
442 _LIT(KLog , "Functionality test of delete call failed ") ; |
|
443 iLog->Log(KLog) ; |
|
444 User :: Leave(KErrArgument) ; |
|
445 } |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 /* if((ErrCode->Value().AsTInt32()) != KErrNone ) |
|
452 { |
|
453 User :: Leave(ErrCode->Value().AsTInt32()) ; |
|
454 } */ |
|
455 |
|
456 |
|
457 |
|
458 cb.Start(); |
|
459 |
|
460 if(cb.Status() != KErrNone) |
|
461 { |
|
462 _LIT(KLog , "Async status error ") ; |
|
463 iLog->Log(KLog) ; |
|
464 User :: Leave (cb.Status()) ; |
|
465 } |
|
466 |
|
467 |
|
468 // delete crit; |
|
469 LogInterface->Close() ; |
|
470 delete ServiceHandler; |
|
471 |
|
472 a.ResetAndDestroy(); |
|
473 a.Close(); |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 } |
|
481 |
|
482 |