kerneltest/e32test/usbho/t_otgdi/src/testcase0670.cpp
changeset 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @internalComponent
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32std_private.h>
       
    20 #include <u32std.h> 	// unicode builds
       
    21 #include <e32base.h>
       
    22 #include <e32base_private.h>
       
    23 #include <e32Test.h>	// RTest headder
       
    24 #include "testcaseroot.h"
       
    25 #include "testcasewd.h"
       
    26 #include "testcase0670.h"
       
    27 
       
    28 
       
    29 
       
    30 // the name below is used to add a pointer to our construction method to a pointer MAP in 
       
    31 // the class factory
       
    32 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0670");
       
    33 const TTestCaseFactoryReceipt<CTestCase0670> CTestCase0670::iFactoryReceipt(KTestCaseId);	
       
    34 
       
    35 CTestCase0670* CTestCase0670::NewL(TBool aHost)
       
    36 	{
       
    37 	LOG_FUNC
       
    38 	CTestCase0670* self = new (ELeave) CTestCase0670(aHost);
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL();
       
    41 	CleanupStack::Pop(self);
       
    42 	return self;
       
    43 	}
       
    44 	
       
    45 
       
    46 CTestCase0670::CTestCase0670(TBool aHost)
       
    47 :	CTestCaseRoot(KTestCaseId, aHost)
       
    48 	{
       
    49 	LOG_FUNC
       
    50 		
       
    51 	} 
       
    52 
       
    53 
       
    54 /**
       
    55  ConstructL
       
    56 */
       
    57 void CTestCase0670::ConstructL()
       
    58 	{
       
    59 	iWDTimer = CTestCaseWatchdog::NewL();
       
    60 	
       
    61 	BaseConstructL();
       
    62 	}
       
    63 
       
    64 
       
    65 CTestCase0670::~CTestCase0670()
       
    66 	{
       
    67 
       
    68 	Cancel();
       
    69 	delete iWDTimer;	
       
    70 	}
       
    71 
       
    72 
       
    73 void CTestCase0670::ExecuteTestCaseL()
       
    74 	{
       
    75 	iCaseStep = EPreconditions;	
       
    76 	iRepeats = KOperationRetriesMax;	// VBus event rise retries
       
    77 	CActiveScheduler::Add(this);
       
    78 	SelfComplete();
       
    79 
       
    80 	}
       
    81 
       
    82 	
       
    83 void CTestCase0670::DoCancel()
       
    84 	{
       
    85 	LOG_FUNC
       
    86 
       
    87 	// cancel our timer
       
    88 	iTimer.Cancel();
       
    89 	}
       
    90 
       
    91 
       
    92 void CTestCase0670::CancelKB(CTestCaseRoot *pThis)
       
    93 	{
       
    94 	CTestCase0670 * p = REINTERPRET_CAST(CTestCase0670 *,pThis);
       
    95 	
       
    96 	// cancel the pending call
       
    97 	p->iConsole->ReadCancel();
       
    98 	}
       
    99 
       
   100 
       
   101 void CTestCase0670::CancelDrive(CTestCaseRoot *pThis)
       
   102 	{
       
   103 	CTestCase0670 * p = REINTERPRET_CAST(CTestCase0670 *,pThis);
       
   104 	// cancel any pending call, and then complete our active obj with a timeout value
       
   105 	p->SelfComplete(KTestCaseWatchdogTO);	
       
   106 	}
       
   107 
       
   108 
       
   109 void CTestCase0670::DescribePreconditions()
       
   110 	{
       
   111 	// H4 width     ****************************
       
   112 	test.Printf(_L("***************************\n"));
       
   113 	test.Printf(_L("* This test uses a Mini-A *\n"));
       
   114 	test.Printf(_L("* to Mini-B cable to link *\n"));
       
   115 	test.Printf(_L("* the H4 board to the OPT *\n"));
       
   116 	test.Printf(_L("* and makes use of the    *\n"));
       
   117 	test.Printf(_L("*  USB OPT test code      *\n"));
       
   118 	test.Printf(_L("***************************\n"));
       
   119 	}
       
   120 
       
   121 
       
   122 // handle event completion	
       
   123 void CTestCase0670::RunStepL()
       
   124 	{
       
   125 	LOG_FUNC
       
   126 	// Obtain the completion code for this CActive obj.
       
   127 	TInt completionCode(iStatus.Int()); 
       
   128 	TBuf<MAX_DSTRLEN> aDescription;
       
   129 		
       
   130 	switch(iCaseStep)
       
   131 		{
       
   132 		case EPreconditions:
       
   133 			if (iAutomated)
       
   134 				{
       
   135 				return TestFailed(KErrAbort,_L("This Test Cannot Run in Automated Mode"));
       
   136 				}
       
   137 			SelfComplete();
       
   138 			iCaseStep = ELoadWithOptTestMode;
       
   139 			break;
       
   140 
       
   141 		case ELoadWithOptTestMode:
       
   142 			if (!StepLoadClient(0x0670/*use default settings for SRP/HNP support*/))
       
   143 				{
       
   144 				return TestFailed(KErrAbort,_L("Client Load Failure"));
       
   145 				}
       
   146 			StepSetOptActive();
       
   147 			if (!StepLoadLDD())
       
   148 				{
       
   149 				return TestFailed(KErrAbort,_L("OTG Load Failure"));
       
   150 				}
       
   151 			iCaseStep = EConnectAtoB;
       
   152 			SelfComplete();
       
   153 			break;
       
   154 			
       
   155 		case EConnectAtoB:
       
   156 			// H4 width     ****************************
       
   157 			test.Printf(_L("\n"));
       
   158 			test.Printf(_L("***********************\n"));
       
   159 //			WAIT_ON_KEYOP( "Connect H4(A) to OPT(B)\n");
       
   160 			test.Printf(_L("Connect H4(A) to OPT(B)\n"));
       
   161 			test.Printf(KPressAnyKeyToContinue);
       
   162 
       
   163 			iCaseStep = EStartOptTD4_5;
       
   164 			RequestCharacter();	
       
   165 			break;
       
   166 
       
   167 		case EStartOptTD4_5:
       
   168 			// H4 width     ****************************
       
   169 			test.Printf(_L("On the OPT, select:\n"));
       
   170 			test.Printf(_L("  Certified FS-A-UUT Test\n"));
       
   171 			test.Printf(_L("  Test TD.4.5-2.9ms-100ms\n"));
       
   172 			test.Printf(_L("  And then Click 'Run' "));
       
   173 			test.Printf(_L("  When test starts, press any key"));
       
   174 			iCaseStep = EPromptYOpt4_5;
       
   175 			RequestCharacter();	
       
   176 			break;
       
   177 
       
   178 		case EPromptYOpt4_5:
       
   179 			iCaseStep = EConfirmOpt4_5;
       
   180 			test.Printf(_L("Did it PASS (Y/N)?"));
       
   181 			RequestCharacter(); // 30 seconds for user input
       
   182 			iWDTimer->IssueRequest(KDelayDurationForTest4_5, this, &CancelKB);
       
   183 			break;
       
   184 
       
   185 		case EConfirmOpt4_5:
       
   186 			// Check watchdog timeout, assume it failed
       
   187 			if (KTestCaseWatchdogTO == iStatus.Int())
       
   188 				{
       
   189 									// H4 width  ****************************
       
   190 				return TestFailed(KErrAbort, _L("OPT timeout - Test Failed"));
       
   191 				}
       
   192 			iWDTimer->Cancel();
       
   193 
       
   194 			// Check user response, look only for 'Y'
       
   195 			if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
       
   196 				{
       
   197 				iCaseStep = EUnloadLdd;
       
   198 				SelfComplete();
       
   199 				}
       
   200 			else
       
   201 				{
       
   202 				return TestFailed(KErrAbort, _L("TD.4.5 - FAILED!"));
       
   203 				}
       
   204 			break;
       
   205 
       
   206 		case EUnloadLdd:
       
   207 			// unload otg
       
   208 			if (!StepUnloadLDD())
       
   209 				{
       
   210 				return TestFailed(KErrAbort,_L("OTG Unload Failure"));	
       
   211 				}
       
   212 			// unload client
       
   213 			if (!StepUnloadClient())
       
   214 				{
       
   215 				return TestFailed(KErrAbort,_L("Client Unload Failure"));	
       
   216 				}
       
   217 			iCaseStep = ELastStep;
       
   218 			SelfComplete();
       
   219 			break;
       
   220 
       
   221 		case ELastStep:
       
   222 			TestPassed();
       
   223 			break;
       
   224 			
       
   225 		default:
       
   226 			test.Printf(_L("<Error> unknown test step"));
       
   227 			Cancel();
       
   228 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
       
   229 		}
       
   230 	}
       
   231