1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/OpenFileByHandle0524.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,153 @@
1.4 +// Copyright (c) 2004-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 +//
1.18 +
1.19 +#include "TestRecord.h"
1.20 +#include "OpenFileByHandle0524.h"
1.21 +
1.22 +#include <caf/caf.h>
1.23 +
1.24 +/**
1.25 + * Constructor
1.26 + */
1.27 +CTestMmfVclntOpenFile0524::CTestMmfVclntOpenFile0524(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
1.28 + : CTestMmfVclntOpenFile0523(aTestName, aSectName, aKeyName, aRec)
1.29 + {
1.30 + }
1.31 +
1.32 +CTestMmfVclntOpenFile0524* CTestMmfVclntOpenFile0524::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
1.33 + {
1.34 + CTestMmfVclntOpenFile0524* self = new (ELeave) CTestMmfVclntOpenFile0524(aTestName,aSectName,aKeyName,aRec);
1.35 + return self;
1.36 + }
1.37 +
1.38 +CTestMmfVclntOpenFile0524* CTestMmfVclntOpenFile0524::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
1.39 + {
1.40 + CTestMmfVclntOpenFile0524* self = CTestMmfVclntOpenFile0524::NewL(aTestName,aSectName,aKeyName,aRec);
1.41 + CleanupStack::PushL(self);
1.42 + return self;
1.43 + }
1.44 +
1.45 +/**
1.46 + * Load and initialise an audio file.
1.47 + */
1.48 +TVerdict CTestMmfVclntOpenFile0524::DoTestStepL()
1.49 + {
1.50 + TVerdict iAllocTestStepResult=EPass;
1.51 + TInt err = KErrNone;
1.52 + TBool result = EFalse;
1.53 +
1.54 + //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
1.55 + if( PerformTestStepL() != EPass )
1.56 + {
1.57 + err = iError;
1.58 + }
1.59 +
1.60 + if (err != KErrNone)
1.61 + {
1.62 + INFO_PRINTF2(_L("Test error, returned error code = %d"), err);
1.63 + User::Leave(err);
1.64 + }
1.65 + else
1.66 + {
1.67 + //Check the iAllocTestStepResult
1.68 + if (iAllocTestStepResult != EPass)
1.69 + {
1.70 + result = ETrue;
1.71 + }
1.72 + }
1.73 +
1.74 + TInt failCount = 1;
1.75 + TBool completed = EFalse;
1.76 + iAllocTestStepResult = EPass; // TODO check?? assume pass
1.77 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.78 + for(;;)
1.79 + {
1.80 + __UHEAP_SETFAIL(RHeap::EFailNext, failCount);
1.81 + __MM_HEAP_MARK;
1.82 +
1.83 + //INFO_PRINTF2(_L("CVideoRecorderUtility: Alloc Test Loop: %d"), failCount);
1.84 +
1.85 + //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
1.86 + TVerdict verdict = EFail;
1.87 + TRAP(err, verdict = PerformTestStepL())
1.88 + if (err == KErrNone && verdict != EPass)
1.89 + {
1.90 + err = iError;
1.91 + }
1.92 +
1.93 + completed = EFalse;
1.94 + if (err == KErrNone)
1.95 + {
1.96 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.97 + if (testAlloc == NULL)
1.98 + {
1.99 + reachedEnd = ETrue;
1.100 + failCount -= 1;
1.101 + }
1.102 + else
1.103 + {
1.104 + User::Free(testAlloc);
1.105 + }
1.106 +
1.107 + //Check the iAllocTestStepResult
1.108 + if (iAllocTestStepResult != EPass)
1.109 + {
1.110 + result = ETrue;
1.111 + }
1.112 +
1.113 + completed = reachedEnd || result;
1.114 + }
1.115 + else if (err != KErrNoMemory) // bad error code
1.116 + {
1.117 + completed = ETrue;
1.118 + result = EFail;
1.119 + }
1.120 +
1.121 + __MM_HEAP_MARKEND;
1.122 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.123 +
1.124 + if (completed)
1.125 + {
1.126 + break; // exit loop
1.127 + }
1.128 +
1.129 + failCount++;
1.130 + }
1.131 +
1.132 + failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
1.133 +
1.134 + if (err != KErrNone || result)
1.135 + {
1.136 + iAllocTestStepResult = EFail;
1.137 + TBuf<80> format;
1.138 + if (result)
1.139 + {
1.140 + format.Format(_L(" Bad result with %d memory allocations tested\n"), failCount);
1.141 + }
1.142 + else
1.143 + {
1.144 + format.Format(_L(" Error(%d) with %d memory allocations tested\n"), err, failCount);
1.145 + }
1.146 + Log(format);
1.147 + }
1.148 + else
1.149 + {
1.150 + TBuf<80> format;
1.151 + format.Format(_L(" Completed OK with %d memory allocations tested\n"), failCount);
1.152 + Log(format);
1.153 + }
1.154 +
1.155 + return iAllocTestStepResult;
1.156 + }