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 "TestRecord.h" sl@0: #include "OpenFileByHandle0524.h" sl@0: sl@0: #include sl@0: sl@0: /** sl@0: * Constructor sl@0: */ sl@0: CTestMmfVclntOpenFile0524::CTestMmfVclntOpenFile0524(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec) sl@0: : CTestMmfVclntOpenFile0523(aTestName, aSectName, aKeyName, aRec) sl@0: { sl@0: } sl@0: sl@0: CTestMmfVclntOpenFile0524* CTestMmfVclntOpenFile0524::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec) sl@0: { sl@0: CTestMmfVclntOpenFile0524* self = new (ELeave) CTestMmfVclntOpenFile0524(aTestName,aSectName,aKeyName,aRec); sl@0: return self; sl@0: } sl@0: sl@0: CTestMmfVclntOpenFile0524* CTestMmfVclntOpenFile0524::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec) sl@0: { sl@0: CTestMmfVclntOpenFile0524* self = CTestMmfVclntOpenFile0524::NewL(aTestName,aSectName,aKeyName,aRec); sl@0: CleanupStack::PushL(self); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: * Load and initialise an audio file. sl@0: */ sl@0: TVerdict CTestMmfVclntOpenFile0524::DoTestStepL() 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( PerformTestStepL() != 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; // TODO 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: //INFO_PRINTF2(_L("CVideoRecorderUtility: Alloc Test Loop: %d"), failCount); sl@0: sl@0: //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<< sl@0: TVerdict verdict = EFail; sl@0: TRAP(err, verdict = PerformTestStepL()) 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: iAllocTestStepResult = EFail; sl@0: TBuf<80> format; 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: }