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