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