kerneltest/e32test/usbho/t_otgdi/src/testcase0460.cpp
changeset 253 d37db4dcc88d
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
252:0a40b8675b23 253:d37db4dcc88d
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 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".
    23 #include <e32base_private.h>
    23 #include <e32base_private.h>
    24 #include <e32Test.h>	// RTest headder
    24 #include <e32Test.h>	// RTest headder
    25 #include "testcaseroot.h"
    25 #include "testcaseroot.h"
    26 #include "testcasefactory.h"
    26 #include "testcasefactory.h"
    27 #include "testcase0460.h"
    27 #include "testcase0460.h"
       
    28 #include "OstTraceDefinitions.h"
       
    29 #ifdef OST_TRACE_COMPILER_IN_USE
       
    30 #include "testcase0460Traces.h"
       
    31 #endif
    28 
    32 
    29 
    33 
    30 
    34 
    31 
    35 
    32 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    36 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    34 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0460");
    38 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0460");
    35 const TTestCaseFactoryReceipt<CTestCase0460> CTestCase0460::iFactoryReceipt(KTestCaseId);	
    39 const TTestCaseFactoryReceipt<CTestCase0460> CTestCase0460::iFactoryReceipt(KTestCaseId);	
    36 
    40 
    37 CTestCase0460* CTestCase0460::NewL(TBool aHost)
    41 CTestCase0460* CTestCase0460::NewL(TBool aHost)
    38 	{
    42 	{
    39 	LOG_FUNC
    43 	if(gVerboseOutput)
       
    44 	    {
       
    45 	    OstTraceFunctionEntry0(CTESTCASE0460_NEWL);
       
    46 	    }
    40 	CTestCase0460* self = new (ELeave) CTestCase0460(aHost);
    47 	CTestCase0460* self = new (ELeave) CTestCase0460(aHost);
    41 	CleanupStack::PushL(self);
    48 	CleanupStack::PushL(self);
    42 	self->ConstructL();
    49 	self->ConstructL();
    43 	CleanupStack::Pop(self);
    50 	CleanupStack::Pop(self);
    44 	return self;
    51 	return self;
    46 	
    53 	
    47 
    54 
    48 CTestCase0460::CTestCase0460(TBool aHost)
    55 CTestCase0460::CTestCase0460(TBool aHost)
    49 :	CTestCaseRoot(KTestCaseId, aHost)
    56 :	CTestCaseRoot(KTestCaseId, aHost)
    50 	{
    57 	{
    51 	LOG_FUNC
    58 	if(gVerboseOutput)
       
    59 	    {
       
    60 	    OstTraceFunctionEntry0(CTESTCASE0460_CTESTCASE0460);
       
    61 	    }
    52 		
    62 		
    53 	} 
    63 	} 
    54 
    64 
    55 
    65 
    56 /**
    66 /**
    57  ConstructL
    67  ConstructL
    58 */
    68 */
    59 void CTestCase0460::ConstructL()
    69 void CTestCase0460::ConstructL()
    60 	{
    70 	{
    61 	LOG_FUNC
    71 	if(gVerboseOutput)
       
    72 	    {
       
    73 	    OstTraceFunctionEntry0(CTESTCASE0460_CONSTRUCTL);
       
    74 	    }
    62 	
    75 	
    63 	BaseConstructL();
    76 	BaseConstructL();
    64 	}
    77 	}
    65 
    78 
    66 
    79 
    67 CTestCase0460::~CTestCase0460()
    80 CTestCase0460::~CTestCase0460()
    68 	{
    81 	{
    69 	LOG_FUNC
    82 	if(gVerboseOutput)
       
    83 	    {
       
    84 	    OstTraceFunctionEntry0(CTESTCASE0460_DCTESTCASE0460);
       
    85 	    }
    70 
    86 
    71 	Cancel();
    87 	Cancel();
    72 	}
    88 	}
    73 
    89 
    74 
    90 
    75 void CTestCase0460::ExecuteTestCaseL()
    91 void CTestCase0460::ExecuteTestCaseL()
    76 	{
    92 	{
    77 	LOG_FUNC
    93 	if(gVerboseOutput)
       
    94 	    {
       
    95 	    OstTraceFunctionEntry0(CTESTCASE0460_EXECUTETESTCASEL);
       
    96 	    }
    78 	iCaseStep = EPreconditions;
    97 	iCaseStep = EPreconditions;
    79 	
    98 	
    80 	CActiveScheduler::Add(this);
    99 	CActiveScheduler::Add(this);
    81 	SelfComplete();
   100 	SelfComplete();
    82 
   101 
    84 
   103 
    85 
   104 
    86 void CTestCase0460::DescribePreconditions()
   105 void CTestCase0460::DescribePreconditions()
    87 	{
   106 	{
    88 	test.Printf(_L("Insert 'A' connector beforehand.\n"));
   107 	test.Printf(_L("Insert 'A' connector beforehand.\n"));
       
   108 	OstTrace0(TRACE_NORMAL, CTESTCASE0460_DESCRIBEPRECONDITIONS, "Insert 'A' connector beforehand.\n");
    89 	}
   109 	}
    90 
   110 
    91 	
   111 	
    92 void CTestCase0460::DoCancel()
   112 void CTestCase0460::DoCancel()
    93 	{
   113 	{
    94 	LOG_FUNC
   114 	if(gVerboseOutput)
       
   115 	    {
       
   116 	    OstTraceFunctionEntry0(CTESTCASE0460_DOCANCEL);
       
   117 	    }
    95 
   118 
    96 	// cancel our timer
   119 	// cancel our timer
    97 	iTimer.Cancel();
   120 	iTimer.Cancel();
    98 	}
   121 	}
    99 	
   122 	
   100 
   123 
   101 // handle event completion	
   124 // handle event completion	
   102 void CTestCase0460::RunStepL()
   125 void CTestCase0460::RunStepL()
   103 	{
   126 	{
   104 	LOG_FUNC
   127 	if(gVerboseOutput)
       
   128 	    {
       
   129 	    OstTraceFunctionEntry0(CTESTCASE0460_RUNSTEPL);
       
   130 	    }
   105 	// Obtain the completion code for this CActive obj.
   131 	// Obtain the completion code for this CActive obj.
   106 	TInt completionCode(iStatus.Int()); 
   132 	TInt completionCode(iStatus.Int()); 
   107 	TBuf<MAX_DSTRLEN> aDescription;
   133 	TBuf<MAX_DSTRLEN> aDescription;
   108 		
   134 		
   109 	switch(iCaseStep)
   135 	switch(iCaseStep)
   116 				SelfComplete();
   142 				SelfComplete();
   117 				break;
   143 				break;
   118 				}
   144 				}
   119 			// prompt to remove connector
   145 			// prompt to remove connector
   120 			test.Printf(KRemoveAConnectorPrompt);
   146 			test.Printf(KRemoveAConnectorPrompt);
       
   147 			OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP01, KRemoveAConnectorPrompt);
   121 			test.Printf(KPressAnyKeyToContinue);
   148 			test.Printf(KPressAnyKeyToContinue);
       
   149 			OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP02, KPressAnyKeyToContinue);
   122 			RequestCharacter();			
   150 			RequestCharacter();			
   123 			break;
   151 			break;
   124 			
   152 			
   125 		case ELoadLdd:
   153 		case ELoadLdd:
   126 			if (!StepLoadLDD())
   154 			if (!StepLoadLDD())
   131 			iCaseStep = ERegisterForEvents;
   159 			iCaseStep = ERegisterForEvents;
   132 			iDequeAttempts = 0;	
   160 			iDequeAttempts = 0;	
   133 
   161 
   134 			// prompt to insert connector
   162 			// prompt to insert connector
   135 			test.Printf(KInsertAConnectorPrompt);
   163 			test.Printf(KInsertAConnectorPrompt);
       
   164 			OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP03, KInsertAConnectorPrompt);
   136 			test.Printf(KPressAnyKeyToContinue);
   165 			test.Printf(KPressAnyKeyToContinue);
       
   166 			OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP04, KPressAnyKeyToContinue);
   137 			RequestCharacter();			
   167 			RequestCharacter();			
   138 			break;
   168 			break;
   139 			// wait on ID_PIN
   169 			// wait on ID_PIN
   140 		case ERegisterForEvents:
   170 		case ERegisterForEvents:
   141 			if (iDequeAttempts > KOperationRetriesMax)
   171 			if (iDequeAttempts > KOperationRetriesMax)
   143 				return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events")));
   173 				return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events")));
   144 				}
   174 				}
   145 			iCaseStep = ETestStateA;
   175 			iCaseStep = ETestStateA;
   146 
   176 
   147 			test.Printf(_L("Waiting for OTG Event\n"));
   177 			test.Printf(_L("Waiting for OTG Event\n"));
       
   178 			OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP05, "Waiting for OTG Event\n");
   148 			otgQueueOtgEventRequest( iOTGEvent, iStatus);
   179 			otgQueueOtgEventRequest( iOTGEvent, iStatus);
   149 
   180 
   150 			SetActive();
   181 			SetActive();
   151 			break;
   182 			break;
   152 			
   183 			
   158 			
   189 			
   159 		case EWait5:
   190 		case EWait5:
   160 		case ETestStateA:
   191 		case ETestStateA:
   161 			OtgEventString(iOTGEvent, aDescription);
   192 			OtgEventString(iOTGEvent, aDescription);
   162 			test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode);
   193 			test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode);
       
   194 			OstTraceExt3(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP06, "Received event %d '%S' status(%d)", iOTGEvent, aDescription, completionCode);
   163 			if (RUsbOtgDriver::EEventAPlugInserted == iOTGEvent)
   195 			if (RUsbOtgDriver::EEventAPlugInserted == iOTGEvent)
   164 				{
   196 				{
   165 				iCaseStep = EUnloadLdd;
   197 				iCaseStep = EUnloadLdd;
   166 				}
   198 				}
   167 			else
   199 			else
   181 			
   213 			
   182 			return TestPassed();
   214 			return TestPassed();
   183 
   215 
   184 		default:
   216 		default:
   185 			test.Printf(_L("<Error> unknown test step"));
   217 			test.Printf(_L("<Error> unknown test step"));
       
   218 			OstTrace0(TRACE_NORMAL, CTESTCASE0460_RUNSTEPL_DUP07, "<Error> unknown test step");
   186 			Cancel();
   219 			Cancel();
   187 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   220 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   188 
   221 
   189 		}
   222 		}
   190 	}
   223 	}