os/kernelhwsrv/kerneltest/e32test/usbho/t_otgdi/src/testcase0456.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usbho/t_otgdi/src/testcase0456.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,164 @@
     1.4 +// Copyright (c) 2007-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 the License "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 +// @internalComponent
    1.18 +// Open/Close 'A'
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +
    1.23 +#include <e32std.h>
    1.24 +#include <e32std_private.h>
    1.25 +#include <u32std.h> 	// unicode builds
    1.26 +#include <e32base.h>
    1.27 +#include <e32base_private.h>
    1.28 +#include <e32Test.h>	// RTest headder
    1.29 +#include "testcaseroot.h"
    1.30 +#include "testcasefactory.h"
    1.31 +#include "testcase0456.h"
    1.32 +
    1.33 +
    1.34 +
    1.35 +
    1.36 +// the name below is used to add a pointer to our construction method to a pointer MAP in 
    1.37 +// the class factory
    1.38 +_LIT(KTestCaseId,"PBASE-USB_OTGDI-0456");
    1.39 +const TTestCaseFactoryReceipt<CTestCase0456> CTestCase0456::iFactoryReceipt(KTestCaseId);	
    1.40 +
    1.41 +
    1.42 +CTestCase0456* CTestCase0456::NewL(TBool aHost)
    1.43 +	{
    1.44 +	LOG_FUNC
    1.45 +	CTestCase0456* self = new (ELeave) CTestCase0456(aHost);
    1.46 +	CleanupStack::PushL(self);
    1.47 +	self->ConstructL();
    1.48 +	CleanupStack::Pop(self);
    1.49 +	return self;
    1.50 +	}
    1.51 +	
    1.52 +
    1.53 +CTestCase0456::CTestCase0456(TBool aHost)
    1.54 +:	CTestCaseRoot(KTestCaseId, aHost)
    1.55 +	{	
    1.56 +	LOG_FUNC
    1.57 +	} 
    1.58 +
    1.59 +
    1.60 +/**
    1.61 + ConstructL
    1.62 +*/
    1.63 +void CTestCase0456::ConstructL()
    1.64 +	{
    1.65 +	LOG_FUNC
    1.66 +	iRepeats = OPEN_REPEATS;
    1.67 +	
    1.68 +	BaseConstructL();
    1.69 +	}
    1.70 +
    1.71 +
    1.72 +CTestCase0456::~CTestCase0456()
    1.73 +	{
    1.74 +	LOG_FUNC
    1.75 +
    1.76 +	Cancel();
    1.77 +	}
    1.78 +
    1.79 +
    1.80 +void CTestCase0456::ExecuteTestCaseL()
    1.81 +	{
    1.82 +	LOG_FUNC
    1.83 +	iCaseStep = EPreconditions;
    1.84 +	
    1.85 +	CActiveScheduler::Add(this);
    1.86 +	SelfComplete();
    1.87 +	}
    1.88 +
    1.89 +
    1.90 +void CTestCase0456::DescribePreconditions()
    1.91 +	{
    1.92 +	test.Printf(_L("Insert A connector beforehand.\n"));
    1.93 +	}
    1.94 +
    1.95 +	
    1.96 +void CTestCase0456::DoCancel()
    1.97 +	{
    1.98 +	LOG_FUNC
    1.99 +
   1.100 +	// cancel our timer
   1.101 +	iTimer.Cancel();
   1.102 +	}
   1.103 +
   1.104 +
   1.105 +// handle event completion	
   1.106 +void CTestCase0456::RunStepL()
   1.107 +	{
   1.108 +	LOG_FUNC
   1.109 +
   1.110 +	// Obtain the completion code for this CActive obj.
   1.111 +	TInt completionCode(iStatus.Int()); 
   1.112 +	
   1.113 +	switch(iCaseStep)
   1.114 +		{
   1.115 +		case EPreconditions:
   1.116 +			{
   1.117 +			test.Printf(KPressAnyKeyToStart);
   1.118 +			iCaseStep = ELoadLdd;
   1.119 +			RequestCharacter();			
   1.120 +			break;			
   1.121 +			}
   1.122 +			
   1.123 +		
   1.124 +		case ELoadLdd:
   1.125 +			test.Printf(_L("Load the LDD iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
   1.126 +			if (!StepLoadLDD())
   1.127 +				{
   1.128 +				break;
   1.129 +				}
   1.130 +
   1.131 +			iCaseStep = EUnloadLdd;
   1.132 +			SelfComplete();
   1.133 +			break;
   1.134 +		case EUnloadLdd:
   1.135 +			if (EFalse == StepUnloadLDD())
   1.136 +				return TestFailed(KErrAbort,_L("Unload Ldd failure"));	
   1.137 +			
   1.138 +			iCaseStep = ELoopDecrement;
   1.139 +			SelfComplete();			
   1.140 +			break;
   1.141 +						
   1.142 +		case ELoopDecrement:
   1.143 +			test.Printf(_L("Repeat test\n"));
   1.144 +
   1.145 +			if (--iRepeats)
   1.146 +				iCaseStep = ELoadLdd;
   1.147 +			else
   1.148 +				iCaseStep = ELastStep;
   1.149 +			SelfComplete();	
   1.150 +		    break;
   1.151 +		  
   1.152 +		// Finnished    
   1.153 +		case ELastStep:
   1.154 +			// PASS
   1.155 +			return TestPassed();
   1.156 +
   1.157 +			
   1.158 +		default:
   1.159 +			test.Printf(_L("<Error> unknown test step"));
   1.160 +			Cancel();
   1.161 +			TestPolicy().SignalTestComplete(KErrCorrupt);
   1.162 +			break;
   1.163 +		}
   1.164 +		
   1.165 +	}
   1.166 +
   1.167 +