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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include <e32svr.h> |
|
22 |
#include <StifParser.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
23 |
#include <StifTestInterface.h> |
19 | 24 |
#include <f32file.h> |
25 |
#include <hal.h> |
|
26 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#include "tsysbattery.h" |
19 | 28 |
#include "sysinfoservice.h" |
29 |
#include "entitykeys.h" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include "tbatterystrengthasyn.h" |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
31 |
#include "tbatlvlnoti.h" |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
32 |
#include "tchargernoti.h" |
19 | 33 |
#include "tbatstrnoti.h" |
34 |
||
35 |
using namespace SysInfo; |
|
36 |
||
37 |
// ----------------------------------------------------------------------------- |
|
38 |
// CTSysBattery::Delete |
|
39 |
// Delete here all resources allocated and opened from test methods. |
|
40 |
// Called from destructor. |
|
41 |
// ----------------------------------------------------------------------------- |
|
42 |
// |
|
43 |
void CTSysBattery::Delete() |
|
44 |
{ |
|
45 |
||
46 |
} |
|
47 |
||
48 |
// ----------------------------------------------------------------------------- |
|
49 |
// CTSysBattery::RunMethodL |
|
50 |
// Run specified method. Contains also table of test mothods and their names. |
|
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// |
|
53 |
TInt CTSysBattery::RunMethodL( |
|
54 |
CStifItemParser& aItem ) |
|
55 |
{ |
|
56 |
||
57 |
static TStifFunctionInfo const KFunctions[] = |
|
58 |
{ |
|
59 |
// Copy this line for every implemented function. |
|
60 |
// First string is the function name used in TestScripter script file. |
|
61 |
// Second is the actual implementation member function. |
|
62 |
ENTRY( "BatteryNotChargingSync-M", CTSysBattery::BatteryNotChargingL), |
|
63 |
ENTRY( "BatteryChargingSync-M", CTSysBattery::BatteryChargingL), |
|
64 |
ENTRY( "BatteryLevelSync-M", CTSysBattery::BatteryLevelL), |
|
65 |
ENTRY( "BatteryLvlNoti-M",CTSysBattery::BatteryLvlNotiL), |
|
66 |
ENTRY( "ChargeStateNoti-M",CTSysBattery::ChargeStateNotiL), |
|
67 |
ENTRY( "BatteryStrengthNoti-M",CTSysBattery::BatteryStrengthNotiL), |
|
68 |
}; |
|
69 |
||
70 |
const TInt count = sizeof( KFunctions ) / |
|
71 |
sizeof( TStifFunctionInfo ); |
|
72 |
||
73 |
return RunInternalL( KFunctions, count, aItem ); |
|
74 |
} |
|
75 |
||
76 |
TInt CTSysBattery::BatteryChargingL(CStifItemParser& ) |
|
77 |
{ |
|
78 |
_LIT( KExample, "BatteryChargingL" ); |
|
79 |
iLog->Log( KExample ); |
|
80 |
TInt Err(PASS); |
|
81 |
||
82 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
83 |
__UHEAP_MARK; |
|
84 |
CSysInfoService *obj = CSysInfoService::NewL(); |
|
85 |
CleanupStack::PushL(obj); |
|
86 |
||
87 |
CSysData* output=NULL; |
|
88 |
||
89 |
TRAPD(err,obj->GetInfoL(KBattery,KBatteryStrength,output)); |
|
90 |
if (!err) |
|
91 |
{ |
|
92 |
if(!output) |
|
93 |
{ |
|
94 |
Err |= FAIL; |
|
95 |
iLog->Log( _L("Output data Set to NULL") ); |
|
96 |
} |
|
97 |
else |
|
98 |
{ |
|
99 |
CleanupStack::PushL(output); |
|
100 |
//Check data type |
|
101 |
if( CSysData::EStatus != output->DataType() ) |
|
102 |
{ |
|
103 |
iLog->Log( _L("Invalid output data") ); |
|
104 |
Err |= FAIL; |
|
105 |
} |
|
106 |
else |
|
107 |
{ |
|
108 |
TInt ChargerState; |
|
109 |
ChargerState = ((CStatus*)output)->Status(); |
|
110 |
if( ECharging != ChargerState ) |
|
111 |
{ |
|
112 |
iLog->Log( _L("Incorrect charging state returned.. %d"),ChargerState ); |
|
113 |
Err |= FAIL; |
|
114 |
} |
|
115 |
} |
|
116 |
CleanupStack::PopAndDestroy(output); |
|
117 |
} |
|
118 |
} |
|
119 |
else |
|
120 |
{ |
|
121 |
Err |= err; |
|
122 |
iLog->Log( _L("GetInfo API returned error: %d"), err); |
|
123 |
} |
|
124 |
||
125 |
CleanupStack::PopAndDestroy(obj); |
|
126 |
__UHEAP_MARKEND; |
|
127 |
||
128 |
#endif |
|
129 |
return Err; |
|
130 |
} |
|
131 |
||
132 |
TInt CTSysBattery::BatteryNotChargingL(CStifItemParser& ) |
|
133 |
{ |
|
134 |
_LIT( KExample, "BatteryNotChargingL" ); |
|
135 |
iLog->Log( KExample ); |
|
136 |
TInt Err(PASS); |
|
137 |
||
138 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
139 |
__UHEAP_MARK; |
|
140 |
CSysInfoService *obj = CSysInfoService::NewL(); |
|
141 |
CleanupStack::PushL(obj); |
|
142 |
||
143 |
CSysData* output=NULL; |
|
144 |
||
145 |
TRAPD(err,obj->GetInfoL(KBattery,KChargingStatus,output)); |
|
146 |
if (!err) |
|
147 |
{ |
|
148 |
if(!output) |
|
149 |
{ |
|
150 |
Err |= FAIL; |
|
151 |
iLog->Log( _L("Output data Set to NULL") ); |
|
152 |
} |
|
153 |
else |
|
154 |
{ |
|
155 |
CleanupStack::PushL(output); |
|
156 |
//Check data type |
|
157 |
if( CSysData::EStatus != output->DataType() ) |
|
158 |
{ |
|
159 |
iLog->Log( _L("Invalid output data") ); |
|
160 |
Err |= FAIL; |
|
161 |
} |
|
162 |
else |
|
163 |
{ |
|
164 |
TInt ChargerState; |
|
165 |
ChargerState = ((CStatus*)output)->Status(); |
|
166 |
if( ENotCharging != ChargerState ) |
|
167 |
{ |
|
168 |
iLog->Log( _L("Incorrect charging state returned.. %d"),ChargerState ); |
|
169 |
Err |= FAIL; |
|
170 |
} |
|
171 |
} |
|
172 |
CleanupStack::PopAndDestroy(output); |
|
173 |
} |
|
174 |
} |
|
175 |
else |
|
176 |
{ |
|
177 |
Err |= err; |
|
178 |
iLog->Log( _L("GetInfo API returned error: %d"), err); |
|
179 |
} |
|
180 |
||
181 |
CleanupStack::PopAndDestroy(obj); |
|
182 |
__UHEAP_MARKEND; |
|
183 |
||
184 |
#endif |
|
185 |
return Err; |
|
186 |
} |
|
187 |
||
188 |
TInt CTSysBattery::BatteryLevelL(CStifItemParser& /*aItem*/) |
|
189 |
{ |
|
190 |
_LIT( KExample, "BatteryLevelL" ); |
|
191 |
iLog->Log( KExample ); |
|
192 |
TInt Err(PASS); |
|
193 |
||
194 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
195 |
__UHEAP_MARK; |
|
196 |
CSysInfoService *obj = CSysInfoService::NewL(); |
|
197 |
CleanupStack::PushL(obj); |
|
198 |
||
199 |
CSysData* output=NULL; |
|
200 |
||
201 |
_LIT(KBatteryLevel,"BatteryLevel"); |
|
202 |
||
203 |
TRAPD(err,obj->GetInfoL(KBattery,KBatteryLevel,output)); |
|
204 |
if ( err == KErrNotFound ) |
|
205 |
{ |
|
206 |
Err = PASS; |
|
207 |
iLog->Log( _L("Battery Level Not supported ")); |
|
208 |
} |
|
209 |
else |
|
210 |
{ |
|
211 |
Err |= FAIL; |
|
212 |
iLog->Log( _L("GetInfo API returned error: %d Expected Error: %d"), err,KErrNotFound); |
|
213 |
} |
|
214 |
||
215 |
CleanupStack::PopAndDestroy(obj); |
|
216 |
__UHEAP_MARKEND; |
|
217 |
||
218 |
#endif |
|
219 |
return Err; |
|
220 |
} |
|
221 |
||
222 |
TInt CTSysBattery::BatteryLvlNotiL(CStifItemParser&) |
|
223 |
{ |
|
224 |
_LIT( KExample, "BatteryLvlNotiL" ); |
|
225 |
iLog->Log( KExample ); |
|
226 |
TInt Err(PASS); |
|
227 |
||
228 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
229 |
__UHEAP_MARK; |
|
230 |
||
231 |
CSysInfoService *obj = CSysInfoService::NewL(); |
|
232 |
CleanupStack::PushL(obj); |
|
233 |
||
234 |
_LIT(KBatteryLevel,"BatteryLevel"); |
|
235 |
||
236 |
TRAPD(err,obj->GetNotificationL(KBattery,KBatteryLevel,1,this)); |
|
237 |
if ( err == KErrNotFound ) |
|
238 |
{ |
|
239 |
Err = PASS; |
|
240 |
iLog->Log( _L("Battery Level Not supported ")); |
|
241 |
} |
|
242 |
else |
|
243 |
{ |
|
244 |
Err |= FAIL; |
|
245 |
iLog->Log( _L("GetInfo API returned error: %d Expected Error: %d"), err,KErrNotFound); |
|
246 |
} |
|
247 |
||
248 |
CleanupStack::PopAndDestroy(obj); |
|
249 |
__UHEAP_MARKEND; |
|
250 |
#endif |
|
251 |
return Err; |
|
252 |
} |
|
253 |
||
254 |
||
255 |
void CTSysBattery::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/, |
|
256 |
CSysData* /*aOutput*/, TInt32 /*aTransID*/, TSysRequest::TRequestType /*aType*/,TInt /*aError*/) |
|
257 |
{ |
|
258 |
||
259 |
} |
|
260 |
TInt CTSysBattery::ChargeStateNotiL(CStifItemParser&) |
|
261 |
{ |
|
262 |
_LIT( KExample, "ChargeStateNotiL" ); |
|
263 |
iLog->Log( KExample ); |
|
264 |
TInt Err(PASS); |
|
265 |
||
266 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
267 |
__UHEAP_MARK; |
|
268 |
||
269 |
CChargerNoti* test = CChargerNoti::NewL(iLog); |
|
270 |
test->Start(); |
|
271 |
Err = test->Result(); |
|
272 |
delete test; |
|
273 |
||
274 |
__UHEAP_MARKEND; |
|
275 |
#endif |
|
276 |
return Err; |
|
277 |
} |
|
278 |
||
279 |
TInt CTSysBattery::BatteryStrengthNotiL(CStifItemParser&) |
|
280 |
{ |
|
281 |
_LIT( KExample, "BatteryStrengthNotiL" ); |
|
282 |
iLog->Log( KExample ); |
|
283 |
TInt Err(PASS); |
|
284 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
285 |
__UHEAP_MARK; |
|
286 |
||
287 |
CBatStrengthNoti* test = CBatStrengthNoti::NewL(iLog); |
|
288 |
test->Start(); |
|
289 |
Err = test->Result(); |
|
290 |
delete test; |
|
291 |
#endif |
|
292 |
__UHEAP_MARKEND; |
|
293 |
return Err; |
|
294 |
} |