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: tsysinfoprovidergeneraltestsblocks |
|
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<f32file.h> |
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include <liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
27 |
#include<liwservicehandler.h> |
19 | 28 |
|
29 |
#include "tsysinfoprovidergeneraltests.h" |
|
30 |
#include "tuseractivitynotifier.h" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
31 |
#include "tmemnotifier.h" |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
32 |
#include "tcriticalmemnoti.h" |
19 | 33 |
#include "sysinfoservice.h" |
34 |
#include "sysinfointerface.h" |
|
35 |
#include"entitykeys.h" |
|
36 |
#include "sysinfoaiwparams.hrh" |
|
37 |
||
38 |
using namespace LIW ; |
|
39 |
using namespace SysInfo; |
|
40 |
using namespace sysinfoaiwparams; |
|
41 |
||
42 |
// ----------------------------------------------------------------------------- |
|
43 |
// CTSysInfoProviderGeneralTests::Delete |
|
44 |
// Delete here all resources allocated and opened from test methods. |
|
45 |
// Called from destructor. |
|
46 |
// ----------------------------------------------------------------------------- |
|
47 |
// |
|
48 |
void CTSysInfoProviderGeneralTests::Delete() |
|
49 |
{ |
|
50 |
||
51 |
} |
|
52 |
||
53 |
// ----------------------------------------------------------------------------- |
|
54 |
// CTSysInfoProviderGeneralTests::RunMethodL |
|
55 |
// Run specified method. Contains also table of test mothods and their names. |
|
56 |
// ----------------------------------------------------------------------------- |
|
57 |
// |
|
58 |
TInt CTSysInfoProviderGeneralTests::RunMethodL( |
|
59 |
CStifItemParser& aItem ) |
|
60 |
{ |
|
61 |
||
62 |
static TStifFunctionInfo const KFunctions[] = |
|
63 |
{ |
|
64 |
// Copy this line for every implemented function. |
|
65 |
// First string is the function name used in TestScripter script file. |
|
66 |
// Second is the actual implementation member function. |
|
67 |
ENTRY( "ConnectedAcc", CTSysInfoProviderGeneralTests::ConnectedAcc), |
|
68 |
ENTRY( "ConnNotification", CTSysInfoProviderGeneralTests::ConnNotification), |
|
69 |
ENTRY( "AccessoryList", CTSysInfoProviderGeneralTests::AccessoryList), |
|
70 |
||
71 |
// connectivity |
|
72 |
ENTRY( "ConnectionList", CTSysInfoProviderGeneralTests::ConnectionList), |
|
73 |
||
74 |
ENTRY( "MemoryCardNotifier-M", CTSysInfoProviderGeneralTests::MemoryCardNotifierL), |
|
75 |
ENTRY( "CriticalMemOnDriveC-M", CTSysInfoProviderGeneralTests::CriticalMemOnDriveCL), |
|
76 |
ENTRY( "CriticalMemOnDriveD-M", CTSysInfoProviderGeneralTests::CriticalMemOnDriveDL), |
|
77 |
ENTRY( "CriticalMemOnDriveE-M", CTSysInfoProviderGeneralTests::CriticalMemOnDriveEL), |
|
78 |
||
79 |
ENTRY( "UserActivityNotifier-M", CTSysInfoProviderGeneralTests::UserActivityNotifierL), |
|
80 |
ENTRY( "UserInactivityNotifier", CTSysInfoProviderGeneralTests::UserInactivityNotifierL) |
|
81 |
}; |
|
82 |
||
83 |
const TInt count = sizeof( KFunctions ) / |
|
84 |
sizeof( TStifFunctionInfo ); |
|
85 |
||
86 |
return RunInternalL( KFunctions, count, aItem ); |
|
87 |
||
88 |
} |
|
89 |
||
90 |
||
91 |
||
92 |
||
93 |
// ----------------------------------------------------------------------------- |
|
94 |
// CTSysInfoProviderGeneralTests::ConnectedAcc |
|
95 |
// |
|
96 |
// ----------------------------------------------------------------------------- |
|
97 |
// |
|
98 |
||
99 |
TInt CTSysInfoProviderGeneralTests::ConnectedAcc(CStifItemParser& /*aItem*/) |
|
100 |
{ |
|
101 |
||
102 |
_LIT( KExample, "ConnectedAcc:" ); |
|
103 |
iLog->Log( KExample ); |
|
104 |
TInt err = KErrNone; |
|
105 |
||
106 |
// On Emulator this is not supported. |
|
107 |
#if (! (defined(__WINS__) || defined(__WINSCW__)) ) |
|
108 |
||
109 |
__UHEAP_MARK; |
|
110 |
||
111 |
CLiwServiceHandler* iServiceHandler = CLiwServiceHandler::NewL(); |
|
112 |
CleanupStack::PushL(iServiceHandler); |
|
113 |
||
114 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
115 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
116 |
||
117 |
||
118 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KIDataSource,KService); |
|
119 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
120 |
||
121 |
RCriteriaArray a; |
|
122 |
a.AppendL(crit); |
|
123 |
||
124 |
iServiceHandler->AttachL(a); |
|
125 |
||
126 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
127 |
||
128 |
delete crit; |
|
129 |
a.Reset(); |
|
130 |
||
131 |
TInt pos = 0; |
|
132 |
MLiwInterface* interface = NULL; |
|
133 |
outparam->FindFirst( pos, KIDataSource ); |
|
134 |
if(pos != KErrNotFound) |
|
135 |
{ |
|
136 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
137 |
} |
|
138 |
||
139 |
outparam->Reset(); |
|
140 |
inparam->Reset(); |
|
141 |
||
142 |
||
143 |
if(interface) |
|
144 |
{ |
|
145 |
iLog->Log( _L("Interface loaded successfully") ); |
|
146 |
TLiwGenericParam entity; |
|
147 |
TLiwVariant entityname; |
|
148 |
TLiwGenericParam key; |
|
149 |
TLiwVariant keyname; |
|
150 |
||
151 |
entityname.Set(KGeneral); |
|
152 |
entity.SetNameAndValueL(KEntity,entityname); |
|
153 |
||
154 |
keyname.Set(KConnectedAccessories); |
|
155 |
key.SetNameAndValueL(KKey,keyname); |
|
156 |
||
157 |
inparam->AppendL(entity); |
|
158 |
||
159 |
inparam->AppendL(key); |
|
160 |
||
161 |
entity.Reset(); |
|
162 |
entityname.Reset(); |
|
163 |
key.Reset(); |
|
164 |
keyname.Reset(); |
|
165 |
||
166 |
iLog->Log( _L("Calling Getinfo") ); |
|
167 |
TRAP(err, interface->ExecuteCmdL(KGetInfo,*inparam,*outparam)); |
|
168 |
||
169 |
pos = 0 ; |
|
170 |
const TLiwGenericParam* output = outparam->FindFirst( pos,KErrorCode ); |
|
171 |
if(pos != KErrNotFound) |
|
172 |
{ |
|
173 |
err = (TInt)((*outparam)[pos].Value().AsTInt32()); |
|
174 |
} |
|
175 |
||
176 |
if(err >= KErrNone) |
|
177 |
{ |
|
178 |
pos = 0 ; |
|
179 |
||
180 |
const TLiwGenericParam* output = outparam->FindFirst( pos,KReturnValue ); |
|
181 |
||
182 |
||
183 |
if(output) |
|
184 |
{ |
|
185 |
iLog->Log( _L("KReturnValue found") ); |
|
186 |
const CLiwMap* Map = output->Value().AsMap(); |
|
187 |
if ( Map ) |
|
188 |
{ |
|
189 |
TLiwVariant data; |
|
190 |
Map->FindL(KAccessoryList,data); |
|
191 |
CLiwIterable* iterlist=data.AsIterable(); |
|
192 |
||
193 |
TInt32 testacctype= 0,testaccstatus= 0; |
|
194 |
if(iterlist) |
|
195 |
{ |
|
196 |
TLiwVariant iterdata; |
|
197 |
TInt count=0; |
|
198 |
while(iterlist->NextL(iterdata)) |
|
199 |
{ |
|
200 |
count++; |
|
201 |
const CLiwMap* Map = iterdata.AsMap(); |
|
202 |
if ( Map ) |
|
203 |
{ |
|
204 |
TLiwVariant acctype; |
|
205 |
if (Map->FindL(KAccessoryType,acctype)) |
|
206 |
{ |
|
207 |
testacctype = acctype.AsTInt32(); |
|
208 |
TBuf<50> buf=_L("Accessory Type: "); |
|
209 |
buf.AppendNum(testacctype); |
|
210 |
iLog->Log(buf); |
|
211 |
acctype.Reset(); |
|
212 |
} |
|
213 |
else |
|
214 |
{ |
|
215 |
iLog->Log( _L("KAccessoryType not found") ); |
|
216 |
} |
|
217 |
||
218 |
||
219 |
TLiwVariant accstatus; |
|
220 |
if(Map->FindL(KAccessoryState,accstatus)) |
|
221 |
{ |
|
222 |
TBuf<50> buf=_L("Accessory Status: "); |
|
223 |
TInt32 testaccstatus = accstatus.AsTInt32(); |
|
224 |
buf.AppendNum(testaccstatus); |
|
225 |
iLog->Log(buf); |
|
226 |
} |
|
227 |
else |
|
228 |
{ |
|
229 |
iLog->Log( _L("KAccessoryStatus not found") ); |
|
230 |
} |
|
231 |
} |
|
232 |
} |
|
233 |
iLog->Log( _L("Connected accessory count: %d"), count); |
|
234 |
iterdata.Reset(); |
|
235 |
} |
|
236 |
data.Reset(); |
|
237 |
}//map |
|
238 |
} |
|
239 |
}//err |
|
240 |
}//interface |
|
241 |
else |
|
242 |
{ |
|
243 |
iLog->Log( _L("Interface load failed") ); |
|
244 |
} |
|
245 |
||
246 |
inparam->Reset(); |
|
247 |
outparam->Reset(); |
|
248 |
||
249 |
interface->Close(); |
|
250 |
||
251 |
CleanupStack::PopAndDestroy( iServiceHandler ); |
|
252 |
||
253 |
__UHEAP_MARKEND; |
|
254 |
#endif |
|
255 |
return err; |
|
256 |
||
257 |
||
258 |
} |
|
259 |
||
260 |
// ----------------------------------------------------------------------------- |
|
261 |
// CTSysInfoProviderGeneralTests::ConnNotification |
|
262 |
// |
|
263 |
// ----------------------------------------------------------------------------- |
|
264 |
// |
|
265 |
TInt CTSysInfoProviderGeneralTests::ConnNotification(CStifItemParser& /*aItem*/) |
|
266 |
{ |
|
267 |
||
268 |
_LIT( KExample, "ConnNotification" ); |
|
269 |
iLog->Log( KExample ); |
|
270 |
||
271 |
int ret=0; |
|
272 |
// On Emulator this is not supported. |
|
273 |
// #if (! (defined(__WINS__) || defined(__WINSCW__)) ) |
|
274 |
||
275 |
ret = ConnectionNotification(iLog); |
|
276 |
// #endif |
|
277 |
||
278 |
if(ret==0) |
|
279 |
return KErrNone; |
|
280 |
else |
|
281 |
return KErrGeneral; |
|
282 |
} |
|
283 |
||
284 |
TInt CTSysInfoProviderGeneralTests::MemoryCardNotifierL(CStifItemParser& /*aItem*/) |
|
285 |
{ |
|
286 |
_LIT( KExample, "MemoryCardNotifierL" ); |
|
287 |
iLog->Log( KExample ); |
|
288 |
TInt RetVal(PASS); |
|
289 |
TInt32 Err(PASS); |
|
290 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
291 |
__UHEAP_MARK; |
|
292 |
||
293 |
CTestMemNotification* test = CTestMemNotification::NewL(iLog); |
|
294 |
test->Start(); |
|
295 |
Err |= test->Result(); |
|
296 |
delete test; |
|
297 |
||
298 |
__UHEAP_MARKEND; |
|
299 |
#endif |
|
300 |
return Err; |
|
301 |
} |
|
302 |
||
303 |
TInt CTSysInfoProviderGeneralTests::CriticalMemOnDriveCL(CStifItemParser& /*aItem*/) |
|
304 |
{ |
|
305 |
_LIT( KExample, "CriticalMemOnDriveCL" ); |
|
306 |
iLog->Log( KExample ); |
|
307 |
TInt RetVal(PASS); |
|
308 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
309 |
__UHEAP_MARK; |
|
310 |
||
311 |
CTCriticalMemNotification* test = CTCriticalMemNotification::NewL(iLog,EDriveC); |
|
312 |
test->Start(); |
|
313 |
RetVal = test->Result(); |
|
314 |
delete test; |
|
315 |
||
316 |
||
317 |
__UHEAP_MARKEND; |
|
318 |
#endif |
|
319 |
return RetVal; |
|
320 |
} |
|
321 |
||
322 |
TInt CTSysInfoProviderGeneralTests::CriticalMemOnDriveDL(CStifItemParser& /*aItem*/) |
|
323 |
{ |
|
324 |
_LIT( KExample, "CriticalMemOnDriveDL" ); |
|
325 |
iLog->Log( KExample ); |
|
326 |
TInt RetVal(PASS); |
|
327 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
328 |
__UHEAP_MARK; |
|
329 |
||
330 |
CTCriticalMemNotification* test = CTCriticalMemNotification::NewL(iLog,EDriveD); |
|
331 |
test->Start(); |
|
332 |
RetVal = test->Result(); |
|
333 |
delete test; |
|
334 |
||
335 |
__UHEAP_MARKEND; |
|
336 |
#endif |
|
337 |
return RetVal; |
|
338 |
} |
|
339 |
||
340 |
||
341 |
TInt CTSysInfoProviderGeneralTests::CriticalMemOnDriveEL(CStifItemParser& /*aItem*/) |
|
342 |
{ |
|
343 |
_LIT( KExample, "CriticalMemOnDriveEL" ); |
|
344 |
iLog->Log( KExample ); |
|
345 |
TInt RetVal(PASS); |
|
346 |
#if ( !(defined(__WINS__) || defined(__WINSCW__)) ) |
|
347 |
__UHEAP_MARK; |
|
348 |
||
349 |
CTCriticalMemNotification* test = CTCriticalMemNotification::NewL(iLog,EDriveE); |
|
350 |
test->Start(); |
|
351 |
RetVal = test->Result(); |
|
352 |
delete test; |
|
353 |
||
354 |
__UHEAP_MARKEND; |
|
355 |
#endif |
|
356 |
return RetVal; |
|
357 |
} |
|
358 |
||
359 |
TInt CTSysInfoProviderGeneralTests::UserActivityNotifierL(CStifItemParser& ) |
|
360 |
{ |
|
361 |
_LIT( KExample, "UserInactivityNotifierL" ); |
|
362 |
iLog->Log( KExample ); |
|
363 |
TInt Err(PASS); |
|
364 |
||
365 |
__UHEAP_MARK; |
|
366 |
||
367 |
CTestUserActivity* test = CTestUserActivity::NewL(iLog,1,CTestUserActivity::ETESTACTIVITY); |
|
368 |
test->Start(); |
|
369 |
Err = test->Result(); |
|
370 |
delete test; |
|
371 |
||
372 |
__UHEAP_MARKEND; |
|
373 |
||
374 |
return Err; |
|
375 |
} |
|
376 |
||
377 |
TInt CTSysInfoProviderGeneralTests::UserInactivityNotifierL(CStifItemParser& ) |
|
378 |
{ |
|
379 |
_LIT( KExample, "UserInactivityNotifierL" ); |
|
380 |
iLog->Log( KExample ); |
|
381 |
TInt Err(PASS); |
|
382 |
||
383 |
__UHEAP_MARK; |
|
384 |
||
385 |
CTestUserActivity* test = CTestUserActivity::NewL(iLog,1,CTestUserActivity::ETESTINACTIVITY); |
|
386 |
test->Start(); |
|
387 |
Err = test->Result(); |
|
388 |
delete test; |
|
389 |
||
390 |
__UHEAP_MARKEND; |
|
391 |
||
392 |
return Err; |
|
393 |
} |
|
394 |
||
395 |
// ----------------------------------------------------------------------------- |
|
396 |
// Ctsysinfoprovidertests::ConnectionList |
|
397 |
// checking for the iterator behaviour |
|
398 |
// |
|
399 |
// ----------------------------------------------------------------------------- |
|
400 |
// |
|
401 |
TInt CTSysInfoProviderGeneralTests::ConnectionList(CStifItemParser& /*aItem*/) |
|
402 |
{ |
|
403 |
int ret=0; |
|
404 |
// On Emulator this is not supported. |
|
405 |
// #if (! (defined(__WINS__) || defined(__WINSCW__)) ) |
|
406 |
||
407 |
ret = ConnList(iLog); |
|
408 |
// #endif |
|
409 |
||
410 |
if(ret==0) |
|
411 |
return KErrNone; |
|
412 |
else |
|
413 |
return KErrGeneral; |
|
414 |
} |
|
415 |
||
416 |
// ----------------------------------------------------------------------------- |
|
417 |
// Ctsysinfoprovidertests::ConnectionList |
|
418 |
// checking for the iterator behaviour |
|
419 |
// |
|
420 |
// ----------------------------------------------------------------------------- |
|
421 |
// |
|
422 |
TInt CTSysInfoProviderGeneralTests::AccessoryList(CStifItemParser& /*aItem*/) |
|
423 |
{ |
|
424 |
int ret=0; |
|
425 |
// On Emulator this is not supported. |
|
426 |
#if (! (defined(__WINS__) || defined(__WINSCW__)) ) |
|
427 |
||
428 |
ret = AccIter(iLog); |
|
429 |
#endif |
|
430 |
||
431 |
if(ret==0) |
|
432 |
return KErrNone; |
|
433 |
else |
|
434 |
return KErrGeneral; |
|
435 |
} |
|
436 |
||
437 |
||
438 |
//End of file |
|
439 |
||
440 |