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 "tfilterdetails.h" |
|
28 |
#include "tprovidercallback.h" |
|
29 |
#include "serviceerrno.h" |
|
30 |
||
31 |
#define Sync 0 |
|
32 |
#define ASync 1 |
|
33 |
||
34 |
void Ctprovidertest :: tgetlistgenericPosL(CFilterDetails *aDetails,TInt aParsedValue) |
|
35 |
||
36 |
{ |
|
37 |
if(aParsedValue==Sync) |
|
38 |
{ |
|
39 |
_LIT(KLog , "sync test case for getlist api") ; |
|
40 |
iLog->Log(KLog) ; |
|
41 |
tgetlistsyncgenericPosL(aDetails); |
|
42 |
} |
|
43 |
||
44 |
else |
|
45 |
{ |
|
46 |
_LIT(KLog , "async test case for getlist api") ; |
|
47 |
iLog->Log(KLog) ; |
|
48 |
tgetlistasyncgenericPosL(aDetails); |
|
49 |
} |
|
50 |
||
51 |
} |
|
52 |
||
53 |
//----------------------------------------------------------------------------- |
|
54 |
// Functionality test for getlist sync call |
|
55 |
//----------------------------------------------------------------------------- |
|
56 |
||
57 |
void Ctprovidertest :: tgetlistsyncgenericPosL(CFilterDetails *aDetails) |
|
58 |
{ |
|
59 |
||
60 |
||
61 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
62 |
// Input and output parameter list |
|
63 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
64 |
||
65 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
66 |
||
67 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
68 |
||
69 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
70 |
||
71 |
RCriteriaArray a; |
|
72 |
||
73 |
a.AppendL(crit); |
|
74 |
||
75 |
ServiceHandler->AttachL(a) ; |
|
76 |
||
77 |
||
78 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
79 |
||
80 |
TInt pos = 0; |
|
81 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
82 |
||
83 |
if(!genericparm) |
|
84 |
{ |
|
85 |
_LIT(KLog , "Logging interface not found") ; |
|
86 |
iLog->Log(KLog) ; |
|
87 |
||
88 |
User :: Leave(KErrArgument) ; |
|
89 |
} |
|
90 |
||
91 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
92 |
||
93 |
||
94 |
||
95 |
// set the identity information |
|
96 |
TBufC8<20>CmdBufSet(KCmdGetList) ; |
|
97 |
||
98 |
outputlist->Reset() ; |
|
99 |
||
100 |
inputlist->Reset() ; |
|
101 |
||
102 |
CLiwDefaultMap *EventFilter = CLiwDefaultMap :: NewL() ; |
|
103 |
||
104 |
//if(aDetails->GetEventId()!=0) |
|
105 |
||
106 |
||
107 |
TBuf <10> EmptyDes ; |
|
108 |
||
109 |
if(aDetails->GetEventId() != EmptyDes) |
|
110 |
{ |
|
111 |
EventFilter->InsertL(KLogId , TLiwVariant(aDetails->GetEventId()) ); |
|
112 |
} |
|
113 |
||
114 |
if(aDetails->GetEventType() > -1) |
|
115 |
{ |
|
116 |
EventFilter->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) ); |
|
117 |
} |
|
118 |
||
119 |
if(aDetails->GetContactType()!=0) |
|
120 |
{ |
|
121 |
EventFilter->InsertL(KContactidKey , TLiwVariant(aDetails->GetContactType()) ); |
|
122 |
} |
|
123 |
||
124 |
if((long)aDetails->GetTimer() !=0 ) |
|
125 |
{ |
|
126 |
EventFilter->InsertL(KEndTimeKey , TLiwVariant((long)aDetails->GetTimer())) ; |
|
127 |
} |
|
128 |
||
129 |
if(aDetails->GetNumberType() != EmptyDes) |
|
130 |
{ |
|
131 |
EventFilter->InsertL(KPhoneNumberKey , TLiwVariant(aDetails->GetNumberType())) ; |
|
132 |
} |
|
133 |
||
134 |
if(aDetails->GetRemotePartyType() != EmptyDes) |
|
135 |
{ |
|
136 |
EventFilter->InsertL(KRemotePartyKey , TLiwVariant(aDetails->GetRemotePartyType())) ; |
|
137 |
} |
|
138 |
||
139 |
if(aDetails->GetDirectionType() >= 0 ) |
|
140 |
{ |
|
141 |
EventFilter->InsertL(KDirectionKey , TLiwVariant(aDetails->GetDirectionType())) ; |
|
142 |
} |
|
143 |
||
144 |
if(aDetails->GetStatusType() >= 0) |
|
145 |
{ |
|
146 |
EventFilter->InsertL(KDeliveryStatusKey , TLiwVariant(aDetails->GetStatusType())) ; |
|
147 |
} |
|
148 |
||
149 |
if(aDetails->GetRecentList() != 0) |
|
150 |
{ |
|
151 |
EventFilter->InsertL(KRecentListKey , TLiwVariant(aDetails->GetRecentList())) ; |
|
152 |
} |
|
153 |
||
154 |
||
155 |
if(aDetails->GetAllEvent() == 1) |
|
156 |
{ |
|
157 |
EventFilter->InsertL(KAllEvents , TLiwVariant(aDetails->GetAllEvent())) ; |
|
158 |
} |
|
159 |
||
160 |
TBufC16<10> contentType(KContentType) ; |
|
161 |
||
162 |
//Insert the contenttype to inputlist |
|
163 |
inputlist->AppendL(TLiwGenericParam(KNullDesC8 , TLiwVariant(contentType))) ; |
|
164 |
||
165 |
||
166 |
inputlist->AppendL(TLiwGenericParam(KPosItem , TLiwVariant(EventFilter))) ; |
|
167 |
EventFilter->DecRef() ; |
|
168 |
||
169 |
||
170 |
||
171 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); |
|
172 |
||
173 |
||
174 |
||
175 |
/** |
|
176 |
* Extract the error param, and check the status of the call |
|
177 |
*/ |
|
178 |
TInt index = 0 ; |
|
179 |
||
180 |
const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
181 |
||
182 |
if(!ErrCode ) |
|
183 |
{ |
|
184 |
_LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
185 |
iLog->Log(KLog) ; |
|
186 |
User :: Leave(KErrArgument) ; |
|
187 |
} |
|
188 |
||
189 |
TInt retval = ErrCode->Value().AsTInt32() ; |
|
190 |
||
191 |
if(retval != SErrNone ) |
|
192 |
{ |
|
193 |
LogInterface->Close() ; |
|
194 |
delete ServiceHandler; |
|
195 |
||
196 |
||
197 |
a.ResetAndDestroy(); |
|
198 |
a.Close(); |
|
199 |
_LIT(KLog , "Functionality test of add call failed ") ; |
|
200 |
iLog->Log(KLog) ; |
|
201 |
User :: Leave(KErrArgument) ; |
|
202 |
} |
|
203 |
||
204 |
||
205 |
||
206 |
pos = 0 ; |
|
207 |
||
208 |
const TLiwGenericParam *LogIterParam = outputlist->FindFirst(pos , KResponse) ; |
|
209 |
||
210 |
||
211 |
||
212 |
// CLiwIterable *LogIter = (LogIterParam->Value()).AsIterable() ; |
|
213 |
||
214 |
//LogIter->Reset(); |
|
215 |
||
216 |
// TLiwVariant var ; |
|
217 |
tlogresultsL(LogIterParam , EGetList) ; |
|
218 |
||
219 |
||
220 |
||
221 |
LogInterface->Close() ; |
|
222 |
delete ServiceHandler ; |
|
223 |
a.ResetAndDestroy() ; |
|
224 |
a.Close() ; |
|
225 |
||
226 |
||
227 |
} |
|
228 |
||
229 |
//----------------------------------------------------------------------------- |
|
230 |
// Functionality test for getlist async call |
|
231 |
//----------------------------------------------------------------------------- |
|
232 |
||
233 |
||
234 |
||
235 |
||
236 |
void Ctprovidertest :: tgetlistasyncgenericPosL(CFilterDetails *aDetails) |
|
237 |
{ |
|
238 |
||
239 |
||
240 |
NotifyCB cb ; |
|
241 |
||
242 |
||
243 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
244 |
// Input and output parameter list |
|
245 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
246 |
||
247 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
248 |
||
249 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
250 |
||
251 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
252 |
||
253 |
RCriteriaArray a; |
|
254 |
||
255 |
a.AppendL(crit); |
|
256 |
||
257 |
ServiceHandler->AttachL(a) ; |
|
258 |
||
259 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
260 |
||
261 |
TInt pos = 0; |
|
262 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
263 |
||
264 |
if(!genericparm) |
|
265 |
{ |
|
266 |
_LIT(KLog , "Logging interface not found") ; |
|
267 |
iLog->Log(KLog) ; |
|
268 |
||
269 |
User :: Leave(KErrArgument) ; |
|
270 |
} |
|
271 |
||
272 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
273 |
||
274 |
||
275 |
// set the identity information |
|
276 |
TBufC8<20>CmdBufSet(KCmdGetList) ; |
|
277 |
||
278 |
outputlist->Reset() ; |
|
279 |
||
280 |
inputlist->Reset() ; |
|
281 |
||
282 |
CLiwDefaultMap *EventFilter = CLiwDefaultMap :: NewL() ; |
|
283 |
||
284 |
||
285 |
TBuf<6> EmptyDes ; |
|
286 |
if(aDetails->GetEventId() != EmptyDes) |
|
287 |
{ |
|
288 |
EventFilter->InsertL(KLogId , TLiwVariant(aDetails->GetEventId()) ); |
|
289 |
} |
|
290 |
||
291 |
if(aDetails->GetEventType() > -1) |
|
292 |
{ |
|
293 |
EventFilter->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) ); |
|
294 |
} |
|
295 |
||
296 |
if(aDetails->GetContactType() != 0) |
|
297 |
{ |
|
298 |
EventFilter->InsertL(KContactidKey , TLiwVariant(aDetails->GetContactType()) ); |
|
299 |
} |
|
300 |
||
301 |
if((long)aDetails->GetTimer() != 0) |
|
302 |
{ |
|
303 |
EventFilter->InsertL(KEndTimeKey , TLiwVariant((long)aDetails->GetTimer())) ; |
|
304 |
} |
|
305 |
||
306 |
if(aDetails->GetNumberType() != EmptyDes) |
|
307 |
{ |
|
308 |
EventFilter->InsertL(KPhoneNumberKey , TLiwVariant(aDetails->GetNumberType())) ; |
|
309 |
} |
|
310 |
||
311 |
if(aDetails->GetRemotePartyType() != EmptyDes) |
|
312 |
{ |
|
313 |
EventFilter->InsertL(KRemotePartyKey , TLiwVariant(aDetails->GetRemotePartyType())) ; |
|
314 |
} |
|
315 |
||
316 |
if(aDetails->GetDirectionType() >= 0) |
|
317 |
{ |
|
318 |
EventFilter->InsertL(KDirectionKey , TLiwVariant(aDetails->GetDirectionType())) ; |
|
319 |
} |
|
320 |
||
321 |
if(aDetails->GetStatusType() >= 0) |
|
322 |
{ |
|
323 |
EventFilter->InsertL(KDeliveryStatusKey , TLiwVariant(aDetails->GetStatusType())) ; |
|
324 |
} |
|
325 |
||
326 |
if(aDetails->GetRecentList() != 0) |
|
327 |
{ |
|
328 |
EventFilter->InsertL(KRecentListKey , TLiwVariant(aDetails->GetRecentList())) ; |
|
329 |
} |
|
330 |
||
331 |
||
332 |
if(aDetails->GetAllEvent() == 1) |
|
333 |
{ |
|
334 |
EventFilter->InsertL(KAllEvents , TLiwVariant(aDetails->GetAllEvent())) ; |
|
335 |
} |
|
336 |
||
337 |
||
338 |
TBufC16<10> contentType(KContentType) ; |
|
339 |
||
340 |
//Insert the contenttype to inputlist |
|
341 |
inputlist->AppendL(TLiwGenericParam(KNullDesC8 , TLiwVariant(contentType))) ; |
|
342 |
||
343 |
||
344 |
inputlist->AppendL(TLiwGenericParam(KPosItem , TLiwVariant(EventFilter))) ; |
|
345 |
EventFilter->DecRef() ; |
|
346 |
||
347 |
||
348 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ,KLiwOptASyncronous , &cb); |
|
349 |
||
350 |
||
351 |
||
352 |
||
353 |
/** |
|
354 |
* Extract the error param, and check the status of the call |
|
355 |
*/ |
|
356 |
||
357 |
TInt index = 0 ; |
|
358 |
||
359 |
const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
360 |
||
361 |
if(!ErrCode ) |
|
362 |
{ |
|
363 |
_LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
364 |
iLog->Log(KLog) ; |
|
365 |
User :: Leave(KErrArgument) ; |
|
366 |
} |
|
367 |
||
368 |
TInt retval = ErrCode->Value().AsTInt32() ; |
|
369 |
||
370 |
if(retval != SErrNone ) |
|
371 |
{ |
|
372 |
_LIT(KLog , "Functionality test of add call failed ") ; |
|
373 |
iLog->Log(KLog) ; |
|
374 |
User :: Leave(KErrArgument) ; |
|
375 |
||
376 |
} |
|
377 |
||
378 |
cb.Start(); |
|
379 |
||
380 |
if(cb.Status() != KErrNone) |
|
381 |
{ |
|
382 |
_LIT(KLog , "Async status error ") ; |
|
383 |
iLog->Log(KLog) ; |
|
384 |
User :: Leave (cb.Status()) ; |
|
385 |
} |
|
386 |
||
387 |
||
388 |
/* pos = 0 ; |
|
389 |
||
390 |
const TLiwGenericParam *LogIterParam = outputlist->FindFirst(pos , KLogIter) ; |
|
391 |
||
392 |
CLiwIterable *LogIter = (LogIterParam->Value()).AsIterable() ; |
|
393 |
||
394 |
TLiwVariant var ; |
|
395 |
LogIter->NextL(var) ;*/ |
|
396 |
LogInterface->Close() ; |
|
397 |
delete ServiceHandler; |
|
398 |
// delete crit; |
|
399 |
||
400 |
a.ResetAndDestroy(); |
|
401 |
a.Close(); |
|
402 |
||
403 |
||
404 |
} |