1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TestCapabilities0014.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,254 @@
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 "TestPlayerCaps0014.h"
1.30 +
1.31 +
1.32 +
1.33 +/**
1.34 + * Constructor
1.35 + */
1.36 +CTestMmfAclntCaps0014::CTestMmfAclntCaps0014(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 +CTestMmfAclntCaps0014* CTestMmfAclntCaps0014::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
1.47 + {
1.48 + CTestMmfAclntCaps0014* self = new (ELeave) CTestMmfAclntCaps0014(aTestName, aSectName, aKeyName);
1.49 + return self;
1.50 + }
1.51 +
1.52 +CTestMmfAclntCaps0014* CTestMmfAclntCaps0014::NewLC(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
1.53 + {
1.54 + CTestMmfAclntCaps0014* self = NewL(aTestName, aSectName, aKeyName);
1.55 + CleanupStack::PushL(self);
1.56 + return self;
1.57 + }
1.58 +
1.59 +//void CTestMmfAclntCaps0014::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 CTestMmfAclntCaps0014::MapcPlayComplete(TInt aError)
1.66 +// {
1.67 +// INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
1.68 +// DoProcess(aError);
1.69 +// }
1.70 +
1.71 +void CTestMmfAclntCaps0014::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
1.72 + {
1.73 + if (aErrorCode == KErrNone)
1.74 + {
1.75 + if (aPreviousState == CMdaAudioClipUtility::ENotReady && aCurrentState==CMdaAudioClipUtility::EOpen)
1.76 + {
1.77 + iPlayer->RecordL();
1.78 + }
1.79 + else if (aPreviousState == CMdaAudioClipUtility::EOpen && aCurrentState==CMdaAudioClipUtility::ERecording)
1.80 + {
1.81 + User::After( 1000000 ); // record for this long
1.82 + iPlayer->Stop();
1.83 + iVerdict = EPass;
1.84 + CActiveScheduler::Stop();
1.85 + }
1.86 + else if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
1.87 + {
1.88 + // this shouldn't happen as record will continue until interrupted
1.89 + iVerdict = EPass;
1.90 + CActiveScheduler::Stop();
1.91 + }
1.92 + }
1.93 + else if (aErrorCode == KErrInUse)
1.94 + {
1.95 + // double check state to ensure behaviour is correct
1.96 + if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
1.97 + {
1.98 + iVerdict = EPass;
1.99 + CActiveScheduler::Stop();
1.100 + }
1.101 + }
1.102 +
1.103 + else
1.104 + {
1.105 + iVerdict = EFail;
1.106 + CActiveScheduler::Stop();
1.107 + }
1.108 +
1.109 + }
1.110 +
1.111 +/** Load and initialise an audio file.
1.112 + */
1.113 +TVerdict CTestMmfAclntCaps0014::DoTestStepL( void )
1.114 + {
1.115 + INFO_PRINTF1( _L("TestPlayerUtils : Caps"));
1.116 + iVerdict = EFail;
1.117 +
1.118 + iServerMonitor = CServerMonitor::NewL(this);
1.119 +
1.120 + // TSI_MMF_SDEVSOUND, MM-MMF-SDEVSOUND-I-0010-HP runs before this
1.121 + // this step does, I-0010-HP creates and uses
1.122 + // rectest1.wav and rectest2.wav
1.123 + // So we need to delete these to avoid errors In this test.
1.124 + RFs fsSession;
1.125 + fsSession.Connect();
1.126 + TRAPD(err,fsSession.Delete(_L("c:\\rectest1.wav")));
1.127 + TRAP(err,fsSession.Delete(_L("c:\\rectest2.wav")));
1.128 + fsSession.Close();
1.129 +
1.130 + // Start Server to play back from another process
1.131 + RTestServ server;
1.132 + User::LeaveIfError(server.Connect(_L("CapTestServer")));
1.133 + CleanupClosePushL(server);
1.134 + RTestSession session1;
1.135 + User::LeaveIfError(session1.Open(server,_L("CapTestStep0014")));
1.136 + TRequestStatus* status = &iServerMonitor->ActiveStatus();
1.137 + // Start Server playback. The RunL of the CServerMonitor class will be called by the server when
1.138 + // playback has started
1.139 + session1.StartProcessing(*status);
1.140 + // Begin activescheduler loop. This will only exit when the whole test is complete
1.141 + CActiveScheduler::Start();
1.142 +
1.143 + // The test is complete. Now shut down the server and get any errors /messages from the server
1.144 + TBuf8<256> message;
1.145 + TVerdict verdict = session1.EndProcessingAndReturnResult(message);
1.146 + if (verdict != EPass)
1.147 + iVerdict = verdict;
1.148 + TBuf16<256> copymess;
1.149 + copymess.Copy(message);
1.150 + INFO_PRINTF2(_L("end processing and return result: %S"),©mess);
1.151 +
1.152 + CleanupStack::PopAndDestroy(&server);
1.153 + return iVerdict;
1.154 + }
1.155 +
1.156 +void CTestMmfAclntCaps0014::CreatePlayer()
1.157 + {
1.158 + // Get the test filename from the configuration file
1.159 + TBuf<KSizeBuf> filename;
1.160 + TPtrC filename1;
1.161 + if(!GetStringFromConfig(iSectName,iKeyName,filename1))
1.162 + {
1.163 + iVerdict = EFail;
1.164 + CActiveScheduler::Stop();
1.165 + }
1.166 + GetDriveName(filename);
1.167 + filename.Append(filename1);
1.168 +
1.169 + iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityNormal);
1.170 + iPlayer->OpenFileL(_L("c:\\rectest2.wav"));
1.171 + }
1.172 +
1.173 +void CTestMmfAclntCaps0014::BeginPlayback()
1.174 + {
1.175 + iPlayer->RecordL();
1.176 + }
1.177 +
1.178 +
1.179 +void CTestMmfAclntCaps0014::DoProcess(TInt aError)
1.180 + {
1.181 + if (aError == KErrNone)
1.182 + {
1.183 + InternalState nextState = iState;
1.184 + switch (iState)
1.185 + {
1.186 + case EWaitingForServer:
1.187 + CreatePlayer();
1.188 + nextState = EInitPlayer;
1.189 + break;
1.190 + case EInitPlayer :
1.191 + BeginPlayback();
1.192 + nextState = EPlaying;
1.193 + break;
1.194 + case EPlaying :
1.195 + iVerdict = EPass;
1.196 + CActiveScheduler::Stop();
1.197 + break;
1.198 + }
1.199 + iState = nextState;
1.200 + }
1.201 + else
1.202 + {
1.203 + iVerdict = EFail;
1.204 + INFO_PRINTF2(_L("Unexpected failure in test, error code %d"), aError);
1.205 + CActiveScheduler::Stop();
1.206 + }
1.207 + }
1.208 +
1.209 +CTestMmfAclntCaps0014::CServerMonitor::CServerMonitor(CTestMmfAclntCaps0014* aParent)
1.210 + :CActive(EPriorityNormal), iParent(aParent)
1.211 + {
1.212 + }
1.213 +
1.214 +
1.215 +CTestMmfAclntCaps0014::CServerMonitor* CTestMmfAclntCaps0014::CServerMonitor::NewL(CTestMmfAclntCaps0014* aParent)
1.216 + {
1.217 + CServerMonitor* self = new (ELeave) CServerMonitor(aParent);
1.218 + CleanupStack::PushL(self);
1.219 + self->ConstructL();
1.220 + CleanupStack::Pop(self);
1.221 + return self;
1.222 + }
1.223 +
1.224 +void CTestMmfAclntCaps0014::CServerMonitor::ConstructL()
1.225 + {
1.226 + CActiveScheduler::Add(this);
1.227 + }
1.228 +
1.229 +void CTestMmfAclntCaps0014::CServerMonitor::DoCancel()
1.230 + {
1.231 + Cancel();
1.232 + }
1.233 +
1.234 +void CTestMmfAclntCaps0014::CServerMonitor::RunL()
1.235 + {
1.236 + // start the client state machine
1.237 + iParent->DoProcess(iStatus.Int());
1.238 + }
1.239 +
1.240 +TRequestStatus& CTestMmfAclntCaps0014::CServerMonitor::ActiveStatus()
1.241 + {
1.242 + SetActive();
1.243 + return iStatus;
1.244 + }
1.245 +
1.246 +
1.247 +CTestMmfAclntCaps0014::~CTestMmfAclntCaps0014()
1.248 + {
1.249 + }
1.250 +
1.251 +void CTestMmfAclntCaps0014::Close()
1.252 + {
1.253 + delete iPlayer;
1.254 + delete iServerMonitor;
1.255 + }
1.256 +
1.257 +