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