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 - 2007 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: Tests sysinfo network information |
|
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 "tsysnetwork.h" |
26 |
||
27 |
// EXTERNAL DATA STRUCTURES |
|
28 |
//extern ?external_data; |
|
29 |
||
30 |
// EXTERNAL FUNCTION PROTOTYPES |
|
31 |
//extern ?external_function( ?arg_type,?arg_type ); |
|
32 |
||
33 |
// CONSTANTS |
|
34 |
//const ?type ?constant_var = ?constant; |
|
35 |
||
36 |
// MACROS |
|
37 |
//#define ?macro ?macro_def |
|
38 |
||
39 |
// LOCAL CONSTANTS AND MACROS |
|
40 |
//const ?type ?constant_var = ?constant; |
|
41 |
//#define ?macro_name ?macro_def |
|
42 |
||
43 |
// MODULE DATA STRUCTURES |
|
44 |
//enum ?declaration |
|
45 |
//typedef ?declaration |
|
46 |
||
47 |
// LOCAL FUNCTION PROTOTYPES |
|
48 |
//?type ?function_name( ?arg_type, ?arg_type ); |
|
49 |
||
50 |
// FORWARD DECLARATIONS |
|
51 |
//class ?FORWARD_CLASSNAME; |
|
52 |
||
53 |
// ============================= LOCAL FUNCTIONS =============================== |
|
54 |
||
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// ?function_name ?description. |
|
57 |
// ?description |
|
58 |
// Returns: ?value_1: ?description |
|
59 |
// ?value_n: ?description_line1 |
|
60 |
// ?description_line2 |
|
61 |
// ----------------------------------------------------------------------------- |
|
62 |
// |
|
63 |
/* |
|
64 |
?type ?function_name( |
|
65 |
?arg_type arg, // ?description |
|
66 |
?arg_type arg) // ?description |
|
67 |
{ |
|
68 |
||
69 |
?code // ?comment |
|
70 |
||
71 |
// ?comment |
|
72 |
?code |
|
73 |
} |
|
74 |
*/ |
|
75 |
||
76 |
// ============================ MEMBER FUNCTIONS =============================== |
|
77 |
||
78 |
// ----------------------------------------------------------------------------- |
|
79 |
// Ctsysnetwork::Delete |
|
80 |
// Delete here all resources allocated and opened from test methods. |
|
81 |
// Called from destructor. |
|
82 |
// ----------------------------------------------------------------------------- |
|
83 |
// |
|
84 |
void Ctsysnetwork::Delete() |
|
85 |
{ |
|
86 |
||
87 |
} |
|
88 |
||
89 |
// ----------------------------------------------------------------------------- |
|
90 |
// Ctsysnetwork::RunMethodL |
|
91 |
// Run specified method. Contains also table of test mothods and their names. |
|
92 |
// ----------------------------------------------------------------------------- |
|
93 |
// |
|
94 |
TInt Ctsysnetwork::RunMethodL( |
|
95 |
CStifItemParser& aItem ) |
|
96 |
{ |
|
97 |
||
98 |
static TStifFunctionInfo const KFunctions[] = |
|
99 |
{ |
|
100 |
// Copy this line for every implemented function. |
|
101 |
// First string is the function name used in TestScripter script file. |
|
102 |
// Second is the actual implementation member function. |
|
103 |
ENTRY( "RegStatus", Ctsysnetwork::RegStatus ), |
|
104 |
ENTRY( "NetworkMode", Ctsysnetwork::NetworkMode), |
|
105 |
ENTRY( "WrongEntity", Ctsysnetwork::WrongEntity), |
|
106 |
ENTRY( "WrongKey", Ctsysnetwork::WrongKey), |
|
107 |
}; |
|
108 |
||
109 |
const TInt count = sizeof( KFunctions ) / |
|
110 |
sizeof( TStifFunctionInfo ); |
|
111 |
||
112 |
return RunInternalL( KFunctions, count, aItem ); |
|
113 |
||
114 |
} |
|
115 |
||
116 |
// ----------------------------------------------------------------------------- |
|
117 |
// Ctsysnetwork::RegStatus |
|
118 |
// Test for getting the registration status |
|
119 |
// ----------------------------------------------------------------------------- |
|
120 |
// |
|
121 |
TInt Ctsysnetwork::RegStatus( CStifItemParser& aItem ) |
|
122 |
{ |
|
123 |
||
124 |
__UHEAP_MARK; |
|
125 |
||
126 |
_LIT(KEntity,"Network") ; |
|
127 |
_LIT(KKey,"RegistrationStatus") ; |
|
128 |
||
129 |
TPtrC entity(KEntity) ; |
|
130 |
TPtrC key(KKey) ; |
|
131 |
||
132 |
TInt returnCode = KErrNone ; |
|
133 |
TInt expStatus = 0; |
|
134 |
TInt expDataType = 0 ; |
|
135 |
aItem.GetNextInt ( expStatus ) ; |
|
136 |
||
137 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
138 |
||
139 |
CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
140 |
||
141 |
if( NULL == CoreObj) |
|
142 |
{ |
|
143 |
iLog->Log(_L8("Failed.. @Core")) ; |
|
144 |
return KErrGeneral ; |
|
145 |
} |
|
146 |
||
147 |
CSysData *sysData ; |
|
148 |
||
149 |
||
150 |
iLog->Log(_L8("ExpStatus : %d"),expStatus) ; |
|
151 |
||
152 |
TRAPD(leaveCode, CoreObj->GetInfoL(entity,key,sysData) ); |
|
153 |
if(KErrNone == leaveCode) |
|
154 |
{ |
|
155 |
||
156 |
TInt retType = sysData->DataType() ; |
|
157 |
||
158 |
if(expDataType == retType) |
|
159 |
{ |
|
160 |
||
161 |
CStatus *status = (CStatus*)sysData ; |
|
162 |
TInt retStatus = status->Status() ; |
|
163 |
||
164 |
if(expStatus != retStatus) |
|
165 |
{ |
|
166 |
returnCode = KErrGeneral ; |
|
167 |
iLog->Log(_L8("Failed.. @retStatus: %d"),retStatus) ; |
|
168 |
} |
|
169 |
else |
|
170 |
{ |
|
171 |
iLog->Log(_L8("Passed..")) ; |
|
172 |
} |
|
173 |
||
174 |
} |
|
175 |
||
176 |
else |
|
177 |
{ |
|
178 |
returnCode = KErrGeneral ; |
|
179 |
iLog->Log(_L8("Failed.. @retType %d"),retType) ; |
|
180 |
} |
|
181 |
||
182 |
delete sysData ; |
|
183 |
||
184 |
} |
|
185 |
else |
|
186 |
{ |
|
187 |
returnCode = KErrGeneral ; |
|
188 |
iLog->Log(_L8("Failed.. @TRAPD %d"),leaveCode) ; |
|
189 |
} |
|
190 |
delete CoreObj ; |
|
191 |
||
192 |
#endif |
|
193 |
||
194 |
__UHEAP_MARKEND ; |
|
195 |
return returnCode ; |
|
196 |
||
197 |
} |
|
198 |
||
199 |
||
200 |
// ----------------------------------------------------------------------------- |
|
201 |
// Ctsysnetwork::NetworkMode |
|
202 |
// Test for getting the Network Mode |
|
203 |
// ----------------------------------------------------------------------------- |
|
204 |
// |
|
205 |
TInt Ctsysnetwork::NetworkMode( CStifItemParser& aItem ) |
|
206 |
{ |
|
207 |
||
208 |
__UHEAP_MARK; |
|
209 |
||
210 |
_LIT(KEntity,"Network") ; |
|
211 |
_LIT(KKey,"NetworkMode") ; |
|
212 |
||
213 |
TPtrC entity(KEntity) ; |
|
214 |
TPtrC key(KKey) ; |
|
215 |
||
216 |
_LIT8(KTest,"Network") ; |
|
217 |
/* TBuf8<32> eightBuf(KTest) ; |
|
218 |
TBuf16<32> sixteenBuf ; |
|
219 |
sixteenBuf.Copy(eightBuf) ; |
|
220 |
||
221 |
TPtrC copyPtr(sixteenBuf) ; |
|
222 |
TPtrC tobeCompPtr(sixteenBuf) ; |
|
223 |
copyPtr.Compare(tobeCompPtr) ; |
|
224 |
*/ |
|
225 |
TInt returnCode = KErrNone ; |
|
226 |
TInt expStatus = 0 ; |
|
227 |
TInt expDataType = 0 ; |
|
228 |
aItem.GetNextInt ( expStatus ) ; |
|
229 |
||
230 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
231 |
||
232 |
CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
233 |
||
234 |
if( NULL == CoreObj) |
|
235 |
{ |
|
236 |
iLog->Log(_L8("Failed.. @Core")) ; |
|
237 |
return KErrGeneral ; |
|
238 |
} |
|
239 |
||
240 |
||
241 |
CSysData *sysData ; |
|
242 |
||
243 |
||
244 |
iLog->Log(_L8("NetworkMode ExpStatus: %d"),expStatus) ; |
|
245 |
TRAPD(leaveCode, CoreObj->GetInfoL(entity,key,sysData)) ; |
|
246 |
if(KErrNone == leaveCode) |
|
247 |
{ |
|
248 |
||
249 |
TInt retType = sysData->DataType() ; |
|
250 |
||
251 |
if(expDataType == retType) |
|
252 |
{ |
|
253 |
||
254 |
CStatus *status = (CStatus*)sysData ; |
|
255 |
TInt retStatus = status->Status() ; |
|
256 |
||
257 |
iLog->Log(_L8("Passed.. @retStatus %d"),retStatus) ; |
|
258 |
} |
|
259 |
||
260 |
else |
|
261 |
{ |
|
262 |
returnCode = KErrGeneral ; |
|
263 |
iLog->Log(_L8("Failed.. @retType: %d"),retType); |
|
264 |
} |
|
265 |
||
266 |
delete sysData ; |
|
267 |
||
268 |
} |
|
269 |
else |
|
270 |
{ |
|
271 |
returnCode = KErrGeneral ; |
|
272 |
iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
273 |
} |
|
274 |
delete CoreObj ; |
|
275 |
||
276 |
#endif |
|
277 |
||
278 |
__UHEAP_MARKEND ; |
|
279 |
return returnCode ; |
|
280 |
||
281 |
} |
|
282 |
||
283 |
||
284 |
// ----------------------------------------------------------------------------- |
|
285 |
// Ctsysnetwork::WrongEntity |
|
286 |
// Test for wrong Entity input values |
|
287 |
// ----------------------------------------------------------------------------- |
|
288 |
// |
|
289 |
TInt Ctsysnetwork::WrongEntity( CStifItemParser& /*aItem*/ ) |
|
290 |
{ |
|
291 |
||
292 |
__UHEAP_MARK; |
|
293 |
||
294 |
_LIT(KEntity,"Networkk") ; |
|
295 |
_LIT(KKey,"NetworkMode") ; |
|
296 |
||
297 |
TPtrC entity(KEntity) ; |
|
298 |
TPtrC key(KKey) ; |
|
299 |
||
300 |
TInt returnCode = KErrNone ; |
|
301 |
||
302 |
CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
303 |
||
304 |
if( NULL == CoreObj) |
|
305 |
{ |
|
306 |
iLog->Log(_L8("Failed.. @Core")) ; |
|
307 |
return KErrGeneral ; |
|
308 |
} |
|
309 |
||
310 |
CSysData *sysData ; |
|
311 |
||
312 |
iLog->Log(_L8("b4..")) ; |
|
313 |
||
314 |
TRAPD(leaveCode, CoreObj->GetInfoL(entity,key,sysData)) ; |
|
315 |
||
316 |
iLog->Log(_L8("af..")) ; |
|
317 |
||
318 |
if(KErrNotFound == leaveCode) |
|
319 |
{ |
|
320 |
iLog->Log(_L8("Passed..")) ; |
|
321 |
} |
|
322 |
else |
|
323 |
{ |
|
324 |
returnCode = KErrGeneral ; |
|
325 |
iLog->Log(_L8("Failed..")) ; |
|
326 |
} |
|
327 |
||
328 |
delete CoreObj ; |
|
329 |
||
330 |
__UHEAP_MARKEND ; |
|
331 |
return returnCode ; |
|
332 |
||
333 |
} |
|
334 |
||
335 |
||
336 |
// ----------------------------------------------------------------------------- |
|
337 |
// Ctsysnetwork::WrongKey |
|
338 |
// Test for wrong key input values |
|
339 |
// ----------------------------------------------------------------------------- |
|
340 |
// |
|
341 |
TInt Ctsysnetwork::WrongKey( CStifItemParser& /*aItem*/ ) |
|
342 |
{ |
|
343 |
||
344 |
__UHEAP_MARK; |
|
345 |
||
346 |
_LIT(KEntity,"Network") ; |
|
347 |
_LIT(KKey,"NetworkModde") ; |
|
348 |
||
349 |
TPtrC entity(KEntity) ; |
|
350 |
TPtrC key(KKey) ; |
|
351 |
||
352 |
TInt returnCode = KErrNone ; |
|
353 |
||
354 |
CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
355 |
||
356 |
if( NULL == CoreObj) |
|
357 |
{ |
|
358 |
iLog->Log(_L8("Failed.. @Core")) ; |
|
359 |
return KErrGeneral ; |
|
360 |
} |
|
361 |
||
362 |
||
363 |
CSysData *sysData ; |
|
364 |
||
365 |
||
366 |
iLog->Log(_L8("b4..")) ; |
|
367 |
TRAPD(leaveCode, CoreObj->GetInfoL(entity,key,sysData)) ; |
|
368 |
iLog->Log(_L8("af..")) ; |
|
369 |
if(KErrNotFound == leaveCode) |
|
370 |
{ |
|
371 |
iLog->Log(_L8("Passed..")) ; |
|
372 |
} |
|
373 |
else |
|
374 |
{ |
|
375 |
returnCode = KErrGeneral ; |
|
376 |
iLog->Log(_L8("Failed..")) ; |
|
377 |
} |
|
378 |
||
379 |
delete CoreObj ; |
|
380 |
||
381 |
__UHEAP_MARKEND ; |
|
382 |
return returnCode ; |
|
383 |
||
384 |
} |
|
385 |
||
386 |
// ----------------------------------------------------------------------------- |
|
387 |
// Ctsysnetwork::?member_function |
|
388 |
// ?implementation_description |
|
389 |
// (other items were commented in a header). |
|
390 |
// ----------------------------------------------------------------------------- |
|
391 |
// |
|
392 |
/* |
|
393 |
TInt Ctsysnetwork::?member_function( |
|
394 |
CItemParser& aItem ) |
|
395 |
{ |
|
396 |
||
397 |
?code |
|
398 |
||
399 |
} |
|
400 |
*/ |
|
401 |
||
402 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
403 |
// None |
|
404 |
||
405 |
// End of File |