sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // @internalComponent sl@0: // sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include // unicode builds sl@0: #include sl@0: #include sl@0: #include // RTest headder sl@0: #include "testcaseroot.h" sl@0: #include "testcase0463.h" sl@0: sl@0: sl@0: sl@0: sl@0: // the name below is used to add a pointer to our construction method to a pointer MAP in sl@0: // the class factory sl@0: _LIT(KTestCaseId,"PBASE-USB_OTGDI-0463"); sl@0: const TTestCaseFactoryReceipt CTestCase0463::iFactoryReceipt(KTestCaseId); sl@0: sl@0: sl@0: CTestCase0463* CTestCase0463::NewL(TBool aHost) sl@0: { sl@0: LOG_FUNC sl@0: CTestCase0463* self = new (ELeave) CTestCase0463(aHost); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CTestCase0463::CTestCase0463(TBool aHost) sl@0: : CTestCaseRoot(KTestCaseId, aHost) sl@0: { sl@0: LOG_FUNC sl@0: } sl@0: sl@0: sl@0: /** sl@0: ConstructL sl@0: */ sl@0: void CTestCase0463::ConstructL() sl@0: { sl@0: LOG_FUNC sl@0: iRepeats = OOMOPEN_REPEATS; sl@0: iAllocFailNumber = OOMOPEN_REPEATS + 1; // allocs 1..11 fail sl@0: sl@0: BaseConstructL(); sl@0: } sl@0: sl@0: sl@0: CTestCase0463::~CTestCase0463() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: Cancel(); sl@0: } sl@0: sl@0: sl@0: void CTestCase0463::ExecuteTestCaseL() sl@0: { sl@0: LOG_FUNC sl@0: iCaseStep = EMarkStack; sl@0: CActiveScheduler::Add(this); sl@0: sl@0: SelfComplete(); sl@0: sl@0: } sl@0: sl@0: void CTestCase0463::DescribePreconditions() sl@0: { sl@0: test.Printf(_L("Insert A connector beforehand.\n")); sl@0: } sl@0: sl@0: sl@0: void CTestCase0463::DoCancel() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: // cancel our timer sl@0: iTimer.Cancel(); sl@0: } sl@0: sl@0: sl@0: // handle event completion sl@0: void CTestCase0463::RunStepL() sl@0: { sl@0: LOG_FUNC sl@0: sl@0: // Obtain the completion code for this CActive obj. sl@0: TInt completionCode(iStatus.Int()); sl@0: sl@0: switch(iCaseStep) sl@0: { sl@0: case EMarkStack: sl@0: SelfComplete(); sl@0: iCaseStep = ELoadLdd; sl@0: break; sl@0: sl@0: case ELoadLdd: sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, iAllocFailNumber); sl@0: __UHEAP_MARK; sl@0: test.Printf(_L("Load the LDD iteration %d/%d\n"), OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS); sl@0: aIntegerP = new TInt; sl@0: CleanupStack::PushL(aIntegerP); sl@0: if (!StepLoadLDD()) sl@0: { sl@0: break; sl@0: } sl@0: // panic if the cleanupstack was messed sl@0: CleanupStack::PopAndDestroy(aIntegerP); sl@0: sl@0: // SAMPLE : some code to test that the __HEAP macros did their stuff sl@0: // uncomment this to verify the test flow would fail sl@0: // { sl@0: // TInt *aInt = new TInt; sl@0: // if (NULL ==aInt) sl@0: // test.Printf(_L("Alloc failed!!!!!!\n")); sl@0: // delete aInt; sl@0: // } sl@0: iCaseStep = EUnloadLdd; sl@0: SelfComplete(); sl@0: break; sl@0: sl@0: case EUnloadLdd: sl@0: if (EFalse == StepUnloadLDD()) sl@0: return TestFailed(KErrAbort,_L("Unload Ldd failure")); sl@0: __UHEAP_MARKEND; sl@0: test.Printf(_L("Heap intact: Asize %d\n"), iAllocFailNumber); sl@0: iCaseStep = ELoopDecrement; sl@0: SelfComplete(); sl@0: break; sl@0: sl@0: case ELoopDecrement: sl@0: test.Printf(_L("Repeat test\n")); sl@0: __UHEAP_RESET; sl@0: iAllocFailNumber--; sl@0: sl@0: if (iRepeats--) sl@0: iCaseStep = ELoadLdd; sl@0: else sl@0: iCaseStep = ELastStep; sl@0: SelfComplete(); sl@0: break; sl@0: sl@0: case ELastStep: sl@0: sl@0: TestPolicy().SignalTestComplete(KErrNone); sl@0: break; sl@0: sl@0: default: sl@0: test.Printf(_L(" unknown test step")); sl@0: Cancel(); sl@0: TestPolicy().SignalTestComplete(KErrCorrupt); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: