kerneltest/e32test/usbho/t_otgdi/src/testcase0464.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".
    21 #include <e32base.h>
    21 #include <e32base.h>
    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 "testcase0464.h"
    25 #include "testcase0464.h"
    26 #include "OstTraceDefinitions.h"
       
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "testcase0464Traces.h"
       
    29 #endif
       
    30 
    26 
    31 
    27 
    32 
    28 
    33 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    29 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    34 // the class factory
    30 // the class factory
    35 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0464");
    31 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0464");
    36 const TTestCaseFactoryReceipt<CTestCase0464> CTestCase0464::iFactoryReceipt(KTestCaseId);	
    32 const TTestCaseFactoryReceipt<CTestCase0464> CTestCase0464::iFactoryReceipt(KTestCaseId);	
    37 
    33 
    38 CTestCase0464* CTestCase0464::NewL(TBool aHost)
    34 CTestCase0464* CTestCase0464::NewL(TBool aHost)
    39 	{
    35 	{
    40 	if(gVerboseOutput)
    36 	LOG_FUNC
    41 	    {
       
    42 	    OstTraceFunctionEntry0(CTESTCASE0464_NEWL);
       
    43 	    }
       
    44 	CTestCase0464* self = new (ELeave) CTestCase0464(aHost);
    37 	CTestCase0464* self = new (ELeave) CTestCase0464(aHost);
    45 	CleanupStack::PushL(self);
    38 	CleanupStack::PushL(self);
    46 	self->ConstructL();
    39 	self->ConstructL();
    47 	CleanupStack::Pop(self);
    40 	CleanupStack::Pop(self);
    48 	return self;
    41 	return self;
    50 	
    43 	
    51 
    44 
    52 CTestCase0464::CTestCase0464(TBool aHost)
    45 CTestCase0464::CTestCase0464(TBool aHost)
    53 :	CTestCaseRoot(KTestCaseId, aHost)
    46 :	CTestCaseRoot(KTestCaseId, aHost)
    54 	{
    47 	{
    55 	if(gVerboseOutput)
    48 	LOG_FUNC
    56 	    {
       
    57 	    OstTraceFunctionEntry0(CTESTCASE0464_CTESTCASE0464);
       
    58 	    }
       
    59 		
    49 		
    60 	} 
    50 	} 
    61 
    51 
    62 
    52 
    63 /**
    53 /**
    64  ConstructL
    54  ConstructL
    65 */
    55 */
    66 void CTestCase0464::ConstructL()
    56 void CTestCase0464::ConstructL()
    67 	{
    57 	{
    68 	if(gVerboseOutput)
    58 	LOG_FUNC
    69 	    {
       
    70 	    OstTraceFunctionEntry0(CTESTCASE0464_CONSTRUCTL);
       
    71 	    }
       
    72 
    59 
    73 	BaseConstructL();
    60 	BaseConstructL();
    74 	}
    61 	}
    75 
    62 
    76 
    63 
    77 CTestCase0464::~CTestCase0464()
    64 CTestCase0464::~CTestCase0464()
    78 	{
    65 	{
    79 	if(gVerboseOutput)
    66 	LOG_FUNC
    80 	    {
       
    81 	    OstTraceFunctionEntry0(CTESTCASE0464_DCTESTCASE0464);
       
    82 	    }
       
    83 
    67 
    84 	Cancel();
    68 	Cancel();
    85 	}
    69 	}
    86 
    70 
    87 
    71 
    88 void CTestCase0464::ExecuteTestCaseL()
    72 void CTestCase0464::ExecuteTestCaseL()
    89 	{
    73 	{
    90 	if(gVerboseOutput)
    74 	LOG_FUNC
    91 	    {
       
    92 	    OstTraceFunctionEntry0(CTESTCASE0464_EXECUTETESTCASEL);
       
    93 	    }
       
    94 	iCaseStep = EPreconditions;
    75 	iCaseStep = EPreconditions;
    95 	
    76 	
    96 	CActiveScheduler::Add(this);
    77 	CActiveScheduler::Add(this);
    97 	SelfComplete();
    78 	SelfComplete();
    98 	}
    79 	}
    99 
    80 
   100 
    81 
   101 void CTestCase0464::DescribePreconditions()
    82 void CTestCase0464::DescribePreconditions()
   102 	{
    83 	{
   103 	test.Printf(_L("Insert 'A' connector beforehand.\n"));
    84 	test.Printf(_L("Insert 'A' connector beforehand.\n"));
   104 	OstTrace0(TRACE_NORMAL, CTESTCASE0464_DESCRIBEPRECONDITIONS, "Insert 'A' connector beforehand.\n");
       
   105 	}
    85 	}
   106 
    86 
   107 	
    87 	
   108 void CTestCase0464::DoCancel()
    88 void CTestCase0464::DoCancel()
   109 	{
    89 	{
   110 	if(gVerboseOutput)
    90 	LOG_FUNC
   111 	    {
       
   112 	    OstTraceFunctionEntry0(CTESTCASE0464_DOCANCEL);
       
   113 	    }
       
   114 
    91 
   115 	// cancel our timer
    92 	// cancel our timer
   116 	iTimer.Cancel();
    93 	iTimer.Cancel();
   117 	}
    94 	}
   118 
    95 
   128 	
   105 	
   129 
   106 
   130 // handle event completion	
   107 // handle event completion	
   131 void CTestCase0464::RunStepL()
   108 void CTestCase0464::RunStepL()
   132 	{
   109 	{
   133 	if(gVerboseOutput)
   110 	LOG_FUNC
   134 	    {
       
   135 	    OstTraceFunctionEntry0(CTESTCASE0464_RUNSTEPL);
       
   136 	    }
       
   137 	// Obtain the completion code for this CActive obj.
   111 	// Obtain the completion code for this CActive obj.
   138 	TInt completionCode(iStatus.Int()); 
   112 	TInt completionCode(iStatus.Int()); 
   139 	TBuf<MAX_DSTRLEN> aDescription;
   113 	TBuf<MAX_DSTRLEN> aDescription;
   140 	TInt err(0);
   114 	TInt err(0);
   141 		
   115 		
   149 				SelfComplete();
   123 				SelfComplete();
   150 				break;
   124 				break;
   151 				}
   125 				}
   152 			// prompt to insert 'A' connector
   126 			// prompt to insert 'A' connector
   153 			test.Printf(KInsertAConnectorPrompt);
   127 			test.Printf(KInsertAConnectorPrompt);
   154 			OstTrace0(TRACE_NORMAL, CTESTCASE0464_RUNSTEPL_DUP01, KInsertAConnectorPrompt);
       
   155 			test.Printf(KPressAnyKeyToContinue);
   128 			test.Printf(KPressAnyKeyToContinue);
   156 			OstTrace0(TRACE_NORMAL, CTESTCASE0464_RUNSTEPL_DUP02, KPressAnyKeyToContinue);
       
   157 			RequestCharacter();			
   129 			RequestCharacter();			
   158 			break;
   130 			break;
   159 
   131 
   160 		case ELoadLdd:
   132 		case ELoadLdd:
   161 			if (!StepLoadLDD())
   133 			if (!StepLoadLDD())
   167 			SelfComplete();
   139 			SelfComplete();
   168 			break;
   140 			break;
   169 
   141 
   170 		case EDriveBus:
   142 		case EDriveBus:
   171 			LOG_VERBOSE1(_L("Turn ON VBus\n"))
   143 			LOG_VERBOSE1(_L("Turn ON VBus\n"))
   172 			if(gVerboseOutput)
       
   173 			    {
       
   174 			    OstTrace0(TRACE_VERBOSE, CTESTCASE0464_RUNSTEPL_DUP03, "Turn ON VBus\n");
       
   175 			    }
       
   176 			err = otgBusRequest();
   144 			err = otgBusRequest();
   177 			if (KErrNone != err)
   145 			if (KErrNone != err)
   178 				{
   146 				{
   179 				return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!"));
   147 				return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!"));
   180 				}
   148 				}
   182 			SelfComplete();
   150 			SelfComplete();
   183 			break;
   151 			break;
   184 
   152 
   185 		case EUnloadLdd:
   153 		case EUnloadLdd:
   186 			LOG_VERBOSE1(_L("Unload.\n"))
   154 			LOG_VERBOSE1(_L("Unload.\n"))
   187 			if(gVerboseOutput)
       
   188 			    {
       
   189 			    OstTrace0(TRACE_VERBOSE, CTESTCASE0464_RUNSTEPL_DUP04, "Unload.\n");
       
   190 			    }
       
   191 			if (EFalse == StepUnloadLDD())
   155 			if (EFalse == StepUnloadLDD())
   192 				return TestFailed(KErrAbort,_L("unload Ldd failure"));	
   156 				return TestFailed(KErrAbort,_L("unload Ldd failure"));	
   193 			test.Printf(_L("Measure VBus =0 and then press Y or N to continue."));
   157 			test.Printf(_L("Measure VBus =0 and then press Y or N to continue."));
   194 			OstTrace0(TRACE_NORMAL, CTESTCASE0464_RUNSTEPL_DUP05, "Measure VBus =0 and then press Y or N to continue.");
       
   195 			RequestCharacter();
   158 			RequestCharacter();
   196 			iCaseStep = EVerifyVBusGone;
   159 			iCaseStep = EVerifyVBusGone;
   197 			break;
   160 			break;
   198 
   161 
   199 		case EVerifyVBusGone:
   162 		case EVerifyVBusGone:
   200 			LOG_VERBOSE1(_L("Test !VBus after unload.\n"))
   163 			LOG_VERBOSE1(_L("Test !VBus after unload.\n"))
   201 			if(gVerboseOutput)
       
   202 			    {
       
   203 			    OstTrace0(TRACE_VERBOSE, CTESTCASE0464_RUNSTEPL_DUP06, "Test !VBus after unload.\n");
       
   204 			    }
       
   205 			// test key response (or via an API)
   164 			// test key response (or via an API)
   206 			if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
   165 			if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
   207 				{
   166 				{
   208 				test.Printf(_L("VBUS drop 'seen' \n"));
   167 				test.Printf(_L("VBUS drop 'seen' \n"));
   209 				OstTrace0(TRACE_NORMAL, CTESTCASE0464_RUNSTEPL_DUP07, "VBUS drop 'seen' \n");
       
   210 				SelfComplete();
   168 				SelfComplete();
   211 				}
   169 				}
   212 			else
   170 			else
   213 				{
   171 				{
   214 				return TestFailed(KErrAbort, _L("VBus drop not 'seen' - FAILED!"));
   172 				return TestFailed(KErrAbort, _L("VBus drop not 'seen' - FAILED!"));
   219 		case ELastStep:
   177 		case ELastStep:
   220 			return TestPassed();
   178 			return TestPassed();
   221 
   179 
   222 		default:
   180 		default:
   223 			test.Printf(_L("<Error> unknown test step"));
   181 			test.Printf(_L("<Error> unknown test step"));
   224 			OstTrace0(TRACE_NORMAL, CTESTCASE0464_RUNSTEPL_DUP08, "<Error> unknown test step");
       
   225 			Cancel();
   182 			Cancel();
   226 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   183 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   227 
   184 
   228 		}
   185 		}
   229 	}
   186 	}