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