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 :: tgetlistgenericL(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 |
tgetlistsyncgenericL(aDetails); |
|
42 |
} |
|
43 |
||
44 |
else |
|
45 |
{ |
|
46 |
_LIT(KLog , "async test case for getlist api") ; |
|
47 |
iLog->Log(KLog) ; |
|
48 |
tgetlistasyncgenericL(aDetails); |
|
49 |
} |
|
50 |
||
51 |
} |
|
52 |
||
53 |
//----------------------------------------------------------------------------- |
|
54 |
// Functionality test for getlist sync call |
|
55 |
//----------------------------------------------------------------------------- |
|
56 |
||
57 |
void Ctprovidertest :: tgetlistsyncgenericL(CFilterDetails *aDetails) |
|
58 |
{ |
|
59 |
//Test case |
|
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 |
TBuf<6> EmptyDes ; |
|
105 |
//if(aDetails->GetEventId()!=0) |
|
106 |
if(aDetails->GetEventId() != EmptyDes) |
|
107 |
{ |
|
108 |
EventFilter->InsertL(KLogId , TLiwVariant(aDetails->GetEventId()) ); |
|
109 |
} |
|
110 |
||
111 |
if(aDetails->GetEventType()>-1) |
|
112 |
{ |
|
113 |
EventFilter->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) ); |
|
114 |
} |
|
115 |
if(aDetails->GetContactType()!=0) |
|
116 |
{ |
|
117 |
EventFilter->InsertL(KContactidKey , TLiwVariant(aDetails->GetContactType()) ); |
|
118 |
} |
|
119 |
||
120 |
||
121 |
if((long)aDetails->GetTimer()!=0) |
|
122 |
{ |
|
123 |
EventFilter->InsertL(KEndTimeKey , TLiwVariant((long)aDetails->GetTimer())) ; |
|
124 |
} |
|
125 |
||
126 |
||
127 |
||
128 |
if(aDetails->GetNumberType() != EmptyDes) |
|
129 |
{ |
|
130 |
EventFilter->InsertL(KPhoneNumberKey , TLiwVariant(aDetails->GetNumberType())) ; |
|
131 |
} |
|
132 |
||
133 |
if(aDetails->GetRemotePartyType() != EmptyDes) |
|
134 |
{ |
|
135 |
EventFilter->InsertL(KRemotePartyKey , TLiwVariant(aDetails->GetRemotePartyType())) ; |
|
136 |
} |
|
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 |
||
161 |
||
162 |
TBufC16<10> contentType(KContentType) ; |
|
163 |
||
164 |
//Insert the contenttype to inputlist |
|
165 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
166 |
||
167 |
||
168 |
inputlist->AppendL(TLiwGenericParam(KFilter , TLiwVariant(EventFilter))) ; |
|
169 |
EventFilter->DecRef() ; |
|
170 |
||
171 |
||
172 |
||
173 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ); |
|
174 |
||
175 |
||
176 |
||
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 |
||
194 |
LogInterface->Close() ; |
|
195 |
delete ServiceHandler; |
|
196 |
||
197 |
||
198 |
a.ResetAndDestroy(); |
|
199 |
a.Close(); |
|
200 |
||
201 |
_LIT(KLog , "Functionality test of add call failed ") ; |
|
202 |
iLog->Log(KLog) ; |
|
203 |
User :: Leave(KErrArgument) ; |
|
204 |
} |
|
205 |
||
206 |
||
207 |
||
208 |
pos = 0 ; |
|
209 |
||
210 |
const TLiwGenericParam *LogIterParam = outputlist->FindFirst(pos , KResponse) ; |
|
211 |
||
212 |
||
213 |
||
214 |
// CLiwIterable *LogIter = (LogIterParam->Value()).AsIterable() ; |
|
215 |
||
216 |
//LogIter->Reset(); |
|
217 |
||
218 |
// TLiwVariant var ; |
|
219 |
tlogresultsL(LogIterParam , EGetList) ; |
|
220 |
||
221 |
||
222 |
||
223 |
LogInterface->Close() ; |
|
224 |
delete ServiceHandler ; |
|
225 |
a.ResetAndDestroy() ; |
|
226 |
a.Close() ; |
|
227 |
||
228 |
||
229 |
} |
|
230 |
||
231 |
//----------------------------------------------------------------------------- |
|
232 |
// Functionality test for getlist async call |
|
233 |
//----------------------------------------------------------------------------- |
|
234 |
||
235 |
||
236 |
||
237 |
||
238 |
void Ctprovidertest :: tgetlistasyncgenericL(CFilterDetails *aDetails) |
|
239 |
{ |
|
240 |
||
241 |
||
242 |
NotifyCB cb ; |
|
243 |
||
244 |
||
245 |
CLiwServiceHandler* ServiceHandler = CLiwServiceHandler::NewL(); |
|
246 |
// Input and output parameter list |
|
247 |
CLiwGenericParamList* inputlist = &(ServiceHandler->InParamListL()); |
|
248 |
||
249 |
CLiwGenericParamList* outputlist = &(ServiceHandler->OutParamListL()); |
|
250 |
||
251 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KDsInterfaceName , KLoggingContents) ; |
|
252 |
||
253 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
254 |
||
255 |
RCriteriaArray a; |
|
256 |
||
257 |
a.AppendL(crit); |
|
258 |
||
259 |
ServiceHandler->AttachL(a) ; |
|
260 |
||
261 |
ServiceHandler->ExecuteServiceCmdL(*crit, *inputlist, *outputlist); |
|
262 |
||
263 |
TInt pos = 0; |
|
264 |
const TLiwGenericParam *genericparm = outputlist->FindFirst(pos , KDsInterfaceName); |
|
265 |
||
266 |
if(!genericparm) |
|
267 |
{ |
|
268 |
_LIT(KLog , "Logging interface not found") ; |
|
269 |
iLog->Log(KLog) ; |
|
270 |
||
271 |
User :: Leave(KErrArgument) ; |
|
272 |
} |
|
273 |
||
274 |
MLiwInterface* LogInterface = (genericparm->Value()).AsInterface(); |
|
275 |
||
276 |
||
277 |
// set the identity information |
|
278 |
TBufC8<20>CmdBufSet(KCmdGetList) ; |
|
279 |
||
280 |
outputlist->Reset() ; |
|
281 |
||
282 |
inputlist->Reset() ; |
|
283 |
||
284 |
CLiwDefaultMap *EventFilter = CLiwDefaultMap :: NewL() ; |
|
285 |
||
286 |
||
287 |
TBuf <10> EmptyDes ; |
|
288 |
||
289 |
if(aDetails->GetEventId() != EmptyDes) |
|
290 |
{ |
|
291 |
EventFilter->InsertL(KLogId, TLiwVariant(aDetails->GetEventId()) ); |
|
292 |
} |
|
293 |
||
294 |
if(aDetails->GetEventType() > -1) |
|
295 |
{ |
|
296 |
EventFilter->InsertL(KEventTypeKey , TLiwVariant(aDetails->GetEventType()) ); |
|
297 |
} |
|
298 |
||
299 |
if(aDetails->GetContactType()!=0) |
|
300 |
{ |
|
301 |
EventFilter->InsertL(KContactidKey , TLiwVariant(aDetails->GetContactType()) ); |
|
302 |
} |
|
303 |
||
304 |
if((long)aDetails->GetTimer() !=0 ) |
|
305 |
{ |
|
306 |
EventFilter->InsertL(KEndTimeKey , TLiwVariant((long)aDetails->GetTimer())) ; |
|
307 |
} |
|
308 |
||
309 |
if(aDetails->GetNumberType() != EmptyDes) |
|
310 |
{ |
|
311 |
EventFilter->InsertL(KPhoneNumberKey , TLiwVariant(aDetails->GetNumberType())) ; |
|
312 |
} |
|
313 |
||
314 |
if(aDetails->GetRemotePartyType() != EmptyDes) |
|
315 |
{ |
|
316 |
EventFilter->InsertL(KRemotePartyKey , TLiwVariant(aDetails->GetRemotePartyType())) ; |
|
317 |
} |
|
318 |
||
319 |
if(aDetails->GetDirectionType() >= 0) |
|
320 |
{ |
|
321 |
EventFilter->InsertL(KDirectionKey , TLiwVariant(aDetails->GetDirectionType())) ; |
|
322 |
} |
|
323 |
||
324 |
if(aDetails->GetStatusType() >= 0) |
|
325 |
{ |
|
326 |
EventFilter->InsertL(KDeliveryStatusKey , TLiwVariant(aDetails->GetStatusType())) ; |
|
327 |
} |
|
328 |
if(aDetails->GetRecentList() != 0) |
|
329 |
{ |
|
330 |
EventFilter->InsertL(KRecentListKey , TLiwVariant(aDetails->GetRecentList())) ; |
|
331 |
} |
|
332 |
||
333 |
||
334 |
if(aDetails->GetAllEvent() == 1) |
|
335 |
{ |
|
336 |
EventFilter->InsertL(KAllEvents , TLiwVariant(aDetails->GetAllEvent())) ; |
|
337 |
} |
|
338 |
||
339 |
TBufC16<10> contentType(KContentType) ; |
|
340 |
||
341 |
//Insert the contenttype to inputlist |
|
342 |
inputlist->AppendL(TLiwGenericParam(KContentTypeKey , TLiwVariant(contentType))) ; |
|
343 |
||
344 |
||
345 |
inputlist->AppendL(TLiwGenericParam(KFilter , TLiwVariant(EventFilter))) ; |
|
346 |
EventFilter->DecRef() ; |
|
347 |
||
348 |
||
349 |
LogInterface->ExecuteCmdL(CmdBufSet , *inputlist , *outputlist ,KLiwOptASyncronous , &cb); |
|
350 |
||
351 |
||
352 |
||
353 |
||
354 |
/** |
|
355 |
* Extract the error param, and check the status of the call |
|
356 |
*/ |
|
357 |
||
358 |
TInt index = 0 ; |
|
359 |
||
360 |
const TLiwGenericParam *ErrCode = outputlist->FindFirst(index , KErrCode) ; |
|
361 |
||
362 |
if(!ErrCode ) |
|
363 |
{ |
|
364 |
_LIT(KLog , "Generic error param missing form the outputlist of add" ) ; |
|
365 |
iLog->Log(KLog) ; |
|
366 |
User :: Leave(KErrArgument) ; |
|
367 |
} |
|
368 |
||
369 |
TInt retval = ErrCode->Value().AsTInt32() ; |
|
370 |
||
371 |
if(retval != SErrNone ) |
|
372 |
{ |
|
373 |
_LIT(KLog , "Functionality test of add call failed ") ; |
|
374 |
iLog->Log(KLog) ; |
|
375 |
User :: Leave(KErrArgument) ; |
|
376 |
||
377 |
} |
|
378 |
||
379 |
cb.Start(); |
|
380 |
||
381 |
if(cb.Status() != KErrNone) |
|
382 |
{ |
|
383 |
_LIT(KLog , "Async status error ") ; |
|
384 |
iLog->Log(KLog) ; |
|
385 |
User :: Leave (cb.Status()) ; |
|
386 |
} |
|
387 |
||
388 |
||
389 |
/* pos = 0 ; |
|
390 |
||
391 |
const TLiwGenericParam *LogIterParam = outputlist->FindFirst(pos , KLogIter) ; |
|
392 |
||
393 |
CLiwIterable *LogIter = (LogIterParam->Value()).AsIterable() ; |
|
394 |
||
395 |
TLiwVariant var ; |
|
396 |
LogIter->NextL(var) ;*/ |
|
397 |
LogInterface->Close() ; |
|
398 |
delete ServiceHandler; |
|
399 |
// delete crit; |
|
400 |
||
401 |
a.ResetAndDestroy(); |
|
402 |
a.Close(); |
|
403 |
||
404 |
||
405 |
} |