sl@0: sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // TestCapabilities.CPP sl@0: // This program is designed the test of the MMF_ACLNT. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file TestPlayerUtils.cpp sl@0: */ sl@0: sl@0: #include sl@0: #include "TestPlayerCaps.h" sl@0: #include "TestPlayerCaps0014.h" sl@0: sl@0: sl@0: sl@0: /** sl@0: * Constructor sl@0: */ sl@0: CTestMmfAclntCaps0014::CTestMmfAclntCaps0014(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName) sl@0: { sl@0: // store the name of this test case sl@0: // this is the name that is used by the script file sl@0: // Each test step initialises it's own name sl@0: iTestStepName = aTestName; sl@0: iSectName = aSectName; sl@0: iKeyName = aKeyName; sl@0: } sl@0: sl@0: CTestMmfAclntCaps0014* CTestMmfAclntCaps0014::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName) sl@0: { sl@0: CTestMmfAclntCaps0014* self = new (ELeave) CTestMmfAclntCaps0014(aTestName, aSectName, aKeyName); sl@0: return self; sl@0: } sl@0: sl@0: CTestMmfAclntCaps0014* CTestMmfAclntCaps0014::NewLC(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName) sl@0: { sl@0: CTestMmfAclntCaps0014* self = NewL(aTestName, aSectName, aKeyName); sl@0: CleanupStack::PushL(self); sl@0: return self; sl@0: } sl@0: sl@0: //void CTestMmfAclntCaps0014::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) sl@0: // { sl@0: // INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete")); sl@0: // DoProcess(aError); sl@0: // } sl@0: sl@0: //void CTestMmfAclntCaps0014::MapcPlayComplete(TInt aError) sl@0: // { sl@0: // INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete")); sl@0: // DoProcess(aError); sl@0: // } sl@0: sl@0: void CTestMmfAclntCaps0014::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) sl@0: { sl@0: if (aErrorCode == KErrNone) sl@0: { sl@0: if (aPreviousState == CMdaAudioClipUtility::ENotReady && aCurrentState==CMdaAudioClipUtility::EOpen) sl@0: { sl@0: iPlayer->RecordL(); sl@0: } sl@0: else if (aPreviousState == CMdaAudioClipUtility::EOpen && aCurrentState==CMdaAudioClipUtility::ERecording) sl@0: { sl@0: User::After( 1000000 ); // record for this long sl@0: iPlayer->Stop(); sl@0: iVerdict = EPass; sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: else if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen) sl@0: { sl@0: // this shouldn't happen as record will continue until interrupted sl@0: iVerdict = EPass; sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: } sl@0: else if (aErrorCode == KErrInUse) sl@0: { sl@0: // double check state to ensure behaviour is correct sl@0: if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen) sl@0: { sl@0: iVerdict = EPass; sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: } sl@0: sl@0: else sl@0: { sl@0: iVerdict = EFail; sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: } sl@0: sl@0: /** Load and initialise an audio file. sl@0: */ sl@0: TVerdict CTestMmfAclntCaps0014::DoTestStepL( void ) sl@0: { sl@0: INFO_PRINTF1( _L("TestPlayerUtils : Caps")); sl@0: iVerdict = EFail; sl@0: sl@0: iServerMonitor = CServerMonitor::NewL(this); sl@0: sl@0: // TSI_MMF_SDEVSOUND, MM-MMF-SDEVSOUND-I-0010-HP runs before this sl@0: // this step does, I-0010-HP creates and uses sl@0: // rectest1.wav and rectest2.wav sl@0: // So we need to delete these to avoid errors In this test. sl@0: RFs fsSession; sl@0: fsSession.Connect(); sl@0: TRAPD(err,fsSession.Delete(_L("c:\\rectest1.wav"))); sl@0: TRAP(err,fsSession.Delete(_L("c:\\rectest2.wav"))); sl@0: fsSession.Close(); sl@0: sl@0: // Start Server to play back from another process sl@0: RTestServ server; sl@0: User::LeaveIfError(server.Connect(_L("CapTestServer"))); sl@0: CleanupClosePushL(server); sl@0: RTestSession session1; sl@0: User::LeaveIfError(session1.Open(server,_L("CapTestStep0014"))); sl@0: TRequestStatus* status = &iServerMonitor->ActiveStatus(); sl@0: // Start Server playback. The RunL of the CServerMonitor class will be called by the server when sl@0: // playback has started sl@0: session1.StartProcessing(*status); sl@0: // Begin activescheduler loop. This will only exit when the whole test is complete sl@0: CActiveScheduler::Start(); sl@0: sl@0: // The test is complete. Now shut down the server and get any errors /messages from the server sl@0: TBuf8<256> message; sl@0: TVerdict verdict = session1.EndProcessingAndReturnResult(message); sl@0: if (verdict != EPass) sl@0: iVerdict = verdict; sl@0: TBuf16<256> copymess; sl@0: copymess.Copy(message); sl@0: INFO_PRINTF2(_L("end processing and return result: %S"),©mess); sl@0: sl@0: CleanupStack::PopAndDestroy(&server); sl@0: return iVerdict; sl@0: } sl@0: sl@0: void CTestMmfAclntCaps0014::CreatePlayer() sl@0: { sl@0: // Get the test filename from the configuration file sl@0: TBuf filename; sl@0: TPtrC filename1; sl@0: if(!GetStringFromConfig(iSectName,iKeyName,filename1)) sl@0: { sl@0: iVerdict = EFail; sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: GetDriveName(filename); sl@0: filename.Append(filename1); sl@0: sl@0: iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityNormal); sl@0: iPlayer->OpenFileL(_L("c:\\rectest2.wav")); sl@0: } sl@0: sl@0: void CTestMmfAclntCaps0014::BeginPlayback() sl@0: { sl@0: iPlayer->RecordL(); sl@0: } sl@0: sl@0: sl@0: void CTestMmfAclntCaps0014::DoProcess(TInt aError) sl@0: { sl@0: if (aError == KErrNone) sl@0: { sl@0: InternalState nextState = iState; sl@0: switch (iState) sl@0: { sl@0: case EWaitingForServer: sl@0: CreatePlayer(); sl@0: nextState = EInitPlayer; sl@0: break; sl@0: case EInitPlayer : sl@0: BeginPlayback(); sl@0: nextState = EPlaying; sl@0: break; sl@0: case EPlaying : sl@0: iVerdict = EPass; sl@0: CActiveScheduler::Stop(); sl@0: break; sl@0: } sl@0: iState = nextState; sl@0: } sl@0: else sl@0: { sl@0: iVerdict = EFail; sl@0: INFO_PRINTF2(_L("Unexpected failure in test, error code %d"), aError); sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: } sl@0: sl@0: CTestMmfAclntCaps0014::CServerMonitor::CServerMonitor(CTestMmfAclntCaps0014* aParent) sl@0: :CActive(EPriorityNormal), iParent(aParent) sl@0: { sl@0: } sl@0: sl@0: sl@0: CTestMmfAclntCaps0014::CServerMonitor* CTestMmfAclntCaps0014::CServerMonitor::NewL(CTestMmfAclntCaps0014* aParent) sl@0: { sl@0: CServerMonitor* self = new (ELeave) CServerMonitor(aParent); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CTestMmfAclntCaps0014::CServerMonitor::ConstructL() sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: void CTestMmfAclntCaps0014::CServerMonitor::DoCancel() sl@0: { sl@0: Cancel(); sl@0: } sl@0: sl@0: void CTestMmfAclntCaps0014::CServerMonitor::RunL() sl@0: { sl@0: // start the client state machine sl@0: iParent->DoProcess(iStatus.Int()); sl@0: } sl@0: sl@0: TRequestStatus& CTestMmfAclntCaps0014::CServerMonitor::ActiveStatus() sl@0: { sl@0: SetActive(); sl@0: return iStatus; sl@0: } sl@0: sl@0: sl@0: CTestMmfAclntCaps0014::~CTestMmfAclntCaps0014() sl@0: { sl@0: } sl@0: sl@0: void CTestMmfAclntCaps0014::Close() sl@0: { sl@0: delete iPlayer; sl@0: delete iServerMonitor; sl@0: } sl@0: sl@0: