kerneltest/e32test/usbho/t_otgdi/src/testcase0679.cpp
changeset 259 57b9594f5772
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
247:d8d70de2bd36 259:57b9594f5772
     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".
    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 "b2bwatchers.h"
    25 #include "b2bwatchers.h"
    26 #include "testcase0679.h"
    26 #include "testcase0679.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "testcase0679Traces.h"
       
    30 #endif
    27 
    31 
    28 #define _REPEATS (oOpenIterations*3)
    32 #define _REPEATS (oOpenIterations*3)
    29 
    33 
    30 
    34 
    31 /* **************************************************************************************
    35 /* **************************************************************************************
    35 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0679");
    39 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0679");
    36 const TTestCaseFactoryReceipt<CTestCase0679> CTestCase0679::iFactoryReceipt(KTestCaseId);	
    40 const TTestCaseFactoryReceipt<CTestCase0679> CTestCase0679::iFactoryReceipt(KTestCaseId);	
    37 
    41 
    38 CTestCase0679* CTestCase0679::NewL(TBool aHost)
    42 CTestCase0679* CTestCase0679::NewL(TBool aHost)
    39 	{
    43 	{
    40 	LOG_FUNC
    44 	if(gVerboseOutput)
       
    45 	    {
       
    46 	    OstTraceFunctionEntry0(CTESTCASE0679_NEWL);
       
    47 	    }
    41 	CTestCase0679* self = new (ELeave) CTestCase0679(aHost);
    48 	CTestCase0679* self = new (ELeave) CTestCase0679(aHost);
    42 	CleanupStack::PushL(self);
    49 	CleanupStack::PushL(self);
    43 	self->ConstructL();
    50 	self->ConstructL();
    44 	CleanupStack::Pop(self);
    51 	CleanupStack::Pop(self);
    45 	return self;
    52 	return self;
    47 	
    54 	
    48 
    55 
    49 CTestCase0679::CTestCase0679(TBool aHost)
    56 CTestCase0679::CTestCase0679(TBool aHost)
    50 	: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) 
    57 	: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) 
    51 	{
    58 	{
    52 	LOG_FUNC
    59 	if(gVerboseOutput)
       
    60 	    {
       
    61 	    OstTraceFunctionEntry0(CTESTCASE0679_CTESTCASE0679);
       
    62 	    }
    53 		
    63 		
    54 	} 
    64 	} 
    55 
    65 
    56 
    66 
    57 /**
    67 /**
    58  ConstructL
    68  ConstructL
    59 */
    69 */
    60 void CTestCase0679::ConstructL()
    70 void CTestCase0679::ConstructL()
    61 	{
    71 	{
    62 	LOG_FUNC
    72 	if(gVerboseOutput)
       
    73 	    {
       
    74 	    OstTraceFunctionEntry0(CTESTCASE0679_CONSTRUCTL);
       
    75 	    }
    63 
    76 
    64 	iDualRoleCase = ETrue;	// another back-back
    77 	iDualRoleCase = ETrue;	// another back-back
    65 		
    78 		
    66 	BaseConstructL();
    79 	BaseConstructL();
    67 	}
    80 	}
    68 
    81 
    69 
    82 
    70 CTestCase0679::~CTestCase0679()
    83 CTestCase0679::~CTestCase0679()
    71 	{
    84 	{
    72 	LOG_FUNC
    85 	if(gVerboseOutput)
       
    86 	    {
       
    87 	    OstTraceFunctionEntry0(CTESTCASE0679_DCTESTCASE0679);
       
    88 	    }
    73 	iCollector.DestroyObservers();
    89 	iCollector.DestroyObservers();
    74 	Cancel();
    90 	Cancel();
    75 	}
    91 	}
    76 
    92 
    77 
    93 
    78 void CTestCase0679::ExecuteTestCaseL()
    94 void CTestCase0679::ExecuteTestCaseL()
    79 	{
    95 	{
    80 	LOG_FUNC
    96 	if(gVerboseOutput)
       
    97 	    {
       
    98 	    OstTraceFunctionEntry0(CTESTCASE0679_EXECUTETESTCASEL);
       
    99 	    }
    81 	iCaseStep = EPreconditions;
   100 	iCaseStep = EPreconditions;
    82 	CActiveScheduler::Add(this);
   101 	CActiveScheduler::Add(this);
    83 	SelfComplete();
   102 	SelfComplete();
    84 	}
   103 	}
    85 
   104 
    86 	
   105 	
    87 void CTestCase0679::DoCancel()
   106 void CTestCase0679::DoCancel()
    88 	{
   107 	{
    89 	LOG_FUNC
   108 	if(gVerboseOutput)
       
   109 	    {
       
   110 	    OstTraceFunctionEntry0(CTESTCASE0679_DOCANCEL);
       
   111 	    }
    90 	// cancel our timer
   112 	// cancel our timer
    91 	iTimer.Cancel();
   113 	iTimer.Cancel();
    92 	}
   114 	}
    93 
   115 
    94 
   116 
    95 // handle event completion	
   117 // handle event completion	
    96 void CTestCase0679::RunStepL()
   118 void CTestCase0679::RunStepL()
    97 	{
   119 	{
    98 	LOG_FUNC
   120 	if(gVerboseOutput)
       
   121 	    {
       
   122 	    OstTraceFunctionEntry0(CTESTCASE0679_RUNSTEPL);
       
   123 	    }
    99 	// Obtain the completion code for this CActive obj.
   124 	// Obtain the completion code for this CActive obj.
   100 	TInt completionCode(iStatus.Int()); 
   125 	TInt completionCode(iStatus.Int()); 
   101 	TBuf<MAX_DSTRLEN> aDescription;
   126 	TBuf<MAX_DSTRLEN> aDescription;
   102 	TInt err(0);
   127 	TInt err(0);
   103 
   128 
   176 			}
   201 			}
   177 			
   202 			
   178 		case EDefaultRoles:
   203 		case EDefaultRoles:
   179 			{
   204 			{
   180 			test.Printf(_L("Into EDefaultRoles step...\n"));
   205 			test.Printf(_L("Into EDefaultRoles step...\n"));
       
   206 			OstTrace0(TRACE_NORMAL, CTESTCASE0679_RUNSTEPL_DUP01, "Into EDefaultRoles step...\n");
   181 			LOG_STEPNAME(_L("EWaitEnumeration"));
   207 			LOG_STEPNAME(_L("EWaitEnumeration"));
   182 			
   208 			
   183 			if (gTestRoleMaster)
   209 			if (gTestRoleMaster)
   184 				{
   210 				{
   185 				//	B-Device should now wait until it is configured
   211 				//	B-Device should now wait until it is configured
   199 				//	to observe the B-Device test code for the pass/fail
   225 				//	to observe the B-Device test code for the pass/fail
   200 				const TInt KTestCase0679ATimeout = 4000;			//	4 seconds before A-Device drops VBus (before B test times out at 5 seconds)
   226 				const TInt KTestCase0679ATimeout = 4000;			//	4 seconds before A-Device drops VBus (before B test times out at 5 seconds)
   201 				iCollector.AddStepTimeout(KTestCase0679ATimeout);	//	NB. In this test on the A-Device, we expect to timeout
   227 				iCollector.AddStepTimeout(KTestCase0679ATimeout);	//	NB. In this test on the A-Device, we expect to timeout
   202 																	//	so a timeout isn't treated as a failure
   228 																	//	so a timeout isn't treated as a failure
   203 				test.Printf(_L("NOTE : Please observe test result on B-Device...\n"));
   229 				test.Printf(_L("NOTE : Please observe test result on B-Device...\n"));
       
   230 				OstTrace0(TRACE_NORMAL, CTESTCASE0679_RUNSTEPL_DUP02, "NOTE : Please observe test result on B-Device...\n");
   204 				iCaseStep = EDropVBus;	//	This is the step the A-Device will go to
   231 				iCaseStep = EDropVBus;	//	This is the step the A-Device will go to
   205 										//	when the timer (set up in previous test) fires
   232 										//	when the timer (set up in previous test) fires
   206 				}
   233 				}
   207 			SetActive();
   234 			SetActive();
   208 			break;
   235 			break;
   210 
   237 
   211 			
   238 			
   212 		case EBConfigured:	//	A B-Device only step!
   239 		case EBConfigured:	//	A B-Device only step!
   213 			{
   240 			{
   214 			test.Printf(_L("Into EBConfigured step...\n"));
   241 			test.Printf(_L("Into EBConfigured step...\n"));
       
   242 			OstTrace0(TRACE_NORMAL, CTESTCASE0679_RUNSTEPL_DUP03, "Into EBConfigured step...\n");
   215 			if (KTestCaseWatchdogTO == iStatus.Int())
   243 			if (KTestCaseWatchdogTO == iStatus.Int())
   216 				{
   244 				{
   217 				iCollector.DestroyObservers();
   245 				iCollector.DestroyObservers();
   218 				return TestFailed(KErrAbort, _L("Timeout"));
   246 				return TestFailed(KErrAbort, _L("Timeout"));
   219 				}
   247 				}
   224 			}
   252 			}
   225 			
   253 			
   226 		case EBSuspended:	
   254 		case EBSuspended:	
   227 			{
   255 			{
   228 			test.Printf(_L("Into EBSuspended step...\n"));
   256 			test.Printf(_L("Into EBSuspended step...\n"));
       
   257 			OstTrace0(TRACE_NORMAL, CTESTCASE0679_RUNSTEPL_DUP04, "Into EBSuspended step...\n");
   229 			if (KTestCaseWatchdogTO == iStatus.Int())
   258 			if (KTestCaseWatchdogTO == iStatus.Int())
   230 				{
   259 				{
   231 				iCollector.DestroyObservers();
   260 				iCollector.DestroyObservers();
   232 				return TestFailed(KErrAbort, _L("Timeout"));
   261 				return TestFailed(KErrAbort, _L("Timeout"));
   233 				}			
   262 				}			
   234 			
   263 			
   235 			// issue HNP
   264 			// issue HNP
   236 			test.Printf(_L("Attempting a swap on a non-HNP enabled link...\n"));
   265 			test.Printf(_L("Attempting a swap on a non-HNP enabled link...\n"));
       
   266 			OstTrace0(TRACE_NORMAL, CTESTCASE0679_RUNSTEPL_DUP05, "Attempting a swap on a non-HNP enabled link...\n");
   237 			iCollector.AddRequiredNotification(EWatcherMessage, RUsbOtgDriver::EMessageHnpNotEnabled);
   267 			iCollector.AddRequiredNotification(EWatcherMessage, RUsbOtgDriver::EMessageHnpNotEnabled);
   238 
   268 
   239 			err = otgBusRequest();	//	Request the host role
   269 			err = otgBusRequest();	//	Request the host role
   240 
   270 
   241 			if (KErrNone != err)
   271 			if (KErrNone != err)
   242 				{
   272 				{
   243 				test.Printf(_L("BusRequest returned %d)"),err);
   273 				test.Printf(_L("BusRequest returned %d)"),err);
       
   274 				OstTrace1(TRACE_NORMAL, CTESTCASE0679_RUNSTEPL_DUP06, "BusRequest returned %d)",err);
   244 				//DS Temp! return TestFailed(KErrAbort, _L("BusRequest() failed!"));
   275 				//DS Temp! return TestFailed(KErrAbort, _L("BusRequest() failed!"));
   245 				}
   276 				}
   246 		
   277 		
   247 			iCaseStep = EBErrorReceived;
   278 			iCaseStep = EBErrorReceived;
   248 			SetActive();
   279 			SetActive();
   250 			}
   281 			}
   251 			
   282 			
   252 		case EBErrorReceived:
   283 		case EBErrorReceived:
   253 			{
   284 			{
   254 			test.Printf(_L("Into EBErrorReceived step...\n"));
   285 			test.Printf(_L("Into EBErrorReceived step...\n"));
       
   286 			OstTrace0(TRACE_NORMAL, CTESTCASE0679_RUNSTEPL_DUP07, "Into EBErrorReceived step...\n");
   255 			if (KTestCaseWatchdogTO == iStatus.Int())
   287 			if (KTestCaseWatchdogTO == iStatus.Int())
   256 				{
   288 				{
   257 				iCollector.DestroyObservers();
   289 				iCollector.DestroyObservers();
   258 				return TestFailed(KErrAbort, _L("Timeout"));
   290 				return TestFailed(KErrAbort, _L("Timeout"));
   259 				}			
   291 				}			
   315 			TestPassed();
   347 			TestPassed();
   316 			break;
   348 			break;
   317 			
   349 			
   318 		default:
   350 		default:
   319 			test.Printf(_L("<Error> unknown test step"));
   351 			test.Printf(_L("<Error> unknown test step"));
       
   352 			OstTrace0(TRACE_NORMAL, CTESTCASE0679_RUNSTEPL_DUP08, "<Error> unknown test step");
   320 			Cancel();
   353 			Cancel();
   321 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   354 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   322 		}
   355 		}
   323 	}
   356 	}