kerneltest/e32test/usbho/t_otgdi/src/testcase0671.cpp
changeset 0 a41df078684a
child 253 d37db4dcc88d
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 "testcase0671.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-0671");
       
    33 const TTestCaseFactoryReceipt<CTestCase0671> CTestCase0671::iFactoryReceipt(KTestCaseId);	
       
    34 
       
    35 CTestCase0671* CTestCase0671::NewL(TBool aHost)
       
    36 	{
       
    37 	LOG_FUNC
       
    38 	CTestCase0671* self = new (ELeave) CTestCase0671(aHost);
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL();
       
    41 	CleanupStack::Pop(self);
       
    42 	return self;
       
    43 	}
       
    44 	
       
    45 
       
    46 CTestCase0671::CTestCase0671(TBool aHost)
       
    47 :	CTestCaseRoot(KTestCaseId, aHost)
       
    48 	{
       
    49 	LOG_FUNC
       
    50 		
       
    51 	} 
       
    52 
       
    53 
       
    54 /**
       
    55  ConstructL
       
    56 */
       
    57 void CTestCase0671::ConstructL()
       
    58 	{
       
    59 	iWDTimer = CTestCaseWatchdog::NewL();
       
    60 	
       
    61 	BaseConstructL();
       
    62 	}
       
    63 
       
    64 
       
    65 CTestCase0671::~CTestCase0671()
       
    66 	{
       
    67 
       
    68 	Cancel();
       
    69 	delete iWDTimer;	
       
    70 	}
       
    71 
       
    72 
       
    73 void CTestCase0671::ExecuteTestCaseL()
       
    74 	{
       
    75 	iCaseStep = EPreconditions;	
       
    76 	iRepeats = KOperationRetriesMax;	// VBus event rise retries
       
    77 	CActiveScheduler::Add(this);
       
    78 	SelfComplete();
       
    79 
       
    80 	}
       
    81 
       
    82 	
       
    83 void CTestCase0671::DoCancel()
       
    84 	{
       
    85 	LOG_FUNC
       
    86 
       
    87 	// cancel our timer
       
    88 	iTimer.Cancel();
       
    89 	}
       
    90 
       
    91 
       
    92 void CTestCase0671::CancelKB(CTestCaseRoot *pThis)
       
    93 	{
       
    94 	CTestCase0671 * p = REINTERPRET_CAST(CTestCase0671 *,pThis);
       
    95 	
       
    96 	// cancel the pending call
       
    97 	p->iConsole->ReadCancel();
       
    98 	}
       
    99 
       
   100 
       
   101 void CTestCase0671::CancelDrive(CTestCaseRoot *pThis)
       
   102 	{
       
   103 	CTestCase0671 * p = REINTERPRET_CAST(CTestCase0671 *,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 CTestCase0671::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 CTestCase0671::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(0x0671/*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 			test.Printf(_L("Connect H4(B) to OPT(A)\n"));
       
   160 			test.Printf(KPressAnyKeyToContinue);
       
   161 
       
   162 			iCaseStep = EStartOptTD5_5;
       
   163 			RequestCharacter();	
       
   164 			break;
       
   165 
       
   166 		case EStartOptTD5_5:
       
   167 			// H4 width     ****************************
       
   168 			test.Printf(_L("On the OPT, select:\n"));
       
   169 			test.Printf(_L("  Certified FS-B-UUT Test\n"));
       
   170 			test.Printf(_L("  Test TD.5.5\n"));
       
   171 			test.Printf(_L("  And then Click 'Run' "));
       
   172 			test.Printf(_L("  When test starts, press any key"));
       
   173 			iCaseStep = EPromptYOpt5_5;
       
   174 			RequestCharacter();	
       
   175 			break;
       
   176 
       
   177 		case EPromptYOpt5_5:
       
   178 			iCaseStep = EConfirmOpt5_5;
       
   179 			test.Printf(_L("Did it PASS (Y/N)?"));
       
   180 			RequestCharacter(); // 30 seconds for user input
       
   181 			iWDTimer->IssueRequest(KDelayDurationForTest4_5, this, &CancelKB);
       
   182 			break;
       
   183 
       
   184 		case EConfirmOpt5_5:
       
   185 			// Check watchdog timeout, assume it failed
       
   186 			if (KTestCaseWatchdogTO == iStatus.Int())
       
   187 				{
       
   188 									// H4 width  ****************************
       
   189 				return TestFailed(KErrAbort, _L("OPT timeout - Test Failed"));
       
   190 				}
       
   191 			iWDTimer->Cancel();
       
   192 
       
   193 			// Check user response, look only for 'Y'
       
   194 			if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
       
   195 				{
       
   196 				iCaseStep = EUnloadLdd;
       
   197 				SelfComplete();
       
   198 				}
       
   199 			else
       
   200 				{
       
   201 				return TestFailed(KErrAbort, _L("TD.5.5 - FAILED!"));
       
   202 				}
       
   203 			break;
       
   204 
       
   205 		case EUnloadLdd:
       
   206 			// unload otg
       
   207 			if (!StepUnloadLDD())
       
   208 				{
       
   209 				return TestFailed(KErrAbort,_L("OTG Unload Failure"));	
       
   210 				}
       
   211 			// unload client
       
   212 			if (!StepUnloadClient())
       
   213 				{
       
   214 				return TestFailed(KErrAbort,_L("Client Unload Failure"));	
       
   215 				}
       
   216 			iCaseStep = ELastStep;
       
   217 			SelfComplete();
       
   218 			break;
       
   219 
       
   220 		case ELastStep:
       
   221 			TestPassed();
       
   222 			break;
       
   223 			
       
   224 		default:
       
   225 			test.Printf(_L("<Error> unknown test step"));
       
   226 			Cancel();
       
   227 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
       
   228 		}
       
   229 	}
       
   230