os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/src/TestCapabilities0014.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
sl@0
     2
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
// All rights reserved.
sl@0
     4
// This component and the accompanying materials are made available
sl@0
     5
// under the terms of "Eclipse Public License v1.0"
sl@0
     6
// which accompanies this distribution, and is available
sl@0
     7
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
//
sl@0
     9
// Initial Contributors:
sl@0
    10
// Nokia Corporation - initial contribution.
sl@0
    11
//
sl@0
    12
// Contributors:
sl@0
    13
//
sl@0
    14
// Description:
sl@0
    15
// TestCapabilities.CPP
sl@0
    16
// This program is designed the test of the MMF_ACLNT.
sl@0
    17
// 
sl@0
    18
//
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file TestPlayerUtils.cpp
sl@0
    22
*/
sl@0
    23
sl@0
    24
#include <simulprocclient.h>
sl@0
    25
#include "TestPlayerCaps.h"
sl@0
    26
#include "TestPlayerCaps0014.h"
sl@0
    27
sl@0
    28
sl@0
    29
sl@0
    30
/**
sl@0
    31
 * Constructor
sl@0
    32
 */
sl@0
    33
CTestMmfAclntCaps0014::CTestMmfAclntCaps0014(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
sl@0
    34
	{
sl@0
    35
	// store the name of this test case
sl@0
    36
	// this is the name that is used by the script file
sl@0
    37
	// Each test step initialises it's own name
sl@0
    38
	iTestStepName = aTestName;
sl@0
    39
	iSectName = aSectName;
sl@0
    40
	iKeyName = aKeyName;
sl@0
    41
	}
sl@0
    42
sl@0
    43
CTestMmfAclntCaps0014* CTestMmfAclntCaps0014::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
sl@0
    44
	{
sl@0
    45
	CTestMmfAclntCaps0014* self = new (ELeave) CTestMmfAclntCaps0014(aTestName, aSectName, aKeyName);
sl@0
    46
	return self;
sl@0
    47
	}
sl@0
    48
sl@0
    49
CTestMmfAclntCaps0014* CTestMmfAclntCaps0014::NewLC(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
sl@0
    50
	{
sl@0
    51
	CTestMmfAclntCaps0014* self = NewL(aTestName, aSectName, aKeyName);
sl@0
    52
	CleanupStack::PushL(self);
sl@0
    53
	return self;
sl@0
    54
	}
sl@0
    55
sl@0
    56
//void CTestMmfAclntCaps0014::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
sl@0
    57
//	{
sl@0
    58
//	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
sl@0
    59
//	DoProcess(aError);
sl@0
    60
//	}
sl@0
    61
sl@0
    62
//void CTestMmfAclntCaps0014::MapcPlayComplete(TInt aError)
sl@0
    63
//	{
sl@0
    64
//	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
sl@0
    65
//	DoProcess(aError);
sl@0
    66
//	}
sl@0
    67
sl@0
    68
void CTestMmfAclntCaps0014::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
sl@0
    69
	{
sl@0
    70
	if (aErrorCode == KErrNone)
sl@0
    71
		{
sl@0
    72
		if (aPreviousState == CMdaAudioClipUtility::ENotReady && aCurrentState==CMdaAudioClipUtility::EOpen)
sl@0
    73
			{
sl@0
    74
			iPlayer->RecordL();
sl@0
    75
			}
sl@0
    76
		else if (aPreviousState == CMdaAudioClipUtility::EOpen && aCurrentState==CMdaAudioClipUtility::ERecording)
sl@0
    77
			{
sl@0
    78
			User::After( 1000000 );		// record for this long
sl@0
    79
			iPlayer->Stop();
sl@0
    80
			iVerdict = EPass;
sl@0
    81
			CActiveScheduler::Stop();
sl@0
    82
			}
sl@0
    83
		else if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
sl@0
    84
			{
sl@0
    85
			// this shouldn't happen as record will continue until interrupted
sl@0
    86
			iVerdict = EPass;
sl@0
    87
			CActiveScheduler::Stop();
sl@0
    88
			}
sl@0
    89
		}
sl@0
    90
	else if (aErrorCode == KErrInUse)
sl@0
    91
		{
sl@0
    92
		// double check state to ensure behaviour is correct
sl@0
    93
		if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
sl@0
    94
			{
sl@0
    95
			iVerdict = EPass;
sl@0
    96
			CActiveScheduler::Stop();
sl@0
    97
			}
sl@0
    98
		}
sl@0
    99
sl@0
   100
	else 
sl@0
   101
		{
sl@0
   102
		iVerdict = EFail;
sl@0
   103
		CActiveScheduler::Stop();
sl@0
   104
		}
sl@0
   105
sl@0
   106
	}
sl@0
   107
sl@0
   108
/** Load and initialise an audio file.
sl@0
   109
 */
sl@0
   110
TVerdict CTestMmfAclntCaps0014::DoTestStepL( void )
sl@0
   111
	{
sl@0
   112
	INFO_PRINTF1( _L("TestPlayerUtils : Caps"));
sl@0
   113
	iVerdict = EFail;
sl@0
   114
sl@0
   115
	iServerMonitor = CServerMonitor::NewL(this);
sl@0
   116
sl@0
   117
	// Start Server to play back from another process
sl@0
   118
	RTestServ server;
sl@0
   119
	User::LeaveIfError(server.Connect(_L("CapTestServer")));
sl@0
   120
	CleanupClosePushL(server);
sl@0
   121
	
sl@0
   122
	RTestSession session1;
sl@0
   123
	User::LeaveIfError(session1.Open(server,_L("CapTestStep0014")));
sl@0
   124
	TRequestStatus* status = &iServerMonitor->ActiveStatus();
sl@0
   125
	// Start Server playback. The RunL of the CServerMonitor class will be called by the server when
sl@0
   126
	// playback has started
sl@0
   127
	session1.StartProcessing(*status);
sl@0
   128
	// Begin activescheduler loop. This will only exit when the whole test is complete 
sl@0
   129
	CActiveScheduler::Start();
sl@0
   130
	
sl@0
   131
	// The test is complete. Now shut down the server and get any errors /messages from the server
sl@0
   132
	TBuf8<256> message;
sl@0
   133
	TVerdict verdict = session1.EndProcessingAndReturnResult(message);
sl@0
   134
	if (verdict != EPass)
sl@0
   135
		iVerdict = verdict;
sl@0
   136
	TBuf16<256> copymess;
sl@0
   137
	copymess.Copy(message);
sl@0
   138
	INFO_PRINTF2(_L("end processing and return result: %S"),&copymess);
sl@0
   139
sl@0
   140
	CleanupStack::PopAndDestroy(&server);
sl@0
   141
	return iVerdict;
sl@0
   142
	}
sl@0
   143
	
sl@0
   144
void CTestMmfAclntCaps0014::CreatePlayer() 
sl@0
   145
	{
sl@0
   146
	// Get the test filename from the configuration file
sl@0
   147
	TBuf<KSizeBuf> filename;
sl@0
   148
	TPtrC filename1; 
sl@0
   149
	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
sl@0
   150
		{
sl@0
   151
		iVerdict = EFail;
sl@0
   152
		CActiveScheduler::Stop();
sl@0
   153
		}
sl@0
   154
	GetDriveName(filename);
sl@0
   155
	filename.Append(filename1);
sl@0
   156
sl@0
   157
	iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityNormal);
sl@0
   158
	iPlayer->OpenFileL(_L("c:\\rectest2.wav"));
sl@0
   159
	}
sl@0
   160
	
sl@0
   161
void CTestMmfAclntCaps0014::BeginPlayback()
sl@0
   162
	{
sl@0
   163
	iPlayer->RecordL();
sl@0
   164
	}
sl@0
   165
	
sl@0
   166
	
sl@0
   167
void CTestMmfAclntCaps0014::DoProcess(TInt aError)
sl@0
   168
	{
sl@0
   169
	if (aError == KErrNone)
sl@0
   170
		{
sl@0
   171
		InternalState nextState = iState;
sl@0
   172
		switch (iState)
sl@0
   173
			{
sl@0
   174
		case EWaitingForServer:
sl@0
   175
			CreatePlayer();
sl@0
   176
			nextState = EInitPlayer;
sl@0
   177
			break;
sl@0
   178
		case EInitPlayer : 
sl@0
   179
			BeginPlayback();
sl@0
   180
			nextState = EPlaying;
sl@0
   181
			break;
sl@0
   182
		case EPlaying :
sl@0
   183
			iVerdict = EPass;
sl@0
   184
			CActiveScheduler::Stop();
sl@0
   185
			break;
sl@0
   186
			}
sl@0
   187
		iState = nextState;
sl@0
   188
		}
sl@0
   189
	else 
sl@0
   190
		{
sl@0
   191
		iVerdict = EFail;
sl@0
   192
		INFO_PRINTF2(_L("Unexpected failure in test, error code %d"), aError);
sl@0
   193
		CActiveScheduler::Stop();
sl@0
   194
		}
sl@0
   195
	}
sl@0
   196
sl@0
   197
CTestMmfAclntCaps0014::CServerMonitor::CServerMonitor(CTestMmfAclntCaps0014* aParent)
sl@0
   198
	:CActive(EPriorityNormal), iParent(aParent)
sl@0
   199
	{
sl@0
   200
	}
sl@0
   201
sl@0
   202
	
sl@0
   203
CTestMmfAclntCaps0014::CServerMonitor* CTestMmfAclntCaps0014::CServerMonitor::NewL(CTestMmfAclntCaps0014* aParent) 
sl@0
   204
	{
sl@0
   205
	CServerMonitor* self = new (ELeave) CServerMonitor(aParent);
sl@0
   206
	CleanupStack::PushL(self);
sl@0
   207
	self->ConstructL();
sl@0
   208
	CleanupStack::Pop(self);
sl@0
   209
	return self;
sl@0
   210
	}
sl@0
   211
sl@0
   212
void CTestMmfAclntCaps0014::CServerMonitor::ConstructL() 
sl@0
   213
	{
sl@0
   214
	CActiveScheduler::Add(this);
sl@0
   215
	}
sl@0
   216
sl@0
   217
void CTestMmfAclntCaps0014::CServerMonitor::DoCancel() 
sl@0
   218
	{
sl@0
   219
	Cancel();
sl@0
   220
	}
sl@0
   221
sl@0
   222
void CTestMmfAclntCaps0014::CServerMonitor::RunL() 
sl@0
   223
	{
sl@0
   224
	// start the client state machine
sl@0
   225
	iParent->DoProcess(iStatus.Int());
sl@0
   226
	}
sl@0
   227
	
sl@0
   228
TRequestStatus& CTestMmfAclntCaps0014::CServerMonitor::ActiveStatus() 
sl@0
   229
	{
sl@0
   230
	SetActive();
sl@0
   231
	return iStatus;
sl@0
   232
	}
sl@0
   233
sl@0
   234
sl@0
   235
CTestMmfAclntCaps0014::~CTestMmfAclntCaps0014()
sl@0
   236
	{
sl@0
   237
	delete iPlayer;
sl@0
   238
	delete iServerMonitor;
sl@0
   239
	}