|
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 connectivity information |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32svr.h> |
|
23 #include <StifParser.h> |
|
24 #include <Stiftestinterface.h> |
|
25 |
|
26 |
|
27 #include "tsysconnectivity.h" |
|
28 #include "tsysconnectivitynot.h" |
|
29 |
|
30 // EXTERNAL DATA STRUCTURES |
|
31 //extern ?external_data; |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 //extern ?external_function( ?arg_type,?arg_type ); |
|
35 |
|
36 // CONSTANTS |
|
37 //const ?type ?constant_var = ?constant; |
|
38 |
|
39 // MACROS |
|
40 //#define ?macro ?macro_def |
|
41 |
|
42 // LOCAL CONSTANTS AND MACROS |
|
43 //const ?type ?constant_var = ?constant; |
|
44 //#define ?macro_name ?macro_def |
|
45 |
|
46 // MODULE DATA STRUCTURES |
|
47 //enum ?declaration |
|
48 //typedef ?declaration |
|
49 |
|
50 // LOCAL FUNCTION PROTOTYPES |
|
51 //?type ?function_name( ?arg_type, ?arg_type ); |
|
52 |
|
53 // FORWARD DECLARATIONS |
|
54 //class ?FORWARD_CLASSNAME; |
|
55 |
|
56 // ============================= LOCAL FUNCTIONS =============================== |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // ?function_name ?description. |
|
60 // ?description |
|
61 // Returns: ?value_1: ?description |
|
62 // ?value_n: ?description_line1 |
|
63 // ?description_line2 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 /* |
|
67 ?type ?function_name( |
|
68 ?arg_type arg, // ?description |
|
69 ?arg_type arg) // ?description |
|
70 { |
|
71 |
|
72 ?code // ?comment |
|
73 |
|
74 // ?comment |
|
75 ?code |
|
76 } |
|
77 */ |
|
78 |
|
79 // ============================ MEMBER FUNCTIONS =============================== |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // Ctsysconnectivity::Delete |
|
83 // Delete here all resources allocated and opened from test methods. |
|
84 // Called from destructor. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void Ctsysconnectivity::Delete() |
|
88 { |
|
89 |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // Ctsysconnectivity::RunMethodL |
|
94 // Run specified method. Contains also table of test mothods and their names. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 TInt Ctsysconnectivity::RunMethodL( |
|
98 CStifItemParser& aItem ) |
|
99 { |
|
100 |
|
101 static TStifFunctionInfo const KFunctions[] = |
|
102 { |
|
103 // Copy this line for every implemented function. |
|
104 // First string is the function name used in TestScripter script file. |
|
105 // Second is the actual implementation member function. |
|
106 ENTRY( "SetAndGetBtState", Ctsysconnectivity::SetAndGetBtState ), |
|
107 ENTRY( "SetAndGetIRState", Ctsysconnectivity::SetAndGetIRState ), |
|
108 ENTRY( "WLanMACAdd", Ctsysconnectivity::WLanMACAdd ), |
|
109 ENTRY( "WrongKey", Ctsysconnectivity::WrongKey ), |
|
110 ENTRY( "SetWrongDataType", Ctsysconnectivity::SetWrongDataType ), |
|
111 ENTRY( "SetWrongKey", Ctsysconnectivity::SetWrongKey ), |
|
112 ENTRY( "ConnNotWithWrongKey", Ctsysconnectivity::ConnNotWithWrongKey ), |
|
113 }; |
|
114 |
|
115 const TInt count = sizeof( KFunctions ) / |
|
116 sizeof( TStifFunctionInfo ); |
|
117 |
|
118 return RunInternalL( KFunctions, count, aItem ); |
|
119 |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // Ctsysconnectivity::SetAndGetBtState |
|
124 // Tests Bluetooth state |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt Ctsysconnectivity::SetAndGetBtState( CStifItemParser& aItem ) |
|
128 { |
|
129 |
|
130 __UHEAP_MARK; |
|
131 |
|
132 _LIT(KEntity,"Connectivity") ; |
|
133 _LIT(KKey,"BlueTooth") ; |
|
134 |
|
135 TInt returnCode = KErrNone ; |
|
136 TInt expState = 0; |
|
137 TInt expDataType = 0 ; |
|
138 TInt defValue = 0 ; |
|
139 aItem.GetNextInt ( expState ) ; |
|
140 |
|
141 CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
142 |
|
143 if( NULL == CoreObj) |
|
144 { |
|
145 iLog->Log(_L8("Failed.. @Core")) ; |
|
146 return KErrGeneral ; |
|
147 } |
|
148 |
|
149 iLog->Log(_L8("expState : %d"),expState) ; |
|
150 CStatus *ipData = CStatus::NewL(expState) ; |
|
151 |
|
152 TRAPD(leaveCode, CoreObj->SetInfoL(KEntity,KKey,ipData)) ; |
|
153 |
|
154 /* |
|
155 if(KErrNone == leaveCode) |
|
156 { |
|
157 |
|
158 CSysData *sysData ; |
|
159 |
|
160 TRAPD(leaveCode, CoreObj->GetInfoL(KEntity,KKey,sysData) ); |
|
161 |
|
162 if(KErrNone == leaveCode) |
|
163 { |
|
164 |
|
165 TInt retType = sysData->DataType() ; |
|
166 |
|
167 if(expDataType == retType) |
|
168 { |
|
169 |
|
170 CStatus *status = (CStatus*)sysData ; |
|
171 TInt retStatus = status->Status() ; |
|
172 |
|
173 if(expState != retStatus) |
|
174 { |
|
175 returnCode = KErrGeneral ; |
|
176 iLog->Log(_L8("retStatus : %d"),retStatus) ; |
|
177 iLog->Log(_L8("Failed.. @retStatus")) ; |
|
178 } |
|
179 else |
|
180 { |
|
181 iLog->Log(_L8("Passed..")) ; |
|
182 } |
|
183 |
|
184 } |
|
185 |
|
186 else |
|
187 { |
|
188 returnCode = KErrGeneral ; |
|
189 iLog->Log(_L8("Failed.. @retType")) ; |
|
190 } |
|
191 delete sysData ; |
|
192 |
|
193 } |
|
194 else |
|
195 { |
|
196 returnCode = KErrGeneral ; |
|
197 iLog->Log(_L8("Failed.. @2 TRAPD")) ; |
|
198 } |
|
199 |
|
200 } |
|
201 else |
|
202 { |
|
203 returnCode = KErrGeneral ; |
|
204 iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
205 } |
|
206 |
|
207 CStatus *defData = CStatus::NewL(defValue) ; |
|
208 |
|
209 CoreObj->SetInfoL(KEntity,KKey,defData) ; |
|
210 |
|
211 delete defData ; |
|
212 */ |
|
213 |
|
214 if(KErrNotFound == leaveCode) |
|
215 { |
|
216 iLog->Log(_L8("Passed..")) ; |
|
217 } |
|
218 else |
|
219 { |
|
220 returnCode = KErrGeneral ; |
|
221 iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
222 } |
|
223 |
|
224 delete ipData ; |
|
225 delete CoreObj ; |
|
226 |
|
227 |
|
228 __UHEAP_MARKEND ; |
|
229 return returnCode ; |
|
230 |
|
231 |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // Ctsysconnectivity::SetAndGetIRState |
|
236 // Tests Set and Get InfraRed state |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 TInt Ctsysconnectivity::SetAndGetIRState( CStifItemParser& aItem ) |
|
240 { |
|
241 |
|
242 __UHEAP_MARK; |
|
243 |
|
244 _LIT(KEntity,"Connectivity") ; |
|
245 _LIT(KKey,"InfraRed") ; |
|
246 |
|
247 TInt returnCode = KErrNone ; |
|
248 TInt expState = 0; |
|
249 TInt expDataType = 0 ; |
|
250 TInt defValue = 0 ; |
|
251 aItem.GetNextInt ( expState ) ; |
|
252 |
|
253 CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
254 |
|
255 if( NULL == CoreObj) |
|
256 { |
|
257 iLog->Log(_L8("Failed.. @Core")) ; |
|
258 return KErrGeneral ; |
|
259 } |
|
260 |
|
261 CStatus *ipData = CStatus::NewL(expState) ; |
|
262 |
|
263 TRAPD(leaveCode, CoreObj->SetInfoL(KEntity,KKey,ipData)) ; |
|
264 |
|
265 /* |
|
266 if(KErrNone == leaveCode) |
|
267 { |
|
268 |
|
269 CSysData *sysData ; |
|
270 |
|
271 iLog->Log(_L8("expState : %d"),expState) ; |
|
272 |
|
273 TRAPD(leaveCode, CoreObj->GetInfoL(KEntity,KKey,sysData) ); |
|
274 |
|
275 if(KErrNone == leaveCode) |
|
276 { |
|
277 |
|
278 TInt retType = sysData->DataType() ; |
|
279 |
|
280 if(expDataType == retType) |
|
281 { |
|
282 |
|
283 CStatus *status = (CStatus*)sysData ; |
|
284 TInt retStatus = status->Status() ; |
|
285 iLog->Log(_L8("retStatus : %d"),retStatus) ; |
|
286 |
|
287 if(expState != retStatus) |
|
288 { |
|
289 returnCode = KErrGeneral ; |
|
290 iLog->Log(_L8("Failed.. @retStatus")) ; |
|
291 } |
|
292 else |
|
293 { |
|
294 iLog->Log(_L8("Passed..")) ; |
|
295 } |
|
296 |
|
297 } |
|
298 |
|
299 else |
|
300 { |
|
301 returnCode = KErrGeneral ; |
|
302 iLog->Log(_L8("Failed.. @retType")) ; |
|
303 } |
|
304 delete sysData ; |
|
305 |
|
306 } |
|
307 else |
|
308 { |
|
309 returnCode = KErrGeneral ; |
|
310 iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
311 } |
|
312 } |
|
313 |
|
314 CStatus *defData = CStatus::NewL(defValue) ; |
|
315 |
|
316 CoreObj->SetInfoL(KEntity,KKey,defData) ; |
|
317 |
|
318 delete defData ; |
|
319 */ |
|
320 |
|
321 if(KErrNotFound == leaveCode) |
|
322 { |
|
323 iLog->Log(_L8("Passed..")) ; |
|
324 } |
|
325 else |
|
326 { |
|
327 returnCode = KErrGeneral ; |
|
328 iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
329 } |
|
330 |
|
331 delete ipData ; |
|
332 delete CoreObj ; |
|
333 |
|
334 __UHEAP_MARKEND ; |
|
335 return returnCode ; |
|
336 |
|
337 |
|
338 } |
|
339 |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // Ctsysconnectivity::WLanMACAdd |
|
343 // Tests WLanMACAdd state |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 TInt Ctsysconnectivity::WLanMACAdd( CStifItemParser& /*aItem*/ ) |
|
347 { |
|
348 |
|
349 __UHEAP_MARK; |
|
350 |
|
351 _LIT(KEntity1,"Features") ; |
|
352 _LIT(KKey1,"WLan") ; |
|
353 _LIT(KEntity2,"Connectivity") ; |
|
354 _LIT(KKey2,"WLanMacAddress") ; |
|
355 |
|
356 |
|
357 TInt returnCode = KErrNone ; |
|
358 |
|
359 #if (!(defined(__WINS__) || defined(__WINSCW__))) |
|
360 |
|
361 TInt featureID = KFeatureIdProtocolWlan ; |
|
362 TInt expDataType = 12 ; |
|
363 TInt expLength = 17 ; |
|
364 TInt isWLanSupported = FeatureManager::FeatureSupported(featureID) ; |
|
365 |
|
366 if(isWLanSupported) |
|
367 { |
|
368 |
|
369 CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
370 |
|
371 if( NULL == CoreObj) |
|
372 { |
|
373 iLog->Log(_L8("Failed.. @Core")) ; |
|
374 return KErrGeneral ; |
|
375 } |
|
376 |
|
377 |
|
378 CSysData *sysData ; |
|
379 |
|
380 |
|
381 TRAPD(leaveCode, CoreObj->GetInfoL(KEntity1,KKey1,sysData) ); |
|
382 |
|
383 if(KErrNone == leaveCode) |
|
384 { |
|
385 TInt IsSupported = ((CStatus*)sysData)->Status(); |
|
386 |
|
387 if(IsSupported) |
|
388 { |
|
389 |
|
390 TRAP(leaveCode, CoreObj->GetInfoL(KEntity2,KKey2,sysData) ); |
|
391 |
|
392 if(KErrNone == leaveCode) |
|
393 { |
|
394 TInt retType = sysData->DataType() ; |
|
395 |
|
396 if(expDataType == retType) |
|
397 { |
|
398 CStringData *status = (CStringData*)sysData ; |
|
399 TPtrC retAddress ; |
|
400 status->StringData(retAddress) ; |
|
401 |
|
402 if(expLength != (retAddress.Length())) |
|
403 { |
|
404 returnCode = KErrGeneral ; |
|
405 iLog->Log(_L8("Failed.. @retStatus")) ; |
|
406 } |
|
407 else |
|
408 { |
|
409 iLog->Log(_L8("Passed..")) ; |
|
410 TBuf8<20> buf; |
|
411 buf.Copy(retAddress); |
|
412 iLog->Log(_L8("WLanMAC Address")) ; |
|
413 iLog->Log(buf); |
|
414 } |
|
415 } |
|
416 |
|
417 else |
|
418 { |
|
419 returnCode = KErrGeneral ; |
|
420 iLog->Log(_L8("Failed.. @retType")) ; |
|
421 } |
|
422 } |
|
423 |
|
424 else |
|
425 { |
|
426 returnCode = KErrGeneral ; |
|
427 iLog->Log(_L8("Failed.. @TRAPD2")) ; |
|
428 } |
|
429 } |
|
430 |
|
431 } |
|
432 else |
|
433 { |
|
434 returnCode = KErrGeneral ; |
|
435 iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
436 } |
|
437 |
|
438 delete sysData ; |
|
439 delete CoreObj ; |
|
440 |
|
441 } |
|
442 |
|
443 #endif |
|
444 |
|
445 __UHEAP_MARKEND ; |
|
446 return returnCode ; |
|
447 |
|
448 |
|
449 } |
|
450 |
|
451 |
|
452 |
|
453 // ----------------------------------------------------------------------------- |
|
454 // Ctsysconnectivity::WrongKey |
|
455 // Test for wrong key input values |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 TInt Ctsysconnectivity::WrongKey( CStifItemParser& /*aItem*/ ) |
|
459 { |
|
460 |
|
461 __UHEAP_MARK; |
|
462 |
|
463 _LIT(KEntity,"Connectivity") ; |
|
464 _LIT(KKey,"StatusCharging") ; |
|
465 |
|
466 TInt returnCode = KErrNone ; |
|
467 |
|
468 CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
469 |
|
470 if( NULL == CoreObj) |
|
471 { |
|
472 iLog->Log(_L8("Failed.. @Core")) ; |
|
473 return KErrGeneral ; |
|
474 } |
|
475 |
|
476 |
|
477 CSysData *sysData ; |
|
478 |
|
479 TRAPD(leaveCode, CoreObj->GetInfoL(KEntity,KKey,sysData)) ; |
|
480 if(KErrNotFound == leaveCode) |
|
481 { |
|
482 iLog->Log(_L8("Passed..")) ; |
|
483 } |
|
484 else |
|
485 { |
|
486 returnCode = KErrGeneral ; |
|
487 iLog->Log(_L8("Failed..")) ; |
|
488 } |
|
489 |
|
490 delete CoreObj ; |
|
491 |
|
492 __UHEAP_MARKEND ; |
|
493 return returnCode ; |
|
494 |
|
495 } |
|
496 |
|
497 |
|
498 // ----------------------------------------------------------------------------- |
|
499 // Ctsysconnectivity::SetWrongDataType |
|
500 // Tests setinfo with wrong data type |
|
501 // ----------------------------------------------------------------------------- |
|
502 // |
|
503 TInt Ctsysconnectivity::SetWrongDataType( CStifItemParser&/* aItem */) |
|
504 { |
|
505 |
|
506 __UHEAP_MARK; |
|
507 |
|
508 _LIT(KEntity,"Connectivity") ; |
|
509 _LIT(KKey,"InfraRed") ; |
|
510 |
|
511 TInt returnCode = KErrNone ; |
|
512 |
|
513 CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
514 |
|
515 if( NULL == CoreObj) |
|
516 { |
|
517 iLog->Log(_L8("Failed.. @Core")) ; |
|
518 return KErrGeneral ; |
|
519 } |
|
520 |
|
521 CStringData *ipData = CStringData::NewL(KEntity) ; |
|
522 |
|
523 TRAPD(leaveCode, CoreObj->SetInfoL(KEntity,KKey,ipData)) ; |
|
524 /* |
|
525 if(KErrArgument != leaveCode) |
|
526 { |
|
527 returnCode = KErrGeneral ; |
|
528 iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
529 } |
|
530 else |
|
531 { |
|
532 iLog->Log(_L8("Passed..")) ; |
|
533 } |
|
534 */ |
|
535 |
|
536 if(KErrNotFound == leaveCode) |
|
537 { |
|
538 iLog->Log(_L8("Passed..")) ; |
|
539 } |
|
540 else |
|
541 { |
|
542 returnCode = KErrGeneral ; |
|
543 iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
544 } |
|
545 |
|
546 |
|
547 delete ipData ; |
|
548 delete CoreObj ; |
|
549 |
|
550 __UHEAP_MARKEND ; |
|
551 return returnCode ; |
|
552 |
|
553 } |
|
554 |
|
555 |
|
556 // ----------------------------------------------------------------------------- |
|
557 // Ctsysconnectivity::SetWrongKey |
|
558 // Tests setinfo with wrong Key |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 TInt Ctsysconnectivity::SetWrongKey( CStifItemParser&/* aItem */) |
|
562 { |
|
563 |
|
564 __UHEAP_MARK; |
|
565 |
|
566 _LIT(KEntity,"Connectivity") ; |
|
567 _LIT(KKey,"InfraRedd") ; |
|
568 |
|
569 TInt returnCode = KErrNone ; |
|
570 |
|
571 CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
572 |
|
573 if( NULL == CoreObj) |
|
574 { |
|
575 iLog->Log(_L8("Failed.. @Core")) ; |
|
576 return KErrGeneral ; |
|
577 } |
|
578 |
|
579 CStatus *ipData = CStatus::NewL(returnCode) ; |
|
580 |
|
581 TRAPD(leaveCode, CoreObj->SetInfoL(KEntity,KKey,ipData)) ; |
|
582 |
|
583 if(KErrNotFound != leaveCode) |
|
584 { |
|
585 returnCode = KErrGeneral ; |
|
586 iLog->Log(_L8("Failed.. @TRAPD")) ; |
|
587 } |
|
588 else |
|
589 { |
|
590 iLog->Log(_L8("Passed..")) ; |
|
591 } |
|
592 |
|
593 delete ipData ; |
|
594 delete CoreObj ; |
|
595 |
|
596 __UHEAP_MARKEND ; |
|
597 return returnCode ; |
|
598 |
|
599 } |
|
600 |
|
601 |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // Ctsysconnectivity::ConnNotWithWrongKey |
|
605 // Example test method function. |
|
606 // (other items were commented in a header). |
|
607 // ----------------------------------------------------------------------------- |
|
608 // |
|
609 TInt Ctsysconnectivity::ConnNotWithWrongKey( CStifItemParser& /*aItem*/ ) |
|
610 { |
|
611 TInt Err = KErrNone ; |
|
612 TInt returnCode = KErrNone ; |
|
613 |
|
614 __UHEAP_MARK; |
|
615 |
|
616 CConnectivityNot *test = CConnectivityNot::NewL(iLog, 0); |
|
617 test->Start(); |
|
618 Err = test->Result(); |
|
619 delete test; |
|
620 |
|
621 if(KErrNotFound != Err) |
|
622 returnCode = KErrGeneral ; |
|
623 |
|
624 __UHEAP_MARKEND; |
|
625 return returnCode ; |
|
626 |
|
627 |
|
628 } |
|
629 // ----------------------------------------------------------------------------- |
|
630 // Ctsysconnectivity::?member_function |
|
631 // ?implementation_description |
|
632 // (other items were commented in a header). |
|
633 // ----------------------------------------------------------------------------- |
|
634 // |
|
635 /* |
|
636 TInt Ctsysconnectivity::?member_function( |
|
637 CItemParser& aItem ) |
|
638 { |
|
639 |
|
640 ?code |
|
641 |
|
642 } |
|
643 */ |
|
644 |
|
645 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
646 // None |
|
647 |
|
648 // End of File |