1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/OpenFileByHandle7806.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,201 @@
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 "OpenFileByHandle7806.h"
1.21 +
1.22 +CTestMmfAclntOpenFile7806::CTestMmfAclntOpenFile7806(const TDesC& aTestName, const TDesC& aSectName)
1.23 + : CTestMmfAclntOpenFile7804(aTestName, aSectName)
1.24 + {}
1.25 +
1.26 +CTestMmfAclntOpenFile7806* CTestMmfAclntOpenFile7806::NewL(const TDesC& aTestName, const TDesC& aSectName)
1.27 + {
1.28 + CTestMmfAclntOpenFile7806* self = new (ELeave) CTestMmfAclntOpenFile7806(aTestName, aSectName);
1.29 + return self;
1.30 + }
1.31 +
1.32 +/**
1.33 + * Open new file.
1.34 + */
1.35 +TVerdict CTestMmfAclntOpenFile7806::DoTestL(CMdaAudioPlayerUtility* aPlayer)
1.36 + {
1.37 + TVerdict iAllocTestStepResult=EPass;
1.38 + TInt err = KErrNone;
1.39 + TBool result = EFalse;
1.40 +
1.41 + //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
1.42 + if( PerformTestL(aPlayer) != EPass )
1.43 + {
1.44 + err = iError;
1.45 + }
1.46 +
1.47 + if (err != KErrNone)
1.48 + {
1.49 + INFO_PRINTF2(_L("Test error, returned error code = %d"), err);
1.50 + User::Leave(err);
1.51 + }
1.52 + else
1.53 + {
1.54 + //Check the iAllocTestStepResult
1.55 + if (iAllocTestStepResult != EPass)
1.56 + {
1.57 + result = ETrue;
1.58 + }
1.59 + }
1.60 +
1.61 + TInt failCount = 1;
1.62 + TBool completed = EFalse;
1.63 + iAllocTestStepResult = EPass; // XXX check?? assume pass
1.64 + TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
1.65 + for(;;)
1.66 + {
1.67 + __UHEAP_SETFAIL(RHeap::EFailNext, failCount);
1.68 + __MM_HEAP_MARK;
1.69 +
1.70 + //>>>>>>>>>>>>>>>>>>>>>>>>Test Method Call<<<<<<<<<<<<<<<<<<<<<<<<<<
1.71 + TVerdict verdict = EFail;
1.72 + TRAP(err, verdict = PerformTestL(aPlayer));
1.73 +
1.74 + if (err == KErrNone && verdict != EPass)
1.75 + {
1.76 + err = iError;
1.77 + }
1.78 +
1.79 + completed = EFalse;
1.80 + if (err == KErrNone)
1.81 + {
1.82 + TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
1.83 + if (testAlloc == NULL)
1.84 + {
1.85 + reachedEnd = ETrue;
1.86 + failCount -= 1;
1.87 + }
1.88 + else
1.89 + {
1.90 + User::Free(testAlloc);
1.91 + }
1.92 +
1.93 + //Check the iAllocTestStepResult
1.94 + if (iAllocTestStepResult != EPass)
1.95 + {
1.96 + result = ETrue;
1.97 + }
1.98 +
1.99 + completed = reachedEnd || result;
1.100 + }
1.101 + else if (err != KErrNoMemory) // bad error code
1.102 + {
1.103 + completed = ETrue;
1.104 + result = EFail;
1.105 + }
1.106 +
1.107 + __MM_HEAP_MARKEND;
1.108 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.109 +
1.110 + if (completed)
1.111 + {
1.112 + break; // exit loop
1.113 + }
1.114 +
1.115 + failCount++;
1.116 + }
1.117 +
1.118 + failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc
1.119 +
1.120 + if (err != KErrNone || result)
1.121 + {
1.122 + TBuf<80> format;
1.123 + iAllocTestStepResult = EFail;
1.124 + if (result)
1.125 + {
1.126 + format.Format(_L(" Bad result with %d memory allocations tested\n"), failCount);
1.127 + }
1.128 + else
1.129 + {
1.130 + format.Format(_L(" Error(%d) with %d memory allocations tested\n"), err, failCount);
1.131 + }
1.132 + Log(format);
1.133 + }
1.134 + else
1.135 + {
1.136 + TBuf<80> format;
1.137 + format.Format(_L(" Completed OK with %d memory allocations tested\n"), failCount);
1.138 + Log(format);
1.139 + }
1.140 +
1.141 + return iAllocTestStepResult;
1.142 + }
1.143 +
1.144 +CTestMmfAclntRepeatPlayAlloc::CTestMmfAclntRepeatPlayAlloc(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
1.145 + : CTestMmfAclntOpenFile7806(aTestName, aSectName), iSectName(aSectName),iKeyName(aKeyName)
1.146 + {}
1.147 +
1.148 +CTestMmfAclntRepeatPlayAlloc* CTestMmfAclntRepeatPlayAlloc::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName)
1.149 + {
1.150 + CTestMmfAclntRepeatPlayAlloc* self = new (ELeave) CTestMmfAclntRepeatPlayAlloc(aTestName, aSectName, aKeyName);
1.151 + return self;
1.152 + }
1.153 +
1.154 +TVerdict CTestMmfAclntRepeatPlayAlloc::PerformTestL(CMdaAudioPlayerUtility* aPlayer)
1.155 + {
1.156 + INFO_PRINTF1( _L("TestPlayerUtils : OpenFileL(RFile&)/Play"));
1.157 + TInt repeatCount;
1.158 + TVerdict ret = EFail;
1.159 + iError = KErrNone;
1.160 +
1.161 + RFs fs;
1.162 +
1.163 + User::LeaveIfError(fs.Connect());
1.164 + CleanupClosePushL(fs);
1.165 + User::LeaveIfError(fs.ShareProtected());
1.166 +
1.167 + TBuf<KSizeBuf> filename;
1.168 + TPtrC filename1;
1.169 + RFile file;
1.170 +
1.171 + if(!GetStringFromConfig(iSectName, iKeyName, filename1))
1.172 + {
1.173 + return EInconclusive;
1.174 + }
1.175 +
1.176 + GetDriveName(filename);
1.177 + filename.Append(filename1);
1.178 +
1.179 + User::LeaveIfError( file.Open( fs, filename, EFileRead ) );
1.180 + CleanupClosePushL(file);
1.181 + if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("numOfRepeat"), repeatCount))
1.182 + {
1.183 + return EInconclusive;
1.184 + }
1.185 + aPlayer->SetRepeats(repeatCount, TTimeIntervalMicroSeconds(2));
1.186 + aPlayer->OpenFileL(file);
1.187 + CActiveScheduler::Start();
1.188 +
1.189 + if (iError == KErrNone)
1.190 + {
1.191 + aPlayer->Play();
1.192 + CActiveScheduler::Start();
1.193 + }
1.194 +
1.195 + if (iError == KErrNone)
1.196 + {
1.197 + ret = EPass;
1.198 + }
1.199 +
1.200 + aPlayer->Close();
1.201 + CleanupStack::PopAndDestroy(2, &fs);
1.202 +
1.203 + return ret;
1.204 + }