os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/Ctlfrm/TSI_MmfCtlfrmStep.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/Ctlfrm/TSI_MmfCtlfrmStep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,614 @@
     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 +// TSIMmfCtlfrmStep.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +// EPOC includes
    1.22 +#include <e32base.h>
    1.23 +
    1.24 +// Test system includes
    1.25 +#include <testframework.h>
    1.26 +#include "TSI_MmfCtlfrmStep.h"
    1.27 +#include "TSI_MmfCtlfrmSuite.h"
    1.28 +#include "TSI_MmfCodes.h"
    1.29 +#include "TSI_MmfEventIds.h"
    1.30 +#include "ActrlTestUids.h"
    1.31 +
    1.32 +#include <mmf/common/mmfcontroller.h>
    1.33 +#include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
    1.34 +
    1.35 +const TUid KTestControllerUid = {KTSIMmfControllerUid};
    1.36 +const TUid KTestController2Uid = {KTSIMmfController2Uid};
    1.37 +//const TUid KTestDataSourceUid = {KTSIMmfDataSourceUid};	
    1.38 +//const TUid KTestDataSinkUid   = {KTSIMmfDataSinkUid};		
    1.39 +
    1.40 +// audio controller, from mmfControllerImplementationUIDs.hrh
    1.41 +//const TUid KTestAudioControllerUid = {KMmfUidControllerAudio};	
    1.42 +
    1.43 +// event values for audio controller testing
    1.44 +const TInt KDelay            = 1000000;
    1.45 +const TInt KMaxRetries       = 12;
    1.46 +
    1.47 +
    1.48 +// ---------------------------
    1.49 +// RTestStepMmfCtlfrm
    1.50 +// base class
    1.51 +
    1.52 +RTestStepMmfCtlfrm::RTestStepMmfCtlfrm() 
    1.53 +	{
    1.54 +	}
    1.55 +
    1.56 +// ---------------------------
    1.57 +// RTestStepMmfCtlfrmTest1
    1.58 +// base class with preamble / postamble to open and close the test controller
    1.59 +
    1.60 +TVerdict RTestStepMmfCtlfrmTest1::OpenL() 
    1.61 +	{
    1.62 +	TInt error = KErrNone;
    1.63 +
    1.64 +	iSettings.iPriority = ETSIMmfPriorityLow;
    1.65 +	iSettings.iPref = EMdaPriorityPreferenceTime;
    1.66 +	iSettings.iState = EMMFStateIdle;
    1.67 +
    1.68 +	// Open a controller
    1.69 +	error = iController.Open(KTestControllerUid, iSettings);
    1.70 +	if (error)
    1.71 +		{
    1.72 +		ERR_PRINTF2(_L("controller failed to open, error %d"), error);
    1.73 +		return iTestStepResult = EInconclusive;
    1.74 +		}
    1.75 +
    1.76 +	return iTestStepResult = EPass;
    1.77 +	}
    1.78 +
    1.79 +void RTestStepMmfCtlfrmTest1::Close() 
    1.80 +	{
    1.81 +	iController.Close();
    1.82 +
    1.83 +	// close controller delay - ensure it has time to finish
    1.84 +	// (so we don't get access violation from something trying to dequeue it before it's closed)
    1.85 +	const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
    1.86 +	User::After(KCloseControllerDelay);
    1.87 +	}
    1.88 +
    1.89 +// ---------------------------
    1.90 +// RTestStepMmfCtlfrmTest2
    1.91 +// base class with preamble / postamble to open and close the test controller 2
    1.92 +
    1.93 +TVerdict RTestStepMmfCtlfrmTest2::OpenL() 
    1.94 +	{
    1.95 +	TInt error = KErrNone;
    1.96 +
    1.97 +	iSettings.iPriority = ETSIMmfPriorityLow;
    1.98 +	iSettings.iPref = EMdaPriorityPreferenceTime;
    1.99 +	iSettings.iState = EMMFStateIdle;
   1.100 +
   1.101 +	// Open a controller
   1.102 +	error = iController.Open(KTestController2Uid, iSettings);
   1.103 +	if (error)
   1.104 +		{
   1.105 +		ERR_PRINTF2(_L("controller failed to open, error %d"), error);
   1.106 +		return iTestStepResult = EInconclusive;
   1.107 +		}
   1.108 +
   1.109 +	return iTestStepResult = EPass;
   1.110 +	}
   1.111 +
   1.112 +void RTestStepMmfCtlfrmTest2::Close() 
   1.113 +	{
   1.114 +	iController.Close();
   1.115 +	// close controller delay - ensure it has time to finish
   1.116 +	// (so we don't get access violation from something trying to dequeue it before it's closed)
   1.117 +	const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
   1.118 +	User::After(KCloseControllerDelay);
   1.119 +	}
   1.120 +
   1.121 +// ---------------------------
   1.122 +// RTestStepMmfCtlfrmAudio
   1.123 +// base class with preamble / postamble to open and close the audio controller
   1.124 +
   1.125 +TVerdict RTestStepMmfCtlfrmAudio::OpenL() 
   1.126 +	{
   1.127 +	TInt error = KErrNone;
   1.128 +
   1.129 +	iSettings.iPriority = ETSIMmfPriorityHigh;
   1.130 +	iSettings.iPref = EMdaPriorityPreferenceQuality;
   1.131 +	iSettings.iState = EMMFStateIdle;
   1.132 +
   1.133 +	// Open a controller
   1.134 +	error = iController.Open(KUidCustomTestAudioPlugin, iSettings);
   1.135 +//	error = iController.Open(KTestAudioControllerUid, iSettings);
   1.136 +	if (error)
   1.137 +		{
   1.138 +		ERR_PRINTF2(_L("controller failed to open, error %d"), error);
   1.139 +		return iTestStepResult = EInconclusive;
   1.140 +		}
   1.141 +
   1.142 +	INFO_PRINTF2(_L("Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
   1.143 +	// Add a source and sink
   1.144 +	_LIT(KTestWavFile, "c:\\TsiMmfCtlfrmData\\test.wav");
   1.145 +	iFileConfig().iPath = KTestWavFile;
   1.146 +	error = iController.AddDataSource(KUidMmfFileSource, iFileConfig);
   1.147 +	if (error)
   1.148 +		{
   1.149 +		ERR_PRINTF2(_L("failed to add a data source, error %d"), error);
   1.150 +		Close();
   1.151 +		return iTestStepResult = EInconclusive;
   1.152 +		}
   1.153 +	error = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
   1.154 +	if (error)
   1.155 +		{
   1.156 +		ERR_PRINTF2(_L("failed to add a data sink, error %d"), error);
   1.157 +		Close();
   1.158 +		return iTestStepResult = EInconclusive;
   1.159 +		}
   1.160 +	
   1.161 +	return iTestStepResult = EPass;
   1.162 +	}
   1.163 +
   1.164 +void RTestStepMmfCtlfrmAudio::Close() 
   1.165 +	{
   1.166 +	iController.Stop();
   1.167 +	iController.Reset();
   1.168 +	iController.Close();
   1.169 +	// close controller delay - ensure it has time to finish
   1.170 +	// (so we don't get access violation from something trying to dequeue it before it's closed)
   1.171 +	const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
   1.172 +	User::After(KCloseControllerDelay);
   1.173 +	}
   1.174 +
   1.175 +// Searches for an event
   1.176 +TVerdict RTestStepMmfCtlfrmAudio::SearchForEvent( TMMFEvent& aEvent )
   1.177 +	{
   1.178 +#ifdef EVENT_SEARCH_DISABLED
   1.179 +	WARN_PRINTF1(_L("Warning : SearchForEvent disabled"));
   1.180 +    TMMFEvent dummyEvent; // JS
   1.181 +	aEvent = dummyEvent;	// to get rid of compiler warning
   1.182 +	return EPass;
   1.183 +#else
   1.184 +
   1.185 +	TVerdict result = EFail;
   1.186 +	
   1.187 +	// status of events
   1.188 +	TRequestStatus timerStatus;
   1.189 +	TRequestStatus eventStatus;
   1.190 +
   1.191 +	// due to problems with the timer as a member variable 
   1.192 +	// added a local timer here
   1.193 +	RTimer  myTimer ;
   1.194 +	myTimer.CreateLocal();
   1.195 +	
   1.196 +    // create an event and initialise with unknown marker
   1.197 +
   1.198 +    TMMFEventPckg receivedEvent;
   1.199 +	
   1.200 +	// for KMaxRetries attempt to find the event
   1.201 +	for( TInt retries = 0; retries < KMaxRetries; retries++ )
   1.202 +		{
   1.203 +		// post receive event to controller
   1.204 +		iController.ReceiveEvents( receivedEvent, eventStatus );
   1.205 +		// start breakout timer to escape
   1.206 +		myTimer.After(timerStatus, KDelay);
   1.207 +		
   1.208 +		// wait for an event to mature
   1.209 +		User::WaitForRequest( eventStatus, timerStatus );
   1.210 +		
   1.211 +		// check if the command is the event 
   1.212 +		// and that a timeout did not occur
   1.213 +        if( IsTimeOut( eventStatus ))
   1.214 +			{
   1.215 +			// cancel the receive events
   1.216 +			CancelReceivedEvents();
   1.217 +			}
   1.218 +		else if( IsSoughtEvent( aEvent, receivedEvent ) )
   1.219 +			{
   1.220 +			// cancel the outstanding timer
   1.221 +			User::Check();
   1.222 +			myTimer.Cancel();
   1.223 +			// set status to pass since we have found the event
   1.224 +			result = EPass;
   1.225 +			break;
   1.226 +			}
   1.227 +		else
   1.228 +			{
   1.229 +			// We rx'd an event other than expected
   1.230 +			myTimer.Cancel();
   1.231 +			}
   1.232 +		}
   1.233 +	return result;
   1.234 +#endif // EVENT_SEARCH_DISABLED
   1.235 +	}
   1.236 +
   1.237 +TBool RTestStepMmfCtlfrmAudio::IsTimeOut( TRequestStatus& aEventStatus )
   1.238 +	{
   1.239 +    return ( aEventStatus == KRequestPending);
   1.240 +	}
   1.241 +
   1.242 +TBool RTestStepMmfCtlfrmAudio::IsSoughtEvent( TMMFEvent& aExpectedEvent, TMMFEventPckg& aReceivedEvent )
   1.243 +	{
   1.244 +	
   1.245 +	TInt expectedUid = aExpectedEvent.iEventType.iUid;
   1.246 +	TInt receivedUid = aReceivedEvent().iEventType.iUid;
   1.247 +
   1.248 +	// display any events we get
   1.249 +	INFO_PRINTF3(_L("Event received : 0x%08x %d"), 
   1.250 +					 aReceivedEvent().iEventType.iUid, aReceivedEvent().iErrorCode);
   1.251 +
   1.252 +	return ((expectedUid == receivedUid) &&
   1.253 +	 	    (aExpectedEvent.iErrorCode == aReceivedEvent().iErrorCode));
   1.254 +	}
   1.255 +
   1.256 +void RTestStepMmfCtlfrmAudio::CancelReceivedEvents()
   1.257 +	{
   1.258 +	iController.CancelReceiveEvents();
   1.259 +	}
   1.260 +
   1.261 +// ---------------------------
   1.262 +// RTestStepMmfCtlfrmAudioPrimed
   1.263 +// as above, with source / sink handles, primed in preamble
   1.264 +
   1.265 +TVerdict RTestStepMmfCtlfrmAudioPrimed::OpenL()
   1.266 +	{
   1.267 +	// initialise the controller, including adding source and sink; prime it.
   1.268 +	// retain handles to the source and sink so we can verify them after reset
   1.269 +	TInt error = KErrNone;
   1.270 +	TVerdict result = EPass;
   1.271 +
   1.272 +	iSourceHandlePtr = NULL;
   1.273 +	iSinkHandlePtr = NULL;
   1.274 +
   1.275 +	iSettings.iPriority = ETSIMmfPriorityHigh;
   1.276 +	iSettings.iPref = EMdaPriorityPreferenceQuality;
   1.277 +	iSettings.iState = EMMFStateIdle;
   1.278 +
   1.279 +	// Open a controller
   1.280 +	error = iController.Open(KUidCustomTestAudioPlugin, iSettings);
   1.281 +	if (error)
   1.282 +		{
   1.283 +		ERR_PRINTF2(_L("controller failed to open, error %d"), error);
   1.284 +		return iTestStepResult = EInconclusive;
   1.285 +		}
   1.286 +
   1.287 +	INFO_PRINTF2(_L("Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
   1.288 +	// Add a source and sink
   1.289 +	_LIT(KTestWavFile, "c:\\TsiMmfCtlfrmData\\test.wav");
   1.290 +	iFileConfig().iPath = KTestWavFile;
   1.291 +
   1.292 +	// add a data source with a handle
   1.293 +	iSourceHandlePtr = new (ELeave) TMMFMessageDestination();
   1.294 +	TMMFMessageDestination& sourceHandle = *iSourceHandlePtr;
   1.295 +	error = iController.AddDataSource(KUidMmfFileSource, iFileConfig, sourceHandle);
   1.296 +	if (error)
   1.297 +		{
   1.298 +		ERR_PRINTF2(_L("AddDataSource failed, error %d"), error);
   1.299 +		Close();
   1.300 +		return iTestStepResult = EInconclusive;
   1.301 +		}
   1.302 +
   1.303 +	// add a data sink with a handle
   1.304 +	iSinkHandlePtr = new (ELeave) TMMFMessageDestination();
   1.305 +	TMMFMessageDestination& sinkHandle = *iSinkHandlePtr;
   1.306 +
   1.307 +	error = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8, sinkHandle);
   1.308 +	if (error)
   1.309 +		{
   1.310 +		ERR_PRINTF2(_L("AddDataSink failed, error %d"), error);
   1.311 +		Close();
   1.312 +		return iTestStepResult = EInconclusive;
   1.313 +		}
   1.314 +
   1.315 +	// prime it
   1.316 +	error = iController.Prime();
   1.317 +	if(error)
   1.318 +		{
   1.319 +		ERR_PRINTF2(_L("Prime failed, error %d"), error);
   1.320 +		Close();
   1.321 +		return iTestStepResult = EInconclusive;
   1.322 +		}
   1.323 +	
   1.324 +	// wait for and process the return event from the custom audio controller
   1.325 +	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
   1.326 +	result = SearchForEvent( primeEvent );
   1.327 +	if( result == EFail )
   1.328 +		{
   1.329 +		ERR_PRINTF1(_L("Custom audio controller did not return a prime event"));
   1.330 +		Close();
   1.331 +		return iTestStepResult = EInconclusive;
   1.332 +		}
   1.333 +
   1.334 +	return iTestStepResult = EPass;
   1.335 +	}
   1.336 +
   1.337 +void RTestStepMmfCtlfrmAudioPrimed::Close() 
   1.338 +	{
   1.339 +	iController.Stop();
   1.340 +	iController.Reset();
   1.341 +	delete iSinkHandlePtr;
   1.342 +	delete iSourceHandlePtr;
   1.343 +	iController.Close();
   1.344 +	// close controller delay - ensure it has time to finish
   1.345 +	// (so we don't get access violation from something trying to dequeue it before it's closed)
   1.346 +	const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
   1.347 +	User::After(KCloseControllerDelay);
   1.348 +	}
   1.349 +
   1.350 +
   1.351 +// ---------------------------
   1.352 +// RTestStepMmfCtlfrmAudioNoSource
   1.353 +// same as RTestStepMmfCtlfrmAudio, but has no source or sink loaded yet
   1.354 +TVerdict RTestStepMmfCtlfrmAudioNoSource::OpenL()
   1.355 +	{
   1.356 +	// preamble - load a controller but give it no data source
   1.357 +	TInt error = KErrNone;
   1.358 +
   1.359 +	iSettings.iPriority = ETSIMmfPriorityHigh;
   1.360 +	iSettings.iPref = EMdaPriorityPreferenceQuality;
   1.361 +	iSettings.iState = EMMFStateIdle;
   1.362 +
   1.363 +	// Open a controller
   1.364 +	error = iController.Open(KUidCustomTestAudioPlugin, iSettings);
   1.365 +	if (error)
   1.366 +		{
   1.367 +		ERR_PRINTF2(_L("controller failed to open, error %d"), error);
   1.368 +		return iTestStepResult = EInconclusive;
   1.369 +		}
   1.370 +
   1.371 +	INFO_PRINTF2(_L("Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
   1.372 +	return iTestStepResult = EPass;
   1.373 +	}
   1.374 +
   1.375 +// ---------------------------
   1.376 +// RTestStepMmfCtlfrmDualAudio
   1.377 +// same as RTestStepMmfCtlfrmAudio, with 2 identical controllers
   1.378 +
   1.379 +TVerdict RTestStepMmfCtlfrmDualAudio::OpenL() 
   1.380 +	{
   1.381 +	TInt error = KErrNone;
   1.382 +
   1.383 +	iSettings.iPriority = ETSIMmfPriorityHigh;
   1.384 +	iSettings.iPref = EMdaPriorityPreferenceTime;
   1.385 +	iSettings.iState = EMMFStateIdle;
   1.386 +
   1.387 +	// Open both controllers
   1.388 +	error = iController1.Open(KUidCustomTestAudioPlugin, iSettings);
   1.389 +	if (error)
   1.390 +		{
   1.391 +		ERR_PRINTF2(_L("iController1 failed to open, error %d"), error);
   1.392 +		return iTestStepResult = EInconclusive;
   1.393 +		}
   1.394 +	INFO_PRINTF2(_L("Controller 1 : Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
   1.395 +	error = iController2.Open(KUidCustomTestAudioPlugin, iSettings);
   1.396 +	if (error)
   1.397 +		{
   1.398 +		ERR_PRINTF2(_L("iController2 failed to open, error %d"), error);
   1.399 +		Close();
   1.400 +		return iTestStepResult = EInconclusive;
   1.401 +		}
   1.402 +	INFO_PRINTF2(_L("Controller 2 : Opened Custom Audio Controller, UID 0x%8x"), KUidCustomTestAudioPlugin);
   1.403 +
   1.404 +	// Add source and sink
   1.405 +	// Use two different files to avoid conflict
   1.406 +	_LIT(KTestWavFile1, "c:\\TsiMmfCtlfrmData\\test.wav");
   1.407 +	_LIT(KTestWavFile2, "c:\\TsiMmfCtlfrmData\\test2.wav");
   1.408 +	iFileConfig1().iPath = KTestWavFile1;
   1.409 +	iFileConfig2().iPath = KTestWavFile2;
   1.410 +	error = iController1.AddDataSource(KUidMmfFileSource, iFileConfig1);
   1.411 +	if (error)
   1.412 +		{
   1.413 +		ERR_PRINTF2(_L("iController1 failed to add a data source, error %d"), error);
   1.414 +		return iTestStepResult = EInconclusive;
   1.415 +		}
   1.416 +	error = iController1.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
   1.417 +	if (error)
   1.418 +		{
   1.419 +		ERR_PRINTF2(_L("iController1 failed to add a data sink, error %d"), error);
   1.420 +		Close();
   1.421 +		return iTestStepResult = EInconclusive;
   1.422 +		}
   1.423 +	error = iController2.AddDataSource(KUidMmfFileSource, iFileConfig2);
   1.424 +	if (error)
   1.425 +		{
   1.426 +		ERR_PRINTF2(_L("iController2 failed to add a data source, error %d"), error);
   1.427 +		Close();
   1.428 +		return iTestStepResult = EInconclusive;
   1.429 +		}
   1.430 +	error = iController2.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
   1.431 +	if (error)
   1.432 +		{
   1.433 +		ERR_PRINTF2(_L("iController2 failed to add a data sink, error %d"), error);
   1.434 +		Close();
   1.435 +		return iTestStepResult = EInconclusive;
   1.436 +		}
   1.437 +	
   1.438 +	return iTestStepResult = EPass;
   1.439 +	}
   1.440 +
   1.441 +void RTestStepMmfCtlfrmDualAudio::Close() 
   1.442 +	{
   1.443 +	iController1.Stop();
   1.444 +	iController1.Reset();
   1.445 +	iController1.Close();
   1.446 +
   1.447 +	iController2.Stop();
   1.448 +	iController2.Reset();
   1.449 +	iController2.Close();
   1.450 +
   1.451 +	// close controller delay - ensure it has time to finish
   1.452 +	// (so we don't get access violation from something trying to dequeue it before it's closed)
   1.453 +	const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
   1.454 +	User::After(KCloseControllerDelay);
   1.455 +	}
   1.456 +
   1.457 +// Searches for an event
   1.458 +TVerdict RTestStepMmfCtlfrmDualAudio::SearchForEvent( TMMFEvent& aEvent, TInt aWhichController )
   1.459 +	{
   1.460 +	// NB don't worry about EVENT_SEARCH_DISABLED here,
   1.461 +	// as generally we'll be looking for events from the Controller Framework here,
   1.462 +	// not from the custom Audio Controller
   1.463 +
   1.464 +	TVerdict result = EFail;
   1.465 +	
   1.466 +	// status of events
   1.467 +	TRequestStatus timerStatus    ;
   1.468 +	TRequestStatus eventStatus    ;
   1.469 +
   1.470 +	RMMFController* theController;
   1.471 +	// which controller are we searching on?
   1.472 +	if(aWhichController == 1)
   1.473 +		theController = &iController1;
   1.474 +	else if(aWhichController == 2)
   1.475 +		theController = &iController2;
   1.476 +	else 
   1.477 +		{
   1.478 +		ERR_PRINTF1(_L("SearchForEvent error : controller must be 1 or 2"));
   1.479 +		return result = EFail;
   1.480 +		}
   1.481 +
   1.482 +	// due to problems with the timer as a member variable 
   1.483 +	// added a local timer here
   1.484 +	RTimer  myTimer ;
   1.485 +	myTimer.CreateLocal();
   1.486 +	
   1.487 +    // create an event and initialise with unknown marker
   1.488 +
   1.489 +    TMMFEventPckg receivedEvent;
   1.490 +	
   1.491 +	// for KMaxRetries attempt to find the event
   1.492 +	for( TInt retries = 0; retries < KMaxRetries; retries++ )
   1.493 +		{
   1.494 +		// post receive event to controller
   1.495 +		(*theController).ReceiveEvents( receivedEvent, eventStatus );
   1.496 +		// start breakout timer to escape
   1.497 +		myTimer.After( timerStatus, KDelay );
   1.498 +		
   1.499 +		// wait for an event to mature
   1.500 +		User::WaitForRequest( eventStatus, timerStatus );
   1.501 +		
   1.502 +		// check if the command is the event 
   1.503 +		// and that a timeout did not occur
   1.504 +        if( IsTimeOut( eventStatus ))
   1.505 +			{
   1.506 +			// cancel the receive events
   1.507 +			CancelReceivedEvents(aWhichController);
   1.508 +			}
   1.509 +		else if( IsSoughtEvent( aEvent, receivedEvent ) )
   1.510 +			{
   1.511 +			// cancel the outstanding timer
   1.512 +			User::Check();
   1.513 +			myTimer.Cancel();
   1.514 +			// set status to pass since we have found the event
   1.515 +			result = EPass;
   1.516 +			break;
   1.517 +			}
   1.518 +		else
   1.519 +			{
   1.520 +			// We rx'd an event other than expected
   1.521 +			myTimer.Cancel();
   1.522 +			}
   1.523 +		}
   1.524 +    return result;
   1.525 +	}
   1.526 +
   1.527 +TBool RTestStepMmfCtlfrmDualAudio::IsTimeOut( TRequestStatus& aEventStatus )
   1.528 +	{
   1.529 +    return (aEventStatus == KRequestPending);
   1.530 +	}
   1.531 +
   1.532 +TBool RTestStepMmfCtlfrmDualAudio::IsSoughtEvent( TMMFEvent& aExpectedEvent, TMMFEventPckg& aReceivedEvent )
   1.533 +	{
   1.534 +	
   1.535 +	TInt expectedUid = aExpectedEvent.iEventType.iUid;
   1.536 +	TInt receivedUid = aReceivedEvent().iEventType.iUid;
   1.537 +
   1.538 +	// display any events we get
   1.539 +	INFO_PRINTF3(_L("Event expected : 0x%08x %d"), 
   1.540 +				 expectedUid, aExpectedEvent.iErrorCode);
   1.541 +	INFO_PRINTF3(_L("Event received : 0x%08x %d"), 
   1.542 +				 aReceivedEvent().iEventType.iUid, aReceivedEvent().iErrorCode);
   1.543 +
   1.544 +	return ((expectedUid == receivedUid) &&
   1.545 +	 	    (aExpectedEvent.iErrorCode == aReceivedEvent().iErrorCode));
   1.546 +	}
   1.547 +
   1.548 +void RTestStepMmfCtlfrmDualAudio::CancelReceivedEvents(TInt aWhichController)
   1.549 +	{
   1.550 +	RMMFController* theController;
   1.551 +	// which controller are we searching on?
   1.552 +	if(aWhichController == 1)
   1.553 +		theController = &iController1;
   1.554 +	else if(aWhichController == 2)
   1.555 +		theController = &iController2;
   1.556 +	else 
   1.557 +		{
   1.558 +		ERR_PRINTF1(_L("CancelReceivedEvents error : controller must be 1 or 2"));
   1.559 +		return;
   1.560 +		}
   1.561 +	(*theController).CancelReceiveEvents();
   1.562 +	}
   1.563 +
   1.564 +// ---------------------------
   1.565 +// RTestStepMmfCtlfrmVideo
   1.566 +// base class with preamble / postamble to open and close the video controller
   1.567 +// NB we're only actually using this to test custom commands
   1.568 +
   1.569 +TVerdict RTestStepMmfCtlfrmVideo::OpenL() 
   1.570 +	{
   1.571 +	TInt error = KErrNone;
   1.572 +
   1.573 +	iSettings.iPriority = ETSIMmfPriorityHigh;
   1.574 +	iSettings.iPref = EMdaPriorityPreferenceQuality;
   1.575 +	iSettings.iState = EMMFStateIdle;
   1.576 +
   1.577 +	// Open a controller
   1.578 +	error = iController.Open(KMmfVideoTestControllerUid, iSettings);
   1.579 +	if (error)
   1.580 +		{
   1.581 +		ERR_PRINTF2(_L("controller failed to open, error %d"), error);
   1.582 +		return iTestStepResult = EInconclusive;
   1.583 +		}
   1.584 +
   1.585 +	INFO_PRINTF2(_L("Opened Custom Video Controller, UID 0x%8x"), KMmfVideoTestControllerUid);
   1.586 +	// Add a source and sink
   1.587 +	_LIT(KTestAviFile, "c:\\VclntITestData\\LongVideo.avi");
   1.588 +	iFileConfig().iPath = KTestAviFile;
   1.589 +	error = iController.AddDataSource(KUidMmfFileSource, iFileConfig);
   1.590 +	if (error)
   1.591 +		{
   1.592 +		ERR_PRINTF2(_L("failed to add a data source, error %d"), error);
   1.593 +		Close();
   1.594 +		return iTestStepResult = EInconclusive;
   1.595 +		}
   1.596 +	error = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
   1.597 +	if (error)
   1.598 +		{
   1.599 +		ERR_PRINTF2(_L("failed to add a data sink, error %d"), error);
   1.600 +		Close();
   1.601 +		return iTestStepResult = EInconclusive;
   1.602 +		}
   1.603 +	
   1.604 +	return iTestStepResult = EPass;
   1.605 +	}
   1.606 +
   1.607 +void RTestStepMmfCtlfrmVideo::Close() 
   1.608 +	{
   1.609 +	iController.Stop();
   1.610 +	iController.Reset();
   1.611 +	iController.Close();
   1.612 +	// close controller delay - ensure it has time to finish
   1.613 +	// (so we don't get access violation from something trying to dequeue it before it's closed)
   1.614 +	const TTimeIntervalMicroSeconds32 KCloseControllerDelay = 500000L;
   1.615 +	User::After(KCloseControllerDelay);
   1.616 +	}
   1.617 +