os/kernelhwsrv/kerneltest/e32test/usbho/t_otgdi/src/testcase0670.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/testcase0670.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,231 @@
     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 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32std.h>
    1.22 +#include <e32std_private.h>
    1.23 +#include <u32std.h> 	// unicode builds
    1.24 +#include <e32base.h>
    1.25 +#include <e32base_private.h>
    1.26 +#include <e32Test.h>	// RTest headder
    1.27 +#include "testcaseroot.h"
    1.28 +#include "testcasewd.h"
    1.29 +#include "testcase0670.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-0670");
    1.36 +const TTestCaseFactoryReceipt<CTestCase0670> CTestCase0670::iFactoryReceipt(KTestCaseId);	
    1.37 +
    1.38 +CTestCase0670* CTestCase0670::NewL(TBool aHost)
    1.39 +	{
    1.40 +	LOG_FUNC
    1.41 +	CTestCase0670* self = new (ELeave) CTestCase0670(aHost);
    1.42 +	CleanupStack::PushL(self);
    1.43 +	self->ConstructL();
    1.44 +	CleanupStack::Pop(self);
    1.45 +	return self;
    1.46 +	}
    1.47 +	
    1.48 +
    1.49 +CTestCase0670::CTestCase0670(TBool aHost)
    1.50 +:	CTestCaseRoot(KTestCaseId, aHost)
    1.51 +	{
    1.52 +	LOG_FUNC
    1.53 +		
    1.54 +	} 
    1.55 +
    1.56 +
    1.57 +/**
    1.58 + ConstructL
    1.59 +*/
    1.60 +void CTestCase0670::ConstructL()
    1.61 +	{
    1.62 +	iWDTimer = CTestCaseWatchdog::NewL();
    1.63 +	
    1.64 +	BaseConstructL();
    1.65 +	}
    1.66 +
    1.67 +
    1.68 +CTestCase0670::~CTestCase0670()
    1.69 +	{
    1.70 +
    1.71 +	Cancel();
    1.72 +	delete iWDTimer;	
    1.73 +	}
    1.74 +
    1.75 +
    1.76 +void CTestCase0670::ExecuteTestCaseL()
    1.77 +	{
    1.78 +	iCaseStep = EPreconditions;	
    1.79 +	iRepeats = KOperationRetriesMax;	// VBus event rise retries
    1.80 +	CActiveScheduler::Add(this);
    1.81 +	SelfComplete();
    1.82 +
    1.83 +	}
    1.84 +
    1.85 +	
    1.86 +void CTestCase0670::DoCancel()
    1.87 +	{
    1.88 +	LOG_FUNC
    1.89 +
    1.90 +	// cancel our timer
    1.91 +	iTimer.Cancel();
    1.92 +	}
    1.93 +
    1.94 +
    1.95 +void CTestCase0670::CancelKB(CTestCaseRoot *pThis)
    1.96 +	{
    1.97 +	CTestCase0670 * p = REINTERPRET_CAST(CTestCase0670 *,pThis);
    1.98 +	
    1.99 +	// cancel the pending call
   1.100 +	p->iConsole->ReadCancel();
   1.101 +	}
   1.102 +
   1.103 +
   1.104 +void CTestCase0670::CancelDrive(CTestCaseRoot *pThis)
   1.105 +	{
   1.106 +	CTestCase0670 * p = REINTERPRET_CAST(CTestCase0670 *,pThis);
   1.107 +	// cancel any pending call, and then complete our active obj with a timeout value
   1.108 +	p->SelfComplete(KTestCaseWatchdogTO);	
   1.109 +	}
   1.110 +
   1.111 +
   1.112 +void CTestCase0670::DescribePreconditions()
   1.113 +	{
   1.114 +	// H4 width     ****************************
   1.115 +	test.Printf(_L("***************************\n"));
   1.116 +	test.Printf(_L("* This test uses a Mini-A *\n"));
   1.117 +	test.Printf(_L("* to Mini-B cable to link *\n"));
   1.118 +	test.Printf(_L("* the H4 board to the OPT *\n"));
   1.119 +	test.Printf(_L("* and makes use of the    *\n"));
   1.120 +	test.Printf(_L("*  USB OPT test code      *\n"));
   1.121 +	test.Printf(_L("***************************\n"));
   1.122 +	}
   1.123 +
   1.124 +
   1.125 +// handle event completion	
   1.126 +void CTestCase0670::RunStepL()
   1.127 +	{
   1.128 +	LOG_FUNC
   1.129 +	// Obtain the completion code for this CActive obj.
   1.130 +	TInt completionCode(iStatus.Int()); 
   1.131 +	TBuf<MAX_DSTRLEN> aDescription;
   1.132 +		
   1.133 +	switch(iCaseStep)
   1.134 +		{
   1.135 +		case EPreconditions:
   1.136 +			if (iAutomated)
   1.137 +				{
   1.138 +				return TestFailed(KErrAbort,_L("This Test Cannot Run in Automated Mode"));
   1.139 +				}
   1.140 +			SelfComplete();
   1.141 +			iCaseStep = ELoadWithOptTestMode;
   1.142 +			break;
   1.143 +
   1.144 +		case ELoadWithOptTestMode:
   1.145 +			if (!StepLoadClient(0x0670/*use default settings for SRP/HNP support*/))
   1.146 +				{
   1.147 +				return TestFailed(KErrAbort,_L("Client Load Failure"));
   1.148 +				}
   1.149 +			StepSetOptActive();
   1.150 +			if (!StepLoadLDD())
   1.151 +				{
   1.152 +				return TestFailed(KErrAbort,_L("OTG Load Failure"));
   1.153 +				}
   1.154 +			iCaseStep = EConnectAtoB;
   1.155 +			SelfComplete();
   1.156 +			break;
   1.157 +			
   1.158 +		case EConnectAtoB:
   1.159 +			// H4 width     ****************************
   1.160 +			test.Printf(_L("\n"));
   1.161 +			test.Printf(_L("***********************\n"));
   1.162 +//			WAIT_ON_KEYOP( "Connect H4(A) to OPT(B)\n");
   1.163 +			test.Printf(_L("Connect H4(A) to OPT(B)\n"));
   1.164 +			test.Printf(KPressAnyKeyToContinue);
   1.165 +
   1.166 +			iCaseStep = EStartOptTD4_5;
   1.167 +			RequestCharacter();	
   1.168 +			break;
   1.169 +
   1.170 +		case EStartOptTD4_5:
   1.171 +			// H4 width     ****************************
   1.172 +			test.Printf(_L("On the OPT, select:\n"));
   1.173 +			test.Printf(_L("  Certified FS-A-UUT Test\n"));
   1.174 +			test.Printf(_L("  Test TD.4.5-2.9ms-100ms\n"));
   1.175 +			test.Printf(_L("  And then Click 'Run' "));
   1.176 +			test.Printf(_L("  When test starts, press any key"));
   1.177 +			iCaseStep = EPromptYOpt4_5;
   1.178 +			RequestCharacter();	
   1.179 +			break;
   1.180 +
   1.181 +		case EPromptYOpt4_5:
   1.182 +			iCaseStep = EConfirmOpt4_5;
   1.183 +			test.Printf(_L("Did it PASS (Y/N)?"));
   1.184 +			RequestCharacter(); // 30 seconds for user input
   1.185 +			iWDTimer->IssueRequest(KDelayDurationForTest4_5, this, &CancelKB);
   1.186 +			break;
   1.187 +
   1.188 +		case EConfirmOpt4_5:
   1.189 +			// Check watchdog timeout, assume it failed
   1.190 +			if (KTestCaseWatchdogTO == iStatus.Int())
   1.191 +				{
   1.192 +									// H4 width  ****************************
   1.193 +				return TestFailed(KErrAbort, _L("OPT timeout - Test Failed"));
   1.194 +				}
   1.195 +			iWDTimer->Cancel();
   1.196 +
   1.197 +			// Check user response, look only for 'Y'
   1.198 +			if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
   1.199 +				{
   1.200 +				iCaseStep = EUnloadLdd;
   1.201 +				SelfComplete();
   1.202 +				}
   1.203 +			else
   1.204 +				{
   1.205 +				return TestFailed(KErrAbort, _L("TD.4.5 - FAILED!"));
   1.206 +				}
   1.207 +			break;
   1.208 +
   1.209 +		case EUnloadLdd:
   1.210 +			// unload otg
   1.211 +			if (!StepUnloadLDD())
   1.212 +				{
   1.213 +				return TestFailed(KErrAbort,_L("OTG Unload Failure"));	
   1.214 +				}
   1.215 +			// unload client
   1.216 +			if (!StepUnloadClient())
   1.217 +				{
   1.218 +				return TestFailed(KErrAbort,_L("Client Unload Failure"));	
   1.219 +				}
   1.220 +			iCaseStep = ELastStep;
   1.221 +			SelfComplete();
   1.222 +			break;
   1.223 +
   1.224 +		case ELastStep:
   1.225 +			TestPassed();
   1.226 +			break;
   1.227 +			
   1.228 +		default:
   1.229 +			test.Printf(_L("<Error> unknown test step"));
   1.230 +			Cancel();
   1.231 +			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   1.232 +		}
   1.233 +	}
   1.234 +