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