Update contrib.
1 // Copyright (c) 2003-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.
14 // This file contains an example Test step implementation
15 // This demonstrates the various functions provided
16 // by the CTestStep base class which are available within
29 #include <testframework.h>
31 // Test system includes
32 #include <testframework.h>
34 #include "TSU_MMFMIDICLNT.h"
35 #include "TS_MMFMIDICLNTsuite.h"
37 #include "TestStepMidiClntAllocFailNew.h"
41 // --------------------------------------------
45 * Static constructor for CTestStepMidiClntAllocFailNew.
48 * @return "CTestStepMidiClntAllocFailNew*"
49 * The constructed CTestStepMidiClntAllocFailNew
54 CTestStepMidiClntAllocFailNew* CTestStepMidiClntAllocFailNew::NewL()
56 CTestStepMidiClntAllocFailNew* self = new(ELeave) CTestStepMidiClntAllocFailNew;
62 * Test step constructor.
63 * Each test step initialises its own name.
68 CTestStepMidiClntAllocFailNew::CTestStepMidiClntAllocFailNew()
70 // store the name of this test case
71 // this is the name that is used by the script file
72 iTestStepName = _L("MM-MMF-MIDICLNT-U-0100-CP");
77 * Test step destructor.
82 CTestStepMidiClntAllocFailNew::~CTestStepMidiClntAllocFailNew()
86 // from MMidiClientUtilityObserver
87 void CTestStepMidiClntAllocFailNew::MmcuoStateChanged(TMidiState /*aOldState*/,TMidiState /*aNewState*/,const TTimeIntervalMicroSeconds& /*aTime*/,TInt /*aError*/)
90 void CTestStepMidiClntAllocFailNew::MmcuoTempoChanged(TInt /*aMicroBeatsPerMinute*/)
93 void CTestStepMidiClntAllocFailNew::MmcuoVolumeChanged(TInt /*aChannel*/,TReal32 /*aVolumeInDecibels*/)
96 void CTestStepMidiClntAllocFailNew::MmcuoMuteChanged(TInt /*aChannel*/,TBool /*aMuted*/)
99 void CTestStepMidiClntAllocFailNew::MmcuoSyncUpdate(const TTimeIntervalMicroSeconds& /*aMicroSeconds*/,TInt64 /*aMicroBeats*/)
102 void CTestStepMidiClntAllocFailNew::MmcuoMetaDataEntryFound(const TInt /*aMetaDataEntryId*/,const TTimeIntervalMicroSeconds& /*aPosition*/)
105 void CTestStepMidiClntAllocFailNew::MmcuoMipMessageReceived(const RArray<TMipMessageEntry>& /*aEntry*/)
108 void CTestStepMidiClntAllocFailNew::MmcuoPolyphonyChanged(TInt /*aNewPolyphony*/)
111 void CTestStepMidiClntAllocFailNew::MmcuoInstrumentChanged(TInt /*aChannel*/,TInt /*aBankId*/,TInt /*aInstrumentId*/)
118 * Each test step must supply an implementation for DoTestStepL.
121 * The result of the test step
126 TVerdict CTestStepMidiClntAllocFailNew::DoTestStepL()
128 iTestStepResult = EPass;
131 // Printing to the console and log file
132 INFO_PRINTF1(_L("MM-MMF-MIDICLNT-U-0100-CP"));
133 INFO_PRINTF1(_L("this is Alloc Failure test of initialising a CMidiClientUtility object with NewL()"));
136 TRAP( err, iMidiClnt = CMidiClientUtility::NewL(*this) );
145 TBool completed = EFalse;
146 TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
149 __UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
152 TRAP( err, (iMidiClnt = CMidiClientUtility::NewL(*this)) );
157 TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
161 failCount--; // -= 1;
164 User::Free(testAlloc);
165 // see if valid result and break if wrong - might be premature result
166 if (iMidiClnt != NULL)
171 completed = reachedEnd;
173 else if (err != KErrNoMemory) // bad error code
177 __UHEAP_SETFAIL(RHeap::ENone ,0);
185 //failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc.
189 INFO_PRINTF3(_L(" Error(%d) with %d memory allocations tested"), err, failCount);
190 iTestStepResult = EFail;
194 INFO_PRINTF2(_L(" Completed OK with %d memory allocations tested"), failCount);
195 iTestStepResult = EPass;
198 if (iMidiClnt != NULL)
204 INFO_PRINTF1(_L("finished with this test step"));
205 // test steps return a result
206 return iTestStepResult;