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) 2002 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: tsysinfoprovidernetworktestsblocks |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
22 |
#include <e32svr.h> |
|
23 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
24 |
#include <StifTestInterface.h> |
19 | 25 |
#include <f32file.h> |
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include <liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#include<liwservicehandler.h> |
19 | 28 |
#include "../../../inc/serviceerrno.h" |
29 |
||
30 |
#include "tsysinfoprovidernetworktests.h" |
|
31 |
#include "tsignalstrengthasyn.h" |
|
32 |
#include "thomenetworkasync.h" |
|
33 |
#include "tcurrentnetworknotify.h" |
|
34 |
#include "tsingnalstrengthnotify.h" |
|
35 |
#include "sysinfoaiwparams.hrh" |
|
36 |
#include"entitykeys.h" |
|
37 |
||
38 |
using namespace LIW ; |
|
39 |
using namespace SysInfo; |
|
40 |
||
41 |
using namespace sysinfoaiwparams; |
|
42 |
||
43 |
||
44 |
// ----------------------------------------------------------------------------- |
|
45 |
// CTSysInfoProviderNetworkTests::Delete |
|
46 |
// Delete here all resources allocated and opened from test methods. |
|
47 |
// Called from destructor. |
|
48 |
// ----------------------------------------------------------------------------- |
|
49 |
// |
|
50 |
void CTSysInfoProviderNetworkTests::Delete() |
|
51 |
{ |
|
52 |
||
53 |
} |
|
54 |
||
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// CTSysInfoProviderNetworkTests::RunMethodL |
|
57 |
// Run specified method. Contains also table of test mothods and their names. |
|
58 |
// ----------------------------------------------------------------------------- |
|
59 |
// |
|
60 |
TInt CTSysInfoProviderNetworkTests::RunMethodL( |
|
61 |
CStifItemParser& aItem ) |
|
62 |
{ |
|
63 |
||
64 |
static TStifFunctionInfo const KFunctions[] = |
|
65 |
{ |
|
66 |
// Copy this line for every implemented function. |
|
67 |
// First string is the function name used in TestScripter script file. |
|
68 |
// Second is the actual implementation member function. |
|
69 |
||
70 |
ENTRY( "SignalStrengthAsyc-M", CTSysInfoProviderNetworkTests::SignalStrengthAsyncL), |
|
71 |
ENTRY( "SignalStrengthNoti-M", CTSysInfoProviderNetworkTests::SignalStrengthNotiL), |
|
72 |
ENTRY( "RegisteredOnHomeNw-M", CTSysInfoProviderNetworkTests::RegisteredOnHomeNwL), |
|
73 |
ENTRY( "NetworkModeGSM-M", CTSysInfoProviderNetworkTests::GetNwModeGSML), |
|
74 |
ENTRY( "HomeNetworkAsyc-M", CTSysInfoProviderNetworkTests::HomeNwAsyncL), |
|
75 |
ENTRY( "CurrentNwNoti-M", CTSysInfoProviderNetworkTests::CurrentNwNotiL), |
|
76 |
}; |
|
77 |
||
78 |
const TInt count = sizeof( KFunctions ) / |
|
79 |
sizeof( TStifFunctionInfo ); |
|
80 |
||
81 |
return RunInternalL( KFunctions, count, aItem ); |
|
82 |
} |
|
83 |
||
84 |
TInt CTSysInfoProviderNetworkTests::RegisteredOnHomeNwL(CStifItemParser& /*aItem*/) |
|
85 |
{ |
|
86 |
||
87 |
TInt Err(PASS); |
|
88 |
_LIT( KExample, "RegisteredOnHomeNwL:" ); |
|
89 |
iLog->Log( KExample ); |
|
90 |
||
91 |
__UHEAP_MARK; |
|
92 |
||
93 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
94 |
CleanupStack::PushL(iServiceHandler); |
|
95 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
96 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
97 |
||
98 |
TInt err = KErrNone; |
|
99 |
||
100 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
101 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
102 |
||
103 |
RCriteriaArray a; |
|
104 |
a.AppendL(crit); |
|
105 |
||
106 |
iServiceHandler->AttachL(a); |
|
107 |
||
108 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
109 |
||
110 |
delete crit; |
|
111 |
a.Reset(); |
|
112 |
||
113 |
TInt pos = 0; |
|
114 |
MLiwInterface* interface = NULL; |
|
115 |
outparam->FindFirst( pos, KIDataSource ); |
|
116 |
if(pos != KErrNotFound) |
|
117 |
{ |
|
118 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
119 |
} |
|
120 |
||
121 |
outparam->Reset(); |
|
122 |
inparam->Reset(); |
|
123 |
||
124 |
if(interface) |
|
125 |
{ |
|
126 |
TLiwGenericParam entity; |
|
127 |
TLiwVariant entityname; |
|
128 |
TLiwGenericParam key; |
|
129 |
TLiwVariant keyname; |
|
130 |
||
131 |
entityname.Set(KNetwork); |
|
132 |
entity.SetNameAndValueL(KEntity,entityname); |
|
133 |
||
134 |
keyname.Set(KRegistrationStatus); |
|
135 |
key.SetNameAndValueL(KKey,keyname); |
|
136 |
||
137 |
inparam->AppendL(entity); |
|
138 |
||
139 |
inparam->AppendL(key); |
|
140 |
||
141 |
entity.Reset(); |
|
142 |
entityname.Reset(); |
|
143 |
key.Reset(); |
|
144 |
keyname.Reset(); |
|
145 |
||
146 |
TRAP(err, interface->ExecuteCmdL(KGetInfo,*inparam,*outparam)); |
|
147 |
||
148 |
||
149 |
pos = 0 ; |
|
150 |
||
151 |
outparam->FindFirst( pos,KErrorCode ); |
|
152 |
if(pos != KErrNotFound) |
|
153 |
{ |
|
154 |
if( (*outparam)[pos].Value().AsTInt32() != KErrNone ) |
|
155 |
err = (TInt)((*outparam)[pos].Value().AsTInt32()); |
|
156 |
} |
|
157 |
||
158 |
if(err == SErrNone) |
|
159 |
{ |
|
160 |
pos = 0 ; |
|
161 |
const TLiwGenericParam* output = outparam->FindFirst( pos,KReturnValue ); |
|
162 |
||
163 |
if(output) |
|
164 |
{ |
|
165 |
const CLiwMap* Map = output->Value().AsMap(); |
|
166 |
if ( Map ) |
|
167 |
{ |
|
168 |
||
169 |
TLiwVariant regTypeVar; |
|
170 |
Map->FindL(KStatus,regTypeVar); |
|
171 |
TInt regType = regTypeVar.AsTInt32(); |
|
172 |
regTypeVar.Reset(); |
|
173 |
||
174 |
TBuf<50> buf; |
|
175 |
buf.AppendNum(regType); |
|
176 |
iLog->Log(buf); |
|
177 |
||
178 |
if( REGISTEREDONHOMENW != regType ) |
|
179 |
{ |
|
180 |
Err |= FAIL; |
|
181 |
iLog->Log( _L("Incorrect NW regitration status") ); |
|
182 |
} |
|
183 |
||
184 |
} |
|
185 |
||
186 |
}//output |
|
187 |
else |
|
188 |
{ |
|
189 |
Err |= err; |
|
190 |
iLog->Log( _L("Output data Set to NULL") ); |
|
191 |
} |
|
192 |
}//err |
|
193 |
else |
|
194 |
{ |
|
195 |
Err |= err; |
|
196 |
iLog->Log( _L("API returned error") ); |
|
197 |
} |
|
198 |
||
199 |
}//interface |
|
200 |
||
201 |
inparam->Reset(); |
|
202 |
outparam->Reset(); |
|
203 |
||
204 |
interface->Close(); |
|
205 |
||
206 |
CleanupStack::PopAndDestroy( iServiceHandler ); |
|
207 |
__UHEAP_MARKEND; |
|
208 |
||
209 |
return Err; |
|
210 |
} |
|
211 |
||
212 |
||
213 |
||
214 |
TInt CTSysInfoProviderNetworkTests::GetNwModeGSML(CStifItemParser& /*aItem*/) |
|
215 |
{ |
|
216 |
||
217 |
TInt Err(PASS); |
|
218 |
_LIT( KExample, "GetNwModeGSML:" ); |
|
219 |
iLog->Log( KExample ); |
|
220 |
||
221 |
__UHEAP_MARK; |
|
222 |
||
223 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
224 |
CleanupStack::PushL(iServiceHandler); |
|
225 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
226 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
227 |
||
228 |
TInt err = KErrNone; |
|
229 |
||
230 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
231 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
232 |
||
233 |
RCriteriaArray a; |
|
234 |
a.AppendL(crit); |
|
235 |
||
236 |
iServiceHandler->AttachL(a); |
|
237 |
||
238 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
239 |
||
240 |
delete crit; |
|
241 |
a.Reset(); |
|
242 |
||
243 |
TInt pos = 0; |
|
244 |
MLiwInterface* interface = NULL; |
|
245 |
outparam->FindFirst( pos, KIDataSource ); |
|
246 |
if(pos != KErrNotFound) |
|
247 |
{ |
|
248 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
249 |
} |
|
250 |
||
251 |
outparam->Reset(); |
|
252 |
inparam->Reset(); |
|
253 |
||
254 |
if(interface) |
|
255 |
{ |
|
256 |
TLiwGenericParam entity; |
|
257 |
TLiwVariant entityname; |
|
258 |
TLiwGenericParam key; |
|
259 |
TLiwVariant keyname; |
|
260 |
||
261 |
entityname.Set(KNetwork); |
|
262 |
entity.SetNameAndValueL(KEntity,entityname); |
|
263 |
||
264 |
keyname.Set(SysInfo::KNetworkMode); |
|
265 |
key.SetNameAndValueL(KKey,keyname); |
|
266 |
||
267 |
inparam->AppendL(entity); |
|
268 |
||
269 |
inparam->AppendL(key); |
|
270 |
||
271 |
entity.Reset(); |
|
272 |
entityname.Reset(); |
|
273 |
key.Reset(); |
|
274 |
keyname.Reset(); |
|
275 |
||
276 |
TRAP(err, interface->ExecuteCmdL(KGetInfo,*inparam,*outparam)); |
|
277 |
||
278 |
||
279 |
pos = 0 ; |
|
280 |
||
281 |
outparam->FindFirst( pos,KErrorCode ); |
|
282 |
if(pos != KErrNotFound) |
|
283 |
{ |
|
284 |
if( (*outparam)[pos].Value().AsTInt32() != KErrNone ) |
|
285 |
err = (TInt)((*outparam)[pos].Value().AsTInt32()); |
|
286 |
} |
|
287 |
||
288 |
if(err == SErrNone) |
|
289 |
{ |
|
290 |
pos = 0 ; |
|
291 |
const TLiwGenericParam* output = outparam->FindFirst( pos,KReturnValue ); |
|
292 |
||
293 |
if(output) |
|
294 |
{ |
|
295 |
const CLiwMap* Map = output->Value().AsMap(); |
|
296 |
if ( Map ) |
|
297 |
{ |
|
298 |
if ( Map ) |
|
299 |
{ |
|
300 |
TLiwVariant netModeVar; |
|
301 |
Map->FindL(KStatus,netModeVar); |
|
302 |
TInt netMode = netModeVar.AsTInt32(); |
|
303 |
netModeVar.Reset(); |
|
304 |
||
305 |
TBuf<50> buf; |
|
306 |
buf.AppendNum(netMode); |
|
307 |
iLog->Log(buf); |
|
308 |
||
309 |
if( GSM != netMode ) |
|
310 |
{ |
|
311 |
Err |= FAIL; |
|
312 |
iLog->Log( _L("Incorrect NW regitration status") ); |
|
313 |
} |
|
314 |
||
315 |
} |
|
316 |
||
317 |
||
318 |
} |
|
319 |
||
320 |
}//output |
|
321 |
else |
|
322 |
{ |
|
323 |
Err |= err; |
|
324 |
iLog->Log( _L("Output data Set to NULL") ); |
|
325 |
} |
|
326 |
}//err |
|
327 |
else |
|
328 |
{ |
|
329 |
Err |= err; |
|
330 |
iLog->Log( _L("API returned error") ); |
|
331 |
} |
|
332 |
||
333 |
}//interface |
|
334 |
||
335 |
inparam->Reset(); |
|
336 |
outparam->Reset(); |
|
337 |
||
338 |
interface->Close(); |
|
339 |
||
340 |
CleanupStack::PopAndDestroy( iServiceHandler ); |
|
341 |
__UHEAP_MARKEND; |
|
342 |
||
343 |
return Err; |
|
344 |
||
345 |
||
346 |
} |
|
347 |
||
348 |
||
349 |
TInt CTSysInfoProviderNetworkTests::SignalStrengthAsyncL(CStifItemParser& aItem) |
|
350 |
{ |
|
351 |
_LIT( KExample, "SignalStrengthAsyncL" ); |
|
352 |
iLog->Log( KExample ); |
|
353 |
TInt Err(PASS); |
|
354 |
||
355 |
__UHEAP_MARK; |
|
356 |
||
357 |
TInt InputStrength; |
|
358 |
aItem.GetNextInt(InputStrength); |
|
359 |
||
360 |
CSignalStrAsync* test = CSignalStrAsync::NewL(iLog,InputStrength); |
|
361 |
test->Start(); |
|
362 |
Err = test->Result(); |
|
363 |
delete test; |
|
364 |
||
365 |
__UHEAP_MARKEND; |
|
366 |
return Err; |
|
367 |
} |
|
368 |
||
369 |
||
370 |
TInt CTSysInfoProviderNetworkTests::SignalStrengthNotiL(CStifItemParser& aItem) |
|
371 |
{ |
|
372 |
_LIT( KExample, "SignalStrengthNotiL" ); |
|
373 |
iLog->Log( KExample ); |
|
374 |
TInt Err(PASS); |
|
375 |
// On Emulator this is not supported. |
|
376 |
#if (! (defined(__WINS__) || defined(__WINSCW__)) ) |
|
377 |
||
378 |
__UHEAP_MARK; |
|
379 |
||
380 |
TInt InputStrength; |
|
381 |
aItem.GetNextInt(InputStrength); |
|
382 |
||
383 |
CSignalStrNotify* test = CSignalStrNotify::NewL(iLog,InputStrength); |
|
384 |
test->Start(); |
|
385 |
Err = test->Result(); |
|
386 |
delete test; |
|
387 |
||
388 |
__UHEAP_MARKEND; |
|
389 |
#endif |
|
390 |
return Err; |
|
391 |
} |
|
392 |
||
393 |
||
394 |
||
395 |
||
396 |
TInt CTSysInfoProviderNetworkTests::HomeNwAsyncL(CStifItemParser& aItem) |
|
397 |
{ |
|
398 |
_LIT( KExample, "HomeNwAsyncL" ); |
|
399 |
iLog->Log( KExample ); |
|
400 |
TInt Err(PASS); |
|
401 |
||
402 |
__UHEAP_MARK; |
|
403 |
||
404 |
CHomeNetAsync* test = CHomeNetAsync::NewL(iLog); |
|
405 |
test->Start(); |
|
406 |
Err = test->Result(); |
|
407 |
delete test; |
|
408 |
||
409 |
__UHEAP_MARKEND; |
|
410 |
return Err; |
|
411 |
} |
|
412 |
||
413 |
||
414 |
TInt CTSysInfoProviderNetworkTests::CurrentNwNotiL(CStifItemParser& aItem) |
|
415 |
{ |
|
416 |
||
417 |
_LIT( KExample, "CurrentNwNotiL" ); |
|
418 |
iLog->Log( KExample ); |
|
419 |
TInt Err(PASS); |
|
420 |
||
421 |
__UHEAP_MARK; |
|
422 |
||
423 |
CCurrentNetNotify* test = CCurrentNetNotify::NewL(iLog); |
|
424 |
test->Start(); |
|
425 |
Err = test->Result(); |
|
426 |
delete test; |
|
427 |
||
428 |
__UHEAP_MARKEND; |
|
429 |
return Err; |
|
430 |
} |
|
431 |