sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "TestPlayerUtils.h" sl@0: #include "OpenFileByHandle7806.h" sl@0: sl@0: CTestMmfAclntOpenFile7806::CTestMmfAclntOpenFile7806(const TDesC& aTestName, const TDesC& aSectName) sl@0: : CTestMmfAclntOpenFile7804(aTestName, aSectName) sl@0: {} sl@0: sl@0: CTestMmfAclntOpenFile7806* CTestMmfAclntOpenFile7806::NewL(const TDesC& aTestName, const TDesC& aSectName) sl@0: { sl@0: CTestMmfAclntOpenFile7806* self = new (ELeave) CTestMmfAclntOpenFile7806(aTestName, aSectName); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: * Open new file. sl@0: */ sl@0: TVerdict CTestMmfAclntOpenFile7806::DoTestL(CMdaAudioPlayerUtility* aPlayer) sl@0: { sl@0: TVerdict iAllocTestStepResult=EPass; sl@0: TInt err = KErrNone; sl@0: TBool result = EFalse; sl@0: sl@0: //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<< sl@0: if( PerformTestL(aPlayer) != EPass ) sl@0: { sl@0: err = iError; sl@0: } sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: INFO_PRINTF2(_L("Test error, returned error code = %d"), err); sl@0: User::Leave(err); sl@0: } sl@0: else sl@0: { sl@0: //Check the iAllocTestStepResult sl@0: if (iAllocTestStepResult != EPass) sl@0: { sl@0: result = ETrue; sl@0: } sl@0: } sl@0: sl@0: TInt failCount = 1; sl@0: TBool completed = EFalse; sl@0: iAllocTestStepResult = EPass; // XXX check?? assume pass sl@0: TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging sl@0: for(;;) sl@0: { sl@0: __UHEAP_SETFAIL(RHeap::EFailNext, failCount); sl@0: __MM_HEAP_MARK; sl@0: sl@0: //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<< sl@0: TVerdict verdict = EFail; sl@0: TRAP(err, verdict = PerformTestL(aPlayer)); sl@0: sl@0: if (err == KErrNone && verdict != EPass) sl@0: { sl@0: err = iError; sl@0: } sl@0: sl@0: completed = EFalse; sl@0: if (err == KErrNone) sl@0: { sl@0: TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test sl@0: if (testAlloc == NULL) sl@0: { sl@0: reachedEnd = ETrue; sl@0: failCount -= 1; sl@0: } sl@0: else sl@0: { sl@0: User::Free(testAlloc); sl@0: } sl@0: sl@0: //Check the iAllocTestStepResult sl@0: if (iAllocTestStepResult != EPass) sl@0: { sl@0: result = ETrue; sl@0: } sl@0: sl@0: completed = reachedEnd || result; sl@0: } sl@0: else if (err != KErrNoMemory) // bad error code sl@0: { sl@0: completed = ETrue; sl@0: result = EFail; sl@0: } sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: sl@0: if (completed) sl@0: { sl@0: break; // exit loop sl@0: } sl@0: sl@0: failCount++; sl@0: } sl@0: sl@0: failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc sl@0: sl@0: if (err != KErrNone || result) sl@0: { sl@0: TBuf<80> format; sl@0: iAllocTestStepResult = EFail; sl@0: if (result) sl@0: { sl@0: format.Format(_L(" Bad result with %d memory allocations tested\n"), failCount); sl@0: } sl@0: else sl@0: { sl@0: format.Format(_L(" Error(%d) with %d memory allocations tested\n"), err, failCount); sl@0: } sl@0: Log(format); sl@0: } sl@0: else sl@0: { sl@0: TBuf<80> format; sl@0: format.Format(_L(" Completed OK with %d memory allocations tested\n"), failCount); sl@0: Log(format); sl@0: } sl@0: sl@0: return iAllocTestStepResult; sl@0: } sl@0: sl@0: CTestMmfAclntRepeatPlayAlloc::CTestMmfAclntRepeatPlayAlloc(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) sl@0: : CTestMmfAclntOpenFile7806(aTestName, aSectName), iSectName(aSectName),iKeyName(aKeyName) sl@0: {} sl@0: sl@0: CTestMmfAclntRepeatPlayAlloc* CTestMmfAclntRepeatPlayAlloc::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) sl@0: { sl@0: CTestMmfAclntRepeatPlayAlloc* self = new (ELeave) CTestMmfAclntRepeatPlayAlloc(aTestName, aSectName, aKeyName); sl@0: return self; sl@0: } sl@0: sl@0: TVerdict CTestMmfAclntRepeatPlayAlloc::PerformTestL(CMdaAudioPlayerUtility* aPlayer) sl@0: { sl@0: INFO_PRINTF1( _L("TestPlayerUtils : OpenFileL(RFile&)/Play")); sl@0: TInt repeatCount; sl@0: TVerdict ret = EFail; sl@0: iError = KErrNone; sl@0: sl@0: RFs fs; sl@0: sl@0: User::LeaveIfError(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: User::LeaveIfError(fs.ShareProtected()); sl@0: sl@0: TBuf filename; sl@0: TPtrC filename1; sl@0: RFile file; sl@0: sl@0: if(!GetStringFromConfig(iSectName, iKeyName, filename1)) sl@0: { sl@0: return EInconclusive; sl@0: } sl@0: sl@0: GetDriveName(filename); sl@0: filename.Append(filename1); sl@0: sl@0: User::LeaveIfError( file.Open( fs, filename, EFileRead ) ); sl@0: CleanupClosePushL(file); sl@0: if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("numOfRepeat"), repeatCount)) sl@0: { sl@0: return EInconclusive; sl@0: } sl@0: aPlayer->SetRepeats(repeatCount, TTimeIntervalMicroSeconds(2)); sl@0: aPlayer->OpenFileL(file); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (iError == KErrNone) sl@0: { sl@0: aPlayer->Play(); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: sl@0: if (iError == KErrNone) sl@0: { sl@0: ret = EPass; sl@0: } sl@0: sl@0: aPlayer->Close(); sl@0: CleanupStack::PopAndDestroy(2, &fs); sl@0: sl@0: return ret; sl@0: }