os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TestCapabilities0012.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
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 "TestPlayerCaps0012.h"
sl@0
    27
sl@0
    28
sl@0
    29
sl@0
    30
/**
sl@0
    31
 * Constructor
sl@0
    32
 */
sl@0
    33
CTestMmfAclntCaps0012::CTestMmfAclntCaps0012(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
CTestMmfAclntCaps0012* CTestMmfAclntCaps0012::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
sl@0
    44
	{
sl@0
    45
	CTestMmfAclntCaps0012* self = new (ELeave) CTestMmfAclntCaps0012(aTestName, aSectName, aKeyName);
sl@0
    46
	return self;
sl@0
    47
	}
sl@0
    48
sl@0
    49
CTestMmfAclntCaps0012* CTestMmfAclntCaps0012::NewLC(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
sl@0
    50
	{
sl@0
    51
	CTestMmfAclntCaps0012* 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 CTestMmfAclntCaps0012::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 CTestMmfAclntCaps0012::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
sl@0
    69
sl@0
    70
/** Load and initialise an audio file.
sl@0
    71
 */
sl@0
    72
TVerdict CTestMmfAclntCaps0012::DoTestStepL( void )
sl@0
    73
	{
sl@0
    74
	INFO_PRINTF1( _L("TestPlayerUtils : Caps"));
sl@0
    75
	iVerdict = EFail;
sl@0
    76
sl@0
    77
	iServerMonitor = CServerMonitor::NewL(this);
sl@0
    78
sl@0
    79
	// Start Server to play back from another process
sl@0
    80
	RTestServ server;
sl@0
    81
	User::LeaveIfError(server.Connect(_L("CapTestServer")));
sl@0
    82
	CleanupClosePushL(server);
sl@0
    83
	
sl@0
    84
	RTestSession session1;
sl@0
    85
	User::LeaveIfError(session1.Open(server,_L("CapTestStep0012")));
sl@0
    86
	TRequestStatus* status = &iServerMonitor->ActiveStatus();
sl@0
    87
	// Start Server playback. The RunL of the CServerMonitor class will be called by the server when
sl@0
    88
	// playback has started
sl@0
    89
	session1.StartProcessing(*status);
sl@0
    90
	// Begin activescheduler loop. This will only exit when the whole test is complete 
sl@0
    91
	CActiveScheduler::Start();
sl@0
    92
	
sl@0
    93
	// The test is complete. Now shut down the server and get any errors /messages from the server
sl@0
    94
	TBuf8<256> message;
sl@0
    95
	TVerdict verdict = session1.EndProcessingAndReturnResult(message);
sl@0
    96
	if (verdict != EPass)
sl@0
    97
		iVerdict = verdict;
sl@0
    98
	TBuf16<256> copymess;
sl@0
    99
	copymess.Copy(message);
sl@0
   100
	INFO_PRINTF2(_L("end processing and return result: %S"),&copymess);
sl@0
   101
sl@0
   102
	CleanupStack::PopAndDestroy(&server);
sl@0
   103
	return iVerdict;
sl@0
   104
	}
sl@0
   105
	
sl@0
   106
void CTestMmfAclntCaps0012::CreatePlayer() 
sl@0
   107
	{
sl@0
   108
	// Get the test filename from the configuration file
sl@0
   109
	TBuf<KSizeBuf> filename;
sl@0
   110
	TPtrC filename1; 
sl@0
   111
	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
sl@0
   112
		{
sl@0
   113
		iVerdict = EFail;
sl@0
   114
		CActiveScheduler::Stop();
sl@0
   115
		}
sl@0
   116
	GetDriveName(filename);
sl@0
   117
	filename.Append(filename1);
sl@0
   118
sl@0
   119
	iPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this, EMdaPriorityNormal);	
sl@0
   120
	}
sl@0
   121
	
sl@0
   122
void CTestMmfAclntCaps0012::BeginPlayback()
sl@0
   123
	{
sl@0
   124
	iPlayer->Play();
sl@0
   125
	}
sl@0
   126
	
sl@0
   127
	
sl@0
   128
void CTestMmfAclntCaps0012::DoProcess(TInt aError)
sl@0
   129
	{
sl@0
   130
	if (aError == KErrNone)
sl@0
   131
		{
sl@0
   132
		InternalState nextState = iState;
sl@0
   133
		switch (iState)
sl@0
   134
			{
sl@0
   135
		case EWaitingForServer:
sl@0
   136
			CreatePlayer();
sl@0
   137
			nextState = EInitPlayer;
sl@0
   138
			break;
sl@0
   139
		case EInitPlayer : 
sl@0
   140
			BeginPlayback();
sl@0
   141
			nextState = EPlaying;
sl@0
   142
			break;
sl@0
   143
		case EPlaying :
sl@0
   144
			iVerdict = EPass;
sl@0
   145
			CActiveScheduler::Stop();
sl@0
   146
			break;
sl@0
   147
			}
sl@0
   148
		iState = nextState;
sl@0
   149
		}
sl@0
   150
	else 
sl@0
   151
		{
sl@0
   152
		iVerdict = EFail;
sl@0
   153
		INFO_PRINTF2(_L("Unexpected failure in test, error code %d"), aError);
sl@0
   154
		CActiveScheduler::Stop();
sl@0
   155
		}
sl@0
   156
	}
sl@0
   157
sl@0
   158
CTestMmfAclntCaps0012::CServerMonitor::CServerMonitor(CTestMmfAclntCaps0012* aParent)
sl@0
   159
	:CActive(EPriorityNormal), iParent(aParent)
sl@0
   160
	{
sl@0
   161
	}
sl@0
   162
sl@0
   163
	
sl@0
   164
CTestMmfAclntCaps0012::CServerMonitor* CTestMmfAclntCaps0012::CServerMonitor::NewL(CTestMmfAclntCaps0012* aParent) 
sl@0
   165
	{
sl@0
   166
	CServerMonitor* self = new (ELeave) CServerMonitor(aParent);
sl@0
   167
	CleanupStack::PushL(self);
sl@0
   168
	self->ConstructL();
sl@0
   169
	CleanupStack::Pop(self);
sl@0
   170
	return self;
sl@0
   171
	}
sl@0
   172
sl@0
   173
void CTestMmfAclntCaps0012::CServerMonitor::ConstructL() 
sl@0
   174
	{
sl@0
   175
	CActiveScheduler::Add(this);
sl@0
   176
	}
sl@0
   177
sl@0
   178
void CTestMmfAclntCaps0012::CServerMonitor::DoCancel() 
sl@0
   179
	{
sl@0
   180
	Cancel();
sl@0
   181
	}
sl@0
   182
sl@0
   183
void CTestMmfAclntCaps0012::CServerMonitor::RunL() 
sl@0
   184
	{
sl@0
   185
	// start the client state machine
sl@0
   186
	iParent->DoProcess(iStatus.Int());
sl@0
   187
	}
sl@0
   188
	
sl@0
   189
TRequestStatus& CTestMmfAclntCaps0012::CServerMonitor::ActiveStatus() 
sl@0
   190
	{
sl@0
   191
	SetActive();
sl@0
   192
	return iStatus;
sl@0
   193
	}
sl@0
   194
sl@0
   195
sl@0
   196
CTestMmfAclntCaps0012::~CTestMmfAclntCaps0012()
sl@0
   197
	{
sl@0
   198
	}
sl@0
   199
sl@0
   200
void CTestMmfAclntCaps0012::Close()
sl@0
   201
	{
sl@0
   202
	delete iPlayer;
sl@0
   203
	delete iServerMonitor;
sl@0
   204
	}
sl@0
   205
sl@0
   206
sl@0
   207