kerneltest/e32test/usbho/t_otgdi/src/testcase1233.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".
    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 "testcase1233.h"
    26 #include "testcase1233.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "testcase1233Traces.h"
       
    30 #endif
    27 
    31 
    28 #include <e32debug.h> 
    32 #include <e32debug.h> 
    29 
    33 
    30 #define LOG_INTO_STEP(a) test.Printf(_L("\nInto Step [%S]\n\n"), &a);
    34 #define LOG_INTO_STEP(a) test.Printf(_L("\nInto Step [%S]\n\n"), &a);
       
    35 
    31 
    36 
    32 /* **************************************************************************************
    37 /* **************************************************************************************
    33  * the name below is used to add a pointer to our construction method to a pointer MAP in 
    38  * the name below is used to add a pointer to our construction method to a pointer MAP in 
    34  * the class factory
    39  * the class factory
    35  */
    40  */
    36 _LIT(KTestCaseId,"PBASE-USB_OTGDI-1233");
    41 _LIT(KTestCaseId,"PBASE-USB_OTGDI-1233");
    37 const TTestCaseFactoryReceipt<CTestCase1233> CTestCase1233::iFactoryReceipt(KTestCaseId);	
    42 const TTestCaseFactoryReceipt<CTestCase1233> CTestCase1233::iFactoryReceipt(KTestCaseId);	
    38 
    43 
    39 CTestCase1233* CTestCase1233::NewL(TBool aHost)
    44 CTestCase1233* CTestCase1233::NewL(TBool aHost)
    40 	{
    45 	{
    41 	LOG_FUNC
    46 	if(gVerboseOutput)
       
    47 	    {
       
    48 	    OstTraceFunctionEntry0(CTESTCASE1233_NEWL);
       
    49 	    }
    42 	CTestCase1233* self = new (ELeave) CTestCase1233(aHost);
    50 	CTestCase1233* self = new (ELeave) CTestCase1233(aHost);
    43 	CleanupStack::PushL(self);
    51 	CleanupStack::PushL(self);
    44 	self->ConstructL();
    52 	self->ConstructL();
    45 	CleanupStack::Pop(self);
    53 	CleanupStack::Pop(self);
    46 	return self;
    54 	return self;
    48 	
    56 	
    49 
    57 
    50 CTestCase1233::CTestCase1233(TBool aHost)
    58 CTestCase1233::CTestCase1233(TBool aHost)
    51 	: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) 
    59 	: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) 
    52 	{
    60 	{
    53 	LOG_FUNC
    61 	if(gVerboseOutput)
       
    62 	    {
       
    63 	    OstTraceFunctionEntry0(CTESTCASE1233_CTESTCASE1233);
       
    64 	    }
    54 		
    65 		
    55 	} 
    66 	} 
    56 
    67 
    57 
    68 
    58 /**
    69 /**
    59  ConstructL
    70  ConstructL
    60 */
    71 */
    61 void CTestCase1233::ConstructL()
    72 void CTestCase1233::ConstructL()
    62 	{
    73 	{
    63 	LOG_FUNC
    74 	if(gVerboseOutput)
       
    75 	    {
       
    76 	    OstTraceFunctionEntry0(CTESTCASE1233_CONSTRUCTL);
       
    77 	    }
    64 
    78 
    65 	iTestVID = 0x0E22;		// Symbian
    79 	iTestVID = 0x0E22;		// Symbian
    66 	iTestPID = 0xF000 + 1233; // Test 1233
    80 	iTestPID = 0xF000 + 1233; // Test 1233
    67 	
    81 	
    68 	BaseConstructL();
    82 	BaseConstructL();
    69 	}
    83 	}
    70 
    84 
    71 
    85 
    72 CTestCase1233::~CTestCase1233()
    86 CTestCase1233::~CTestCase1233()
    73 	{
    87 	{
    74 	LOG_FUNC
    88 	if(gVerboseOutput)
       
    89 	    {
       
    90 	    OstTraceFunctionEntry0(CTESTCASE1233_DCTESTCASE1233);
       
    91 	    }
    75 	iCollector.DestroyObservers();
    92 	iCollector.DestroyObservers();
    76 	Cancel();
    93 	Cancel();
    77 	}
    94 	}
    78 
    95 
    79 
    96 
    80 void CTestCase1233::ExecuteTestCaseL()
    97 void CTestCase1233::ExecuteTestCaseL()
    81 	{
    98 	{
    82 	LOG_FUNC
    99 	if(gVerboseOutput)
       
   100 	    {
       
   101 	    OstTraceFunctionEntry0(CTESTCASE1233_EXECUTETESTCASEL);
       
   102 	    }
    83 	iCaseStep = EPreconditions;
   103 	iCaseStep = EPreconditions;
    84 	CActiveScheduler::Add(this);
   104 	CActiveScheduler::Add(this);
    85 	SelfComplete();
   105 	SelfComplete();
    86 	}
   106 	}
    87 
   107 
    88 	
   108 	
    89 void CTestCase1233::DoCancel()
   109 void CTestCase1233::DoCancel()
    90 	{
   110 	{
    91 	LOG_FUNC
   111 	if(gVerboseOutput)
       
   112 	    {
       
   113 	    OstTraceFunctionEntry0(CTESTCASE1233_DOCANCEL);
       
   114 	    }
    92 	// cancel our timer
   115 	// cancel our timer
    93 	iTimer.Cancel();
   116 	iTimer.Cancel();
    94 	}
   117 	}
    95 
   118 
    96 
   119 
    97 void CTestCase1233::RunStepL()
   120 void CTestCase1233::RunStepL()
    98 	{
   121 	{
    99 	LOG_FUNC
   122 	if(gVerboseOutput)
       
   123 	    {
       
   124 	    OstTraceFunctionEntry0(CTESTCASE1233_RUNSTEPL);
       
   125 	    }
   100 	
   126 	
   101 	// Obtain the completion code for this CActive obj.
   127 	// Obtain the completion code for this CActive obj.
   102 	TInt completionCode(iStatus.Int()); 
   128 	TInt completionCode(iStatus.Int()); 
   103 	TBuf<MAX_DSTRLEN> aDescription;
   129 	TBuf<MAX_DSTRLEN> aDescription;
   104 
   130 
   184 			iTestPID++;
   210 			iTestPID++;
   185 			
   211 			
   186 			if ( iTestPID > 0x0108 )
   212 			if ( iTestPID > 0x0108 )
   187 				{
   213 				{
   188 				test.Printf(_L("All VID/PID pairs done\n"));
   214 				test.Printf(_L("All VID/PID pairs done\n"));
       
   215 				OstTrace0(TRACE_NORMAL, CTESTCASE1233_RUNSTEPL_DUP01, "All VID/PID pairs done\n");
   189 				
   216 				
   190 				iCaseStep = EUnloadLdd;
   217 				iCaseStep = EUnloadLdd;
   191 				}
   218 				}
   192 			else
   219 			else
   193 				{
   220 				{
   194 				if(gTestRoleMaster)
   221 				if(gTestRoleMaster)
   195 					{
   222 					{
   196 					// B
   223 					// B
   197 					test.Printf(_L("Setting VID/PID of 0x%04x/0x%04x\n"),iTestVID,iTestPID);
   224 					test.Printf(_L("Setting VID/PID of 0x%04x/0x%04x\n"),iTestVID,iTestPID);
       
   225 					OstTraceExt2(TRACE_NORMAL, CTESTCASE1233_RUNSTEPL_DUP02, "Setting VID/PID of 0x%04x/0x%04x\n",(TUint32)iTestVID,(TUint32)iTestPID);
   198 					
   226 					
   199 					if (!StepChangeVidPid(iTestVID,iTestPID))
   227 					if (!StepChangeVidPid(iTestVID,iTestPID))
   200 						{
   228 						{
   201 						return TestFailed(KErrAbort, _L("VID/PID Change Failure"));
   229 						return TestFailed(KErrAbort, _L("VID/PID Change Failure"));
   202 						}
   230 						}
   203 					}
   231 					}
   204 				else
   232 				else
   205 					{
   233 					{
   206 					// A
   234 					// A
   207 					test.Printf(_L("Expecting VID/PID of 0x%04x/0x%04x\n"),iTestVID,iTestPID);
   235 					test.Printf(_L("Expecting VID/PID of 0x%04x/0x%04x\n"),iTestVID,iTestPID);
       
   236 					OstTraceExt2(TRACE_NORMAL, CTESTCASE1233_RUNSTEPL_DUP03, "Expecting VID/PID of 0x%04x/0x%04x\n",(TUint32)iTestVID,(TUint32)iTestPID);
   208 					}
   237 					}
   209 				
   238 				
   210 				iCollector.ClearAllEvents();
   239 				iCollector.ClearAllEvents();
   211 				iCaseStep = ERaiseVBus;
   240 				iCaseStep = ERaiseVBus;
   212 				}
   241 				}
   237 				}
   266 				}
   238 			else
   267 			else
   239 				{ 
   268 				{ 
   240 				// A device
   269 				// A device
   241 				test.Printf(_L("Raising VBUS for VID/PID = 0x%04x/0x%04x\n"),iTestVID,iTestPID);
   270 				test.Printf(_L("Raising VBUS for VID/PID = 0x%04x/0x%04x\n"),iTestVID,iTestPID);
       
   271 				OstTraceExt2(TRACE_NORMAL, CTESTCASE1233_RUNSTEPL_DUP04, "Raising VBUS for VID/PID = 0x%04x/0x%04x\n",(TUint32)iTestVID,(TUint32)iTestPID);
   242 				
   272 				
   243 				if ( otgBusRequest() != KErrNone )
   273 				if ( otgBusRequest() != KErrNone )
   244 					{
   274 					{
   245 					return TestFailed(KErrAbort, _L("Raise Vbus - RUsbOtgDriver::BusRequest() FAILED!"));
   275 					return TestFailed(KErrAbort, _L("Raise Vbus - RUsbOtgDriver::BusRequest() FAILED!"));
   246 					}
   276 					}
   265 				}
   295 				}
   266 
   296 
   267 			if ( otgVbusPresent() )
   297 			if ( otgVbusPresent() )
   268 				{
   298 				{
   269 				test.Printf(_L("...VBUS is UP\n"));
   299 				test.Printf(_L("...VBUS is UP\n"));
       
   300 				OstTrace0(TRACE_NORMAL, CTESTCASE1233_RUNSTEPL_DUP05, "...VBUS is UP\n");
   270 				iCaseStep = EDropVBus;
   301 				iCaseStep = EDropVBus;
   271 				}
   302 				}
   272 			else
   303 			else
   273 				{
   304 				{
   274 				test.Printf(_L("...VBUS is DOWN\n"));
   305 				test.Printf(_L("...VBUS is DOWN\n"));
       
   306 				OstTrace0(TRACE_NORMAL, CTESTCASE1233_RUNSTEPL_DUP06, "...VBUS is DOWN\n");
   275 				return TestFailed(KErrAbort, _L("Vbus did not rise - FAILED!"));
   307 				return TestFailed(KErrAbort, _L("Vbus did not rise - FAILED!"));
   276 				}
   308 				}
   277 
   309 
   278 			if (gTestRoleMaster)
   310 			if (gTestRoleMaster)
   279 				{
   311 				{
   342 				}
   374 				}
   343 
   375 
   344 			if ( otgVbusPresent() )
   376 			if ( otgVbusPresent() )
   345 				{
   377 				{
   346 				test.Printf(_L("...VBUS is UP\n"));
   378 				test.Printf(_L("...VBUS is UP\n"));
       
   379 				OstTrace0(TRACE_NORMAL, CTESTCASE1233_RUNSTEPL_DUP07, "...VBUS is UP\n");
   347 				return TestFailed(KErrAbort, _L("Vbus did not rise - FAILED!"));
   380 				return TestFailed(KErrAbort, _L("Vbus did not rise - FAILED!"));
   348 				}
   381 				}
   349 			else
   382 			else
   350 				{
   383 				{
   351 				test.Printf(_L("...VBUS is DOWN\n"));
   384 				test.Printf(_L("...VBUS is DOWN\n"));
       
   385 				OstTrace0(TRACE_NORMAL, CTESTCASE1233_RUNSTEPL_DUP08, "...VBUS is DOWN\n");
   352 				iCaseStep = ELoopToNextPID;
   386 				iCaseStep = ELoopToNextPID;
   353 				}
   387 				}
   354 
   388 
   355 			SelfComplete();
   389 			SelfComplete();
   356 			break;
   390 			break;