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 |
#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 :: taddgenericPosL(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 |
taddsyncgenericPosL(aDetails); |
|
44 |
} |
|
45 |
||
46 |
else |
|
47 |
{ |
|
48 |
_LIT(KLog , "async test case for add api") ; |
|
49 |
iLog->Log(KLog) ; |
|
50 |
taddasyncgenericPosL(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 :: taddsyncgenericPosL(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 |
TBuf <6> EmptyDes ; |
|
124 |
||
125 |
if(aDetails->GetDurationType() != 0) |
|
126 |
{ |
|
127 |
EventDetails->InsertL(KEventDurationKey ,TLiwVariant(aDetails->GetDurationType()) ); |
|
128 |
} |
|
129 |
||
130 |
if(aDetails->GetContactType()!=0) |
|
131 |
{ |
|
132 |
EventDetails->InsertL(KContactidKey , TLiwVariant(aDetails->GetContactType()) ); |
|
133 |
} |
|
134 |
||
135 |
if(aDetails->GetLinkType()!=0) |
|
136 |
{ |
|
137 |
EventDetails->InsertL(KLinkKey , TLiwVariant(aDetails->GetLinkType()) ); |
|
138 |
} |
|
139 |
||
140 |
if(aDetails->GetTimer()!=0) |
|
141 |
{ |
|
142 |
EventDetails->InsertL(KEventTimeKey , TLiwVariant(aDetails->GetTimer())) ; |
|
143 |
} |
|
144 |
||
145 |
if(aDetails->GetSubjectType() != EmptyDes) |
|
146 |
{ |
|
147 |
EventDetails->InsertL(KSubjectKey , TLiwVariant(aDetails->GetSubjectType())) ; |
|
148 |
} |
|
149 |
||
150 |
if(aDetails->GetNumberType()!= EmptyDes) |
|
151 |
{ |
|
152 |
EventDetails->InsertL(KPhoneNumberKey , TLiwVariant(aDetails->GetNumberType())) ; |
|
153 |
} |
|
154 |
||
155 |
if(aDetails->GetRemotePartyType() != EmptyDes) |
|
156 |
{ |
|
157 |
EventDetails->InsertL(KRemotePartyKey , TLiwVariant(aDetails->GetRemotePartyType())) ; |
|
158 |
} |
|
159 |
||
160 |
if(aDetails->GetDirectionType() >= 0) |
|
161 |
{ |
|
162 |
EventDetails->InsertL(KDirectionKey , TLiwVariant(aDetails->GetDirectionType())) ; |
|
163 |
} |
|
164 |
||
165 |
if(aDetails->GetDescriptionType() != EmptyDes) |
|
166 |
{ |
|
167 |
EventDetails->InsertL(KDescriptionKey , TLiwVariant(aDetails->GetDescriptionType())) ; |
|
168 |
} |
|
169 |
||
170 |
if(aDetails->GetStatusType() >= 0) |
|
171 |
{ |
|
172 |
EventDetails->InsertL(KDeliveryStatusKey , TLiwVariant(aDetails->GetStatusType())) ; |
|
173 |
} |
|
174 |
||
175 |
||
176 |
TBuf16 <10> Contents(KContentType) ; |
|
177 |
||
178 |
inputlist->AppendL(TLiwGenericParam(KNullDesC8 , TLiwVariant(Contents))) ; |
|
179 |
||
180 |
inputlist->AppendL(TLiwGenericParam(KPosItem ,TLiwVariant(EventDetails))) ; |
|
181 |
EventDetails->DecRef(); |
|
182 |
||
183 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); |
|
184 |
||
185 |
||
186 |
||
187 |
/** |
|
188 |
* Extract the error param, and check the status of the call |
|
189 |
*/ |
|
190 |
TInt index = 0 ; |
|
191 |
||
192 |
const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
193 |
||
194 |
if(!ErrCode ) |
|
195 |
{ |
|
196 |
_LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
197 |
iLog->Log(KLog) ; |
|
198 |
User :: Leave(KErrArgument) ; |
|
199 |
} |
|
200 |
||
201 |
TInt retval = ErrCode->Value().AsTInt32() ; |
|
202 |
||
203 |
if(retval != SErrNone ) |
|
204 |
{ |
|
205 |
||
206 |
LogInterface->Close() ; |
|
207 |
delete ServiceHandler; |
|
208 |
a.ResetAndDestroy(); |
|
209 |
a.Close(); |
|
210 |
||
211 |
||
212 |
||
213 |
_LIT(KLog , "Functionality test of add call failed ") ; |
|
214 |
iLog->Log(KLog) ; |
|
215 |
User :: Leave(KErrArgument) ; |
|
216 |
} |
|
217 |
||
218 |
/* if((ErrCode->Value().AsTInt32()) != KErrNone ) |
|
219 |
{ |
|
220 |
User :: Leave(ErrCode->Value().AsTInt32()) ; |
|
221 |
} */ |
|
222 |
||
223 |
||
224 |
/** Log the event details to a file |
|
225 |
*/ |
|
226 |
||
227 |
index = 0 ; |
|
228 |
const TLiwGenericParam *genparm = outputlist->FindFirst(index , KResponse) ; |
|
229 |
||
230 |
if(!genparm) |
|
231 |
{ |
|
232 |
_LIT8(KLog , "Log id of the added item not found") ; |
|
233 |
iLog->Log(KLog) ; |
|
234 |
User :: Leave(KErrArgument) ; |
|
235 |
} |
|
236 |
||
237 |
tlogresultsL(genparm , EAddEvent) ; |
|
238 |
||
239 |
LogInterface->Close() ; |
|
240 |
delete ServiceHandler; |
|
241 |
// delete crit; |
|
242 |
||
243 |
a.ResetAndDestroy(); |
|
244 |
a.Close(); |
|
245 |
||
246 |
||
247 |
||
248 |
||
249 |
||
250 |
} |
|
251 |
||
252 |
//----------------------------------------------------------------------------- |
|
253 |
// Functionality test for add async call |
|
254 |
//----------------------------------------------------------------------------- |
|
255 |
||
256 |
||
257 |
||
258 |
||
259 |
void Ctprovidertest :: taddasyncgenericPosL(CEventDetails *aDetails) |
|
260 |
{ |
|
261 |
||
262 |
||
263 |
||
264 |
NotifyCB cb ; |
|
265 |
||
266 |
||
267 |
||
268 |
||
269 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
270 |
||
271 |
||
272 |
||
273 |
// Input and output parameter list |
|
274 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
275 |
||
276 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
277 |
||
278 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
279 |
||
280 |
||
281 |
||
282 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
283 |
||
284 |
RCriteriaArray a; |
|
285 |
||
286 |
||
287 |
a.AppendL(crit); |
|
288 |
||
289 |
||
290 |
||
291 |
||
292 |
ServiceHandler->AttachL(a) ; |
|
293 |
||
294 |
||
295 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
296 |
||
297 |
||
298 |
||
299 |
||
300 |
TInt pos = 0; |
|
301 |
||
302 |
||
303 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
304 |
||
305 |
if(!genericparm) |
|
306 |
{ |
|
307 |
_LIT(KLog , "Logging interface not found") ; |
|
308 |
iLog->Log(KLog) ; |
|
309 |
||
310 |
User :: Leave(KErrArgument) ; |
|
311 |
} |
|
312 |
||
313 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
314 |
||
315 |
||
316 |
||
317 |
||
318 |
||
319 |
//First set the identity information |
|
320 |
TBufC8<20>CmdBufSet(KCmdAdd) ; |
|
321 |
||
322 |
outputlist->Reset() ; |
|
323 |
||
324 |
inputlist->Reset() ; |
|
325 |
||
326 |
CLiwDefaultMap *EventDetails = CLiwDefaultMap :: NewL() ; |
|
327 |
||
328 |
EventDetails->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) ); |
|
329 |
||
330 |
if(aDetails->GetDurationType() != 0) |
|
331 |
{ |
|
332 |
EventDetails->InsertL(KEventDurationKey ,TLiwVariant(aDetails->GetDurationType()) ); |
|
333 |
} |
|
334 |
||
335 |
if(aDetails->GetContactType() != 0 ) |
|
336 |
{ |
|
337 |
EventDetails->InsertL(KContactidKey , TLiwVariant(aDetails->GetContactType()) ); |
|
338 |
} |
|
339 |
||
340 |
if(aDetails->GetLinkType() != 0) |
|
341 |
{ |
|
342 |
EventDetails->InsertL(KLinkKey , TLiwVariant(aDetails->GetLinkType()) ); |
|
343 |
} |
|
344 |
||
345 |
if(aDetails->GetTimer() != 0) |
|
346 |
{ |
|
347 |
EventDetails->InsertL(KEventTimeKey , TLiwVariant(aDetails->GetTimer())) ; |
|
348 |
} |
|
349 |
||
350 |
||
351 |
TBuf<6> EmptyDes ; |
|
352 |
if(aDetails->GetSubjectType() != EmptyDes) |
|
353 |
{ |
|
354 |
EventDetails->InsertL(KSubjectKey , TLiwVariant(aDetails->GetSubjectType())) ; |
|
355 |
} |
|
356 |
||
357 |
if(aDetails->GetNumberType() != EmptyDes) |
|
358 |
{ |
|
359 |
EventDetails->InsertL(KPhoneNumberKey , TLiwVariant(aDetails->GetNumberType())) ; |
|
360 |
} |
|
361 |
||
362 |
if(aDetails->GetRemotePartyType() != EmptyDes ) |
|
363 |
{ |
|
364 |
EventDetails->InsertL(KRemotePartyKey , TLiwVariant(aDetails->GetRemotePartyType())) ; |
|
365 |
} |
|
366 |
||
367 |
if(aDetails->GetDirectionType() >= 0 ) |
|
368 |
{ |
|
369 |
EventDetails->InsertL(KDirectionKey , TLiwVariant(aDetails->GetDirectionType())) ; |
|
370 |
} |
|
371 |
||
372 |
if(aDetails->GetDescriptionType() != EmptyDes) |
|
373 |
{ |
|
374 |
EventDetails->InsertL(KDescriptionKey , TLiwVariant(aDetails->GetDescriptionType())) ; |
|
375 |
} |
|
376 |
||
377 |
if(aDetails->GetStatusType() >=0 ) |
|
378 |
{ |
|
379 |
EventDetails->InsertL(KDeliveryStatusKey , TLiwVariant(aDetails->GetStatusType())) ; |
|
380 |
} |
|
381 |
||
382 |
||
383 |
||
384 |
//EventDetails->InsertL(KEventDataKey , TLiwVariant(true)) ; |
|
385 |
TBufC16<10> contentType(KContentType) ; |
|
386 |
||
387 |
//Insert the contenttype to inputlist |
|
388 |
inputlist->AppendL(TLiwGenericParam(KNullDesC8 , TLiwVariant(contentType))) ; |
|
389 |
||
390 |
||
391 |
inputlist->AppendL(TLiwGenericParam(KPosItem , TLiwVariant(EventDetails))) ; |
|
392 |
EventDetails->DecRef(); |
|
393 |
||
394 |
||
395 |
||
396 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ,KLiwOptASyncronous , &cb); |
|
397 |
||
398 |
||
399 |
||
400 |
||
401 |
/** |
|
402 |
* Extract the error param, and check the status of the call |
|
403 |
*/ |
|
404 |
TInt index = 0 ; |
|
405 |
||
406 |
const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
407 |
||
408 |
||
409 |
||
410 |
if(!ErrCode ) |
|
411 |
{ |
|
412 |
_LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
413 |
iLog->Log(KLog) ; |
|
414 |
User :: Leave(KErrArgument) ; |
|
415 |
} |
|
416 |
||
417 |
TInt retval = ErrCode->Value().AsTInt32() ; |
|
418 |
||
419 |
if(retval != SErrNone ) |
|
420 |
{ |
|
421 |
LogInterface->Close() ; |
|
422 |
delete ServiceHandler; |
|
423 |
a.ResetAndDestroy(); |
|
424 |
a.Close(); |
|
425 |
||
426 |
_LIT(KLog , "Functionality test of delete call failed ") ; |
|
427 |
iLog->Log(KLog) ; |
|
428 |
User :: Leave(KErrArgument) ; |
|
429 |
} |
|
430 |
||
431 |
||
432 |
||
433 |
||
434 |
||
435 |
/* if((ErrCode->Value().AsTInt32()) != KErrNone ) |
|
436 |
{ |
|
437 |
User :: Leave(ErrCode->Value().AsTInt32()) ; |
|
438 |
} */ |
|
439 |
||
440 |
||
441 |
||
442 |
cb.Start(); |
|
443 |
||
444 |
if(cb.Status() != KErrNone) |
|
445 |
{ |
|
446 |
_LIT(KLog , "Async status error ") ; |
|
447 |
iLog->Log(KLog) ; |
|
448 |
User :: Leave (cb.Status()) ; |
|
449 |
} |
|
450 |
||
451 |
||
452 |
// delete crit; |
|
453 |
LogInterface->Close() ; |
|
454 |
delete ServiceHandler; |
|
455 |
||
456 |
a.ResetAndDestroy(); |
|
457 |
a.Close(); |
|
458 |
||
459 |
||
460 |
||
461 |
||
462 |
||
463 |
||
464 |
} |