1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/Actrl/TestStepsGetSet.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,2861 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// TestStepsGetSet
1.18 +//
1.19 +
1.20 +#include <e32std.h>
1.21 +#include <e32base.h>
1.22 +#include <mmf/common/mmfcontroller.h>
1.23 +#include <mmf/server/mmffile.h>
1.24 +#include <mmf/server/mmfdes.h>
1.25 +#include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
1.26 +#include <mmf/common/mmfstandardcustomcommands.h>
1.27 +
1.28 +//const TInt KPlayDelayNewMail = 100000000; //arbitrary delay
1.29 +
1.30 +// Test system includes
1.31 +#include <testframework.h>
1.32 +
1.33 +#include "ActrlTestUids.h"
1.34 +
1.35 +// Specific includes for this test suite
1.36 +#include "TS_MMF_ACTRL_TestStep.h"
1.37 +#include "TS_MMF_ACTRL_TestSuite.h"
1.38 +
1.39 +// Specific includes for these test steps
1.40 +#include "TestStepsGetSet.h"
1.41 +
1.42 +/**
1.43 +*
1.44 +* Test step constructor.
1.45 +* Each test step initialises its own name.
1.46 +*
1.47 +*/
1.48 +CTestStepGetSetVolumeInPrimed::CTestStepGetSetVolumeInPrimed()
1.49 + {
1.50 + // store the name of this test case
1.51 + // this is the name that is used by the script file
1.52 + iTestStepName = _L("MM-MMF-ACTRL-U-0001-HP");
1.53 + }
1.54 +
1.55 +/**
1.56 +*
1.57 +* Test step destructor.
1.58 +*
1.59 +*/
1.60 +CTestStepGetSetVolumeInPrimed::~CTestStepGetSetVolumeInPrimed()
1.61 + {
1.62 + }
1.63 +
1.64 +/**
1.65 +*
1.66 +* Do the test step.
1.67 +* Each test step must supply an implementation for DoTestStepL.
1.68 +* This test does nothing more than exercise the rotate & scale code
1.69 +* @return "TVerdict" the status of the test
1.70 +* The result of the test step
1.71 +*/
1.72 +TVerdict CTestStepGetSetVolumeInPrimed::DoTestStepL( void )
1.73 + {
1.74 + __MM_HEAP_MARK;
1.75 +
1.76 + TVerdict result = EPass;
1.77 +
1.78 + _LIT( KTestPlay, "Play Test");
1.79 + Log( KTestPlay );
1.80 +
1.81 + _LIT( KTestStepPlay, "This test checks getting/setting volume in primed");
1.82 + Log( KTestStepPlay );
1.83 +
1.84 + // [ audio file to play ]
1.85 + _LIT(KTestWavFile, "newmail.wav");
1.86 + SetReadFileNameL( KTestWavFile );
1.87 +
1.88 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.89 + User::LeaveIfError( errorCode );
1.90 +
1.91 + //[ add data source and sink and prime the controller ]
1.92 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.93 + User::LeaveIfError( errorCode );
1.94 +
1.95 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.96 + User::LeaveIfError( errorCode );
1.97 +
1.98 + errorCode = iController.Prime();
1.99 + User::LeaveIfError( errorCode );
1.100 +
1.101 + // [ wait for and process the return event from the audio output ]
1.102 +
1.103 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.104 + result = SearchForEvent( primeEvent );
1.105 + if( result == EFail )
1.106 + {
1.107 + return result;
1.108 + }
1.109 +
1.110 + //[ set up audio commands utility ]
1.111 + RMMFAudioPlayDeviceCustomCommands theCommander( iController );
1.112 +
1.113 + // [ get the maximum volume ]
1.114 + TInt maxVolume = 0;
1.115 + errorCode =theCommander.GetMaxVolume( maxVolume );
1.116 + User::LeaveIfError( errorCode );
1.117 +
1.118 + //[ set the volume to 1/2 max volume ]
1.119 + TInt theVolume = maxVolume /2;
1.120 +
1.121 + //[ set the volume ]
1.122 + errorCode =theCommander.SetVolume( theVolume );
1.123 + User::LeaveIfError( errorCode );
1.124 +
1.125 + //[ get the volume ]
1.126 + TInt theNewVolume (0);
1.127 + errorCode =theCommander.GetVolume( theNewVolume );
1.128 + User::LeaveIfError( errorCode );
1.129 +
1.130 + // [ if set volume = got volume and
1.131 + // rx'd event was ok then we are fine ]
1.132 + if( theNewVolume == theVolume )
1.133 + {
1.134 + result = EPass ;
1.135 + }
1.136 + //[ ensure the controller is unloaded so that it does
1.137 + // not interfere with the following test ]
1.138 + // There is an error in this code and the stop followed by reset
1.139 + // ensure the controller resources are released.
1.140 + iController.Stop();
1.141 + iController.Reset();
1.142 + iController.Close();
1.143 +
1.144 + __MM_HEAP_MARKEND;
1.145 +
1.146 + // test steps return a result
1.147 + return result;
1.148 + }
1.149 +
1.150 +
1.151 +/**
1.152 +*
1.153 +*
1.154 +*
1.155 +*/
1.156 +CTestStepGetSetVolumeInPlay::CTestStepGetSetVolumeInPlay()
1.157 + {
1.158 + // store the name of this test case
1.159 + // this is the name that is used by the script file
1.160 + iTestStepName = _L("MM-MMF-ACTRL-U-0002-HP");
1.161 + }
1.162 +
1.163 +/**
1.164 +*
1.165 +* ~CTestStepGetSetVolumeInPlay
1.166 +*
1.167 +*/
1.168 +CTestStepGetSetVolumeInPlay::~CTestStepGetSetVolumeInPlay()
1.169 + {
1.170 + }
1.171 +
1.172 +/**
1.173 +*
1.174 +* DoTestStepL
1.175 +*
1.176 +*/
1.177 +TVerdict CTestStepGetSetVolumeInPlay::DoTestStepL( void )
1.178 + {
1.179 + __MM_HEAP_MARK;
1.180 +
1.181 + TVerdict result = EFail;
1.182 +
1.183 + _LIT( KTestPlay, "Play Test");
1.184 + Log( KTestPlay );
1.185 +
1.186 + _LIT( KTestStepPlay, "This test checks playing an audio clip");
1.187 + Log( KTestStepPlay );
1.188 +
1.189 + // [ audio file to play ]
1.190 + _LIT(KTestWavFile, "newmail.wav");
1.191 + SetReadFileNameL( KTestWavFile );
1.192 +
1.193 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.194 + User::LeaveIfError( errorCode );
1.195 +
1.196 + //[ add data source and sink and prime the controller ]
1.197 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.198 + User::LeaveIfError( errorCode );
1.199 +
1.200 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.201 + User::LeaveIfError( errorCode );
1.202 +
1.203 + errorCode = iController.Prime();
1.204 + User::LeaveIfError( errorCode );
1.205 +
1.206 + // [ wait for and process the return event from the audio output ]
1.207 +
1.208 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.209 + TVerdict searchResult = SearchForEvent( primeEvent );
1.210 + if( searchResult == EFail )
1.211 + {
1.212 + return searchResult;
1.213 + }
1.214 +
1.215 + User::LeaveIfError( iController.Play() );
1.216 +
1.217 + // note this test does not wait around
1.218 + // to detect that the audio has been played
1.219 + // [ now process the confirmation event that play has reached audio output
1.220 + // this is the raison detre of the test ]
1.221 + TMMFEvent playEvent( KPlayTestId, KErrNone );
1.222 +
1.223 + searchResult = SearchForEvent( playEvent );
1.224 + if( searchResult == EFail )
1.225 + {
1.226 + return searchResult;
1.227 + }
1.228 +
1.229 + //[ set up audio commands utility ]
1.230 + RMMFAudioPlayDeviceCustomCommands theCommander( iController );
1.231 +
1.232 + // [ get the maximum volume ]
1.233 + TInt maxVolume = 0;
1.234 + errorCode =theCommander.GetMaxVolume( maxVolume );
1.235 + User::LeaveIfError( errorCode );
1.236 +
1.237 + //[ set the volume to 1/2 max volume ]
1.238 + TInt theVolume = maxVolume /2;
1.239 +
1.240 + //[ set the volume ]
1.241 + errorCode =theCommander.SetVolume( theVolume );
1.242 + User::LeaveIfError( errorCode );
1.243 + //[ get the volume ]
1.244 + TInt theNewVolume (0);
1.245 + errorCode =theCommander.GetVolume( theNewVolume );
1.246 + User::LeaveIfError( errorCode );
1.247 +
1.248 + // [ if set volume = got volume, setVolume2 != got volume
1.249 + // and rx'd event was ok then we are fine ]
1.250 + TInt overVolume = maxVolume+1;
1.251 +
1.252 + //[ set the volume ]
1.253 + TInt overVolumeErrorCode =theCommander.SetVolume( overVolume );
1.254 + //[ get the volume ]
1.255 + TInt overVolumeResult (-100); // arbitrary initial value
1.256 + errorCode =theCommander.GetVolume( overVolumeResult );
1.257 + User::LeaveIfError( errorCode );
1.258 +
1.259 + TInt underVolume = -1;
1.260 +
1.261 + //[ set the volume ]
1.262 + TInt underVolumeErrorCode =theCommander.SetVolume( underVolume );
1.263 + //[ get the volume ]
1.264 + TInt underVolumeResult (0); //arbitrary initial value
1.265 + errorCode =theCommander.GetVolume( underVolumeResult );
1.266 + User::LeaveIfError( errorCode );
1.267 +
1.268 + //[ set the status of the test ]
1.269 + if( ( theVolume == theNewVolume ) && // volume has been set correctly
1.270 + ( overVolumeErrorCode != KErrNone) && // over volume detected
1.271 + (theVolume == overVolumeResult) && // volume remains unchanged
1.272 + (underVolumeErrorCode != KErrNone) && // under volume detected
1.273 + ( theVolume == underVolumeResult)) // volume remains unchanged
1.274 + {
1.275 + result = EPass;
1.276 + }
1.277 +
1.278 + //[ ensure the controller is unloaded so that it does
1.279 + // not interfere with the following test ]
1.280 + // There is error in this code and the stop followed by reset
1.281 + // ensure the controller resources are released.
1.282 + iController.Stop();
1.283 + iController.Reset();
1.284 + iController.Close();
1.285 +
1.286 + __MM_HEAP_MARKEND;
1.287 +
1.288 + // test steps return a result
1.289 + return result;
1.290 + }
1.291 +
1.292 +/**
1.293 +CTestStepGetSetVolumeInStopped
1.294 +
1.295 +*/
1.296 +CTestStepGetSetVolumeInStopped::CTestStepGetSetVolumeInStopped()
1.297 + {
1.298 + iTestStepName = _L("MM-MMF-ACTRL-U-0003-HP");
1.299 + }
1.300 +
1.301 +/**
1.302 +~CTestStepGetSetVolumeInStopped
1.303 +*/
1.304 +CTestStepGetSetVolumeInStopped::~CTestStepGetSetVolumeInStopped()
1.305 + {
1.306 + }
1.307 +
1.308 +/**
1.309 +*
1.310 +*DoTestStepL
1.311 +*
1.312 +*/
1.313 +TVerdict CTestStepGetSetVolumeInStopped::DoTestStepL( void )
1.314 + {
1.315 + __MM_HEAP_MARK;
1.316 + TVerdict result = EFail;
1.317 +
1.318 + _LIT( KTestPlay, "Get/Set Volume while stopped");
1.319 + Log( KTestPlay );
1.320 +
1.321 + _LIT( KTestStepPlay, "This test checks get/set volume while stopped");
1.322 + Log( KTestStepPlay );
1.323 +
1.324 + // [ audio file to play ]
1.325 + _LIT(KTestWavFile, "newmail.wav");
1.326 + SetReadFileNameL( KTestWavFile );
1.327 +
1.328 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.329 + User::LeaveIfError( errorCode );
1.330 +
1.331 + //[ add data source and sink and prime the controller ]
1.332 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.333 + User::LeaveIfError( errorCode );
1.334 +
1.335 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.336 + User::LeaveIfError( errorCode );
1.337 +
1.338 + //[ set up audio commands utility ]
1.339 + RMMFAudioPlayDeviceCustomCommands theCommander( iController );
1.340 +
1.341 + // [ get the maximum volume ]
1.342 + TInt maxVolume = 0;
1.343 + errorCode =theCommander.GetMaxVolume( maxVolume );
1.344 + User::LeaveIfError( errorCode );
1.345 +
1.346 + //[ set the volume to 1/2 max volume ]
1.347 + TInt theVolume = maxVolume /2;
1.348 +
1.349 + //[ set the volume ]
1.350 + errorCode =theCommander.SetVolume( theVolume );
1.351 + User::LeaveIfError( errorCode );
1.352 + //[ get the volume ]
1.353 + TInt theNewVolume (0);
1.354 + errorCode =theCommander.GetVolume( theNewVolume );
1.355 + User::LeaveIfError( errorCode );
1.356 +
1.357 + // [ if set volume = got volume, setVolume2 != got volume
1.358 + // and rx'd event was ok then we are fine ]
1.359 + TInt overVolume = maxVolume+1;
1.360 +
1.361 + //[ set the volume ]
1.362 + TInt overVolumeErrorCode =theCommander.SetVolume( overVolume );
1.363 + //[ get the volume ]
1.364 + TInt overVolumeResult (-100); //arbitrary initial value
1.365 + errorCode =theCommander.GetVolume( overVolumeResult );
1.366 + User::LeaveIfError( errorCode );
1.367 +
1.368 + TInt underVolume = -1; //arbitrary initial value
1.369 +
1.370 + //[ set the volume ]
1.371 + TInt underVolumeErrorCode =theCommander.SetVolume( underVolume );
1.372 + //[ get the volume ]
1.373 + TInt underVolumeResult (0);
1.374 + errorCode =theCommander.GetVolume( underVolumeResult );
1.375 + User::LeaveIfError( errorCode );
1.376 +
1.377 + //[ set the status of the test ]
1.378 + if( ( theVolume == theNewVolume ) && // volume has been set correctly
1.379 + ( overVolumeErrorCode != KErrNone) && // over volume detected
1.380 + (theVolume == overVolumeResult) && // volume remains unchanged
1.381 + (underVolumeErrorCode != KErrNone) && // under volume detected
1.382 + ( theVolume == underVolumeResult)) // volume remains unchanged
1.383 + {
1.384 + result = EPass;
1.385 + }
1.386 +
1.387 + //[ ensure the controller is unloaded so that it does
1.388 + // not interfere with the following test ]
1.389 + // There is error in this code and the stop followed by reset
1.390 + // ensure the controller resources are released.
1.391 + iController.Stop();
1.392 + iController.Reset();
1.393 + iController.Close();
1.394 +
1.395 + __MM_HEAP_MARKEND;
1.396 + return result;
1.397 + }
1.398 +
1.399 +/**
1.400 +*
1.401 +* CTestStepGetSetBalanceInPrimed
1.402 +*
1.403 +*/
1.404 +CTestStepGetSetBalanceInPrimed::CTestStepGetSetBalanceInPrimed()
1.405 + {
1.406 + iTestStepName = _L("MM-MMF-ACTRL-U-0005-HP");
1.407 + }
1.408 +
1.409 +/**
1.410 +*
1.411 +* ~CTestStepGetSetBalanceInPrimed
1.412 +*/
1.413 +CTestStepGetSetBalanceInPrimed::~CTestStepGetSetBalanceInPrimed()
1.414 + {
1.415 + }
1.416 +
1.417 +/**
1.418 +*
1.419 +* DoTestStepL
1.420 +*
1.421 +*/
1.422 +TVerdict CTestStepGetSetBalanceInPrimed::DoTestStepL( void )
1.423 + {
1.424 + __MM_HEAP_MARK;
1.425 + TVerdict result = EFail;
1.426 +
1.427 + _LIT( KTestPlay, "Get/Set Balance while primed");
1.428 + Log( KTestPlay );
1.429 +
1.430 + _LIT( KTestStepPlay, "This test checks get/set balance while primed");
1.431 + Log( KTestStepPlay );
1.432 +
1.433 + // [ audio file to play ]
1.434 + _LIT(KTestWavFile, "newmail.wav");
1.435 + SetReadFileNameL( KTestWavFile );
1.436 +
1.437 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.438 + User::LeaveIfError( errorCode );
1.439 +
1.440 + //[ add data source and sink and prime the controller ]
1.441 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.442 + User::LeaveIfError( errorCode );
1.443 +
1.444 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.445 + User::LeaveIfError( errorCode );
1.446 +
1.447 + errorCode = iController.Prime();
1.448 + User::LeaveIfError( errorCode );
1.449 +
1.450 + // [ wait for and process the return event from the audio output ]
1.451 +
1.452 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.453 + TVerdict searchResult = SearchForEvent( primeEvent );
1.454 + if( searchResult == EFail )
1.455 + {
1.456 + return searchResult;
1.457 + }
1.458 +
1.459 + //[ set up audio commands utility ]
1.460 + RMMFAudioPlayDeviceCustomCommands theCommander( iController );
1.461 +
1.462 + // [ set the balance to an arbitrary value within the range -100 , 100 ]
1.463 + TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
1.464 + //[ set the Balance, we are expecting failure ]
1.465 + TInt setErrorCode =theCommander.SetBalance( theBalance );
1.466 +
1.467 + //[ get the balance, we are expecting failure ]
1.468 + TInt theNewBalance (0);
1.469 + TInt getErrorCode =theCommander.GetBalance( theNewBalance );
1.470 +
1.471 + //[ set the status of the test ]
1.472 + if( ( getErrorCode == KErrNone) &&
1.473 + ( setErrorCode == KErrNone) )
1.474 + {
1.475 + result = EPass;
1.476 + }
1.477 +
1.478 + //[ ensure the controller is unloaded so that it does
1.479 + // not interfere with the following test ]
1.480 + // There is error in this code and the stop followed by reset
1.481 + // ensure the controller resources are released.
1.482 + iController.Stop();
1.483 + iController.Reset();
1.484 + iController.Close();
1.485 +
1.486 + __MM_HEAP_MARKEND;
1.487 + return result;
1.488 + }
1.489 +
1.490 +/**
1.491 +*
1.492 +* CTestStepGetSetBalanceInPlay
1.493 +*/
1.494 +CTestStepGetSetBalanceInPlay::CTestStepGetSetBalanceInPlay()
1.495 + {
1.496 + iTestStepName = _L("MM-MMF-ACTRL-U-0007-HP");
1.497 + }
1.498 +
1.499 +/**
1.500 +*
1.501 +* ~CTestStepGetSetBalanceInPlay
1.502 +*/
1.503 +CTestStepGetSetBalanceInPlay::~CTestStepGetSetBalanceInPlay()
1.504 + {
1.505 + }
1.506 +
1.507 +/**
1.508 +*
1.509 +* DoTestStepL
1.510 +*
1.511 +*/
1.512 +TVerdict CTestStepGetSetBalanceInPlay::DoTestStepL( void )
1.513 + {
1.514 + __MM_HEAP_MARK;
1.515 + TVerdict result = EFail;
1.516 +
1.517 + _LIT( KTestPlay, "Get/Set Balance while in Play");
1.518 + Log( KTestPlay );
1.519 +
1.520 + _LIT( KTestStepPlay, "This test checks get/set balance while playing");
1.521 + Log( KTestStepPlay );
1.522 +
1.523 + // [ audio file to play ]
1.524 + _LIT(KTestWavFile, "newmail.wav");
1.525 + SetReadFileNameL( KTestWavFile );
1.526 +
1.527 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.528 + User::LeaveIfError( errorCode );
1.529 +
1.530 + //[ add data source and sink and prime the controller ]
1.531 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.532 + User::LeaveIfError( errorCode );
1.533 +
1.534 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.535 + User::LeaveIfError( errorCode );
1.536 +
1.537 + errorCode = iController.Prime();
1.538 + User::LeaveIfError( errorCode );
1.539 +
1.540 + // [ wait for and process the return event from the audio output ]
1.541 +
1.542 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.543 + TVerdict searchResult = SearchForEvent( primeEvent );
1.544 + if( searchResult == EFail )
1.545 + {
1.546 + return searchResult;
1.547 + }
1.548 +
1.549 + //[ set the controller to play ]
1.550 + User::LeaveIfError( iController.Play() );
1.551 +
1.552 + //[ set up audio commands utility ]
1.553 + RMMFAudioPlayDeviceCustomCommands theCommander( iController );
1.554 +
1.555 + // [ set the balance to an arbitrary value between 0,100 and map to the range -100,100 ]
1.556 + TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;;
1.557 + //[ set the Balance ]
1.558 + TInt setErrorCode =theCommander.SetBalance( theBalance );
1.559 +
1.560 + //[ get the balance ]
1.561 + TInt theNewBalance (0);
1.562 + TInt getErrorCode =theCommander.GetBalance( theNewBalance );
1.563 +
1.564 + //[ set the status of the test ]
1.565 + if(
1.566 + ( getErrorCode != KErrNone) && // under volume detected
1.567 + ( setErrorCode != KErrNone)) // volume remains unchanged
1.568 + {
1.569 + result = EPass;
1.570 + }
1.571 +
1.572 + TMMFEvent playEvent( KPlayTestId, KErrNone );
1.573 + searchResult = SearchForEvent( playEvent );
1.574 + if( searchResult != EFail )
1.575 + {
1.576 + result = EPass;
1.577 + }
1.578 +
1.579 + //[ ensure the controller is unloaded so that it does
1.580 + // not interfere with the following test ]
1.581 + // There is error in this code and the stop followed by reset
1.582 + // ensure the controller resources are released.
1.583 + iController.Stop();
1.584 + iController.Reset();
1.585 + iController.Close();
1.586 +
1.587 + __MM_HEAP_MARKEND;
1.588 + return result;
1.589 + }
1.590 +
1.591 +/**
1.592 +*
1.593 +* CTestStepGetSetBalanceInStopped
1.594 +*
1.595 +*/
1.596 +CTestStepGetSetBalanceInStopped::CTestStepGetSetBalanceInStopped()
1.597 + {
1.598 + iTestStepName = _L("MM-MMF-ACTRL-U-0006-HP");
1.599 + }
1.600 +
1.601 +/**
1.602 +*
1.603 +* CTestStepGetSetBalanceInStopped
1.604 +*
1.605 +*/
1.606 +CTestStepGetSetBalanceInStopped::~CTestStepGetSetBalanceInStopped()
1.607 + {
1.608 + }
1.609 +
1.610 +/**
1.611 +*
1.612 +* DoTestStepL
1.613 +*
1.614 +*/
1.615 +TVerdict CTestStepGetSetBalanceInStopped::DoTestStepL( void )
1.616 + {
1.617 + __MM_HEAP_MARK;
1.618 + TVerdict result = EFail;
1.619 +
1.620 + _LIT( KTestPlay, "Get/Set Balance while stopped");
1.621 + Log( KTestPlay );
1.622 +
1.623 + _LIT( KTestStepPlay, "This test checks get/set balance while stopped");
1.624 + Log( KTestStepPlay );
1.625 +
1.626 + // [ audio file to play ]
1.627 + _LIT(KTestWavFile, "newmail.wav");
1.628 + SetReadFileNameL( KTestWavFile );
1.629 +
1.630 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.631 + User::LeaveIfError( errorCode );
1.632 +
1.633 + //[ add data source and sink and prime the controller ]
1.634 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.635 + User::LeaveIfError( errorCode );
1.636 +
1.637 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.638 + User::LeaveIfError( errorCode );
1.639 +
1.640 + //[ set up audio commands utility ]
1.641 + RMMFAudioPlayDeviceCustomCommands theCommander( iController );
1.642 +
1.643 + // [ set the balance ]
1.644 + TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;;
1.645 + //[ set the Balance ]
1.646 + errorCode =theCommander.SetBalance( theBalance );
1.647 + User::LeaveIfError( errorCode );
1.648 +
1.649 + //[ get the balance ]
1.650 + TInt theNewBalance (0);
1.651 + errorCode =theCommander.GetBalance( theNewBalance );
1.652 + User::LeaveIfError( errorCode );
1.653 +
1.654 + // [ if set balance = got balance, setbalance2 != got balance
1.655 + // and rx'd event was ok then we are fine
1.656 + // set the balance to an arbitrary value in the range 0..100 and map to the soundev range]
1.657 + TInt overBalance = (300 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
1.658 +
1.659 + //[ set the volume ]
1.660 + TInt overBalanceErrorCode =theCommander.SetBalance( overBalance );
1.661 + //[ get the volume ]
1.662 + TInt overBalanceResult (-106); // set to an arbitrary value
1.663 + errorCode =theCommander.GetBalance( overBalanceResult );
1.664 + User::LeaveIfError( errorCode );
1.665 +
1.666 + // [ set the under balance to a value < 0 and map to the correct range]
1.667 + TInt underBalance = (-50 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
1.668 +
1.669 + //[ set the volume ]
1.670 + TInt underBalanceErrorCode =theCommander.SetBalance( underBalance );
1.671 + //[ get the volume ]
1.672 + TInt underBalanceResult (0);
1.673 + errorCode =theCommander.GetBalance( underBalanceResult );
1.674 + User::LeaveIfError( errorCode );
1.675 +
1.676 + // Set the test result
1.677 + if ((theBalance == theNewBalance) && // balance set correctly
1.678 + (overBalanceErrorCode == KErrNone) && // no error setting over balance
1.679 + (overBalanceResult == KMMFBalanceMaxRight) && // over balance is set to KMMFBalanceMaxRight
1.680 + (underBalanceErrorCode == KErrNone) && // no error setting under balance
1.681 + (underBalanceResult == KMMFBalanceMaxLeft)) // under balance is set to KMMFBalanceMaxLeft
1.682 + {
1.683 + result = EPass;
1.684 + }
1.685 +
1.686 + //[ ensure the controller is unloaded so that it does
1.687 + // not interfere with the following test ]
1.688 + // There is error in this code and the stop followed by reset
1.689 + // ensure the controller resources are released.
1.690 + iController.Stop();
1.691 + iController.Reset();
1.692 + iController.Close();
1.693 +
1.694 + __MM_HEAP_MARKEND;
1.695 + return result;
1.696 + }
1.697 +//
1.698 +/**
1.699 +*
1.700 +* CTestStepGetSetPositionInPaused
1.701 +*
1.702 +*/
1.703 +CTestStepGetSetPositionInPaused::CTestStepGetSetPositionInPaused()
1.704 + {
1.705 + iTestStepName = _L("MM-MMF-ACTRL-U-0070-HP");
1.706 + }
1.707 +
1.708 +/**
1.709 +*
1.710 +* ~CTestStepGetSetPositionInPaused
1.711 +*
1.712 +*/
1.713 +CTestStepGetSetPositionInPaused::~CTestStepGetSetPositionInPaused()
1.714 + {
1.715 + }
1.716 +
1.717 +/**
1.718 +*
1.719 +* DoTestStepL
1.720 +*
1.721 +*/
1.722 +TVerdict CTestStepGetSetPositionInPaused::DoTestStepL( void )
1.723 + {
1.724 + __MM_HEAP_MARK;
1.725 +
1.726 + TVerdict result = EPass;
1.727 + TTimeIntervalMicroSeconds position(0);
1.728 +
1.729 + _LIT( KTestPause, "Pause Test");
1.730 + Log( KTestPause );
1.731 +
1.732 + _LIT( KTestStepPause, "This test checks set/get position whilst paused: Play->Pause->Rewind->Play (Proper verification requires headphones)");
1.733 + Log( KTestStepPause );
1.734 +
1.735 + // [ audio file to play ]
1.736 + // At time of writing, this file is approx 8s duration.
1.737 + _LIT(KTestWavFile, "mainTst.wav");
1.738 + SetReadFileNameL( KTestWavFile );
1.739 +
1.740 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.741 + User::LeaveIfError( errorCode );
1.742 +
1.743 + //[ add data source and sink and prime the controller ]
1.744 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.745 + User::LeaveIfError( errorCode );
1.746 +
1.747 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.748 + User::LeaveIfError( errorCode );
1.749 +
1.750 + User::LeaveIfError( iController.Prime() );
1.751 +
1.752 + // [ wait for and process the return event from the audio output ]
1.753 +
1.754 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.755 + TVerdict searchResult = SearchForEvent( primeEvent );
1.756 + if( searchResult == EFail )
1.757 + {
1.758 + return searchResult;
1.759 + }
1.760 +
1.761 + User::LeaveIfError( iController.GetPosition( position ) );
1.762 + INFO_PRINTF2(_L("Position at start is %d"), position.Int64());
1.763 +
1.764 +
1.765 + // note this test does not wait around
1.766 + // to detect that the audio has been played
1.767 + User::LeaveIfError( iController.Play() );
1.768 +
1.769 + // [ now process the confirmation event that play has reached audio output
1.770 + // this is the raison detre of the test ]
1.771 + TMMFEvent playEvent1( KPlayTestId, KErrNone );
1.772 + searchResult = SearchForEvent( playEvent1 );
1.773 + if( searchResult == EFail )
1.774 + {
1.775 + return searchResult;
1.776 + }
1.777 +
1.778 + // [ play for two seconds ]
1.779 + User::After(2000000);
1.780 +
1.781 + User::LeaveIfError( iController.GetPosition( position ) );
1.782 + INFO_PRINTF2(_L("Position before pause is %d"), position.Int64());
1.783 +
1.784 +
1.785 + // [ The controller is in the play state and
1.786 + // should not return an error if pause is called ]
1.787 + User::LeaveIfError( iController.Pause() );
1.788 +
1.789 + TMMFEvent pauseEvent( KPauseTestId, KErrNone );
1.790 + result = SearchForEvent( pauseEvent );
1.791 + if( result == EFail )
1.792 + {
1.793 + return result;
1.794 + }
1.795 +
1.796 + User::LeaveIfError( iController.GetPosition( position ) );
1.797 + INFO_PRINTF2(_L("Position after pause is %d"), position.Int64());
1.798 +
1.799 + //[ ok lets reset to the beginning ]
1.800 + User::LeaveIfError( iController.SetPosition( TTimeIntervalMicroSeconds(0) ) );
1.801 +
1.802 + User::LeaveIfError( iController.GetPosition( position ) );
1.803 + INFO_PRINTF2(_L("Position after rewind is %d"), position.Int64());
1.804 +
1.805 +
1.806 + // [ Now let's start to play again ]
1.807 +
1.808 + // note this test does not wait around
1.809 + // to detect that the audio has been played
1.810 + User::LeaveIfError( iController.Play() );
1.811 +
1.812 + // [ now process the confirmation event that play has reached audio output
1.813 + // this is the raison detre of the test ]
1.814 + TMMFEvent playEvent2( KPlayTestId, KErrNone );
1.815 + searchResult = SearchForEvent( playEvent2 );
1.816 + if( searchResult == EFail )
1.817 + {
1.818 + return searchResult;
1.819 + }
1.820 +
1.821 + // [ play for 10s (approx entire file) ]
1.822 + User::After(10000000);
1.823 +
1.824 + //[ ensure the controller is unloaded so that it does
1.825 + // not interfere with the following test ]
1.826 + // There is error in this code and the stop followed by reset
1.827 + // ensure the controller resources are released.
1.828 + iController.Stop();
1.829 + iController.Reset();
1.830 + iController.Close();
1.831 +
1.832 + __MM_HEAP_MARKEND;
1.833 + return result;
1.834 + }
1.835 +//
1.836 +/**
1.837 +*
1.838 +* CTestStepGetSetPositionInPlay
1.839 +*
1.840 +*/
1.841 +CTestStepGetSetPositionInPlay::CTestStepGetSetPositionInPlay()
1.842 + {
1.843 + iTestStepName = _L("MM-MMF-ACTRL-U-0008-HP");
1.844 + }
1.845 +
1.846 +/**
1.847 +*
1.848 +* ~CTestStepGetSetPositionInPlay
1.849 +*
1.850 +*/
1.851 +CTestStepGetSetPositionInPlay::~CTestStepGetSetPositionInPlay()
1.852 + {
1.853 + }
1.854 +
1.855 +/**
1.856 +*
1.857 +* DoTestStepL
1.858 +*
1.859 +*/
1.860 +TVerdict CTestStepGetSetPositionInPlay::DoTestStepL( void )
1.861 + {
1.862 + __MM_HEAP_MARK;
1.863 +
1.864 + TVerdict result = EPass;
1.865 +
1.866 + _LIT( KTestPlay, "Play Test");
1.867 + Log( KTestPlay );
1.868 +
1.869 + _LIT( KTestStepPlay, "This test checks set/get position whilst playing");
1.870 + Log( KTestStepPlay );
1.871 +
1.872 + // [ audio file to play ]
1.873 + _LIT(KTestWavFile, "newmail.wav");
1.874 + SetReadFileNameL( KTestWavFile );
1.875 +
1.876 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.877 + User::LeaveIfError( errorCode );
1.878 +
1.879 + //[ add data source and sink and prime the controller ]
1.880 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.881 + User::LeaveIfError( errorCode );
1.882 +
1.883 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.884 + User::LeaveIfError( errorCode );
1.885 +
1.886 + errorCode = iController.Prime();
1.887 + User::LeaveIfError( errorCode );
1.888 +
1.889 + // [ wait for and process the return event from the audio output ]
1.890 +
1.891 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.892 + TVerdict searchResult = SearchForEvent( primeEvent );
1.893 + if( searchResult == EFail )
1.894 + {
1.895 + return searchResult;
1.896 + }
1.897 +
1.898 + User::LeaveIfError( iController.Play() );
1.899 +
1.900 + // note this test does not wait around
1.901 + // to detect that the audio has been played
1.902 + // [ now process the confirmation event that play has reached audio output
1.903 + // this is the raison detre of the test ]
1.904 + TMMFEvent playEvent( KPlayTestId, KErrNone );
1.905 +
1.906 + searchResult = SearchForEvent( playEvent );
1.907 + if( searchResult == EFail )
1.908 + {
1.909 + return searchResult;
1.910 + }
1.911 +
1.912 + //[ ok lets set/get the position ]
1.913 + TTimeIntervalMicroSeconds theStartPosition(0);
1.914 + TInt posSetError = iController.SetPosition( theStartPosition );
1.915 +
1.916 + // [get the position ]
1.917 + TTimeIntervalMicroSeconds theCurrentPosition;
1.918 + TInt posGetError = iController.GetPosition( theCurrentPosition );
1.919 +
1.920 + // [ the test has passed if we have no errors in both cases ]
1.921 + if( (posGetError != KErrNone ) &&
1.922 + (posSetError != KErrNone ) )
1.923 + {
1.924 + result = EFail ;
1.925 + }
1.926 +
1.927 + //[ ensure the controller is unloaded so that it does
1.928 + // not interfere with the following test ]
1.929 + // There is error in this code and the stop followed by reset
1.930 + // ensure the controller resources are released.
1.931 + iController.Stop();
1.932 + iController.Reset();
1.933 + iController.Close();
1.934 +
1.935 + __MM_HEAP_MARKEND;
1.936 + return result;
1.937 + }
1.938 +
1.939 +/**
1.940 +*
1.941 +*
1.942 +* CTestStepGetSetPositionInStopped
1.943 +*
1.944 +*/
1.945 +CTestStepGetSetPositionInStopped::CTestStepGetSetPositionInStopped()
1.946 + {
1.947 + iTestStepName = _L("MM-MMF-ACTRL-U-0009-HP");
1.948 + }
1.949 +
1.950 +/**
1.951 +*
1.952 +* ~CTestStepGetSetPositionInStopped
1.953 +*/
1.954 +CTestStepGetSetPositionInStopped::~CTestStepGetSetPositionInStopped()
1.955 + {
1.956 + }
1.957 +
1.958 +/**
1.959 +*
1.960 +* DoTestStepL
1.961 +*
1.962 +*/
1.963 +TVerdict CTestStepGetSetPositionInStopped::DoTestStepL( void )
1.964 + {
1.965 + __MM_HEAP_MARK;
1.966 + TVerdict result = EPass ;
1.967 + //[ In this state it should not be possible to set the positio]
1.968 +
1.969 + _LIT( KTestPlay, "Set/Get Position while stopped");
1.970 + Log( KTestPlay );
1.971 +
1.972 + _LIT( KTestStepPlay, "This test checks get/set position while stopped");
1.973 + Log( KTestStepPlay );
1.974 +
1.975 + // [ audio file to play ]
1.976 + _LIT(KTestWavFile, "newmail.wav");
1.977 + SetReadFileNameL( KTestWavFile );
1.978 +
1.979 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.980 + User::LeaveIfError( errorCode );
1.981 +
1.982 +
1.983 + //[ add data source and sink and prime the controller ]
1.984 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.985 + User::LeaveIfError( errorCode );
1.986 +
1.987 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.988 + User::LeaveIfError( errorCode );
1.989 +
1.990 + //[ set the position to the start ]
1.991 + TTimeIntervalMicroSeconds theStartPosition(0);
1.992 + TInt posSetError = iController.SetPosition( theStartPosition );
1.993 +
1.994 + // [get the position ]
1.995 + TTimeIntervalMicroSeconds theCurrentPosition;
1.996 + TInt posGetError = iController.GetPosition( theCurrentPosition );
1.997 +
1.998 + // [ the test has passed if we have errors in both cases ]
1.999 + if( (posGetError == KErrNone ) ||
1.1000 + (posSetError == KErrNone ) )
1.1001 + {
1.1002 + result = EFail ;
1.1003 + }
1.1004 +
1.1005 + //[ ensure the controller is unloaded so that it does
1.1006 + // not interfere with the following test ]
1.1007 + // There is error in this code and the stop followed by reset
1.1008 + // ensure the controller resources are released.
1.1009 + iController.Stop();
1.1010 + iController.Reset();
1.1011 + iController.Close();
1.1012 +
1.1013 + __MM_HEAP_MARKEND;
1.1014 + return result ;
1.1015 + }
1.1016 +
1.1017 +/**
1.1018 +*
1.1019 +* CTestStepGetSetPositionInPrimed
1.1020 +*/
1.1021 +CTestStepGetSetPositionInPrimed::CTestStepGetSetPositionInPrimed()
1.1022 + {
1.1023 + iTestStepName = _L("MM-MMF-ACTRL-U-0010-HP");
1.1024 + }
1.1025 +
1.1026 +/**
1.1027 +*
1.1028 +* ~CTestStepGetSetPositionInStopped
1.1029 +*/
1.1030 +CTestStepGetSetPositionInPrimed::~CTestStepGetSetPositionInPrimed()
1.1031 + {
1.1032 + }
1.1033 +
1.1034 +/**
1.1035 +*
1.1036 +* DoTestStepL
1.1037 +*
1.1038 +*/
1.1039 +TVerdict CTestStepGetSetPositionInPrimed::DoTestStepL( void )
1.1040 + {
1.1041 + __MM_HEAP_MARK;
1.1042 + TVerdict result = EPass ;
1.1043 +
1.1044 + _LIT( KTestStepPlay, "GetSet Position In Primed");
1.1045 + Log( KTestStepPlay );
1.1046 +
1.1047 + // [ audio file to play ]
1.1048 + _LIT(KTestWavFile, "newmail.wav");
1.1049 + SetReadFileNameL( KTestWavFile );
1.1050 +
1.1051 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.1052 + User::LeaveIfError( errorCode );
1.1053 +
1.1054 + //[ add data source and sink and prime the controller ]
1.1055 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.1056 + User::LeaveIfError( errorCode );
1.1057 +
1.1058 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.1059 + User::LeaveIfError( errorCode );
1.1060 +
1.1061 + errorCode = iController.Prime();
1.1062 + User::LeaveIfError( errorCode );
1.1063 +
1.1064 + // [ wait for and process the return event from the audio output ]
1.1065 +
1.1066 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.1067 + TVerdict searchResult = SearchForEvent( primeEvent );
1.1068 + if( searchResult == EFail )
1.1069 + {
1.1070 + return searchResult;
1.1071 + }
1.1072 +
1.1073 + // [get the duration of the file]
1.1074 + TTimeIntervalMicroSeconds theDuration;
1.1075 + TInt durationError = iController.GetDuration(theDuration);
1.1076 + User::LeaveIfError( durationError );
1.1077 +
1.1078 + //[ set the position to the end ]
1.1079 + TInt posError = iController.SetPosition( theDuration );
1.1080 + User::LeaveIfError( posError );
1.1081 +
1.1082 + // [get the position ]
1.1083 + TTimeIntervalMicroSeconds theEndPosition;
1.1084 + TInt positionError = iController.GetPosition( theEndPosition );
1.1085 + User::LeaveIfError( positionError );
1.1086 +
1.1087 + // [ set the position beyond the end ]
1.1088 + TInt64 beyondTheEnd = theDuration.Int64();
1.1089 + beyondTheEnd *= 1000000;
1.1090 + TTimeIntervalMicroSeconds beyondTheEndPosition( beyondTheEnd);
1.1091 +
1.1092 + // [get the position ]
1.1093 + TTimeIntervalMicroSeconds theCurrentPosition;
1.1094 + TInt currentPositionError = iController.GetPosition( theCurrentPosition );
1.1095 + User::LeaveIfError( currentPositionError );
1.1096 +
1.1097 + //[ set the position beyond the end ]
1.1098 + TInt beyondEndError = iController.SetPosition( beyondTheEndPosition );
1.1099 +
1.1100 + //[ get the position ]
1.1101 + TTimeIntervalMicroSeconds theCurrentPosition2;
1.1102 + currentPositionError = iController.GetPosition( theCurrentPosition2 );
1.1103 + User::LeaveIfError( currentPositionError );
1.1104 +
1.1105 + if( (theCurrentPosition2 != theCurrentPosition ) &&
1.1106 + ( beyondEndError == KErrNone ))
1.1107 + {
1.1108 + // altered position when wrong position was sent
1.1109 + // assumes this violation does not corrupt the current position
1.1110 + return EFail;
1.1111 + }
1.1112 +
1.1113 + // [ set the position before the start ]
1.1114 + currentPositionError = iController.GetPosition( theCurrentPosition );
1.1115 + User::LeaveIfError( currentPositionError );
1.1116 +
1.1117 + //[ set the position to a time < 0 ]
1.1118 + TTimeIntervalMicroSeconds beforeTheStart( -10000 );
1.1119 + //[ set the position beyond the end ]
1.1120 + TInt beforeStartError = iController.SetPosition( beforeTheStart );
1.1121 +
1.1122 + //[ get the position ]
1.1123 + currentPositionError = iController.GetPosition( theCurrentPosition2 );
1.1124 + User::LeaveIfError( currentPositionError );
1.1125 +
1.1126 + // [determine the results of the test]
1.1127 + if( (theCurrentPosition2 != theCurrentPosition ) &&
1.1128 + ( beforeStartError == KErrNone ))
1.1129 + {
1.1130 + // altered position when wrong position was sent
1.1131 + // assumes this violation does not corrupt the current position
1.1132 + return EFail;
1.1133 + }
1.1134 +
1.1135 + //[ ensure the controller is unloaded so that it does
1.1136 + // not interfere with the following test ]
1.1137 + // There is error in this code and the stop followed by reset
1.1138 + // ensure the controller resources are released.
1.1139 + iController.Stop();
1.1140 + iController.Reset();
1.1141 + iController.Close();
1.1142 +
1.1143 + __MM_HEAP_MARKEND;
1.1144 + return result;
1.1145 + }
1.1146 +
1.1147 +/**
1.1148 +*
1.1149 +* CTestStepGetSetNumChannelsOnSource
1.1150 +*
1.1151 +*/
1.1152 +CTestStepGetSetNumChannelsOnSource::CTestStepGetSetNumChannelsOnSource()
1.1153 + {
1.1154 + iTestStepName = _L("MM-MMF-ACTRL-U-0021-HP");
1.1155 + }
1.1156 +
1.1157 +/**
1.1158 +*
1.1159 +* ~CTestStepGetSetNumChannelsOnSource
1.1160 +*
1.1161 +*/
1.1162 +CTestStepGetSetNumChannelsOnSource::~CTestStepGetSetNumChannelsOnSource()
1.1163 + {
1.1164 + }
1.1165 +
1.1166 +/**
1.1167 +*
1.1168 +* DoTestStepL
1.1169 +*
1.1170 +*/
1.1171 +TVerdict CTestStepGetSetNumChannelsOnSource::DoTestStepL( void )
1.1172 + {
1.1173 + __MM_HEAP_MARK;
1.1174 + TVerdict result = EPass;
1.1175 +
1.1176 + _LIT( KTestSourceNumChannels, "GetSet Num Channels on the Source");
1.1177 + Log( KTestSourceNumChannels);
1.1178 +
1.1179 + _LIT( KTestSinkBitRateReason, "This test checks the set/get num channels on the source");
1.1180 + Log( KTestSinkBitRateReason );
1.1181 +
1.1182 + // [ audio file to play ]
1.1183 + _LIT(KTestWavFile, "newmail.wav");
1.1184 + SetReadFileNameL( KTestWavFile );
1.1185 +
1.1186 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.1187 + User::LeaveIfError( errorCode );
1.1188 +
1.1189 + // [ attempt to get the source num channels ]
1.1190 + RMMFAudioControllerCustomCommands theCommander( iController );
1.1191 +
1.1192 + TUint theRate = 0;
1.1193 + errorCode = theCommander.GetSourceNumChannels(theRate);
1.1194 + if( errorCode == KErrNone )
1.1195 + {
1.1196 + result = EFail;
1.1197 + return result;
1.1198 + }
1.1199 +
1.1200 + //[ ok lets add the source and sink ]
1.1201 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.1202 + User::LeaveIfError( errorCode );
1.1203 +
1.1204 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.1205 + User::LeaveIfError( errorCode );
1.1206 +
1.1207 + theRate = 0;
1.1208 + errorCode = theCommander.GetSourceNumChannels(theRate);
1.1209 + User::LeaveIfError( errorCode );
1.1210 +
1.1211 + //[ get the format ]
1.1212 + TUid theFormatUID;
1.1213 + errorCode = theCommander.GetSourceFormat(theFormatUID);
1.1214 + User::LeaveIfError( errorCode );
1.1215 +
1.1216 + //[ ensure we are in are not a raw format because
1.1217 + // this functionality is only supported in raw format]
1.1218 + if( theFormatUID == KFormatRAWRead )
1.1219 + {
1.1220 + result = EFail;
1.1221 + return result;
1.1222 + }
1.1223 +
1.1224 + // lets set the num of channels to 2
1.1225 + errorCode = theCommander.SetSourceNumChannels(theRate);
1.1226 + if( errorCode != KErrNone )
1.1227 + {
1.1228 + result = EFail;
1.1229 + return result ;
1.1230 + }
1.1231 +
1.1232 + //[ ensure the controller is unloaded so that it does
1.1233 + // not interfere with the following test ]
1.1234 + // There is error in this code and the stop followed by reset
1.1235 + // ensure the controller resources are released.
1.1236 + iController.Stop();
1.1237 + iController.Reset();
1.1238 + iController.Close();
1.1239 +
1.1240 + __MM_HEAP_MARKEND;
1.1241 + return EPass;
1.1242 + }
1.1243 +
1.1244 +/**
1.1245 +*
1.1246 +* CTestStepGetSetNumChannelsOnSink
1.1247 +*
1.1248 +*/
1.1249 +CTestStepGetSetNumChannelsOnSink::CTestStepGetSetNumChannelsOnSink()
1.1250 + {
1.1251 + iTestStepName = _L("MM-MMF-ACTRL-U-0022-HP");
1.1252 + }
1.1253 +
1.1254 +/**
1.1255 +*
1.1256 +* ~CTestStepGetSetNumChannelsOnSink
1.1257 +*
1.1258 +*/
1.1259 +CTestStepGetSetNumChannelsOnSink::~CTestStepGetSetNumChannelsOnSink()
1.1260 + {
1.1261 + }
1.1262 +
1.1263 +/**
1.1264 +*
1.1265 +* DoTestStepL
1.1266 +*
1.1267 +*/
1.1268 +TVerdict CTestStepGetSetNumChannelsOnSink::DoTestStepL( void )
1.1269 + {
1.1270 + __MM_HEAP_MARK;
1.1271 + TVerdict result = EPass;
1.1272 +
1.1273 + _LIT( KTestSourceNumChannels, "GetSet Num Channels on the Sink");
1.1274 + Log( KTestSourceNumChannels);
1.1275 +
1.1276 + _LIT( KTestSinkBitRateReason, "This test checks the set/get num channels on the sink");
1.1277 + Log( KTestSinkBitRateReason );
1.1278 +
1.1279 + // [ audio file to play ]
1.1280 + _LIT(KTestWavFile, "newmail.wav");
1.1281 + SetReadFileNameL( KTestWavFile );
1.1282 +
1.1283 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.1284 + User::LeaveIfError( errorCode );
1.1285 +
1.1286 + //[ attempt to get the sink num channels ]
1.1287 + RMMFAudioControllerCustomCommands theCommander( iController );
1.1288 +
1.1289 + TUint theRate = 0;
1.1290 + errorCode = theCommander.GetSinkNumChannels(theRate);
1.1291 + if( errorCode == KErrNone )
1.1292 + {
1.1293 + result = EFail;
1.1294 + return result;
1.1295 + }
1.1296 +
1.1297 + //[ ok lets add the source and sink ]
1.1298 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.1299 + User::LeaveIfError( errorCode );
1.1300 +
1.1301 + //[ add data source and sink and prime the controller ]
1.1302 + errorCode = iController.AddDataSink(KUidMmfFileSink, ReadFileConfig());
1.1303 + User::LeaveIfError( errorCode );
1.1304 +
1.1305 + //[ ok lets try to set the sink format to raw]
1.1306 + errorCode = theCommander.SetSinkFormat(KFormatRAWWrite);
1.1307 + User::LeaveIfError( errorCode );
1.1308 +
1.1309 + //[ ok lets set the number of channels ]
1.1310 + // lets set the num of channels to 2
1.1311 + TUint theNumChannels = 2;
1.1312 + errorCode = theCommander.SetSinkNumChannels(theNumChannels);
1.1313 + User::LeaveIfError( errorCode );
1.1314 +
1.1315 + // [ get the number of channels and see if it is the same ]
1.1316 + TUint theNewNumChannels = 0;
1.1317 + errorCode = theCommander.GetSinkNumChannels(theNewNumChannels);
1.1318 + User::LeaveIfError( errorCode );
1.1319 +
1.1320 + if( theNumChannels != theNewNumChannels )
1.1321 + {
1.1322 + result = EFail;
1.1323 + return result;
1.1324 + }
1.1325 +
1.1326 + //[ ensure the controller is unloaded so that it does
1.1327 + // not interfere with the following test ]
1.1328 + // There is error in this code and the stop followed by reset
1.1329 + // ensure the controller resources are released.
1.1330 + iController.Stop();
1.1331 + iController.Reset();
1.1332 + iController.Close();
1.1333 +
1.1334 + __MM_HEAP_MARKEND;
1.1335 + return result;
1.1336 + }
1.1337 +
1.1338 +/**
1.1339 +*
1.1340 +* CTestStepGetSetSinkFormat
1.1341 +*
1.1342 +*/
1.1343 +CTestStepGetSetSinkFormat::CTestStepGetSetSinkFormat()
1.1344 + {
1.1345 + iTestStepName = _L("MM-MMF-ACTRL-U-0023-HP");
1.1346 + }
1.1347 +
1.1348 +/**
1.1349 +*
1.1350 +* ~CTestStepGetSetSinkFormat
1.1351 +*
1.1352 +*/
1.1353 +CTestStepGetSetSinkFormat::~CTestStepGetSetSinkFormat()
1.1354 + {
1.1355 + }
1.1356 +
1.1357 +/**
1.1358 +*
1.1359 +* DoTestStepL
1.1360 +*
1.1361 +*/
1.1362 +TVerdict CTestStepGetSetSinkFormat::DoTestStepL( void )
1.1363 + {
1.1364 + __MM_HEAP_MARK;
1.1365 + TVerdict result = EPass ;
1.1366 +
1.1367 + _LIT( KTestSinkFormat, "Test Step Get/Set sink format");
1.1368 + Log( KTestSinkFormat );
1.1369 +
1.1370 + _LIT( KTestStepSinkFormat, "This test checks the set/get sink format");
1.1371 + Log( KTestStepSinkFormat );
1.1372 +
1.1373 + // [ audio file to play ]
1.1374 + _LIT(KTestWavFileRecord, "TempW.wav");
1.1375 + SetWriteFileNameL( KTestWavFileRecord );
1.1376 +
1.1377 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.1378 + User::LeaveIfError( errorCode );
1.1379 +
1.1380 + RMMFAudioControllerCustomCommands theCommander( iController );
1.1381 +
1.1382 +
1.1383 + //[ add sink format when no sink exists ]
1.1384 + errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
1.1385 + if( errorCode == KErrNone )
1.1386 + {
1.1387 + result = EFail;
1.1388 + return result;
1.1389 + }
1.1390 +
1.1391 + //[ ok lets add the source and sink ]
1.1392 + errorCode = iController.AddDataSource(KUidMmfAudioInput, KNullDesC8);
1.1393 + User::LeaveIfError( errorCode );
1.1394 +
1.1395 + errorCode = iController.AddDataSink(KUidMmfFileSink, WriteFileConfig());
1.1396 + User::LeaveIfError( errorCode );
1.1397 +
1.1398 + errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
1.1399 + User::LeaveIfError( errorCode );
1.1400 +
1.1401 + // [ add the format where the uid == the uid of the format ]
1.1402 + errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
1.1403 + User::LeaveIfError( errorCode );
1.1404 +
1.1405 + //[ ok lets try to set the sink format to au]
1.1406 + errorCode = theCommander.SetSinkFormat( KFormatAUWrite );
1.1407 + User::LeaveIfError( errorCode );
1.1408 +
1.1409 + errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
1.1410 + User::LeaveIfError( errorCode );
1.1411 +
1.1412 + // [ wait for and process the return event from the audio output ]
1.1413 + errorCode = iController.Prime();
1.1414 + User::LeaveIfError( errorCode );
1.1415 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.1416 + result = SearchForEvent( primeEvent );
1.1417 + if( result == EFail )
1.1418 + {
1.1419 + return result;
1.1420 + }
1.1421 +
1.1422 + errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
1.1423 + if( errorCode == KErrNone )
1.1424 + {
1.1425 + result = EFail;
1.1426 + return result;
1.1427 + }
1.1428 +
1.1429 + //[ lets do some recording ]
1.1430 + // note this test does not wait around
1.1431 + // to detect that the audio has been played
1.1432 + // [ now process the confirmation event that play has reached audio output
1.1433 + // this is the raison detre of the test ]
1.1434 + errorCode = iController.Play();
1.1435 + User::LeaveIfError( errorCode );
1.1436 + TMMFEvent playEvent( KPlayTestId, KErrNone );
1.1437 + result = SearchForEvent( playEvent );
1.1438 + if( result == EFail )
1.1439 + {
1.1440 + return result;
1.1441 + }
1.1442 +
1.1443 + // [ check that we cannot set the sink format when
1.1444 + // no data sink has been added to the controller ]
1.1445 + errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
1.1446 + if( errorCode == KErrNone )
1.1447 + {
1.1448 + result = EFail;
1.1449 + return result;
1.1450 + }
1.1451 +
1.1452 + // [ lets wait a few seconds for record to write its data ]
1.1453 + RTimer myTimer ;
1.1454 + User::LeaveIfError( myTimer.CreateLocal());
1.1455 + TRequestStatus timerStatus ;
1.1456 + const TInt KDelay = 1000000 ; // arbitrary delay
1.1457 + myTimer.After( timerStatus, KDelay );
1.1458 + User::WaitForRequest( timerStatus );
1.1459 +
1.1460 + //[ ensure the controller is unloaded so that it does
1.1461 + // not interfere with the following test ]
1.1462 + // There is error in this code and the stop followed by reset
1.1463 + // ensure the controller resources are released.
1.1464 + iController.Stop();
1.1465 + iController.Reset();
1.1466 + iController.Close();
1.1467 +
1.1468 + __MM_HEAP_MARKEND;
1.1469 + return result;
1.1470 + }
1.1471 +
1.1472 +/**
1.1473 +*
1.1474 +* CTestStepGetSetSourceFormat
1.1475 +*
1.1476 +*/
1.1477 +CTestStepGetSetSourceFormat::CTestStepGetSetSourceFormat()
1.1478 + {
1.1479 + iTestStepName = _L("MM-MMF-ACTRL-U-0024-HP");
1.1480 + }
1.1481 +
1.1482 +/**
1.1483 +*
1.1484 +* CTestStepGetSetSourceFormat
1.1485 +*
1.1486 +*/
1.1487 +CTestStepGetSetSourceFormat::~CTestStepGetSetSourceFormat()
1.1488 + {
1.1489 + }
1.1490 +
1.1491 +/**
1.1492 +*
1.1493 +* DoTestStepL
1.1494 +*
1.1495 +*/
1.1496 +TVerdict CTestStepGetSetSourceFormat::DoTestStepL( void )
1.1497 + {
1.1498 + __MM_HEAP_MARK;
1.1499 + TVerdict result = EPass;
1.1500 +
1.1501 + _LIT( KTestSourceNumChannels, "Test Step GetSet Source Format");
1.1502 + Log( KTestSourceNumChannels);
1.1503 +
1.1504 + _LIT( KTestSinkBitRateReason, "This test checks the set/get source format");
1.1505 + Log( KTestSinkBitRateReason );
1.1506 +
1.1507 + // [ audio file to play ]
1.1508 + _LIT(KTestWavFile, "newmail.wav");
1.1509 + SetReadFileNameL( KTestWavFile );
1.1510 +
1.1511 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.1512 + User::LeaveIfError( errorCode );
1.1513 +
1.1514 + RMMFAudioControllerCustomCommands theCommander( iController );
1.1515 +
1.1516 + //[ add source format when no source exists ]
1.1517 + errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
1.1518 + if( errorCode == KErrNone )
1.1519 + {
1.1520 + result = EFail;
1.1521 + return result;
1.1522 + }
1.1523 +
1.1524 + //[ ok lets add the source and sink ]
1.1525 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.1526 + User::LeaveIfError( errorCode );
1.1527 +
1.1528 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.1529 + User::LeaveIfError( errorCode );
1.1530 +
1.1531 + //errorCode = theCommander.SetSourceFormat( KWavUid );
1.1532 + errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
1.1533 + User::LeaveIfError( errorCode );
1.1534 +
1.1535 + // [ add the format where the uid == the uid of the format ]
1.1536 + errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
1.1537 + User::LeaveIfError( errorCode );
1.1538 +
1.1539 + //[ ok lets try to set the source format to raw]
1.1540 + errorCode = theCommander.SetSourceFormat(KFormatRAWRead);
1.1541 + User::LeaveIfError( errorCode );
1.1542 +
1.1543 + // [ add the format where the uid == the uid of the format ]
1.1544 + errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
1.1545 + User::LeaveIfError( errorCode );
1.1546 +
1.1547 +
1.1548 + // [ wait for and process the return event from the audio output ]
1.1549 + errorCode = iController.Prime();
1.1550 + User::LeaveIfError( errorCode );
1.1551 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.1552 + result = SearchForEvent( primeEvent );
1.1553 + if( result == EFail )
1.1554 + {
1.1555 + return result;
1.1556 + }
1.1557 +
1.1558 + // [ check that we cannot set the sink format when
1.1559 + // no data sink has been added to the controller ]
1.1560 + errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
1.1561 + if( errorCode == KErrNone )
1.1562 + {
1.1563 + result = EFail;
1.1564 + return result;
1.1565 + }
1.1566 +
1.1567 + // [ lets do some recording ]
1.1568 + // note this test does not wait around
1.1569 + // to detect that the audio has been played
1.1570 + // [ now process the confirmation event that play has reached audio output
1.1571 + // this is the raison detre of the test ]
1.1572 + errorCode = iController.Play();
1.1573 + User::LeaveIfError( errorCode );
1.1574 + TMMFEvent playEvent( KPlayTestId, KErrNone );
1.1575 + result = SearchForEvent( playEvent );
1.1576 + if( result == EFail )
1.1577 + {
1.1578 + return result;
1.1579 + }
1.1580 +
1.1581 +
1.1582 + // [ check that we cannot set the sink format when
1.1583 + // no data sink has been added to the controller ]
1.1584 + errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
1.1585 + if( errorCode == KErrNone )
1.1586 + {
1.1587 + result = EFail;
1.1588 + return result;
1.1589 + }
1.1590 +
1.1591 + // [ lets wait a few seconds for record to write its data ]
1.1592 + RTimer myTimer ;
1.1593 + User::LeaveIfError( myTimer.CreateLocal());
1.1594 + TRequestStatus timerStatus ;
1.1595 + const TInt KDelay = 1000000 ; // arbitrary delay
1.1596 + myTimer.After( timerStatus, KDelay );
1.1597 + User::WaitForRequest( timerStatus );
1.1598 +
1.1599 + //[ ensure the controller is unloaded so that it does
1.1600 + // not interfere with the following test ]
1.1601 + // There is error in this code and the stop followed by reset
1.1602 + // ensure the controller resources are released.
1.1603 + iController.Stop();
1.1604 + iController.Reset();
1.1605 + iController.Close();
1.1606 +
1.1607 + __MM_HEAP_MARKEND;
1.1608 + return result;
1.1609 + }
1.1610 +
1.1611 +/**
1.1612 +*
1.1613 +* CTestStepGetSetSourceSampleRate
1.1614 +*
1.1615 +*/
1.1616 +CTestStepGetSetSourceSampleRate::CTestStepGetSetSourceSampleRate()
1.1617 + {
1.1618 + iTestStepName = _L("MM-MMF-ACTRL-U-0025-HP");
1.1619 + }
1.1620 +
1.1621 +/**
1.1622 +*
1.1623 +* ~CTestStepGetSetSourceSampleRate
1.1624 +*
1.1625 +*/
1.1626 +CTestStepGetSetSourceSampleRate::~CTestStepGetSetSourceSampleRate()
1.1627 + {
1.1628 + }
1.1629 +
1.1630 +/**
1.1631 +*
1.1632 +* CTestStepGetSetSourceSampleRate
1.1633 +*
1.1634 +*/
1.1635 +TVerdict CTestStepGetSetSourceSampleRate::DoTestStepL( void )
1.1636 + {
1.1637 + __MM_HEAP_MARK;
1.1638 + TVerdict result = EPass;
1.1639 +
1.1640 + _LIT( KTestSourceNumChannels, "GetSet Source Sample Rate");
1.1641 + Log( KTestSourceNumChannels);
1.1642 +
1.1643 + _LIT( KTestSinkBitRateReason, "This test checks the set/get source sample rate");
1.1644 + Log( KTestSinkBitRateReason );
1.1645 +
1.1646 + // [ audio file to play ]
1.1647 + _LIT(KTestWavFile, "newmail.wav");
1.1648 + SetReadFileNameL( KTestWavFile );
1.1649 +
1.1650 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.1651 + User::LeaveIfError( errorCode );
1.1652 +
1.1653 + //[ attempt to get the sink num channels ]
1.1654 + RMMFAudioControllerCustomCommands theCommander( iController );
1.1655 +
1.1656 + RArray<TUint> supportedRates;
1.1657 + CleanupClosePushL(supportedRates);
1.1658 + TRAPD(errorCode2, theCommander.GetSupportedSourceSampleRatesL(supportedRates));
1.1659 + if ((errorCode2 == KErrNone ) || supportedRates.Count())
1.1660 + {
1.1661 + // should have failed with either an error code or non zero supported rates
1.1662 + result = EFail;
1.1663 + return result;
1.1664 + }
1.1665 +
1.1666 + TUint theRate = 0;
1.1667 + errorCode = theCommander.GetSourceSampleRate(theRate);
1.1668 + if( errorCode == KErrNone )
1.1669 + {
1.1670 + result = EFail;
1.1671 + return result;
1.1672 + }
1.1673 +
1.1674 + //[ ok lets add the source and sink ]
1.1675 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.1676 + User::LeaveIfError( errorCode );
1.1677 +
1.1678 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.1679 + User::LeaveIfError( errorCode );
1.1680 +
1.1681 + // Store the original sample rate
1.1682 + TUint origRate = 0;
1.1683 + errorCode = theCommander.GetSourceSampleRate(origRate);
1.1684 + if (errorCode != KErrNone)
1.1685 + {
1.1686 + INFO_PRINTF2(_L("Error getting original source sample rate %d"), errorCode);
1.1687 + return EFail;
1.1688 + }
1.1689 +
1.1690 + // Ensure the array is empty
1.1691 + supportedRates.Reset();
1.1692 + TRAPD( errorCode3,theCommander.GetSupportedSourceSampleRatesL(supportedRates));
1.1693 + User::LeaveIfError( errorCode3 );
1.1694 +
1.1695 + TUint theNewRate = 0;
1.1696 +
1.1697 + for (TInt index = 0; index < supportedRates.Count(); index++)
1.1698 + {
1.1699 + theRate = supportedRates[index];
1.1700 + // SetSourceSampleRate
1.1701 + errorCode = theCommander.SetSourceSampleRate(theRate);
1.1702 + if (theRate == origRate)
1.1703 + {
1.1704 + if (errorCode != KErrNone)
1.1705 + {
1.1706 + INFO_PRINTF2(_L("SetSourceSampleRate returned unexpected error %d"), errorCode);
1.1707 + result = EFail;
1.1708 + break;
1.1709 + }
1.1710 + }
1.1711 + else
1.1712 + {
1.1713 + // Setting source sample rate to a different value
1.1714 + // is tolerated (INC038043) to preserve BC with 6.1
1.1715 + if (errorCode != KErrNone)
1.1716 + {
1.1717 + INFO_PRINTF3(_L("SetSourceDataType returned %d, expecting %d"), errorCode, KErrAlreadyExists);
1.1718 + result = EFail;
1.1719 + break;
1.1720 + }
1.1721 + }
1.1722 + // GetSourceSampleRate
1.1723 + errorCode = theCommander.GetSourceSampleRate(theNewRate);
1.1724 + if (theNewRate != origRate)
1.1725 + {
1.1726 + INFO_PRINTF3(_L("GetSourceSampleRate rate %d did not match expected %d"), theNewRate, origRate);
1.1727 + result = EFail;
1.1728 + break;
1.1729 + }
1.1730 +
1.1731 + if (errorCode != KErrNone)
1.1732 + {
1.1733 + INFO_PRINTF3(_L("GetSourceSampleRate returned unexpected error %d, expected %d"), errorCode, KErrNone);
1.1734 + result = EFail;
1.1735 + break;
1.1736 + }
1.1737 + }
1.1738 +
1.1739 + CleanupStack::PopAndDestroy(1); // supportedRates
1.1740 +
1.1741 + //[ ensure the controller is unloaded so that it does
1.1742 + // not interfere with the following test ]
1.1743 + // There is error in this code and the stop followed by reset
1.1744 + // ensure the controller resources are released.
1.1745 + iController.Stop();
1.1746 + iController.Reset();
1.1747 + iController.Close();
1.1748 +
1.1749 + __MM_HEAP_MARKEND;
1.1750 + return result ;
1.1751 + }
1.1752 +
1.1753 +/**
1.1754 +*
1.1755 +* CTestStepGetSetSinkSampleRate
1.1756 +*
1.1757 +*/
1.1758 +CTestStepGetSetSinkSampleRate::CTestStepGetSetSinkSampleRate()
1.1759 + {
1.1760 + iTestStepName = _L("MM-MMF-ACTRL-U-0026-HP");
1.1761 + }
1.1762 +
1.1763 +/**
1.1764 +*
1.1765 +* ~CTestStepGetSetSinkSampleRate
1.1766 +*
1.1767 +*/
1.1768 +CTestStepGetSetSinkSampleRate::~CTestStepGetSetSinkSampleRate()
1.1769 + {
1.1770 + }
1.1771 +
1.1772 +/**
1.1773 +*
1.1774 +* DoTestStepL
1.1775 +*
1.1776 +*/
1.1777 +TVerdict CTestStepGetSetSinkSampleRate::DoTestStepL( void )
1.1778 + {
1.1779 + __MM_HEAP_MARK;
1.1780 + TVerdict result = EPass;
1.1781 +
1.1782 + _LIT( KTestSourceNumChannels, "GetSet Sink Sample Rate");
1.1783 + Log( KTestSourceNumChannels);
1.1784 +
1.1785 + _LIT( KTestSinkBitRateReason, "This test checks the set/get sink sample rate");
1.1786 + Log( KTestSinkBitRateReason );
1.1787 +
1.1788 + // [ audio file to play ]
1.1789 + _LIT(KTestWavFile, "newmail.wav");
1.1790 + SetReadFileNameL( KTestWavFile );
1.1791 +
1.1792 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.1793 + User::LeaveIfError( errorCode );
1.1794 +
1.1795 + //[ attempt to get the sink num channels ]
1.1796 + RMMFAudioControllerCustomCommands theCommander( iController );
1.1797 +
1.1798 + TUint theRate = 0;
1.1799 + errorCode = theCommander.GetSinkSampleRate(theRate);
1.1800 + if( errorCode == KErrNone )
1.1801 + {
1.1802 + result = EFail;
1.1803 + }
1.1804 +
1.1805 + //[ ok lets add the source and sink ]
1.1806 + if(result==EPass)
1.1807 + {
1.1808 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.1809 + if(errorCode!=KErrNone)
1.1810 + {
1.1811 + result=EFail;
1.1812 + }
1.1813 + }
1.1814 +
1.1815 + if(result==EPass)
1.1816 + {
1.1817 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.1818 + if(errorCode!=KErrNone)
1.1819 + {
1.1820 + result=EFail;
1.1821 + }
1.1822 + }
1.1823 +
1.1824 + if(result==EPass)
1.1825 + {
1.1826 + theRate = 0;
1.1827 + errorCode = theCommander.GetSinkSampleRate(theRate);
1.1828 + if(errorCode!=KErrNotSupported)
1.1829 + {
1.1830 + INFO_PRINTF2(_L("GetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
1.1831 + result = EFail;
1.1832 + }
1.1833 + }
1.1834 +
1.1835 + if(result==EPass)
1.1836 + {
1.1837 + //[ set the sample rate ]
1.1838 + errorCode = theCommander.SetSinkSampleRate(theRate);
1.1839 + if(errorCode!=KErrNotSupported)
1.1840 + {
1.1841 + INFO_PRINTF2(_L("SetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
1.1842 + result = EFail;
1.1843 + }
1.1844 + }
1.1845 +
1.1846 + if(result==EPass)
1.1847 + {
1.1848 + TUint theSampleRate( 8000); // set sample rate to 8khz arbitrary value
1.1849 + //[ set the sample rate ]
1.1850 + theRate = theSampleRate; // known reasonable value
1.1851 + errorCode = theCommander.SetSinkSampleRate(theRate);
1.1852 + if(errorCode!=KErrNotSupported)
1.1853 + {
1.1854 + INFO_PRINTF2(_L("SetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
1.1855 + result = EFail;
1.1856 + }
1.1857 + }
1.1858 +
1.1859 + if(result==EPass)
1.1860 + {
1.1861 + theRate = 0;
1.1862 + errorCode = theCommander.GetSinkSampleRate(theRate);
1.1863 + if(errorCode!=KErrNotSupported)
1.1864 + {
1.1865 + INFO_PRINTF2(_L("GetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
1.1866 + result = EFail;
1.1867 + }
1.1868 + }
1.1869 +
1.1870 + //[ ensure the controller is unloaded so that it does
1.1871 + // not interfere with the following test ]
1.1872 + // There is error in this code and the stop followed by reset
1.1873 + // ensure the controller resources are released.
1.1874 + iController.Stop();
1.1875 + iController.Reset();
1.1876 + iController.Close();
1.1877 +
1.1878 + __MM_HEAP_MARKEND;
1.1879 + return result;
1.1880 + }
1.1881 +
1.1882 +/**
1.1883 +*
1.1884 +* CTestStepGetSetSourceBitRate
1.1885 +*
1.1886 +*/
1.1887 +CTestStepGetSetSourceBitRate::CTestStepGetSetSourceBitRate()
1.1888 + {
1.1889 + iTestStepName = _L("MM-MMF-ACTRL-U-0027-HP");
1.1890 + }
1.1891 +
1.1892 +/**
1.1893 +*
1.1894 +* ~CTestStepGetSetSourceBitRate
1.1895 +*
1.1896 +*/
1.1897 +CTestStepGetSetSourceBitRate::~CTestStepGetSetSourceBitRate()
1.1898 + {
1.1899 + }
1.1900 +
1.1901 +/**
1.1902 +*
1.1903 +* DoTestStepL
1.1904 +*
1.1905 +*/
1.1906 +TVerdict CTestStepGetSetSourceBitRate::DoTestStepL( void )
1.1907 + {
1.1908 + __MM_HEAP_MARK;
1.1909 + TVerdict result = EPass;
1.1910 +
1.1911 + _LIT( KTestSourceNumChannels, "GetSet Source Bit Rate");
1.1912 + Log( KTestSourceNumChannels);
1.1913 +
1.1914 + _LIT( KTestSinkBitRateReason, "This test checks the set/get source bit rate");
1.1915 + Log( KTestSinkBitRateReason );
1.1916 +
1.1917 + // [ audio file to play ]
1.1918 + _LIT(KTestWavFile, "newmail.wav");
1.1919 + SetReadFileNameL( KTestWavFile );
1.1920 +
1.1921 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.1922 + User::LeaveIfError( errorCode );
1.1923 +
1.1924 + //[ attempt to get the sink num channels ]
1.1925 + RMMFAudioControllerCustomCommands theCommander( iController );
1.1926 +
1.1927 + TUint theRate = 0;
1.1928 + errorCode = theCommander.GetSourceBitRate(theRate);
1.1929 + if( errorCode == KErrNone )
1.1930 + {
1.1931 + result = EFail;
1.1932 + return result;
1.1933 + }
1.1934 +
1.1935 + //[ ok lets add the source and sink ]
1.1936 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.1937 + User::LeaveIfError( errorCode );
1.1938 +
1.1939 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.1940 + User::LeaveIfError( errorCode );
1.1941 +
1.1942 + theRate = 0;
1.1943 + errorCode = theCommander.GetSourceBitRate(theRate);
1.1944 + User::LeaveIfError( errorCode );
1.1945 +
1.1946 + // check to see if the bitrate is greater than zero
1.1947 + // (it should exactly be samplerate*bitspersample)
1.1948 + if (theRate == 0)
1.1949 + {
1.1950 + result = EFail;
1.1951 + return result;
1.1952 + }
1.1953 +
1.1954 + //[ this is currently not supported ]
1.1955 + errorCode = theCommander.SetSourceBitRate(theRate);
1.1956 + if( errorCode == KErrNone )
1.1957 + {
1.1958 + result = EFail;
1.1959 + return result;
1.1960 + }
1.1961 +
1.1962 + //[ ensure the controller is unloaded so that it does
1.1963 + // not interfere with the following test ]
1.1964 + // There is error in this code and the stop followed by reset
1.1965 + // ensure the controller resources are released.
1.1966 + iController.Stop();
1.1967 + iController.Reset();
1.1968 + iController.Close();
1.1969 +
1.1970 + __MM_HEAP_MARKEND;
1.1971 + return result;
1.1972 + }
1.1973 +
1.1974 +/**
1.1975 +*
1.1976 +* CTestStepGetSetSourceDataType
1.1977 +*
1.1978 +*/
1.1979 +CTestStepGetSetSourceDataType::CTestStepGetSetSourceDataType()
1.1980 + {
1.1981 + iTestStepName = _L("MM-MMF-ACTRL-U-0028-HP");
1.1982 + }
1.1983 +
1.1984 +/**
1.1985 +*
1.1986 +* ~CTestStepGetSetSourceDataType
1.1987 +*
1.1988 +*/
1.1989 +CTestStepGetSetSourceDataType::~CTestStepGetSetSourceDataType()
1.1990 + {
1.1991 + }
1.1992 +
1.1993 +/**
1.1994 +*
1.1995 +* DoTestStepL
1.1996 +*
1.1997 +*/
1.1998 +TVerdict CTestStepGetSetSourceDataType::DoTestStepL( void )
1.1999 + {
1.2000 + __MM_HEAP_MARK;
1.2001 + TVerdict result = EPass;
1.2002 +
1.2003 + _LIT( KTestSourceNumChannels, "GetSet Source Data type");
1.2004 + Log( KTestSourceNumChannels);
1.2005 +
1.2006 + _LIT( KTestSinkBitRateReason, "This test checks the set/get source data type");
1.2007 + Log( KTestSinkBitRateReason );
1.2008 +
1.2009 + // [ audio file to play ]
1.2010 + _LIT(KTestWavFile, "newmail.wav");
1.2011 + SetReadFileNameL( KTestWavFile );
1.2012 +
1.2013 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.2014 + User::LeaveIfError( errorCode );
1.2015 +
1.2016 + //[ attempt to get the sink num channels ]
1.2017 + RMMFAudioControllerCustomCommands theCommander( iController );
1.2018 +
1.2019 + TFourCC theFCC;
1.2020 + errorCode = theCommander.GetSourceDataType( theFCC );
1.2021 + if( errorCode == KErrNone )
1.2022 + {
1.2023 + result = EFail;
1.2024 + return result;
1.2025 + }
1.2026 +
1.2027 + //[ ok lets add the source and sink ]
1.2028 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.2029 + User::LeaveIfError( errorCode );
1.2030 +
1.2031 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.2032 + User::LeaveIfError( errorCode );
1.2033 +
1.2034 + errorCode = theCommander.GetSourceDataType( theFCC );
1.2035 + User::LeaveIfError( errorCode );
1.2036 +
1.2037 + TFourCC theNewFCC;
1.2038 + errorCode = theCommander.SetSourceDataType( theFCC );
1.2039 + User::LeaveIfError( errorCode );
1.2040 +
1.2041 + errorCode = theCommander.GetSourceDataType( theNewFCC );
1.2042 + User::LeaveIfError( errorCode );
1.2043 +
1.2044 + if( theNewFCC != theFCC )
1.2045 + {
1.2046 + result = EFail;
1.2047 + }
1.2048 +
1.2049 + //[ ensure the controller is unloaded so that it does
1.2050 + // not interfere with the following test ]
1.2051 + // There is error in this code and the stop followed by reset
1.2052 + // ensure the controller resources are released.
1.2053 + iController.Stop();
1.2054 + iController.Reset();
1.2055 + iController.Close();
1.2056 +
1.2057 + __MM_HEAP_MARKEND;
1.2058 + return result;
1.2059 + }
1.2060 +
1.2061 +/**
1.2062 +*
1.2063 +* CTestStepGetSetSinkDataType
1.2064 +*
1.2065 +*/
1.2066 +CTestStepGetSetSinkDataType::CTestStepGetSetSinkDataType()
1.2067 + {
1.2068 + iTestStepName = _L("MM-MMF-ACTRL-U-0029-HP");
1.2069 + }
1.2070 +
1.2071 +/**
1.2072 +*
1.2073 +* ~CTestStepGetSetSinkDataType
1.2074 +*
1.2075 +*/
1.2076 +CTestStepGetSetSinkDataType::~CTestStepGetSetSinkDataType()
1.2077 + {
1.2078 + }
1.2079 +
1.2080 +/**
1.2081 +*
1.2082 +* DoTestStepL
1.2083 +*
1.2084 +*/
1.2085 +TVerdict CTestStepGetSetSinkDataType::DoTestStepL( void )
1.2086 + {
1.2087 + __MM_HEAP_MARK;
1.2088 + TVerdict result = EPass;
1.2089 +
1.2090 + _LIT( KTestSourceNumChannels, "GetSet Sink Data type");
1.2091 + Log( KTestSourceNumChannels);
1.2092 +
1.2093 + _LIT( KTestSinkBitRateReason, "This test checks the set/get sink data type");
1.2094 + Log( KTestSinkBitRateReason );
1.2095 +
1.2096 + // [ audio file to play ]
1.2097 + _LIT(KTestWavFile, "newmail.wav");
1.2098 + SetReadFileNameL( KTestWavFile );
1.2099 +
1.2100 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.2101 + User::LeaveIfError( errorCode );
1.2102 +
1.2103 + //[ attempt to get the sink num channels ]
1.2104 + RMMFAudioControllerCustomCommands theCommander( iController );
1.2105 +
1.2106 + TFourCC theFCC;
1.2107 + errorCode = theCommander.GetSinkDataType( theFCC );
1.2108 + if( errorCode == KErrNone )
1.2109 + {
1.2110 + result = EFail;
1.2111 + }
1.2112 +
1.2113 + //[ ok lets add the source and sink ]
1.2114 + if(result==EPass)
1.2115 + {
1.2116 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.2117 + if(errorCode!=KErrNone)
1.2118 + {
1.2119 + result=EFail;
1.2120 + }
1.2121 + }
1.2122 +
1.2123 + if(result==EPass)
1.2124 + {
1.2125 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.2126 + if(errorCode!=KErrNone)
1.2127 + {
1.2128 + result=EFail;
1.2129 + }
1.2130 + }
1.2131 +
1.2132 + if(result==EPass)
1.2133 + {
1.2134 + errorCode = theCommander.GetSinkDataType( theFCC );
1.2135 + if(errorCode!=KErrNotSupported)
1.2136 + {
1.2137 + INFO_PRINTF2(_L("GetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
1.2138 + result = EFail;
1.2139 + }
1.2140 + }
1.2141 +
1.2142 + if(result==EPass)
1.2143 + {
1.2144 + errorCode = theCommander.SetSinkDataType( theFCC );
1.2145 + if(errorCode!=KErrNotSupported)
1.2146 + {
1.2147 + INFO_PRINTF2(_L("SetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
1.2148 + result = EFail;
1.2149 + }
1.2150 + }
1.2151 +
1.2152 + if(result==EPass)
1.2153 + {
1.2154 + TFourCC theNewFCC;
1.2155 + errorCode = theCommander.GetSinkDataType( theNewFCC );
1.2156 + if(errorCode!=KErrNotSupported)
1.2157 + {
1.2158 + INFO_PRINTF2(_L("GetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
1.2159 + result = EFail;
1.2160 + }
1.2161 + }
1.2162 +
1.2163 + //[ ensure the controller is unloaded so that it does
1.2164 + // not interfere with the following test ]
1.2165 + // There is error in this code and the stop followed by reset
1.2166 + // ensure the controller resources are released.
1.2167 + iController.Stop();
1.2168 + iController.Reset();
1.2169 + iController.Close();
1.2170 +
1.2171 + __MM_HEAP_MARKEND;
1.2172 + return result;
1.2173 + }
1.2174 +
1.2175 +/**
1.2176 +*
1.2177 +* CTestStepGetSetSinkBitRate
1.2178 +*
1.2179 +*/
1.2180 +
1.2181 +CTestStepGetSetSinkBitRate::CTestStepGetSetSinkBitRate()
1.2182 + {
1.2183 + iTestStepName = _L("MM-MMF-ACTRL-U-0030-HP");
1.2184 + }
1.2185 +
1.2186 +/**
1.2187 +*
1.2188 +* ~CTestStepGetSetSinkDataType
1.2189 +*
1.2190 +*/
1.2191 +
1.2192 +CTestStepGetSetSinkBitRate::~CTestStepGetSetSinkBitRate()
1.2193 + {
1.2194 + }
1.2195 +
1.2196 +/**
1.2197 +*
1.2198 +* DoTestStepL
1.2199 +*
1.2200 +*/
1.2201 +
1.2202 +TVerdict CTestStepGetSetSinkBitRate::DoTestStepL( void )
1.2203 + {
1.2204 + __MM_HEAP_MARK;
1.2205 + TVerdict result = EPass;
1.2206 +
1.2207 + _LIT( KTestSourceNumChannels, "GetSetSinkBitRate");
1.2208 + Log( KTestSourceNumChannels);
1.2209 +
1.2210 + _LIT( KTestSinkBitRateReason, "This test checks setting and getting a sinks bit rate");
1.2211 + Log( KTestSinkBitRateReason );
1.2212 +
1.2213 + // [ audio file to play ]
1.2214 + _LIT(KTestWavFile, "newmail.wav");
1.2215 + SetReadFileNameL( KTestWavFile );
1.2216 +
1.2217 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.2218 + User::LeaveIfError( errorCode );
1.2219 +
1.2220 + // [ attempt to get the bit rate with out a sink]
1.2221 + RMMFAudioControllerCustomCommands theCommander( iController );
1.2222 +
1.2223 + TUint theRate = 0;
1.2224 + errorCode = theCommander.GetSinkBitRate(theRate);
1.2225 + if( errorCode == KErrNone )
1.2226 + {
1.2227 + result = EFail;
1.2228 + return result;
1.2229 + }
1.2230 +
1.2231 + //[ add data source and sink and prime the controller ]
1.2232 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.2233 + User::LeaveIfError( errorCode );
1.2234 +
1.2235 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.2236 + User::LeaveIfError( errorCode );
1.2237 +
1.2238 + errorCode = theCommander.GetSinkBitRate(theRate);
1.2239 + if( errorCode == KErrNone )
1.2240 + {
1.2241 + result = EFail;
1.2242 + return result;
1.2243 + }
1.2244 +
1.2245 + errorCode = iController.Prime();
1.2246 + User::LeaveIfError( errorCode );
1.2247 +
1.2248 + // [ wait for and process the return event from the audio output ]
1.2249 +
1.2250 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.2251 + result = SearchForEvent( primeEvent );
1.2252 + if( result == EFail )
1.2253 + {
1.2254 + return result;
1.2255 + }
1.2256 +
1.2257 + //[ check when we are primed ]
1.2258 + errorCode = theCommander.GetSinkBitRate(theRate);
1.2259 + if( errorCode == KErrNone )
1.2260 + {
1.2261 + result = EFail;
1.2262 + return result;
1.2263 + }
1.2264 +
1.2265 + // [ lets reset and add a data sink and source that will
1.2266 + // exercise the happy day scenario ]
1.2267 + errorCode = iController.Reset();
1.2268 + User::LeaveIfError( errorCode );
1.2269 +
1.2270 + // [ check when recording ]
1.2271 + _LIT(KTestWavFileRecord, "16bitmpcm.wav");
1.2272 +
1.2273 + SetReadFileNameL( KTestWavFileRecord );
1.2274 + // check if record file already exists
1.2275 + TEntry fileEntry;
1.2276 + TInt fileErr = iFs.Entry(ReadFileConfig()().iPath, fileEntry);
1.2277 + if (fileErr != KErrNotFound)
1.2278 + {
1.2279 + User::LeaveIfError(fileErr);
1.2280 + }
1.2281 +
1.2282 + //[ add data source and sink and prime the controller ]
1.2283 + errorCode = iController.AddDataSource(KUidMmfAudioInput, KNullDesC8);
1.2284 + User::LeaveIfError( errorCode );
1.2285 +
1.2286 + //[ add data source and sink and prime the controller ]
1.2287 + errorCode = iController.AddDataSink(KUidMmfFileSink, ReadFileConfig());
1.2288 + User::LeaveIfError( errorCode );
1.2289 +
1.2290 + //[lets get the sink bit rate]
1.2291 + errorCode = theCommander.GetSinkBitRate(theRate);
1.2292 + User::LeaveIfError( errorCode );
1.2293 +
1.2294 + // check to see if the bitrate is greater than zero
1.2295 + // (it should exactly be samplerate*bitspersample)
1.2296 + // fail if the bitrate returned is zero and the record file exists
1.2297 + if ((theRate == 0) && (fileErr != KErrNotFound))
1.2298 + {
1.2299 + result = EFail;
1.2300 + return result;
1.2301 + }
1.2302 +
1.2303 + const TUint KArbitraryBitRate = 1000; // 1 Khz
1.2304 + //[lets get the sink bit rate]
1.2305 + errorCode = theCommander.SetSinkBitRate( KArbitraryBitRate );
1.2306 + if( errorCode == KErrNone )
1.2307 + {
1.2308 + result = EFail;
1.2309 + return result;
1.2310 + }
1.2311 +
1.2312 + errorCode = iController.Prime();
1.2313 + User::LeaveIfError( errorCode );
1.2314 +
1.2315 + // [ wait for and process the return event from the audio output ]
1.2316 + result = SearchForEvent( primeEvent );
1.2317 + if( result == EFail )
1.2318 + {
1.2319 + return result;
1.2320 + }
1.2321 +
1.2322 + //[ get the bit rate while playing ]
1.2323 + User::LeaveIfError( iController.Play() );
1.2324 + TMMFEvent playEvent( KPlayTestId, KErrNone );
1.2325 +
1.2326 + result = SearchForEvent( playEvent );
1.2327 + if( result == EFail )
1.2328 + {
1.2329 + return result;
1.2330 + }
1.2331 +
1.2332 + //[lets get the sink bit rate]
1.2333 + errorCode = theCommander.GetSinkBitRate(theRate);
1.2334 + User::LeaveIfError( errorCode );
1.2335 +
1.2336 + // check to see if the bitrate is greater than zero
1.2337 + // (it should exactly be samplerate*bitspersample)
1.2338 + if (theRate == 0)
1.2339 + {
1.2340 + result = EFail;
1.2341 + return result;
1.2342 + }
1.2343 +
1.2344 + //[lets get the sink bit rate]
1.2345 + errorCode = theCommander.SetSinkBitRate(1000);
1.2346 + if( errorCode == KErrNone )
1.2347 + {
1.2348 + result = EFail;
1.2349 + return result;
1.2350 + }
1.2351 +
1.2352 + //[ ensure the controller is unloaded so that it does
1.2353 + // not interfere with the following test ]
1.2354 + // There is error in this code and the stop followed by reset
1.2355 + // ensure the controller resources are released.
1.2356 + iController.Stop();
1.2357 + iController.Reset();
1.2358 + iController.Close();
1.2359 +
1.2360 + __MM_HEAP_MARKEND;
1.2361 +
1.2362 + // test steps return a result
1.2363 + return result;
1.2364 + }
1.2365 +
1.2366 +/**
1.2367 +*
1.2368 +* CTestStepGetSetMetaData
1.2369 +*/
1.2370 +CTestStepGetSetMetaData::CTestStepGetSetMetaData()
1.2371 + {
1.2372 + iTestStepName = _L("MM-MMF-ACTRL-U-0031-HP");
1.2373 + }
1.2374 +
1.2375 +/**
1.2376 +*
1.2377 +* ~CTestStepGetSetMetaData
1.2378 +*/
1.2379 +CTestStepGetSetMetaData::~CTestStepGetSetMetaData()
1.2380 + {
1.2381 + }
1.2382 +
1.2383 +/**
1.2384 +*
1.2385 +* DoTestStepL
1.2386 +*/
1.2387 +TVerdict CTestStepGetSetMetaData::DoTestStepL( void )
1.2388 + {
1.2389 + __MM_HEAP_MARK;
1.2390 +
1.2391 + TVerdict result = EFail;
1.2392 +
1.2393 + _LIT( KTestPlay, "Meta data test with play scenario Test");
1.2394 + Log( KTestPlay );
1.2395 +
1.2396 + _LIT( KTestStepPlay, "This test checks setting/getting meta data");
1.2397 + Log( KTestStepPlay );
1.2398 +
1.2399 + // [ audio file to play ]
1.2400 + _LIT(KTestWavFile, "newmail.wav");
1.2401 + SetReadFileNameL( KTestWavFile );
1.2402 +
1.2403 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.2404 + User::LeaveIfError( errorCode );
1.2405 +
1.2406 + //[ add data source and sink and prime the controller ]
1.2407 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.2408 + User::LeaveIfError( errorCode );
1.2409 +
1.2410 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.2411 + User::LeaveIfError( errorCode );
1.2412 +
1.2413 + // [ lets get the number of meta data entries
1.2414 + // for this format the meta data is unsupported ]
1.2415 + TInt numEntries = 0;
1.2416 + errorCode = iController.GetNumberOfMetaDataEntries( numEntries );
1.2417 + if( errorCode != KErrNotSupported )
1.2418 + {
1.2419 + User::LeaveIfError( errorCode );
1.2420 + }
1.2421 +
1.2422 + // [ lets get a meta data entry ]
1.2423 + const TInt KIndex = 0;
1.2424 + TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
1.2425 + if( errorCode != KErrNotSupported )
1.2426 + {
1.2427 + User::LeaveIfError( errorCode );
1.2428 + }
1.2429 +
1.2430 + errorCode = iController.Prime();
1.2431 + User::LeaveIfError( errorCode );
1.2432 +
1.2433 + // [ wait for and process the return event from the audio output ]
1.2434 +
1.2435 + TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1.2436 + result = SearchForEvent( primeEvent );
1.2437 + if( result == EFail )
1.2438 + {
1.2439 + return result;
1.2440 + }
1.2441 +
1.2442 + // [ lets get the number of meta data entries
1.2443 + // for this format the meta data is unsupported ]
1.2444 + numEntries = 0;
1.2445 + errorCode = iController.GetNumberOfMetaDataEntries( numEntries );
1.2446 + if( errorCode != KErrNotSupported )
1.2447 + {
1.2448 + User::LeaveIfError( errorCode );
1.2449 + }
1.2450 +
1.2451 + // [ lets get a meta data entry ]
1.2452 + TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
1.2453 + if( errorCode != KErrNotSupported )
1.2454 + {
1.2455 + User::LeaveIfError( errorCode );
1.2456 + }
1.2457 +
1.2458 + User::LeaveIfError( iController.Play() );
1.2459 +
1.2460 + // note this test does not wait around
1.2461 + // to detect that the audio has been played
1.2462 + // [ now process the confirmation event that play has reached audio output
1.2463 + // this is the raison detre of the test ]
1.2464 + TMMFEvent playEvent( KPlayTestId, KErrNone );
1.2465 +
1.2466 + result = SearchForEvent( playEvent );
1.2467 +
1.2468 + // [ lets try to get the meta data when playing ]
1.2469 +
1.2470 + errorCode = iController.GetNumberOfMetaDataEntries( numEntries );
1.2471 + if( errorCode != KErrNotReady )
1.2472 + {
1.2473 + User::LeaveIfError( errorCode );
1.2474 + }
1.2475 +
1.2476 + // [ lets get a meta data entry ]
1.2477 + // This kills the thread and is under investigation
1.2478 + TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
1.2479 + if( errorCode != KErrNotReady )
1.2480 + {
1.2481 + User::LeaveIfError( errorCode );
1.2482 + }
1.2483 +
1.2484 + //[ ensure the controller is unloaded so that it does
1.2485 + // not interfere with the following test ]
1.2486 + // There is error in this code and the stop followed by reset
1.2487 + // ensure the controller resources are released.
1.2488 + iController.Stop();
1.2489 + iController.Reset();
1.2490 + iController.Close();
1.2491 +
1.2492 + __MM_HEAP_MARKEND;
1.2493 +
1.2494 + // test steps return a result
1.2495 + return EPass;
1.2496 + }
1.2497 +
1.2498 +/**
1.2499 +*
1.2500 +* CTestStepGetSupportedSinkDataTypes
1.2501 +*
1.2502 +*/
1.2503 +CTestStepGetSupportedSinkDataTypes::CTestStepGetSupportedSinkDataTypes()
1.2504 + {
1.2505 + iTestStepName = _L("MM-MMF-ACTRL-U-0034-HP");
1.2506 + }
1.2507 +
1.2508 +/**
1.2509 +*
1.2510 +* ~CTestStepGetSupportedSinkDataTypes
1.2511 +*
1.2512 +*/
1.2513 +CTestStepGetSupportedSinkDataTypes::~CTestStepGetSupportedSinkDataTypes()
1.2514 + {
1.2515 + }
1.2516 +
1.2517 +/**
1.2518 +*
1.2519 +* DoTestStepL
1.2520 +* This test gets the supported sink data types
1.2521 +*
1.2522 +*/
1.2523 +TVerdict CTestStepGetSupportedSinkDataTypes::DoTestStepL( void )
1.2524 + {
1.2525 + __MM_HEAP_MARK;
1.2526 + TVerdict result = EPass;
1.2527 + _LIT( KTestSourceNumChannels, "GetSupported Sink Data types");
1.2528 + Log( KTestSourceNumChannels);
1.2529 +
1.2530 + _LIT( KTestSinkBitRateReason, "This test checks the get supported sink data types method");
1.2531 + Log( KTestSinkBitRateReason );
1.2532 +
1.2533 + // [ audio file to play ]
1.2534 + _LIT(KTestWavFile, "newmail.wav");
1.2535 + SetReadFileNameL( KTestWavFile );
1.2536 +
1.2537 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.2538 + User::LeaveIfError( errorCode );
1.2539 +
1.2540 + //[ attempt to get the sink num channels ]
1.2541 + RMMFAudioControllerCustomCommands theCommander( iController );
1.2542 +
1.2543 + RArray<TFourCC> supportedDataTypes;
1.2544 + CleanupClosePushL(supportedDataTypes);
1.2545 +
1.2546 + TRAPD( errorCode2, theCommander.GetSupportedSinkDataTypesL( supportedDataTypes ));
1.2547 + if( ( errorCode2 == KErrNone ) || supportedDataTypes.Count() )
1.2548 + {
1.2549 + //[ should have failed with either an error code or non zero supported types ]
1.2550 + result = EFail;
1.2551 + }
1.2552 +
1.2553 + //[ ok lets add the source and sink ]
1.2554 + if(result==EPass)
1.2555 + {
1.2556 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.2557 + if(errorCode!=KErrNone)
1.2558 + {
1.2559 + result=EFail;
1.2560 + }
1.2561 + }
1.2562 +
1.2563 + if(result==EPass)
1.2564 + {
1.2565 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.2566 + if(errorCode!=KErrNone)
1.2567 + {
1.2568 + result=EFail;
1.2569 + }
1.2570 + }
1.2571 +
1.2572 + if(result==EPass)
1.2573 + {
1.2574 + //[ ensure the array is empty ]
1.2575 + supportedDataTypes.Reset();
1.2576 + TRAPD( errorCode3,theCommander.GetSupportedSinkDataTypesL( supportedDataTypes ));
1.2577 + if(errorCode3!=KErrNotSupported)
1.2578 + {
1.2579 + INFO_PRINTF2(_L("GetSupportedSinkDataTypesL left with %d when KErrNotSupported is expected"), errorCode);
1.2580 + result = EFail;
1.2581 + }
1.2582 + }
1.2583 +
1.2584 +
1.2585 + //[ pop supportedDataTypes ]
1.2586 + CleanupStack::PopAndDestroy(1);//supportedDataTypes
1.2587 +
1.2588 + //[ ensure the controller is unloaded so that it does
1.2589 + // not interfere with the following test ]
1.2590 + // There is error in this code and the stop followed by reset
1.2591 + // ensure the controller resources are released.
1.2592 + iController.Stop();
1.2593 + iController.Reset();
1.2594 + iController.Close();
1.2595 +
1.2596 + __MM_HEAP_MARKEND;
1.2597 + return result;
1.2598 + }
1.2599 +
1.2600 +/**
1.2601 +*
1.2602 +* CTestStepGetSupportedSourceDataTypes
1.2603 +*
1.2604 +*/
1.2605 +CTestStepGetSupportedSourceDataTypes::CTestStepGetSupportedSourceDataTypes()
1.2606 + {
1.2607 + iTestStepName = _L("MM-MMF-ACTRL-U-0035-HP");
1.2608 + }
1.2609 +
1.2610 +/**
1.2611 +*
1.2612 +* ~CTestStepGetSupportedSourceDataTypes
1.2613 +*
1.2614 +*/
1.2615 +CTestStepGetSupportedSourceDataTypes::~CTestStepGetSupportedSourceDataTypes()
1.2616 + {
1.2617 + }
1.2618 +
1.2619 +/**
1.2620 +*
1.2621 +* DoTestStepL
1.2622 +*
1.2623 +*/
1.2624 +TVerdict CTestStepGetSupportedSourceDataTypes::DoTestStepL( void )
1.2625 + {
1.2626 + __MM_HEAP_MARK;
1.2627 + TVerdict result = EPass;
1.2628 +
1.2629 + _LIT( KTestSourceNumChannels, "GetSupported Source Data types");
1.2630 + Log( KTestSourceNumChannels);
1.2631 +
1.2632 + _LIT( KTestSinkBitRateReason, "This test checks the get supported source data types method");
1.2633 + Log( KTestSinkBitRateReason );
1.2634 +
1.2635 + // [ audio file to play ]
1.2636 + _LIT(KTestWavFile, "newmail.wav");
1.2637 + SetReadFileNameL( KTestWavFile );
1.2638 +
1.2639 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.2640 + User::LeaveIfError( errorCode );
1.2641 +
1.2642 + //[ attempt to get the sink num channels ]
1.2643 + RMMFAudioControllerCustomCommands theCommander( iController );
1.2644 +
1.2645 + RArray<TFourCC> supportedDataTypes;
1.2646 + CleanupClosePushL(supportedDataTypes);
1.2647 +
1.2648 + TRAPD( errorCode2, theCommander.GetSupportedSourceDataTypesL( supportedDataTypes ));
1.2649 + if( ( errorCode2 == KErrNone ) || supportedDataTypes.Count() )
1.2650 + {
1.2651 + //[ should have failed with either an error code or non zero supported types ]
1.2652 + result = EFail;
1.2653 + return result;
1.2654 + }
1.2655 +
1.2656 + //[ ok lets add the source and sink ]
1.2657 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.2658 + User::LeaveIfError( errorCode );
1.2659 +
1.2660 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.2661 + User::LeaveIfError( errorCode );
1.2662 +
1.2663 + //[ ensure the array is empty ]
1.2664 + supportedDataTypes.Reset();
1.2665 + TRAPD( errorCode3,theCommander.GetSupportedSourceDataTypesL( supportedDataTypes ));
1.2666 + User::LeaveIfError( errorCode3 );
1.2667 +
1.2668 + // Store the original FCC
1.2669 + TFourCC origFCC;
1.2670 + errorCode = theCommander.GetSourceDataType(origFCC);
1.2671 + if (errorCode != KErrNone)
1.2672 + {
1.2673 + INFO_PRINTF2(_L("GetSourceDataType returned error %d"), errorCode);
1.2674 + return EFail;
1.2675 + }
1.2676 +
1.2677 + TFourCC theNewFCC;
1.2678 + TFourCC theFCC;
1.2679 +
1.2680 + //[ loop over the possible set of data types that are supported ]
1.2681 + for( TInt index = 0; index < supportedDataTypes.Count(); index++ )
1.2682 + {
1.2683 + theFCC = supportedDataTypes[ index];
1.2684 + errorCode = theCommander.SetSourceDataType( theFCC );
1.2685 +
1.2686 + if (theFCC == origFCC)
1.2687 + {
1.2688 + // Trying to set the correct FCC
1.2689 + if (errorCode != KErrNone)
1.2690 + {
1.2691 + INFO_PRINTF2(_L("SetSourceDataType returned unexpected error %d"), errorCode);
1.2692 + result = EFail;
1.2693 + break;
1.2694 + }
1.2695 + }
1.2696 + else
1.2697 + {
1.2698 + if (errorCode != KErrAlreadyExists)
1.2699 + {
1.2700 + INFO_PRINTF3(_L("SetSourceDataType returned %d, expecting %d"), errorCode, KErrAlreadyExists);
1.2701 + result = EFail;
1.2702 + break;
1.2703 + }
1.2704 + }
1.2705 +
1.2706 + errorCode = theCommander.GetSourceDataType( theNewFCC );
1.2707 + if (theNewFCC != origFCC)
1.2708 + {
1.2709 + INFO_PRINTF1(_L("GetSourceDataType returned incorrect FCC"));
1.2710 + result = EFail;
1.2711 + break;
1.2712 + }
1.2713 +
1.2714 + if (errorCode != KErrNone)
1.2715 + {
1.2716 + INFO_PRINTF2(_L("GetSourceDataType returned unexpected error %d"), errorCode);
1.2717 + result = EFail;
1.2718 + break;
1.2719 + }
1.2720 + }
1.2721 +
1.2722 + //[ pop supportedDataTypes ]
1.2723 + CleanupStack::PopAndDestroy(1);//supportedDataTypes
1.2724 +
1.2725 + //[ ensure the controller is unloaded so that it does
1.2726 + // not interfere with the following test ]
1.2727 + // There is error in this code and the stop followed by reset
1.2728 + // ensure the controller resources are released.
1.2729 + iController.Stop();
1.2730 + iController.Reset();
1.2731 + iController.Close();
1.2732 +
1.2733 + __MM_HEAP_MARKEND;
1.2734 + return result;
1.2735 + }
1.2736 +
1.2737 +/**
1.2738 +*
1.2739 +* CTestStepGetSupportedSourceNumChannels
1.2740 +*
1.2741 +*/
1.2742 +CTestStepGetSupportedSourceNumChannels::CTestStepGetSupportedSourceNumChannels()
1.2743 + {
1.2744 + iTestStepName = _L("MM-MMF-ACTRL-U-0036-HP");
1.2745 + }
1.2746 +
1.2747 +/**
1.2748 +*
1.2749 +* ~CTestStepGetSupportedSourceNumChannels
1.2750 +*
1.2751 +*/
1.2752 +CTestStepGetSupportedSourceNumChannels::~CTestStepGetSupportedSourceNumChannels()
1.2753 + {
1.2754 + }
1.2755 +
1.2756 +/**
1.2757 +*
1.2758 +* DoTestStepL
1.2759 +* This test tests the number of channels supported by a source
1.2760 +*
1.2761 +*/
1.2762 +TVerdict CTestStepGetSupportedSourceNumChannels::DoTestStepL( void )
1.2763 + {
1.2764 + __MM_HEAP_MARK;
1.2765 + TVerdict result = EPass;
1.2766 +
1.2767 + _LIT( KTestSourceNumChannels, "GetSupported Source Num Channels");
1.2768 + Log( KTestSourceNumChannels);
1.2769 +
1.2770 + _LIT( KTestSinkBitRateReason, "This test checks the get supported source channels");
1.2771 + Log( KTestSinkBitRateReason );
1.2772 +
1.2773 + // [ audio file to play ]
1.2774 + _LIT(KTestWavFile, "newmail.wav");
1.2775 + SetReadFileNameL( KTestWavFile );
1.2776 +
1.2777 + TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
1.2778 + User::LeaveIfError( errorCode );
1.2779 +
1.2780 + //[ attempt to get the sink num channels ]
1.2781 + RMMFAudioControllerCustomCommands theCommander( iController );
1.2782 +
1.2783 + RArray<TUint> supportedChannels;
1.2784 + CleanupClosePushL(supportedChannels);
1.2785 +
1.2786 + TRAPD( errorCode2, theCommander.GetSupportedSourceNumChannelsL( supportedChannels));
1.2787 + if( errorCode2 == KErrNone )
1.2788 + {
1.2789 + //[ should have failed with either an error code or non zero supported types ]
1.2790 + result = EFail;
1.2791 + return result;
1.2792 + }
1.2793 +
1.2794 + //[ ok lets add the source and sink ]
1.2795 + errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
1.2796 + User::LeaveIfError( errorCode );
1.2797 +
1.2798 + errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
1.2799 + User::LeaveIfError( errorCode );
1.2800 +
1.2801 + //[ ensure the array is empty ]
1.2802 + supportedChannels.Reset();
1.2803 + TRAPD( errorCode3, theCommander.GetSupportedSourceNumChannelsL( supportedChannels));
1.2804 + User::LeaveIfError( errorCode3 );
1.2805 +
1.2806 + TUint orgNumChannels = 0;
1.2807 + errorCode = theCommander.GetSourceNumChannels( orgNumChannels);
1.2808 + User::LeaveIfError( errorCode );
1.2809 +
1.2810 + //[ loop over the possible set of data types that are supported ]
1.2811 + for( TInt index = 0; index < supportedChannels.Count(); index++ )
1.2812 + {
1.2813 + TUint oldNumChannels = supportedChannels[ index];
1.2814 + TUint numChannels = 0;
1.2815 + //[ wav files currently do not support a variable num source channels]
1.2816 + errorCode = theCommander.SetSourceNumChannels( oldNumChannels);
1.2817 + if (oldNumChannels == orgNumChannels)
1.2818 + {
1.2819 + // We tried to set the right number of channels for clip
1.2820 + if (errorCode != KErrNone)
1.2821 + {
1.2822 + INFO_PRINTF2(_L("Error calling SetSourceNumChannels %d"), errorCode);
1.2823 + result = EFail;
1.2824 + break;
1.2825 + }
1.2826 + }
1.2827 + else
1.2828 + {
1.2829 + // Setting source sample rate to a different value
1.2830 + // is tolerated (INC038043) to preserve BC with 6.1
1.2831 + if (errorCode != KErrNone)
1.2832 + {
1.2833 + INFO_PRINTF2(_L("Unexpected error code returned by SetSourceNumChannels %d"), errorCode);
1.2834 + result = EFail;
1.2835 + break;
1.2836 + }
1.2837 + }
1.2838 +
1.2839 + //[ check the set operation resulted in no change of the
1.2840 + // number of channels ]
1.2841 + errorCode = theCommander.GetSourceNumChannels( numChannels);
1.2842 + User::LeaveIfError( errorCode );
1.2843 + if( orgNumChannels != numChannels )
1.2844 + {
1.2845 + INFO_PRINTF3(_L("GetSourceNumChannels returned %d, expecting %d"), numChannels, orgNumChannels);
1.2846 + result = EFail;
1.2847 + break;
1.2848 + }
1.2849 + }
1.2850 +
1.2851 + //[ pop supportedChannels ]
1.2852 + CleanupStack::PopAndDestroy(1);//supportedChannels
1.2853 +
1.2854 + //[ ensure the controller is unloaded so that it does
1.2855 + // not interfere with the following test ]
1.2856 + // There is error in this code and the stop followed by reset
1.2857 + // ensure the controller resources are released.
1.2858 + iController.Stop();
1.2859 + iController.Reset();
1.2860 + iController.Close();
1.2861 +
1.2862 + __MM_HEAP_MARKEND;
1.2863 + return result;
1.2864 + }