1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usbho/t_otgdi/src/testcase0464.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,188 @@
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 "testcase0464.h"
1.29 +
1.30 +
1.31 +
1.32 +// the name below is used to add a pointer to our construction method to a pointer MAP in
1.33 +// the class factory
1.34 +_LIT(KTestCaseId,"PBASE-USB_OTGDI-0464");
1.35 +const TTestCaseFactoryReceipt<CTestCase0464> CTestCase0464::iFactoryReceipt(KTestCaseId);
1.36 +
1.37 +CTestCase0464* CTestCase0464::NewL(TBool aHost)
1.38 + {
1.39 + LOG_FUNC
1.40 + CTestCase0464* self = new (ELeave) CTestCase0464(aHost);
1.41 + CleanupStack::PushL(self);
1.42 + self->ConstructL();
1.43 + CleanupStack::Pop(self);
1.44 + return self;
1.45 + }
1.46 +
1.47 +
1.48 +CTestCase0464::CTestCase0464(TBool aHost)
1.49 +: CTestCaseRoot(KTestCaseId, aHost)
1.50 + {
1.51 + LOG_FUNC
1.52 +
1.53 + }
1.54 +
1.55 +
1.56 +/**
1.57 + ConstructL
1.58 +*/
1.59 +void CTestCase0464::ConstructL()
1.60 + {
1.61 + LOG_FUNC
1.62 +
1.63 + BaseConstructL();
1.64 + }
1.65 +
1.66 +
1.67 +CTestCase0464::~CTestCase0464()
1.68 + {
1.69 + LOG_FUNC
1.70 +
1.71 + Cancel();
1.72 + }
1.73 +
1.74 +
1.75 +void CTestCase0464::ExecuteTestCaseL()
1.76 + {
1.77 + LOG_FUNC
1.78 + iCaseStep = EPreconditions;
1.79 +
1.80 + CActiveScheduler::Add(this);
1.81 + SelfComplete();
1.82 + }
1.83 +
1.84 +
1.85 +void CTestCase0464::DescribePreconditions()
1.86 + {
1.87 + test.Printf(_L("Insert 'A' connector beforehand.\n"));
1.88 + }
1.89 +
1.90 +
1.91 +void CTestCase0464::DoCancel()
1.92 + {
1.93 + LOG_FUNC
1.94 +
1.95 + // cancel our timer
1.96 + iTimer.Cancel();
1.97 + }
1.98 +
1.99 +
1.100 +void CTestCase0464::CancelKB(CTestCaseRoot *pThis)
1.101 + {
1.102 + CTestCase0464 * p = REINTERPRET_CAST(CTestCase0464 *,pThis);
1.103 + // cancel any pending call, and then complete our active obj with a timeout value
1.104 +
1.105 + p->iConsole->ReadCancel();
1.106 +
1.107 + }
1.108 +
1.109 +
1.110 +// handle event completion
1.111 +void CTestCase0464::RunStepL()
1.112 + {
1.113 + LOG_FUNC
1.114 + // Obtain the completion code for this CActive obj.
1.115 + TInt completionCode(iStatus.Int());
1.116 + TBuf<MAX_DSTRLEN> aDescription;
1.117 + TInt err(0);
1.118 +
1.119 + switch(iCaseStep)
1.120 + {
1.121 + case EPreconditions:
1.122 + iCaseStep = ELoadLdd;
1.123 + if (iAutomated)
1.124 + {
1.125 + iCaseStep = ELoadLdd;
1.126 + SelfComplete();
1.127 + break;
1.128 + }
1.129 + // prompt to insert 'A' connector
1.130 + test.Printf(KInsertAConnectorPrompt);
1.131 + test.Printf(KPressAnyKeyToContinue);
1.132 + RequestCharacter();
1.133 + break;
1.134 +
1.135 + case ELoadLdd:
1.136 + if (!StepLoadLDD())
1.137 + {
1.138 + break;
1.139 + }
1.140 +
1.141 + iCaseStep = EDriveBus;
1.142 + SelfComplete();
1.143 + break;
1.144 +
1.145 + case EDriveBus:
1.146 + LOG_VERBOSE1(_L("Turn ON VBus\n"))
1.147 + err = otgBusRequest();
1.148 + if (KErrNone != err)
1.149 + {
1.150 + return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!"));
1.151 + }
1.152 + iCaseStep = EUnloadLdd;
1.153 + SelfComplete();
1.154 + break;
1.155 +
1.156 + case EUnloadLdd:
1.157 + LOG_VERBOSE1(_L("Unload.\n"))
1.158 + if (EFalse == StepUnloadLDD())
1.159 + return TestFailed(KErrAbort,_L("unload Ldd failure"));
1.160 + test.Printf(_L("Measure VBus =0 and then press Y or N to continue."));
1.161 + RequestCharacter();
1.162 + iCaseStep = EVerifyVBusGone;
1.163 + break;
1.164 +
1.165 + case EVerifyVBusGone:
1.166 + LOG_VERBOSE1(_L("Test !VBus after unload.\n"))
1.167 + // test key response (or via an API)
1.168 + if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
1.169 + {
1.170 + test.Printf(_L("VBUS drop 'seen' \n"));
1.171 + SelfComplete();
1.172 + }
1.173 + else
1.174 + {
1.175 + return TestFailed(KErrAbort, _L("VBus drop not 'seen' - FAILED!"));
1.176 + }
1.177 + iCaseStep = ELastStep;
1.178 + break;
1.179 +
1.180 + case ELastStep:
1.181 + return TestPassed();
1.182 +
1.183 + default:
1.184 + test.Printf(_L("<Error> unknown test step"));
1.185 + Cancel();
1.186 + return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
1.187 +
1.188 + }
1.189 + }
1.190 +
1.191 +