os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TestCapabilities0014.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
	// TSI_MMF_SDEVSOUND, MM-MMF-SDEVSOUND-I-0010-HP runs before this 
sl@0
   118
	// this step does, I-0010-HP creates and uses 
sl@0
   119
	// rectest1.wav and rectest2.wav 
sl@0
   120
	// So we need to delete these to avoid errors In this test.
sl@0
   121
	RFs fsSession;
sl@0
   122
	fsSession.Connect();
sl@0
   123
	TRAPD(err,fsSession.Delete(_L("c:\\rectest1.wav")));
sl@0
   124
	TRAP(err,fsSession.Delete(_L("c:\\rectest2.wav")));
sl@0
   125
	fsSession.Close();
sl@0
   126
	
sl@0
   127
	// Start Server to play back from another process
sl@0
   128
	RTestServ server;
sl@0
   129
	User::LeaveIfError(server.Connect(_L("CapTestServer")));
sl@0
   130
	CleanupClosePushL(server);
sl@0
   131
	RTestSession session1;
sl@0
   132
	User::LeaveIfError(session1.Open(server,_L("CapTestStep0014")));
sl@0
   133
	TRequestStatus* status = &iServerMonitor->ActiveStatus();
sl@0
   134
	// Start Server playback. The RunL of the CServerMonitor class will be called by the server when
sl@0
   135
	// playback has started
sl@0
   136
	session1.StartProcessing(*status);
sl@0
   137
	// Begin activescheduler loop. This will only exit when the whole test is complete 
sl@0
   138
	CActiveScheduler::Start();
sl@0
   139
	
sl@0
   140
	// The test is complete. Now shut down the server and get any errors /messages from the server
sl@0
   141
	TBuf8<256> message;
sl@0
   142
	TVerdict verdict = session1.EndProcessingAndReturnResult(message);
sl@0
   143
	if (verdict != EPass)
sl@0
   144
		iVerdict = verdict;
sl@0
   145
	TBuf16<256> copymess;
sl@0
   146
	copymess.Copy(message);
sl@0
   147
	INFO_PRINTF2(_L("end processing and return result: %S"),&copymess);
sl@0
   148
sl@0
   149
	CleanupStack::PopAndDestroy(&server);
sl@0
   150
	return iVerdict;
sl@0
   151
	}
sl@0
   152
	
sl@0
   153
void CTestMmfAclntCaps0014::CreatePlayer() 
sl@0
   154
	{
sl@0
   155
	// Get the test filename from the configuration file
sl@0
   156
	TBuf<KSizeBuf> filename;
sl@0
   157
	TPtrC filename1; 
sl@0
   158
	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
sl@0
   159
		{
sl@0
   160
		iVerdict = EFail;
sl@0
   161
		CActiveScheduler::Stop();
sl@0
   162
		}
sl@0
   163
	GetDriveName(filename);
sl@0
   164
	filename.Append(filename1);
sl@0
   165
	
sl@0
   166
	iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityNormal);
sl@0
   167
	iPlayer->OpenFileL(_L("c:\\rectest2.wav"));
sl@0
   168
	}
sl@0
   169
	
sl@0
   170
void CTestMmfAclntCaps0014::BeginPlayback()
sl@0
   171
	{
sl@0
   172
	iPlayer->RecordL();
sl@0
   173
	}
sl@0
   174
	
sl@0
   175
	
sl@0
   176
void CTestMmfAclntCaps0014::DoProcess(TInt aError)
sl@0
   177
	{
sl@0
   178
	if (aError == KErrNone)
sl@0
   179
		{
sl@0
   180
		InternalState nextState = iState;
sl@0
   181
		switch (iState)
sl@0
   182
			{
sl@0
   183
		case EWaitingForServer:
sl@0
   184
			CreatePlayer();
sl@0
   185
			nextState = EInitPlayer;
sl@0
   186
			break;
sl@0
   187
		case EInitPlayer : 
sl@0
   188
			BeginPlayback();
sl@0
   189
			nextState = EPlaying;
sl@0
   190
			break;
sl@0
   191
		case EPlaying :
sl@0
   192
			iVerdict = EPass;
sl@0
   193
			CActiveScheduler::Stop();
sl@0
   194
			break;
sl@0
   195
			}
sl@0
   196
		iState = nextState;
sl@0
   197
		}
sl@0
   198
	else 
sl@0
   199
		{
sl@0
   200
		iVerdict = EFail;
sl@0
   201
		INFO_PRINTF2(_L("Unexpected failure in test, error code %d"), aError);
sl@0
   202
		CActiveScheduler::Stop();
sl@0
   203
		}
sl@0
   204
	}
sl@0
   205
sl@0
   206
CTestMmfAclntCaps0014::CServerMonitor::CServerMonitor(CTestMmfAclntCaps0014* aParent)
sl@0
   207
	:CActive(EPriorityNormal), iParent(aParent)
sl@0
   208
	{
sl@0
   209
	}
sl@0
   210
sl@0
   211
	
sl@0
   212
CTestMmfAclntCaps0014::CServerMonitor* CTestMmfAclntCaps0014::CServerMonitor::NewL(CTestMmfAclntCaps0014* aParent) 
sl@0
   213
	{
sl@0
   214
	CServerMonitor* self = new (ELeave) CServerMonitor(aParent);
sl@0
   215
	CleanupStack::PushL(self);
sl@0
   216
	self->ConstructL();
sl@0
   217
	CleanupStack::Pop(self);
sl@0
   218
	return self;
sl@0
   219
	}
sl@0
   220
sl@0
   221
void CTestMmfAclntCaps0014::CServerMonitor::ConstructL() 
sl@0
   222
	{
sl@0
   223
	CActiveScheduler::Add(this);
sl@0
   224
	}
sl@0
   225
sl@0
   226
void CTestMmfAclntCaps0014::CServerMonitor::DoCancel() 
sl@0
   227
	{
sl@0
   228
	Cancel();
sl@0
   229
	}
sl@0
   230
sl@0
   231
void CTestMmfAclntCaps0014::CServerMonitor::RunL() 
sl@0
   232
	{
sl@0
   233
	// start the client state machine
sl@0
   234
	iParent->DoProcess(iStatus.Int());
sl@0
   235
	}
sl@0
   236
	
sl@0
   237
TRequestStatus& CTestMmfAclntCaps0014::CServerMonitor::ActiveStatus() 
sl@0
   238
	{
sl@0
   239
	SetActive();
sl@0
   240
	return iStatus;
sl@0
   241
	}
sl@0
   242
sl@0
   243
sl@0
   244
CTestMmfAclntCaps0014::~CTestMmfAclntCaps0014()
sl@0
   245
	{
sl@0
   246
	}
sl@0
   247
	
sl@0
   248
void CTestMmfAclntCaps0014::Close()
sl@0
   249
	{
sl@0
   250
	delete iPlayer;
sl@0
   251
	delete iServerMonitor;
sl@0
   252
	}
sl@0
   253
sl@0
   254