|
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 battery information |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32svr.h> |
|
23 #include <StifParser.h> |
|
24 #include <Stiftestinterface.h> |
|
25 #include "tsysbattery.h" |
|
26 #include "tsysbatterystrengthasync.h" |
|
27 #include "tsysbatterynot.h" |
|
28 |
|
29 using namespace SysInfo; |
|
30 |
|
31 // EXTERNAL DATA STRUCTURES |
|
32 //extern ?external_data; |
|
33 |
|
34 // EXTERNAL FUNCTION PROTOTYPES |
|
35 //extern ?external_function( ?arg_type,?arg_type ); |
|
36 |
|
37 // CONSTANTS |
|
38 //const ?type ?constant_var = ?constant; |
|
39 |
|
40 // MACROS |
|
41 //#define ?macro ?macro_def |
|
42 |
|
43 // LOCAL CONSTANTS AND MACROS |
|
44 //const ?type ?constant_var = ?constant; |
|
45 //#define ?macro_name ?macro_def |
|
46 |
|
47 // MODULE DATA STRUCTURES |
|
48 //enum ?declaration |
|
49 //typedef ?declaration |
|
50 |
|
51 // LOCAL FUNCTION PROTOTYPES |
|
52 //?type ?function_name( ?arg_type, ?arg_type ); |
|
53 |
|
54 // FORWARD DECLARATIONS |
|
55 //class ?FORWARD_CLASSNAME; |
|
56 |
|
57 // ============================= LOCAL FUNCTIONS =============================== |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // ?function_name ?description. |
|
61 // ?description |
|
62 // Returns: ?value_1: ?description |
|
63 // ?value_n: ?description_line1 |
|
64 // ?description_line2 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 /* |
|
68 ?type ?function_name( |
|
69 ?arg_type arg, // ?description |
|
70 ?arg_type arg) // ?description |
|
71 { |
|
72 |
|
73 ?code // ?comment |
|
74 |
|
75 // ?comment |
|
76 ?code |
|
77 } |
|
78 */ |
|
79 |
|
80 // ============================ MEMBER FUNCTIONS =============================== |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // Ctsysbattery::Delete |
|
84 // Delete here all resources allocated and opened from test methods. |
|
85 // Called from destructor. |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void Ctsysbattery::Delete() |
|
89 { |
|
90 |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // Ctsysbattery::RunMethodL |
|
95 // Run specified method. Contains also table of test mothods and their names. |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 TInt Ctsysbattery::RunMethodL( |
|
99 CStifItemParser& aItem ) |
|
100 { |
|
101 |
|
102 static TStifFunctionInfo const KFunctions[] = |
|
103 { |
|
104 // Copy this line for every implemented function. |
|
105 // First string is the function name used in TestScripter script file. |
|
106 // Second is the actual implementation member function. |
|
107 |
|
108 ENTRY( "WrongKey", Ctsysbattery::WrongKey ), |
|
109 ENTRY( "BatteryLevelAsync", Ctsysbattery::BatteryLevelAsync ), |
|
110 ENTRY( "BatteryNotWrongData", Ctsysbattery::BatteryNotWrongData ), |
|
111 ENTRY( "BatteryNotWrongKey", Ctsysbattery::BatteryNotWrongKey ), |
|
112 }; |
|
113 |
|
114 const TInt count = sizeof( KFunctions ) / |
|
115 sizeof( TStifFunctionInfo ); |
|
116 |
|
117 return RunInternalL( KFunctions, count, aItem ); |
|
118 |
|
119 } |
|
120 |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // Ctsysbattery::WrongKey |
|
124 // Test for wrong key input values |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt Ctsysbattery::WrongKey( CStifItemParser& /*aItem*/ ) |
|
128 { |
|
129 |
|
130 __UHEAP_MARK; |
|
131 |
|
132 _LIT(KEntity,"Battery") ; |
|
133 _LIT(KKey,"StatusCharging") ; |
|
134 |
|
135 TInt returnCode = KErrNone ; |
|
136 |
|
137 CSysInfoService *CoreObj = CSysInfoService :: NewL() ; |
|
138 |
|
139 if( NULL == CoreObj) |
|
140 { |
|
141 iLog->Log(_L8("Failed.. @Core")) ; |
|
142 return KErrGeneral ; |
|
143 } |
|
144 |
|
145 CSysData *sysData ; |
|
146 |
|
147 TRAPD(leaveCode, CoreObj->GetInfoL(KEntity,KKey,sysData)) ; |
|
148 if(KErrNotFound == leaveCode) |
|
149 { |
|
150 iLog->Log(_L8("Passed..")) ; |
|
151 } |
|
152 else |
|
153 { |
|
154 returnCode = KErrGeneral ; |
|
155 iLog->Log(_L8("Failed..")) ; |
|
156 } |
|
157 |
|
158 delete CoreObj ; |
|
159 |
|
160 __UHEAP_MARKEND ; |
|
161 return returnCode ; |
|
162 |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // Ctsysbattery::BatteryLevelAsync |
|
167 // Tests Getinfo() for battery level information throws KErrNotSupported |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 TInt Ctsysbattery::BatteryLevelAsync( CStifItemParser& /*aItem*/ ) |
|
171 { |
|
172 TInt Err ; |
|
173 TInt returnCode = KErrNone ; |
|
174 |
|
175 __UHEAP_MARK; |
|
176 |
|
177 CBatteryStrengthAsync* test = CBatteryStrengthAsync::NewL(iLog); |
|
178 test->Start(); |
|
179 Err = test->Result(); |
|
180 delete test; |
|
181 |
|
182 if( KErrNotFound == Err ) |
|
183 returnCode = KErrNone ; |
|
184 else |
|
185 returnCode = KErrGeneral ; |
|
186 |
|
187 |
|
188 __UHEAP_MARKEND ; |
|
189 return returnCode ; |
|
190 |
|
191 } |
|
192 |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // Ctsysbattery::BatteryNotWrongData |
|
196 // Example test method function. |
|
197 // (other items were commented in a header). |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 TInt Ctsysbattery::BatteryNotWrongData( CStifItemParser& /*aItem*/ ) |
|
201 { |
|
202 TInt Err = KErrNone ; |
|
203 TInt returnCode = KErrNone ; |
|
204 |
|
205 __UHEAP_MARK; |
|
206 |
|
207 CBatteryNot *test = CBatteryNot::NewL(iLog, 0); |
|
208 test->Start(); |
|
209 Err = test->Result(); |
|
210 delete test; |
|
211 |
|
212 if(KErrArgument != Err) |
|
213 returnCode = KErrGeneral ; |
|
214 |
|
215 __UHEAP_MARKEND; |
|
216 return returnCode ; |
|
217 |
|
218 |
|
219 } |
|
220 |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // Ctsysbattery::BatteryNotWrongKey |
|
224 // Example test method function. |
|
225 // (other items were commented in a header). |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 TInt Ctsysbattery::BatteryNotWrongKey( CStifItemParser& /*aItem*/ ) |
|
229 { |
|
230 TInt Err = KErrNone ; |
|
231 TInt returnCode = KErrNone ; |
|
232 |
|
233 __UHEAP_MARK; |
|
234 |
|
235 CBatteryNot *test = CBatteryNot::NewL(iLog, 1); |
|
236 test->Start(); |
|
237 Err = test->Result(); |
|
238 delete test; |
|
239 |
|
240 if(KErrNotFound != Err) |
|
241 returnCode = KErrGeneral ; |
|
242 |
|
243 __UHEAP_MARKEND; |
|
244 return returnCode ; |
|
245 |
|
246 |
|
247 } |
|
248 |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // Ctsysbattery::?member_function |
|
252 // ?implementation_description |
|
253 // (other items were commented in a header). |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 /* |
|
257 TInt Ctsysbattery::?member_function( |
|
258 CItemParser& aItem ) |
|
259 { |
|
260 |
|
261 ?code |
|
262 |
|
263 } |
|
264 */ |
|
265 |
|
266 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
267 // None |
|
268 |
|
269 // End of File |