57
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 "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: This file contains testclass implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// [INCLUDE FILES] - do not remove
|
|
19 |
#include <e32svr.h>
|
|
20 |
#include <e32cmn.h>
|
|
21 |
#include <StifParser.h>
|
|
22 |
#include <Stiftestinterface.h>
|
|
23 |
#include <data_caging_path_literals.hrh>
|
|
24 |
#include <centralrepository.h>
|
|
25 |
#include<RadioStubManager.h>
|
|
26 |
#include <ctsydomainpskeys.h>
|
|
27 |
#include <publicruntimeids.hrh>
|
|
28 |
#include <sacls.h>
|
|
29 |
|
|
30 |
#include "UtilsTestModule.h"
|
|
31 |
#include "cradiosystemeventcollector.h"
|
|
32 |
#include "radioengineutils.h"
|
|
33 |
|
|
34 |
|
|
35 |
// EXTERNAL DATA STRUCTURES
|
|
36 |
//extern ?external_data;
|
|
37 |
|
|
38 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
39 |
//extern ?external_function( ?arg_type,?arg_type );
|
|
40 |
|
|
41 |
// CONSTANTS
|
|
42 |
//const ?type ?constant_var = ?constant;
|
|
43 |
//_LIT( KStifScriptEmptyString, "EMPTYSTRING" );
|
|
44 |
//_LIT( KEmptyString, "" );
|
|
45 |
_LIT_SECURITY_POLICY_PASS(KRadioServerReadPolicy);
|
|
46 |
_LIT_SECURITY_POLICY_C1(KRadioServerWritePolicy, ECapabilityWriteUserData);
|
|
47 |
|
|
48 |
// MACROS
|
|
49 |
//#define ?macro ?macro_def
|
|
50 |
|
|
51 |
// LOCAL CONSTANTS AND MACROS
|
|
52 |
//const ?type ?constant_var = ?constant;
|
|
53 |
//#define ?macro_name ?macro_def
|
|
54 |
|
|
55 |
// MODULE DATA STRUCTURES
|
|
56 |
//enum ?declaration
|
|
57 |
//typedef ?declaration
|
|
58 |
|
|
59 |
// LOCAL FUNCTION PROTOTYPES
|
|
60 |
//?type ?function_name( ?arg_type, ?arg_type );
|
|
61 |
|
|
62 |
// FORWARD DECLARATIONS
|
|
63 |
//class ?FORWARD_CLASSNAME;
|
|
64 |
|
|
65 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// ?function_name ?description.
|
|
69 |
// ?description
|
|
70 |
// Returns: ?value_1: ?description
|
|
71 |
// ?value_n: ?description_line1
|
|
72 |
// ?description_line2
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
/*
|
|
76 |
?type ?function_name(
|
|
77 |
?arg_type arg, // ?description
|
|
78 |
?arg_type arg) // ?description
|
|
79 |
{
|
|
80 |
|
|
81 |
?code // ?comment
|
|
82 |
|
|
83 |
// ?comment
|
|
84 |
?code
|
|
85 |
}
|
|
86 |
*/
|
|
87 |
|
|
88 |
|
|
89 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
90 |
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
// CPresetUtilityTestModule::Delete
|
|
93 |
// Delete here all resources allocated and opened from test methods.
|
|
94 |
// Called from destructor.
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
void CUtilsTestModule::Delete()
|
|
98 |
{
|
|
99 |
FUNC_LOG;
|
|
100 |
|
|
101 |
}
|
|
102 |
|
|
103 |
// -----------------------------------------------------------------------------
|
|
104 |
// CUtilsTestModule::RunMethodL
|
|
105 |
// Run specified method. Contains also table of test mothods and their names.
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
TInt CUtilsTestModule::RunMethodL(
|
|
109 |
CStifItemParser& aItem )
|
|
110 |
{
|
|
111 |
FUNC_LOG;
|
|
112 |
|
|
113 |
static TStifFunctionInfo const KFunctions[] =
|
|
114 |
{
|
|
115 |
// Copy this line for every implemented function.
|
|
116 |
// First string is the function name used in TestScripter script file.
|
|
117 |
// Second is the actual implementation member function.
|
|
118 |
ENTRY( "Example", CUtilsTestModule::ExampleL ),
|
|
119 |
// [test cases entries] - Do not remove
|
|
120 |
ENTRY( "CreateSystemEventCollectorL", CUtilsTestModule::CreateSystemEventCollectorL ),
|
|
121 |
ENTRY( "DestroySystemEventCollector", CUtilsTestModule::DestroySystemEventCollector ),
|
|
122 |
ENTRY( "IsNetworkCoverage", CUtilsTestModule::IsNetworkCoverage ),
|
|
123 |
ENTRY( "IsMobileNetworkCoverage", CUtilsTestModule::IsMobileNetworkCoverage ),
|
|
124 |
ENTRY( "IsCallActive", CUtilsTestModule::IsCallActive ),
|
|
125 |
ENTRY( "IsAudioResourcesAvailable", CUtilsTestModule::IsAudioResourcesAvailable ),
|
|
126 |
ENTRY( "IsHeadsetConnectedL", CUtilsTestModule::IsHeadsetConnectedL ),
|
|
127 |
ENTRY( "OOMTestForCreation", CUtilsTestModule::OOMTestForCreation ),
|
|
128 |
ENTRY( "tstSetPropertyValueForHeadset", CUtilsTestModule::tstSetPropertyValueForHeadset ),
|
|
129 |
ENTRY( "tstSetPropertyValueForNetworkStatus", CUtilsTestModule::tstSetPropertyValueForNetworkStatus ),
|
|
130 |
ENTRY( "tstSetPropertyValueForCallState", CUtilsTestModule::tstSetPropertyValueForCallState ),
|
|
131 |
ENTRY( "CreateAudioRouterL", CUtilsTestModule::CreateAudioRouterL ),
|
|
132 |
ENTRY( "DestroyAudioRouter", CUtilsTestModule::DestroyAudioRouter ),
|
|
133 |
ENTRY( "OOMTestForAudioRouterCreation", CUtilsTestModule::OOMTestForAudioRouterCreation ),
|
|
134 |
ENTRY( "CreateRoutableAudioL", CUtilsTestModule::CreateRoutableAudioL ),
|
|
135 |
ENTRY( "DestroyRoutableAudio", CUtilsTestModule::DestroyRoutableAudio ),
|
|
136 |
ENTRY( "OOMTestForRoutableAudioCreation", CUtilsTestModule::OOMTestForRoutableAudioCreation )
|
|
137 |
//ADD NEW ENTRY HERE
|
|
138 |
|
|
139 |
};
|
|
140 |
|
|
141 |
const TInt count = sizeof( KFunctions ) /
|
|
142 |
sizeof( TStifFunctionInfo );
|
|
143 |
|
|
144 |
return RunInternalL( KFunctions, count, aItem );
|
|
145 |
|
|
146 |
}
|
|
147 |
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
// CUtilsTestModule::ExampleL
|
|
150 |
// Example test method function.
|
|
151 |
// (other items were commented in a header).
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
TInt CUtilsTestModule::ExampleL( CStifItemParser& aItem )
|
|
155 |
{
|
|
156 |
FUNC_LOG;
|
|
157 |
|
|
158 |
// Print to UI
|
|
159 |
_LIT( KSettingsTestModule, "UtilsTestModule" );
|
|
160 |
_LIT( KExample, "In Example" );
|
|
161 |
TestModuleIf().Printf( 0, KSettingsTestModule, KExample );
|
|
162 |
// Print to log file
|
|
163 |
iLog->Log( KExample );
|
|
164 |
|
|
165 |
TInt i = 0;
|
|
166 |
TPtrC string;
|
|
167 |
_LIT( KParam, "Param[%i]: %S" );
|
|
168 |
while ( aItem.GetNextString ( string ) == KErrNone )
|
|
169 |
{
|
|
170 |
TestModuleIf().Printf( i, KSettingsTestModule,
|
|
171 |
KParam, i, &string );
|
|
172 |
++i;
|
|
173 |
}
|
|
174 |
|
|
175 |
return KErrNone;
|
|
176 |
|
|
177 |
}
|
|
178 |
|
|
179 |
//-----------------------------------------------------------------------------
|
|
180 |
// CPresetUtilityTest::CreateSystemEventCollectorL
|
|
181 |
//-----------------------------------------------------------------------------
|
|
182 |
TInt CUtilsTestModule::CreateSystemEventCollectorL(CStifItemParser& /*aItem*/)
|
|
183 |
{
|
|
184 |
FUNC_LOG;
|
|
185 |
|
|
186 |
TInt err(KErrNone);
|
|
187 |
err = InitSharedMemory();
|
|
188 |
if ( KErrNone == err )
|
|
189 |
{
|
|
190 |
tstDefineAndAttachTestProperties();
|
|
191 |
}
|
|
192 |
if ((!iSystemEventCollector) && (KErrNone == err))
|
|
193 |
{
|
|
194 |
TRAP( err, RadioEngineUtils::InitializeL(); );
|
|
195 |
if (KErrNone != err)
|
|
196 |
{
|
|
197 |
INFO_1( "RadioEngineUtils::InitializeL() failed err = %i", err )
|
|
198 |
iRadioStubManagerChunk.Close();
|
|
199 |
}
|
|
200 |
else
|
|
201 |
{
|
|
202 |
TRAP( err, iSystemEventCollector = CRadioSystemEventCollector::NewL(); );
|
|
203 |
if ( KErrNone == err )
|
|
204 |
{
|
|
205 |
TRAP( err, iSystemEventCollector->AddObserverL( this ); );
|
|
206 |
if ( KErrNone != err )
|
|
207 |
{
|
|
208 |
INFO_1( "iSystemEventCollector->AddObserverL() failed err = %i", err )
|
|
209 |
iRadioStubManagerChunk.Close();
|
|
210 |
delete iSystemEventCollector;
|
|
211 |
iSystemEventCollector = NULL;
|
|
212 |
RadioEngineUtils::Release();
|
|
213 |
}
|
|
214 |
}
|
|
215 |
else
|
|
216 |
{
|
|
217 |
INFO_1( "CRadioSystemEventCollector::NewL() failed err = %i", err )
|
|
218 |
iRadioStubManagerChunk.Close();
|
|
219 |
RadioEngineUtils::Release();
|
|
220 |
}
|
|
221 |
}
|
|
222 |
}
|
|
223 |
if ( KErrNoMemory == err )
|
|
224 |
{
|
|
225 |
User::Leave( err );
|
|
226 |
}
|
|
227 |
MRadioAudioRoutingObserver* observer(NULL);
|
|
228 |
iSystemEventCollector->AsObserver( observer );
|
|
229 |
if (NULL == observer)
|
|
230 |
{
|
|
231 |
INFO("Null pointer got for MRadioAudioRoutingObserver from MRadioAudioRoutingObserver from iSystemEventCollector->AsObserver.");
|
|
232 |
}
|
|
233 |
return err;
|
|
234 |
}
|
|
235 |
|
|
236 |
//-----------------------------------------------------------------------------
|
|
237 |
// CUtilsTestModule::DestroySystemEventCollector
|
|
238 |
//-----------------------------------------------------------------------------
|
|
239 |
TInt CUtilsTestModule::DestroySystemEventCollector(CStifItemParser& /*aItem*/)
|
|
240 |
{
|
|
241 |
FUNC_LOG;
|
|
242 |
if (iSystemEventCollector)
|
|
243 |
{
|
|
244 |
iSystemEventCollector->RemoveObserver(this);
|
|
245 |
iRadioStubManagerChunk.Close();
|
|
246 |
delete iSystemEventCollector;
|
|
247 |
iSystemEventCollector = NULL;
|
|
248 |
RadioEngineUtils::Release();
|
|
249 |
iPropertyHeadsetStatus.Delete(KStub_KRadioPSUid, SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected);
|
|
250 |
iPropertyHeadsetStatus.Close();
|
|
251 |
iPropertyNetworkStatus.Delete(KStub_KUidSystemCategory, KUidNetworkStatusValue);
|
|
252 |
iPropertyNetworkStatus.Close();
|
|
253 |
iPropertyCallState.Delete(KStub_KPSUidCtsyCallInformation, KCTsyCallState);
|
|
254 |
iPropertyCallState.Close();
|
|
255 |
}
|
|
256 |
return KErrNone;
|
|
257 |
}
|
|
258 |
|
|
259 |
//-----------------------------------------------------------------------------
|
|
260 |
// CUtilsTestModule::OOMTestForCreation
|
|
261 |
//-----------------------------------------------------------------------------
|
|
262 |
TInt CUtilsTestModule::OOMTestForCreation(CStifItemParser& /*aItem*/)
|
|
263 |
{
|
|
264 |
FUNC_LOG;
|
|
265 |
TInt err(KErrNone);
|
|
266 |
err = InitSharedMemory();
|
|
267 |
if (KErrNone == err)
|
|
268 |
{
|
|
269 |
RadioEngineUtils::InitializeL();
|
|
270 |
TInt i(-1);
|
|
271 |
for (err = KErrNoMemory; KErrNoMemory == err; __UHEAP_MARKEND)
|
|
272 |
{
|
|
273 |
TRAP ( err,
|
|
274 |
{
|
|
275 |
++i;
|
|
276 |
INFO_1("loop count = %i", i );
|
|
277 |
__UHEAP_MARK;
|
|
278 |
__UHEAP_FAILNEXT( i );
|
|
279 |
TRAP( err, CreateSystemEventCollector2L(); );
|
|
280 |
if ( iSystemEventCollector )
|
|
281 |
{
|
|
282 |
delete iSystemEventCollector;
|
|
283 |
iSystemEventCollector = NULL;
|
|
284 |
}
|
|
285 |
}
|
|
286 |
);
|
|
287 |
}
|
|
288 |
__UHEAP_RESET;
|
|
289 |
RadioEngineUtils::Release();
|
|
290 |
iRadioStubManagerChunk.Close();
|
|
291 |
}
|
|
292 |
return err;
|
|
293 |
}
|
|
294 |
|
|
295 |
// -----------------------------------------------------------------------------
|
|
296 |
// CUtilsTestModule::IsNetworkCoverage()
|
|
297 |
// Returns: Errors.
|
|
298 |
// -----------------------------------------------------------------------------
|
|
299 |
TInt CUtilsTestModule::IsNetworkCoverage(CStifItemParser& aItem)
|
|
300 |
{
|
|
301 |
FUNC_LOG;
|
|
302 |
TInt err(KErrNone);
|
|
303 |
TBool expectedNetworkCoverageStatus(EFalse);
|
|
304 |
// read parameters
|
|
305 |
if (aItem.GetNextInt(expectedNetworkCoverageStatus))
|
|
306 |
{
|
|
307 |
err = KErrBadTestParameter;
|
|
308 |
ERROR(err, "Missing Parameter: expectedNetworkCoverageStatus.");
|
|
309 |
}
|
|
310 |
TBool networkCoverageStatus(iSystemEventCollector->IsNetworkCoverage());
|
|
311 |
if (expectedNetworkCoverageStatus != networkCoverageStatus)
|
|
312 |
{
|
|
313 |
INFO_2(
|
|
314 |
"Failed: networkCoverageStatus=%i, expectedNetworkCoverageStatus=%i.",
|
|
315 |
networkCoverageStatus, expectedNetworkCoverageStatus);
|
|
316 |
err = KErrUnexpectedValue;
|
|
317 |
}
|
|
318 |
return err;
|
|
319 |
}
|
|
320 |
|
|
321 |
// -----------------------------------------------------------------------------
|
|
322 |
// CUtilsTestModule::IsMobileNetworkCoverage()
|
|
323 |
// Returns: Errors.
|
|
324 |
// -----------------------------------------------------------------------------
|
|
325 |
TInt CUtilsTestModule::IsMobileNetworkCoverage(CStifItemParser& aItem)
|
|
326 |
{
|
|
327 |
FUNC_LOG;
|
|
328 |
TInt err(KErrNone);
|
|
329 |
TBool expectedMobileNetworkCoverageStatus(EFalse);
|
|
330 |
// read parameters
|
|
331 |
if (aItem.GetNextInt(expectedMobileNetworkCoverageStatus))
|
|
332 |
{
|
|
333 |
err = KErrBadTestParameter;
|
|
334 |
ERROR(err, "Missing Parameter: expectedMobileNetworkCoverageStatus.");
|
|
335 |
}
|
|
336 |
TBool mobileNetworkCoverageStatus(
|
|
337 |
iSystemEventCollector->IsMobileNetworkCoverage());
|
|
338 |
if (expectedMobileNetworkCoverageStatus != mobileNetworkCoverageStatus)
|
|
339 |
{
|
|
340 |
INFO_2(
|
|
341 |
"Failed: mobileNetworkCoverageStatus=%i, expectedMobileNetworkCoverageStatus=%i.",
|
|
342 |
mobileNetworkCoverageStatus,
|
|
343 |
expectedMobileNetworkCoverageStatus);
|
|
344 |
err = KErrUnexpectedValue;
|
|
345 |
}
|
|
346 |
return err;
|
|
347 |
}
|
|
348 |
|
|
349 |
// -----------------------------------------------------------------------------
|
|
350 |
// CUtilsTestModule::IsCallActive()
|
|
351 |
// Returns: Errors.
|
|
352 |
// -----------------------------------------------------------------------------
|
|
353 |
TInt CUtilsTestModule::IsCallActive(CStifItemParser& aItem)
|
|
354 |
{
|
|
355 |
FUNC_LOG;
|
|
356 |
TInt err(KErrNone);
|
|
357 |
TBool expectedCallActiveStatus(EFalse);
|
|
358 |
// read parameters
|
|
359 |
if (aItem.GetNextInt(expectedCallActiveStatus))
|
|
360 |
{
|
|
361 |
err = KErrBadTestParameter;
|
|
362 |
ERROR(err, "Missing Parameter: expectedCallActiveStatus.");
|
|
363 |
}
|
|
364 |
TBool callActiveStatus(iSystemEventCollector->IsCallActive());
|
|
365 |
if (expectedCallActiveStatus != callActiveStatus)
|
|
366 |
{
|
|
367 |
INFO_2("Failed: callActiveStatus=%i, expectedCallActiveStatus=%i.",
|
|
368 |
callActiveStatus, expectedCallActiveStatus);
|
|
369 |
err = KErrUnexpectedValue;
|
|
370 |
}
|
|
371 |
return err;
|
|
372 |
}
|
|
373 |
|
|
374 |
// -----------------------------------------------------------------------------
|
|
375 |
// CUtilsTestModule::IsAudioResourcesAvailable()
|
|
376 |
// Returns: Errors.
|
|
377 |
// -----------------------------------------------------------------------------
|
|
378 |
TInt CUtilsTestModule::IsAudioResourcesAvailable(CStifItemParser& aItem)
|
|
379 |
{
|
|
380 |
FUNC_LOG;
|
|
381 |
TInt err(KErrNone);
|
|
382 |
TBool expectedAudioResourcesAvailableStatus(EFalse);
|
|
383 |
// read parameters
|
|
384 |
if (aItem.GetNextInt(expectedAudioResourcesAvailableStatus))
|
|
385 |
{
|
|
386 |
err = KErrBadTestParameter;
|
|
387 |
ERROR(err,
|
|
388 |
"Missing Parameter: expectedAudioResourcesAvailableStatus.");
|
|
389 |
}
|
|
390 |
TBool audioResourcesAvailableStatus(
|
|
391 |
iSystemEventCollector->IsAudioResourcesAvailable());
|
|
392 |
if (expectedAudioResourcesAvailableStatus
|
|
393 |
!= audioResourcesAvailableStatus)
|
|
394 |
{
|
|
395 |
INFO_2(
|
|
396 |
"Failed: audioResourcesAvailableStatus=%i, expectedAudioResourcesAvailableStatus=%i.",
|
|
397 |
audioResourcesAvailableStatus,
|
|
398 |
expectedAudioResourcesAvailableStatus);
|
|
399 |
err = KErrUnexpectedValue;
|
|
400 |
}
|
|
401 |
return err;
|
|
402 |
}
|
|
403 |
|
|
404 |
// -----------------------------------------------------------------------------
|
|
405 |
// CUtilsTestModule::IsHeadsetConnectedL()
|
|
406 |
// Returns: Errors.
|
|
407 |
// -----------------------------------------------------------------------------
|
|
408 |
TInt CUtilsTestModule::IsHeadsetConnectedL(CStifItemParser& aItem)
|
|
409 |
{
|
|
410 |
FUNC_LOG;
|
|
411 |
TInt err(KErrNone);
|
|
412 |
TBool expectedHeadsetConnectedStatus(EFalse);
|
|
413 |
// read parameters
|
|
414 |
if (aItem.GetNextInt(expectedHeadsetConnectedStatus))
|
|
415 |
{
|
|
416 |
err = KErrBadTestParameter;
|
|
417 |
ERROR(err, "Missing Parameter: expectedHeadsetConnectedStatus.");
|
|
418 |
}
|
|
419 |
TBool
|
|
420 |
headsetConnectedStatus(
|
|
421 |
iSystemEventCollector->IsHeadsetConnectedL());
|
|
422 |
if (expectedHeadsetConnectedStatus != headsetConnectedStatus)
|
|
423 |
{
|
|
424 |
INFO_2(
|
|
425 |
"Failed: headsetConnectedStatus=%i, expectedHeadsetConnectedStatus=%i.",
|
|
426 |
headsetConnectedStatus, expectedHeadsetConnectedStatus);
|
|
427 |
err = KErrUnexpectedValue;
|
|
428 |
}
|
|
429 |
return err;
|
|
430 |
}
|
|
431 |
|
|
432 |
// -----------------------------------------------------------------------------
|
|
433 |
// CUtilsTestModule::tstSetPropertyValueForHeadset()
|
|
434 |
// Returns: System error.
|
|
435 |
// -----------------------------------------------------------------------------
|
|
436 |
TInt CUtilsTestModule::tstSetPropertyValueForHeadset( CStifItemParser& aItem )
|
|
437 |
{
|
|
438 |
FUNC_LOG;
|
|
439 |
TInt err( KErrNone );
|
|
440 |
TBool headsetConnectedStatus(EFalse);
|
|
441 |
// read parameters
|
|
442 |
if (aItem.GetNextInt(headsetConnectedStatus))
|
|
443 |
{
|
|
444 |
err = KErrBadTestParameter;
|
|
445 |
ERROR(err, "Missing Parameter: headsetConnectedStatus.");
|
|
446 |
}
|
|
447 |
err = iPropertyHeadsetStatus.Set(KStub_KRadioPSUid, SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected, headsetConnectedStatus);
|
|
448 |
ERROR(err, "Headset property Attach() failed!");
|
|
449 |
return err;
|
|
450 |
}
|
|
451 |
|
|
452 |
// -----------------------------------------------------------------------------
|
|
453 |
// CUtilsTestModule::tstSetPropertyValueForNetworkStatus()
|
|
454 |
// Returns: System error.
|
|
455 |
// -----------------------------------------------------------------------------
|
|
456 |
TInt CUtilsTestModule::tstSetPropertyValueForNetworkStatus( CStifItemParser& aItem )
|
|
457 |
{
|
|
458 |
FUNC_LOG;
|
|
459 |
TInt err( KErrNone );
|
|
460 |
TInt networkStatus(NULL);
|
|
461 |
// read parameters
|
|
462 |
if (aItem.GetNextInt(networkStatus))
|
|
463 |
{
|
|
464 |
err = KErrBadTestParameter;
|
|
465 |
ERROR(err, "Missing Parameter: networkStatus.");
|
|
466 |
}
|
|
467 |
err = iPropertyNetworkStatus.Set(KStub_KUidSystemCategory, KUidNetworkStatusValue, networkStatus);
|
|
468 |
ERROR(err, "Network status property Attach() failed!");
|
|
469 |
return err;
|
|
470 |
}
|
|
471 |
|
|
472 |
// -----------------------------------------------------------------------------
|
|
473 |
// CUtilsTestModule::tstSetPropertyValueForCallState()
|
|
474 |
// Returns: System error.
|
|
475 |
// -----------------------------------------------------------------------------
|
|
476 |
TInt CUtilsTestModule::tstSetPropertyValueForCallState( CStifItemParser& aItem )
|
|
477 |
{
|
|
478 |
FUNC_LOG;
|
|
479 |
TInt err( KErrNone );
|
|
480 |
TInt callState(EFalse);
|
|
481 |
// read parameters
|
|
482 |
if (aItem.GetNextInt(callState))
|
|
483 |
{
|
|
484 |
err = KErrBadTestParameter;
|
|
485 |
ERROR(err, "Missing Parameter: callState.");
|
|
486 |
}
|
|
487 |
err = iPropertyCallState.Set(KStub_KPSUidCtsyCallInformation, KCTsyCallState, callState);
|
|
488 |
ERROR(err, "Call state property Attach() failed!");
|
|
489 |
return err;
|
|
490 |
}
|
|
491 |
|
|
492 |
|
|
493 |
// -----------------------------------------------------------------------------
|
|
494 |
// CUtilsTestModule::HandleSystemEventL()
|
|
495 |
// Returns: none.
|
|
496 |
// -----------------------------------------------------------------------------
|
|
497 |
void CUtilsTestModule::HandleSystemEventL(TRadioSystemEventType aEventType)
|
|
498 |
{
|
|
499 |
FUNC_LOG;
|
|
500 |
INFO_1("aEventType = %d", aEventType);
|
|
501 |
|
|
502 |
switch (aEventType)
|
|
503 |
{
|
|
504 |
case ERadioAudioResourcesAvailable:
|
|
505 |
{
|
|
506 |
INFO("ERadioAudioResourcesAvailable");
|
|
507 |
}
|
|
508 |
break;
|
|
509 |
|
|
510 |
case ERadioAudioAutoResumeForbidden:
|
|
511 |
{
|
|
512 |
INFO("ERadioAudioAutoResumeForbidden");
|
|
513 |
}
|
|
514 |
break;
|
|
515 |
|
|
516 |
case ERadioAudioRouteHeadset:
|
|
517 |
{
|
|
518 |
INFO("ERadioAudioRouteHeadset");
|
|
519 |
}
|
|
520 |
break;
|
|
521 |
|
|
522 |
case ERadioAudioRouteSpeaker:
|
|
523 |
{
|
|
524 |
INFO("ERadioAudioRouteSpeaker");
|
|
525 |
}
|
|
526 |
break;
|
|
527 |
|
|
528 |
case ERadioCallActivated:
|
|
529 |
{
|
|
530 |
INFO("ERadioCallActivated");
|
|
531 |
}
|
|
532 |
break;
|
|
533 |
|
|
534 |
case ERadioCallDeactivated:
|
|
535 |
{
|
|
536 |
INFO("ERadioCallDeactivated");
|
|
537 |
}
|
|
538 |
break;
|
|
539 |
|
|
540 |
case ERadioHeadsetConnected:
|
|
541 |
{
|
|
542 |
INFO("ERadioHeadsetConnected");
|
|
543 |
}
|
|
544 |
break;
|
|
545 |
|
|
546 |
case ERadioHeadsetDisconnected:
|
|
547 |
{
|
|
548 |
INFO("ERadioHeadsetDisconnected");
|
|
549 |
}
|
|
550 |
break;
|
|
551 |
default:
|
|
552 |
{
|
|
553 |
INFO("Unexpected event type");
|
|
554 |
break;
|
|
555 |
}
|
|
556 |
}
|
|
557 |
}
|
|
558 |
|
|
559 |
// -----------------------------------------------------------------------------
|
|
560 |
// CUtilsTestModule::tstDefineAndAttachTestProperties()
|
|
561 |
// Returns: none.
|
|
562 |
// -----------------------------------------------------------------------------
|
|
563 |
TInt CUtilsTestModule::tstDefineAndAttachTestProperties()
|
|
564 |
{
|
|
565 |
FUNC_LOG;
|
|
566 |
TInt err(RProperty::Define(KStub_KRadioPSUid,
|
|
567 |
SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected,
|
|
568 |
RProperty::EInt, KRadioServerReadPolicy,
|
|
569 |
KRadioServerWritePolicy));
|
|
570 |
ERROR(err, "Property SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected Define() failed!");
|
|
571 |
err = iPropertyHeadsetStatus.Attach(KStub_KRadioPSUid, SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected);
|
|
572 |
ERROR(err, "Property SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected Attach() failed!");
|
|
573 |
err = iPropertyCallState.Set(KStub_KRadioPSUid, SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected, EFalse);
|
|
574 |
ERROR(err, "Property SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected Set() failed!");
|
|
575 |
|
|
576 |
err = RProperty::Define(KStub_KUidSystemCategory,
|
|
577 |
KUidNetworkStatusValue,
|
|
578 |
RProperty::EInt, KRadioServerReadPolicy,
|
|
579 |
KRadioServerWritePolicy);
|
|
580 |
ERROR(err, "Property KUidNetworkStatusValue Define() failed!");
|
|
581 |
err = iPropertyNetworkStatus.Attach(KStub_KUidSystemCategory, KUidNetworkStatusValue);
|
|
582 |
ERROR(err, "Property KUidNetworkStatusValue Attach() failed!");
|
|
583 |
err = iPropertyNetworkStatus.Set(KStub_KUidSystemCategory, KUidNetworkStatusValue, ESANetworkAvailable);
|
|
584 |
ERROR(err, "Property KUidNetworkStatusValue Set() failed!");
|
|
585 |
|
|
586 |
|
|
587 |
err = RProperty::Define(KStub_KPSUidCtsyCallInformation,
|
|
588 |
KCTsyCallState,
|
|
589 |
RProperty::EInt, KRadioServerReadPolicy,
|
|
590 |
KRadioServerWritePolicy);
|
|
591 |
ERROR(err, "Property KCTsyCallState Define() failed!");
|
|
592 |
err = iPropertyCallState.Attach(KStub_KPSUidCtsyCallInformation, KCTsyCallState);
|
|
593 |
ERROR(err, "Property KCTsyCallState Attach() failed!");
|
|
594 |
err = iPropertyCallState.Set(KStub_KPSUidCtsyCallInformation, KCTsyCallState, EPSCTsyCallStateNone);
|
|
595 |
ERROR(err, "Property KCTsyCallState Set() failed!");
|
|
596 |
|
|
597 |
return err;
|
|
598 |
}
|
|
599 |
|
|
600 |
// -----------------------------------------------------------------------------
|
|
601 |
// CUtilsTestModule::InitSharedMemory
|
|
602 |
// Returns: errors.
|
|
603 |
// -----------------------------------------------------------------------------
|
|
604 |
//
|
|
605 |
TInt CUtilsTestModule::InitSharedMemory()
|
|
606 |
|
|
607 |
{
|
|
608 |
FUNC_LOG;
|
|
609 |
TInt err = iRadioStubManagerChunk.CreateGlobal(
|
|
610 |
KRadioStubManagerLocalChunkName, sizeof(SRadioStubManager),
|
|
611 |
sizeof(SRadioStubManager), EOwnerThread);
|
|
612 |
if (KErrAlreadyExists == err)
|
|
613 |
{
|
|
614 |
INFO("Memory chunk KRadioStubManagerLocalChunkName already exists.");
|
|
615 |
err = iRadioStubManagerChunk.OpenGlobal(
|
|
616 |
KRadioStubManagerLocalChunkName, EFalse, // == Read | Write
|
|
617 |
EOwnerThread);
|
|
618 |
}
|
|
619 |
if (KErrNone == err)
|
|
620 |
{
|
|
621 |
if (sizeof(SRadioStubManager) > iRadioStubManagerChunk.MaxSize())
|
|
622 |
{
|
|
623 |
err = KErrCorrupt;
|
|
624 |
INFO_1(
|
|
625 |
"Improper size for memory chunk KRadioStubManagerLocalChunkName. Err = %i",
|
|
626 |
err);
|
|
627 |
}
|
|
628 |
else
|
|
629 |
{
|
|
630 |
TUint8* basePtr = iRadioStubManagerChunk.Base();
|
|
631 |
if (!basePtr)
|
|
632 |
{
|
|
633 |
err = KErrCorrupt;
|
|
634 |
INFO_1(
|
|
635 |
"Getting base pointer of memory chunk KRadioStubManagerLocalChunkName failed. Err=%i",
|
|
636 |
err);
|
|
637 |
}
|
|
638 |
else
|
|
639 |
{
|
|
640 |
iRadioStubManager = (SRadioStubManager*) basePtr;
|
|
641 |
// Zero configuration/control data
|
|
642 |
iRadioStubManager->FillZ();
|
|
643 |
}
|
|
644 |
}
|
|
645 |
}
|
|
646 |
else
|
|
647 |
{
|
|
648 |
INFO_1(
|
|
649 |
"Creation of memory chunk KRadioStubManagerLocalChunkName failed. Err = %i",
|
|
650 |
err);
|
|
651 |
}
|
|
652 |
INFO_1("return value, Err = %i", err);
|
|
653 |
return err;
|
|
654 |
}
|
|
655 |
|
|
656 |
// -----------------------------------------------------------------------------
|
|
657 |
// CUtilsTestModule::CreateSystemEventCollector2L
|
|
658 |
// Returns: errors.
|
|
659 |
// -----------------------------------------------------------------------------
|
|
660 |
//
|
|
661 |
TInt CUtilsTestModule::CreateSystemEventCollector2L()
|
|
662 |
{
|
|
663 |
FUNC_LOG;
|
|
664 |
TInt err(KErrNone);
|
|
665 |
if (!iSystemEventCollector)
|
|
666 |
{
|
|
667 |
iSystemEventCollector = CRadioSystemEventCollector::NewL();
|
|
668 |
iSystemEventCollector->AddObserverL(this);
|
|
669 |
}
|
|
670 |
else
|
|
671 |
{
|
|
672 |
INFO( "KErrAlreadyExists" )
|
|
673 |
err = KErrAlreadyExists;
|
|
674 |
}
|
|
675 |
return err;
|
|
676 |
}
|
|
677 |
|
|
678 |
// -----------------------------------------------------------------------------
|
|
679 |
// CUtilsTestModule::AudioRouteChangedL
|
|
680 |
// Returns: none
|
|
681 |
// -----------------------------------------------------------------------------
|
|
682 |
//
|
|
683 |
void CUtilsTestModule::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute )
|
|
684 |
{
|
|
685 |
FUNC_LOG;
|
|
686 |
INFO_1( "aRoute = %i", aRoute );
|
|
687 |
iRoute = aRoute;
|
|
688 |
|
|
689 |
}
|
|
690 |
|
|
691 |
//-----------------------------------------------------------------------------
|
|
692 |
// CUtilsTestModule::CreateAudioRouterL
|
|
693 |
//-----------------------------------------------------------------------------
|
|
694 |
TInt CUtilsTestModule::CreateAudioRouterL(CStifItemParser& /*aItem*/)
|
|
695 |
{
|
|
696 |
FUNC_LOG;
|
|
697 |
|
|
698 |
TInt err(KErrNone);
|
|
699 |
err = InitSharedMemory();
|
|
700 |
if ((!iAudioRouter) && (KErrNone == err))
|
|
701 |
{
|
|
702 |
TRAP( err, RadioEngineUtils::InitializeL(); );
|
|
703 |
if (KErrNone != err)
|
|
704 |
{
|
|
705 |
INFO_1( "RadioEngineUtils::InitializeL() failed err = %i", err )
|
|
706 |
iRadioStubManagerChunk.Close();
|
|
707 |
}
|
|
708 |
else
|
|
709 |
{
|
|
710 |
TRAP( err, iAudioRouter = CRadioAudioRouter::NewL( *this ); );
|
|
711 |
if ( KErrNone != err )
|
|
712 |
{
|
|
713 |
INFO_1( "CRadioAudioRouter::NewL() failed err = %i", err )
|
|
714 |
iRadioStubManagerChunk.Close();
|
|
715 |
RadioEngineUtils::Release();
|
|
716 |
}
|
|
717 |
}
|
|
718 |
}
|
|
719 |
if ( KErrNoMemory == err )
|
|
720 |
{
|
|
721 |
User::Leave( err );
|
|
722 |
}
|
|
723 |
return err;
|
|
724 |
}
|
|
725 |
|
|
726 |
//-----------------------------------------------------------------------------
|
|
727 |
// CUtilsTestModule::DestroyAudioRouter
|
|
728 |
//-----------------------------------------------------------------------------
|
|
729 |
TInt CUtilsTestModule::DestroyAudioRouter(CStifItemParser& /*aItem*/)
|
|
730 |
{
|
|
731 |
FUNC_LOG;
|
|
732 |
if (iAudioRouter)
|
|
733 |
{
|
|
734 |
iRadioStubManagerChunk.Close();
|
|
735 |
delete iAudioRouter;
|
|
736 |
iAudioRouter = NULL;
|
|
737 |
RadioEngineUtils::Release();
|
|
738 |
}
|
|
739 |
return KErrNone;
|
|
740 |
}
|
|
741 |
|
|
742 |
//-----------------------------------------------------------------------------
|
|
743 |
// CUtilsTestModule::OOMTestForAudioRouterCreation
|
|
744 |
//-----------------------------------------------------------------------------
|
|
745 |
TInt CUtilsTestModule::OOMTestForAudioRouterCreation(CStifItemParser& /*aItem*/)
|
|
746 |
{
|
|
747 |
FUNC_LOG;
|
|
748 |
TInt err(KErrNone);
|
|
749 |
err = InitSharedMemory();
|
|
750 |
if (KErrNone == err)
|
|
751 |
{
|
|
752 |
RadioEngineUtils::InitializeL();
|
|
753 |
TInt i(-1);
|
|
754 |
for (err = KErrNoMemory; KErrNoMemory == err; __UHEAP_MARKEND)
|
|
755 |
{
|
|
756 |
TRAP ( err,
|
|
757 |
{
|
|
758 |
++i;
|
|
759 |
INFO_1("loop count = %i", i );
|
|
760 |
__UHEAP_MARK;
|
|
761 |
__UHEAP_FAILNEXT( i );
|
|
762 |
TRAP( err, CreateAudioRouter2L(); );
|
|
763 |
if ( iAudioRouter )
|
|
764 |
{
|
|
765 |
delete iAudioRouter;
|
|
766 |
iAudioRouter = NULL;
|
|
767 |
}
|
|
768 |
}
|
|
769 |
);
|
|
770 |
}
|
|
771 |
__UHEAP_RESET;
|
|
772 |
RadioEngineUtils::Release();
|
|
773 |
iRadioStubManagerChunk.Close();
|
|
774 |
}
|
|
775 |
return err;
|
|
776 |
}
|
|
777 |
|
|
778 |
// -----------------------------------------------------------------------------
|
|
779 |
// CUtilsTestModule::CreateAudioRouter2L
|
|
780 |
// Returns: errors.
|
|
781 |
// -----------------------------------------------------------------------------
|
|
782 |
//
|
|
783 |
TInt CUtilsTestModule::CreateAudioRouter2L()
|
|
784 |
{
|
|
785 |
FUNC_LOG;
|
|
786 |
TInt err(KErrNone);
|
|
787 |
if (!iAudioRouter)
|
|
788 |
{
|
|
789 |
iAudioRouter = CRadioAudioRouter::NewL( *this );
|
|
790 |
}
|
|
791 |
else
|
|
792 |
{
|
|
793 |
INFO( "KErrAlreadyExists" )
|
|
794 |
err = KErrAlreadyExists;
|
|
795 |
}
|
|
796 |
return err;
|
|
797 |
}
|
|
798 |
|
|
799 |
//-----------------------------------------------------------------------------
|
|
800 |
// CUtilsTestModule::CreateRoutableAudioL
|
|
801 |
//-----------------------------------------------------------------------------
|
|
802 |
TInt CUtilsTestModule::CreateRoutableAudioL(CStifItemParser& /*aItem*/)
|
|
803 |
{
|
|
804 |
FUNC_LOG;
|
|
805 |
|
|
806 |
TInt err( CreateRoutableAudio2L() );
|
|
807 |
return err;
|
|
808 |
}
|
|
809 |
|
|
810 |
//-----------------------------------------------------------------------------
|
|
811 |
// CUtilsTestModule::CreateRoutableAudio2L
|
|
812 |
//-----------------------------------------------------------------------------
|
|
813 |
TInt CUtilsTestModule::CreateRoutableAudio2L()
|
|
814 |
{
|
|
815 |
FUNC_LOG;
|
|
816 |
|
|
817 |
TInt err(KErrNone);
|
|
818 |
if (!iRoutableAudio)
|
|
819 |
{
|
|
820 |
TRAP( err, iRoutableAudio = new (ELeave) CRadioRoutableAudio( iAudioRouter ); );
|
|
821 |
if ( KErrNone != err )
|
|
822 |
{
|
|
823 |
INFO_1( "new CRadioRoutableAudio failed err = %i", err )
|
|
824 |
}
|
|
825 |
}
|
|
826 |
if ( KErrNoMemory == err )
|
|
827 |
{
|
|
828 |
User::Leave( err );
|
|
829 |
}
|
|
830 |
return err;
|
|
831 |
}
|
|
832 |
|
|
833 |
//-----------------------------------------------------------------------------
|
|
834 |
// CUtilsTestModule::DestroyRoutableAudio
|
|
835 |
//-----------------------------------------------------------------------------
|
|
836 |
TInt CUtilsTestModule::DestroyRoutableAudio(CStifItemParser& /*aItem*/)
|
|
837 |
{
|
|
838 |
FUNC_LOG;
|
|
839 |
if (iRoutableAudio)
|
|
840 |
{
|
|
841 |
delete iRoutableAudio;
|
|
842 |
iRoutableAudio = NULL;
|
|
843 |
// Note that previous delete call destroyed also Audio Router.
|
|
844 |
iAudioRouter = NULL;
|
|
845 |
iRadioStubManagerChunk.Close();
|
|
846 |
RadioEngineUtils::Release();
|
|
847 |
}
|
|
848 |
return KErrNone;
|
|
849 |
}
|
|
850 |
|
|
851 |
//-----------------------------------------------------------------------------
|
|
852 |
// CUtilsTestModule::OOMTestForRoutableAudioCreation
|
|
853 |
//-----------------------------------------------------------------------------
|
|
854 |
TInt CUtilsTestModule::OOMTestForRoutableAudioCreation(CStifItemParser& /*aItem*/)
|
|
855 |
{
|
|
856 |
FUNC_LOG;
|
|
857 |
TInt err(KErrNone);
|
|
858 |
TInt i(-1);
|
|
859 |
for (err = KErrNoMemory; KErrNoMemory == err; __UHEAP_MARKEND)
|
|
860 |
{
|
|
861 |
++i;
|
|
862 |
INFO_1("loop count = %i", i );
|
|
863 |
__UHEAP_MARK;
|
|
864 |
__UHEAP_FAILNEXT( i );
|
|
865 |
TRAP( err, CreateRoutableAudio2L(); );
|
|
866 |
if ( iRoutableAudio )
|
|
867 |
{
|
|
868 |
delete iRoutableAudio;
|
|
869 |
iRoutableAudio = NULL;
|
|
870 |
// Note that previous delete call destroyed also Audio Router.
|
|
871 |
iAudioRouter = NULL;
|
|
872 |
iRadioStubManagerChunk.Close();
|
|
873 |
RadioEngineUtils::Release();
|
|
874 |
}
|
|
875 |
}
|
|
876 |
__UHEAP_RESET;
|
|
877 |
return err;
|
|
878 |
}
|
|
879 |
|
|
880 |
// -----------------------------------------------------------------------------
|
|
881 |
// CUtilsTestModule::?member_function
|
|
882 |
// ?implementation_description
|
|
883 |
// (other items were commented in a header).
|
|
884 |
// -----------------------------------------------------------------------------
|
|
885 |
//
|
|
886 |
/*
|
|
887 |
TInt CUtilsTestModule::?member_function(
|
|
888 |
CItemParser& aItem )
|
|
889 |
{
|
|
890 |
FUNC_LOG;
|
|
891 |
|
|
892 |
?code
|
|
893 |
|
|
894 |
}
|
|
895 |
*/
|
|
896 |
|
|
897 |
|
|
898 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
899 |
// None
|
|
900 |
|
|
901 |
|
|
902 |
// [End of File] - Do not remove
|