os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/OpenFileByHandle_PlayTone.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/OpenFileByHandle_PlayTone.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,134 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This program is designed the test of the MMF_ACLNT.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file OpenFileByHandle_PlayTone.cpp
    1.23 +*/
    1.24 +
    1.25 +#include "OpenFileByHandle_PlayTone.h"
    1.26 +
    1.27 +//const TInt KHeapSizeToneTestEKA2 = 128000; // Heapsize for tone tests on EKA2
    1.28 +
    1.29 +//------------------------------------------------------------------
    1.30 +
    1.31 +/**
    1.32 + * Constructor
    1.33 + */
    1.34 +CTestMmfAclntOpenToneFile::CTestMmfAclntOpenToneFile(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
    1.35 +	: CTestMmfAclntTone(aTestName)
    1.36 +	{
    1.37 +	// store the name of this test case
    1.38 +	// this is the name that is used by the script file
    1.39 +	// Each test step initialises it's own name
    1.40 +	iSectName = aSectName;
    1.41 +	iKeyName= aKeyName;
    1.42 +	}
    1.43 +
    1.44 +CTestMmfAclntOpenToneFile* CTestMmfAclntOpenToneFile::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
    1.45 +	{
    1.46 +	CTestMmfAclntOpenToneFile* self = new (ELeave) CTestMmfAclntOpenToneFile(aTestName,aSectName,aKeyName);
    1.47 +	return self;
    1.48 +	}
    1.49 +
    1.50 +TVerdict CTestMmfAclntOpenToneFile::DoTestStepPreambleL()
    1.51 +	{
    1.52 +	TPtrC filename;
    1.53 +	if(!GetStringFromConfig(iSectName, iKeyName, filename))
    1.54 +		{
    1.55 +		return EInconclusive;
    1.56 +		}
    1.57 +
    1.58 +	// Create a sequence file
    1.59 +	TInt length;
    1.60 +	RFs fs;
    1.61 +
    1.62 +	fs.Connect();
    1.63 +	CleanupClosePushL(fs);
    1.64 +#ifdef __IPC_V2_PRESENT__
    1.65 +	User::LeaveIfError(fs.ShareAuto());
    1.66 +#else
    1.67 +	User::LeaveIfError(fs.Share(RSessionBase::EExplicitAttach));
    1.68 +#endif
    1.69 +	RFile file;
    1.70 +	User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
    1.71 +	CleanupClosePushL(file);
    1.72 +	User::LeaveIfError(file.Write(KFixedSequenceData()));
    1.73 +	User::LeaveIfError(file.Size(length));
    1.74 +	CleanupStack::PopAndDestroy(2, &fs);
    1.75 +
    1.76 +	return CTestMmfAclntStep::DoTestStepPreambleL();
    1.77 +	}
    1.78 +
    1.79 +/**
    1.80 + * Play a tone file
    1.81 + */
    1.82 +TVerdict CTestMmfAclntOpenToneFile::DoTestStepL( void )
    1.83 +	{
    1.84 +	INFO_PRINTF1( _L("TestTone : Play File"));
    1.85 +
    1.86 +	TVerdict ret = EFail;
    1.87 +
    1.88 +	RFs fs;
    1.89 +
    1.90 +	User::LeaveIfError(fs.Connect());
    1.91 +	CleanupClosePushL(fs);
    1.92 +	User::LeaveIfError(fs.ShareProtected());
    1.93 +
    1.94 +	TPtrC filename;
    1.95 +	if(!GetStringFromConfig(iSectName, iKeyName, filename))
    1.96 +		{
    1.97 +		return EInconclusive;
    1.98 +		}
    1.99 +
   1.100 +	iError = KErrTimedOut;
   1.101 +	// perform test using this file
   1.102 +	CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
   1.103 +	CleanupStack::PushL(toneUtil);
   1.104 +
   1.105 +	RFile file;
   1.106 +	User::LeaveIfError( file.Open( fs, filename, EFileRead | EFileShareAny ) );
   1.107 +	CleanupClosePushL(file);
   1.108 +
   1.109 +	toneUtil->PrepareToPlayFileSequence(file);
   1.110 +	CleanupStack::PopAndDestroy(&file);
   1.111 +
   1.112 +	// Wait for prepare
   1.113 +	INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
   1.114 +	CActiveScheduler::Start();
   1.115 +
   1.116 +	User::LeaveIfError( file.Open( fs, filename, EFileRead | EFileShareAny ) );
   1.117 +	CleanupClosePushL(file);
   1.118 +
   1.119 +	toneUtil->PrepareToPlayFileSequence(file);
   1.120 +	// Wait for prepare
   1.121 +	INFO_PRINTF1( _L("re-initialise CMdaAudioToneUtility"));
   1.122 +	CActiveScheduler::Start();
   1.123 +
   1.124 +	if(iError == KErrNone)
   1.125 +		{
   1.126 +		ret = DoTestL(toneUtil);
   1.127 +		}
   1.128 +
   1.129 +	if(ret == EFail)
   1.130 +		{
   1.131 +		ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
   1.132 +		}
   1.133 +
   1.134 +	CleanupStack::PopAndDestroy(3, &fs);
   1.135 +
   1.136 +	return ret;
   1.137 +	}