Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "TestPlayerUtils.h"
17 #include "OpenFileByHandle7806.h"
19 CTestMmfAclntOpenFile7806::CTestMmfAclntOpenFile7806(const TDesC& aTestName, const TDesC& aSectName)
20 : CTestMmfAclntOpenFile7804(aTestName, aSectName)
23 CTestMmfAclntOpenFile7806* CTestMmfAclntOpenFile7806::NewL(const TDesC& aTestName, const TDesC& aSectName)
25 CTestMmfAclntOpenFile7806* self = new (ELeave) CTestMmfAclntOpenFile7806(aTestName, aSectName);
32 TVerdict CTestMmfAclntOpenFile7806::DoTestL(CMdaAudioPlayerUtility* aPlayer)
34 TVerdict iAllocTestStepResult=EPass;
36 TBool result = EFalse;
38 //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
39 if( PerformTestL(aPlayer) != EPass )
46 INFO_PRINTF2(_L("Test error, returned error code = %d"), err);
51 //Check the iAllocTestStepResult
52 if (iAllocTestStepResult != EPass)
59 TBool completed = EFalse;
60 iAllocTestStepResult = EPass; // XXX check?? assume pass
61 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
64 __UHEAP_SETFAIL(RHeap::EFailNext, failCount);
67 //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
68 TVerdict verdict = EFail;
69 TRAP(err, verdict = PerformTestL(aPlayer));
71 if (err == KErrNone && verdict != EPass)
79 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
80 if (testAlloc == NULL)
87 User::Free(testAlloc);
90 //Check the iAllocTestStepResult
91 if (iAllocTestStepResult != EPass)
96 completed = reachedEnd || result;
98 else if (err != KErrNoMemory) // bad error code
105 __UHEAP_SETFAIL(RHeap::ENone, 0);
115 failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
117 if (err != KErrNone || result)
120 iAllocTestStepResult = EFail;
123 format.Format(_L(" Bad result with %d memory allocations tested\n"), failCount);
127 format.Format(_L(" Error(%d) with %d memory allocations tested\n"), err, failCount);
134 format.Format(_L(" Completed OK with %d memory allocations tested\n"), failCount);
138 return iAllocTestStepResult;
141 CTestMmfAclntRepeatPlayAlloc::CTestMmfAclntRepeatPlayAlloc(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
142 : CTestMmfAclntOpenFile7806(aTestName, aSectName), iSectName(aSectName),iKeyName(aKeyName)
145 CTestMmfAclntRepeatPlayAlloc* CTestMmfAclntRepeatPlayAlloc::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
147 CTestMmfAclntRepeatPlayAlloc* self = new (ELeave) CTestMmfAclntRepeatPlayAlloc(aTestName, aSectName, aKeyName);
151 TVerdict CTestMmfAclntRepeatPlayAlloc::PerformTestL(CMdaAudioPlayerUtility* aPlayer)
153 INFO_PRINTF1( _L("TestPlayerUtils : OpenFileL(RFile&)/Play"));
155 TVerdict ret = EFail;
160 User::LeaveIfError(fs.Connect());
161 CleanupClosePushL(fs);
162 User::LeaveIfError(fs.ShareProtected());
164 TBuf<KSizeBuf> filename;
168 if(!GetStringFromConfig(iSectName, iKeyName, filename1))
170 return EInconclusive;
173 GetDriveName(filename);
174 filename.Append(filename1);
176 User::LeaveIfError( file.Open( fs, filename, EFileRead ) );
177 CleanupClosePushL(file);
178 if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("numOfRepeat"), repeatCount))
180 return EInconclusive;
182 aPlayer->SetRepeats(repeatCount, TTimeIntervalMicroSeconds(2));
183 aPlayer->OpenFileL(file);
184 CActiveScheduler::Start();
186 if (iError == KErrNone)
189 CActiveScheduler::Start();
192 if (iError == KErrNone)
198 CleanupStack::PopAndDestroy(2, &fs);