os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TestCapabilities0012.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/ACLNT/TestCapabilities0012.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,207 @@
     1.4 +
     1.5 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// under the terms of "Eclipse Public License v1.0"
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +// TestCapabilities.CPP
    1.19 +// This program is designed the test of the MMF_ACLNT.
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +/**
    1.24 + @file TestPlayerUtils.cpp
    1.25 +*/
    1.26 +
    1.27 +#include <simulprocclient.h>
    1.28 +#include "TestPlayerCaps.h"
    1.29 +#include "TestPlayerCaps0012.h"
    1.30 +
    1.31 +
    1.32 +
    1.33 +/**
    1.34 + * Constructor
    1.35 + */
    1.36 +CTestMmfAclntCaps0012::CTestMmfAclntCaps0012(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
    1.37 +	{
    1.38 +	// store the name of this test case
    1.39 +	// this is the name that is used by the script file
    1.40 +	// Each test step initialises it's own name
    1.41 +	iTestStepName = aTestName;
    1.42 +	iSectName = aSectName;
    1.43 +	iKeyName = aKeyName;
    1.44 +	}
    1.45 +
    1.46 +CTestMmfAclntCaps0012* CTestMmfAclntCaps0012::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
    1.47 +	{
    1.48 +	CTestMmfAclntCaps0012* self = new (ELeave) CTestMmfAclntCaps0012(aTestName, aSectName, aKeyName);
    1.49 +	return self;
    1.50 +	}
    1.51 +
    1.52 +CTestMmfAclntCaps0012* CTestMmfAclntCaps0012::NewLC(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
    1.53 +	{
    1.54 +	CTestMmfAclntCaps0012* self = NewL(aTestName, aSectName, aKeyName);
    1.55 +	CleanupStack::PushL(self);
    1.56 +	return self;
    1.57 +	}
    1.58 +
    1.59 +void CTestMmfAclntCaps0012::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
    1.60 +	{
    1.61 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
    1.62 +	DoProcess(aError);
    1.63 +	}
    1.64 +
    1.65 +void CTestMmfAclntCaps0012::MapcPlayComplete(TInt aError)
    1.66 +	{
    1.67 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
    1.68 +	DoProcess(aError);
    1.69 +	}
    1.70 +
    1.71 +
    1.72 +
    1.73 +/** Load and initialise an audio file.
    1.74 + */
    1.75 +TVerdict CTestMmfAclntCaps0012::DoTestStepL( void )
    1.76 +	{
    1.77 +	INFO_PRINTF1( _L("TestPlayerUtils : Caps"));
    1.78 +	iVerdict = EFail;
    1.79 +
    1.80 +	iServerMonitor = CServerMonitor::NewL(this);
    1.81 +
    1.82 +	// Start Server to play back from another process
    1.83 +	RTestServ server;
    1.84 +	User::LeaveIfError(server.Connect(_L("CapTestServer")));
    1.85 +	CleanupClosePushL(server);
    1.86 +	
    1.87 +	RTestSession session1;
    1.88 +	User::LeaveIfError(session1.Open(server,_L("CapTestStep0012")));
    1.89 +	TRequestStatus* status = &iServerMonitor->ActiveStatus();
    1.90 +	// Start Server playback. The RunL of the CServerMonitor class will be called by the server when
    1.91 +	// playback has started
    1.92 +	session1.StartProcessing(*status);
    1.93 +	// Begin activescheduler loop. This will only exit when the whole test is complete 
    1.94 +	CActiveScheduler::Start();
    1.95 +	
    1.96 +	// The test is complete. Now shut down the server and get any errors /messages from the server
    1.97 +	TBuf8<256> message;
    1.98 +	TVerdict verdict = session1.EndProcessingAndReturnResult(message);
    1.99 +	if (verdict != EPass)
   1.100 +		iVerdict = verdict;
   1.101 +	TBuf16<256> copymess;
   1.102 +	copymess.Copy(message);
   1.103 +	INFO_PRINTF2(_L("end processing and return result: %S"),&copymess);
   1.104 +
   1.105 +	CleanupStack::PopAndDestroy(&server);
   1.106 +	return iVerdict;
   1.107 +	}
   1.108 +	
   1.109 +void CTestMmfAclntCaps0012::CreatePlayer() 
   1.110 +	{
   1.111 +	// Get the test filename from the configuration file
   1.112 +	TBuf<KSizeBuf> filename;
   1.113 +	TPtrC filename1; 
   1.114 +	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
   1.115 +		{
   1.116 +		iVerdict = EFail;
   1.117 +		CActiveScheduler::Stop();
   1.118 +		}
   1.119 +	GetDriveName(filename);
   1.120 +	filename.Append(filename1);
   1.121 +
   1.122 +	iPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this, EMdaPriorityNormal);	
   1.123 +	}
   1.124 +	
   1.125 +void CTestMmfAclntCaps0012::BeginPlayback()
   1.126 +	{
   1.127 +	iPlayer->Play();
   1.128 +	}
   1.129 +	
   1.130 +	
   1.131 +void CTestMmfAclntCaps0012::DoProcess(TInt aError)
   1.132 +	{
   1.133 +	if (aError == KErrNone)
   1.134 +		{
   1.135 +		InternalState nextState = iState;
   1.136 +		switch (iState)
   1.137 +			{
   1.138 +		case EWaitingForServer:
   1.139 +			CreatePlayer();
   1.140 +			nextState = EInitPlayer;
   1.141 +			break;
   1.142 +		case EInitPlayer : 
   1.143 +			BeginPlayback();
   1.144 +			nextState = EPlaying;
   1.145 +			break;
   1.146 +		case EPlaying :
   1.147 +			iVerdict = EPass;
   1.148 +			CActiveScheduler::Stop();
   1.149 +			break;
   1.150 +			}
   1.151 +		iState = nextState;
   1.152 +		}
   1.153 +	else 
   1.154 +		{
   1.155 +		iVerdict = EFail;
   1.156 +		INFO_PRINTF2(_L("Unexpected failure in test, error code %d"), aError);
   1.157 +		CActiveScheduler::Stop();
   1.158 +		}
   1.159 +	}
   1.160 +
   1.161 +CTestMmfAclntCaps0012::CServerMonitor::CServerMonitor(CTestMmfAclntCaps0012* aParent)
   1.162 +	:CActive(EPriorityNormal), iParent(aParent)
   1.163 +	{
   1.164 +	}
   1.165 +
   1.166 +	
   1.167 +CTestMmfAclntCaps0012::CServerMonitor* CTestMmfAclntCaps0012::CServerMonitor::NewL(CTestMmfAclntCaps0012* aParent) 
   1.168 +	{
   1.169 +	CServerMonitor* self = new (ELeave) CServerMonitor(aParent);
   1.170 +	CleanupStack::PushL(self);
   1.171 +	self->ConstructL();
   1.172 +	CleanupStack::Pop(self);
   1.173 +	return self;
   1.174 +	}
   1.175 +
   1.176 +void CTestMmfAclntCaps0012::CServerMonitor::ConstructL() 
   1.177 +	{
   1.178 +	CActiveScheduler::Add(this);
   1.179 +	}
   1.180 +
   1.181 +void CTestMmfAclntCaps0012::CServerMonitor::DoCancel() 
   1.182 +	{
   1.183 +	Cancel();
   1.184 +	}
   1.185 +
   1.186 +void CTestMmfAclntCaps0012::CServerMonitor::RunL() 
   1.187 +	{
   1.188 +	// start the client state machine
   1.189 +	iParent->DoProcess(iStatus.Int());
   1.190 +	}
   1.191 +	
   1.192 +TRequestStatus& CTestMmfAclntCaps0012::CServerMonitor::ActiveStatus() 
   1.193 +	{
   1.194 +	SetActive();
   1.195 +	return iStatus;
   1.196 +	}
   1.197 +
   1.198 +
   1.199 +CTestMmfAclntCaps0012::~CTestMmfAclntCaps0012()
   1.200 +	{
   1.201 +	}
   1.202 +
   1.203 +void CTestMmfAclntCaps0012::Close()
   1.204 +	{
   1.205 +	delete iPlayer;
   1.206 +	delete iServerMonitor;
   1.207 +	}
   1.208 +
   1.209 +
   1.210 +