kerneltest/e32test/usbho/t_otgdi/src/testcase0676.cpp
branchRCL_3
changeset 257 3e88ff8f41d5
parent 256 c1f20ce4abcf
equal deleted inserted replaced
256:c1f20ce4abcf 257:3e88ff8f41d5
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 #include <e32base_private.h>
    22 #include <e32base_private.h>
    23 #include <e32Test.h>	// RTest headder
    23 #include <e32Test.h>	// RTest headder
    24 #include "testcaseroot.h"
    24 #include "testcaseroot.h"
    25 #include "testcasewd.h"
    25 #include "testcasewd.h"
    26 #include "testcase0676.h"
    26 #include "testcase0676.h"
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "testcase0676Traces.h"
       
    30 #endif
       
    31 
    27 
    32 #define _REPEATS (oOpenIterations*3)
    28 #define _REPEATS (oOpenIterations*3)
    33 
    29 
    34 
    30 
    35 
    31 
    38 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0676");
    34 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0676");
    39 const TTestCaseFactoryReceipt<CTestCase0676> CTestCase0676::iFactoryReceipt(KTestCaseId);	
    35 const TTestCaseFactoryReceipt<CTestCase0676> CTestCase0676::iFactoryReceipt(KTestCaseId);	
    40 
    36 
    41 CTestCase0676* CTestCase0676::NewL(TBool aHost)
    37 CTestCase0676* CTestCase0676::NewL(TBool aHost)
    42 	{
    38 	{
    43 	if(gVerboseOutput)
    39 	LOG_FUNC
    44 	    {
       
    45 	    OstTraceFunctionEntry0(CTESTCASE0676_NEWL);
       
    46 	    }
       
    47 	CTestCase0676* self = new (ELeave) CTestCase0676(aHost);
    40 	CTestCase0676* self = new (ELeave) CTestCase0676(aHost);
    48 	CleanupStack::PushL(self);
    41 	CleanupStack::PushL(self);
    49 	self->ConstructL();
    42 	self->ConstructL();
    50 	CleanupStack::Pop(self);
    43 	CleanupStack::Pop(self);
    51 	return self;
    44 	return self;
    53 	
    46 	
    54 
    47 
    55 CTestCase0676::CTestCase0676(TBool aHost)
    48 CTestCase0676::CTestCase0676(TBool aHost)
    56 :	CTestCaseRoot(KTestCaseId, aHost)
    49 :	CTestCaseRoot(KTestCaseId, aHost)
    57 	{
    50 	{
    58 	if(gVerboseOutput)
    51 	LOG_FUNC
    59 	    {
       
    60 	    OstTraceFunctionEntry0(CTESTCASE0676_CTESTCASE0676);
       
    61 	    }
       
    62 		
    52 		
    63 	} 
    53 	} 
    64 
    54 
    65 
    55 
    66 /**
    56 /**
    67  ConstructL
    57  ConstructL
    68 */
    58 */
    69 void CTestCase0676::ConstructL()
    59 void CTestCase0676::ConstructL()
    70 	{
    60 	{
    71 	if(gVerboseOutput)
    61 	LOG_FUNC
    72 	    {
       
    73 	    OstTraceFunctionEntry0(CTESTCASE0676_CONSTRUCTL);
       
    74 	    }
       
    75 	iWDTimer = CTestCaseWatchdog::NewL();
    62 	iWDTimer = CTestCaseWatchdog::NewL();
    76 	iRepeats = OPEN_REPEATS;
    63 	iRepeats = OPEN_REPEATS;
    77 		
    64 		
    78 	BaseConstructL();
    65 	BaseConstructL();
    79 	}
    66 	}
    80 
    67 
    81 
    68 
    82 CTestCase0676::~CTestCase0676()
    69 CTestCase0676::~CTestCase0676()
    83 	{
    70 	{
    84 	if(gVerboseOutput)
    71 	LOG_FUNC
    85 	    {
       
    86 	    OstTraceFunctionEntry0(CTESTCASE0676_DCTESTCASE0676);
       
    87 	    }
       
    88 
    72 
    89 	Cancel();
    73 	Cancel();
    90 	delete iWDTimer;
    74 	delete iWDTimer;
    91 	
    75 	
    92 	}
    76 	}
    93 
    77 
    94 
    78 
    95 void CTestCase0676::ExecuteTestCaseL()
    79 void CTestCase0676::ExecuteTestCaseL()
    96 	{
    80 	{
    97 	if(gVerboseOutput)
    81 	LOG_FUNC
    98 	    {
       
    99 	    OstTraceFunctionEntry0(CTESTCASE0676_EXECUTETESTCASEL);
       
   100 	    }
       
   101 	iCaseStep = EPreconditions;
    82 	iCaseStep = EPreconditions;
   102 	
    83 	
   103 	iRepeats = KOperationRetriesMax;	// VBus event rise retries
    84 	iRepeats = KOperationRetriesMax;	// VBus event rise retries
   104 	
    85 	
   105 	CActiveScheduler::Add(this);
    86 	CActiveScheduler::Add(this);
   108 	}
    89 	}
   109 
    90 
   110 	
    91 	
   111 void CTestCase0676::DoCancel()
    92 void CTestCase0676::DoCancel()
   112 	{
    93 	{
   113 	if(gVerboseOutput)
    94 	LOG_FUNC
   114 	    {
       
   115 	    OstTraceFunctionEntry0(CTESTCASE0676_DOCANCEL);
       
   116 	    }
       
   117 
    95 
   118 	// cancel our timer
    96 	// cancel our timer
   119 	iTimer.Cancel();
    97 	iTimer.Cancel();
   120 	}
    98 	}
   121 
    99 
   122 
   100 
   123 void CTestCase0676::CancelKB(CTestCaseRoot *pThis)
   101 void CTestCase0676::CancelKB(CTestCaseRoot *pThis)
   124 	{
   102 	{
   125 	if(gVerboseOutput)
   103 	LOG_FUNC
   126 	    {
       
   127 	    OstTraceFunctionEntry0(CTESTCASE0676_CANCELKB);
       
   128 	    }
       
   129 	CTestCase0676 * p = REINTERPRET_CAST(CTestCase0676 *,pThis);
   104 	CTestCase0676 * p = REINTERPRET_CAST(CTestCase0676 *,pThis);
   130 	// cancel any pending call, and then complete our active obj with a cancel value
   105 	// cancel any pending call, and then complete our active obj with a cancel value
   131 	p->iConsole->ReadCancel();
   106 	p->iConsole->ReadCancel();
   132 
   107 
   133 	}
   108 	}
   134 
   109 
   135 
   110 
   136 void CTestCase0676::CancelNotify(CTestCaseRoot *pThis)
   111 void CTestCase0676::CancelNotify(CTestCaseRoot *pThis)
   137 	{
   112 	{
   138 	if(gVerboseOutput)
   113 	LOG_FUNC
   139 	    {
       
   140 	    OstTraceFunctionEntry0(CTESTCASE0676_CANCELNOTIFY);
       
   141 	    }
       
   142 	CTestCase0676 * p = REINTERPRET_CAST(CTestCase0676 *,pThis);
   114 	CTestCase0676 * p = REINTERPRET_CAST(CTestCase0676 *,pThis);
   143 	// cancel any pending call, and then complete our active obj with a timeout value
   115 	// cancel any pending call, and then complete our active obj with a timeout value
   144 	p->otgCancelOtgVbusNotification();
   116 	p->otgCancelOtgVbusNotification();
   145 	p->SelfComplete(KTestCaseWatchdogTO);
   117 	p->SelfComplete(KTestCaseWatchdogTO);
   146 	}
   118 	}
   148 
   120 
   149 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed
   121 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed
   150 void CTestCase0676::DescribePreconditions()
   122 void CTestCase0676::DescribePreconditions()
   151 	{
   123 	{
   152 	test.Printf(_L("Insert 'A' connector beforehand.\n"));
   124 	test.Printf(_L("Insert 'A' connector beforehand.\n"));
   153 	OstTrace0(TRACE_NORMAL, CTESTCASE0676_DESCRIBEPRECONDITIONS, "Insert 'A' connector beforehand.\n");
       
   154 	}
   125 	}
   155 
   126 
   156 void CTestCase0676::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep)
   127 void CTestCase0676::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep)
   157 	{
   128 	{
   158 	LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000));
   129 	LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000));
   159 	if(gVerboseOutput)
       
   160 	    {
       
   161 	    OstTrace1(TRACE_VERBOSE, CTESTCASE0676_CONTINUEAFTER, "Wait %dms before drop VBus", (TInt)(aMicroSecs.Int()/1000));;
       
   162 	    }
       
   163 	iTimer.After(iStatus, aMicroSecs);
   130 	iTimer.After(iStatus, aMicroSecs);
   164 	iCaseStep = aStep;
   131 	iCaseStep = aStep;
   165 	SetActive();
   132 	SetActive();
   166 	}
   133 	}
   167 
   134 
   168 // handle event completion	
   135 // handle event completion	
   169 void CTestCase0676::RunStepL()
   136 void CTestCase0676::RunStepL()
   170 	{
   137 	{
   171 	if(gVerboseOutput)
   138 	LOG_FUNC
   172 	    {
       
   173 	    OstTraceFunctionEntry0(CTESTCASE0676_RUNSTEPL);
       
   174 	    }
       
   175 	// Obtain the completion code for this CActive obj.
   139 	// Obtain the completion code for this CActive obj.
   176 	TInt completionCode(iStatus.Int()); 
   140 	TInt completionCode(iStatus.Int()); 
   177 	TBuf<MAX_DSTRLEN> aDescription;
   141 	TBuf<MAX_DSTRLEN> aDescription;
   178 	TInt err(0);
   142 	TInt err(0);
   179 
   143 
   188 				SelfComplete();
   152 				SelfComplete();
   189 				break;
   153 				break;
   190 				}
   154 				}
   191 			// prompt to insert connector
   155 			// prompt to insert connector
   192 			test.Printf(KInsertAConnectorPrompt);
   156 			test.Printf(KInsertAConnectorPrompt);
   193 			OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP01, KInsertAConnectorPrompt);
       
   194 			test.Printf(KPressAnyKeyToContinue);
   157 			test.Printf(KPressAnyKeyToContinue);
   195 			OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP02, KPressAnyKeyToContinue);
       
   196 			RequestCharacter();			
   158 			RequestCharacter();			
   197 			break;
   159 			break;
   198 			
   160 			
   199 		case ELoadLdd:
   161 		case ELoadLdd:
   200 			// 1. load the LDD and init.
   162 			// 1. load the LDD and init.
   216 			// if doing this test in /AUTO mode, we would fail this now
   178 			// if doing this test in /AUTO mode, we would fail this now
   217 			// however if we can control ID_PIN through an API in future, we turn in on now.
   179 			// however if we can control ID_PIN through an API in future, we turn in on now.
   218 			if (!otgIdPinPresent())
   180 			if (!otgIdPinPresent())
   219 				{
   181 				{
   220 				test.Printf(KInsertAConnectorPrompt);
   182 				test.Printf(KInsertAConnectorPrompt);
   221 				OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP03, KInsertAConnectorPrompt);
       
   222 				test.Printf(KPressAnyKeyToContinue);
   183 				test.Printf(KPressAnyKeyToContinue);
   223 				OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP04, KPressAnyKeyToContinue);
       
   224 				RequestCharacter();
   184 				RequestCharacter();
   225 
   185 
   226 				iCaseStep = EDetectAPlug;
   186 				iCaseStep = EDetectAPlug;
   227 				}
   187 				}
   228 			else
   188 			else
   247 			
   207 			
   248 		case ELoopDriveVBus:
   208 		case ELoopDriveVBus:
   249 			// 4. DRIVE VBUS
   209 			// 4. DRIVE VBUS
   250 			iWDTimer->Cancel();
   210 			iWDTimer->Cancel();
   251 			test.Printf(_L("Drive VBus, iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
   211 			test.Printf(_L("Drive VBus, iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
   252 			OstTraceExt2(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP05, "Drive VBus, iteration %d/%d\n", OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
       
   253 			// test for VBus rise next
   212 			// test for VBus rise next
   254 			test.Printf(_L("Waiting for VBus Event\n"));
   213 			test.Printf(_L("Waiting for VBus Event\n"));
   255 			OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP06, "Waiting for VBus Event\n");
       
   256 			iStatus = KRequestPending;
   214 			iStatus = KRequestPending;
   257 			otgQueueOtgVbusNotification( iOTGVBus, iStatus );
   215 			otgQueueOtgVbusNotification( iOTGVBus, iStatus );
   258 
   216 
   259 			// turn on VBus, since the call is not a Queing a-sync call we do this after the async call
   217 			// turn on VBus, since the call is not a Queing a-sync call we do this after the async call
   260 			err = otgBusRequest();	// ok to turn on VBus now
   218 			err = otgBusRequest();	// ok to turn on VBus now
   351 			TestPassed();
   309 			TestPassed();
   352 			break;
   310 			break;
   353 			
   311 			
   354 		default:
   312 		default:
   355 			test.Printf(_L("<Error> unknown test step"));
   313 			test.Printf(_L("<Error> unknown test step"));
   356 			OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP07, "<Error> unknown test step");
       
   357 			Cancel();
   314 			Cancel();
   358 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   315 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   359 		}
   316 		}
   360 	}
   317 	}
   361 
   318