kerneltest/e32test/usbho/t_otgdi/src/testcase0462.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 "testcasewd.h"
    25 #include "testcasewd.h"
    26 #include "testcase0462.h"
    26 #include "testcase0462.h"
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "testcase0462Traces.h"
       
    30 #endif
       
    31 
    27 
    32 
    28 
    33 
    29 
    34 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    30 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    35 // the class factory
    31 // the class factory
    36 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0462");
    32 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0462");
    37 const TTestCaseFactoryReceipt<CTestCase0462> CTestCase0462::iFactoryReceipt(KTestCaseId);	
    33 const TTestCaseFactoryReceipt<CTestCase0462> CTestCase0462::iFactoryReceipt(KTestCaseId);	
    38 
    34 
    39 CTestCase0462* CTestCase0462::NewL(TBool aHost)
    35 CTestCase0462* CTestCase0462::NewL(TBool aHost)
    40 	{
    36 	{
    41 	if(gVerboseOutput)
    37 	LOG_FUNC
    42 	    {
       
    43 	    OstTraceFunctionEntry0(CTESTCASE0462_NEWL);
       
    44 	    }
       
    45 	CTestCase0462* self = new (ELeave) CTestCase0462(aHost);
    38 	CTestCase0462* self = new (ELeave) CTestCase0462(aHost);
    46 	CleanupStack::PushL(self);
    39 	CleanupStack::PushL(self);
    47 	self->ConstructL();
    40 	self->ConstructL();
    48 	CleanupStack::Pop(self);
    41 	CleanupStack::Pop(self);
    49 	return self;
    42 	return self;
    51 	
    44 	
    52 
    45 
    53 CTestCase0462::CTestCase0462(TBool aHost)
    46 CTestCase0462::CTestCase0462(TBool aHost)
    54 :	CTestCaseRoot(KTestCaseId, aHost)
    47 :	CTestCaseRoot(KTestCaseId, aHost)
    55 	{
    48 	{
    56 	if(gVerboseOutput)
    49 	LOG_FUNC
    57 	    {
       
    58 	    OstTraceFunctionEntry0(CTESTCASE0462_CTESTCASE0462);
       
    59 	    }
       
    60 		
    50 		
    61 	} 
    51 	} 
    62 
    52 
    63 
    53 
    64 /**
    54 /**
    65  ConstructL
    55  ConstructL
    66 */
    56 */
    67 void CTestCase0462::ConstructL()
    57 void CTestCase0462::ConstructL()
    68 	{
    58 	{
    69 	if(gVerboseOutput)
    59 	LOG_FUNC
    70 	    {
       
    71 	    OstTraceFunctionEntry0(CTESTCASE0462_CONSTRUCTL);
       
    72 	    }
       
    73 	iRepeats = KOperationRetriesMax;
    60 	iRepeats = KOperationRetriesMax;
    74 	iWDTimer = CTestCaseWatchdog::NewL();
    61 	iWDTimer = CTestCaseWatchdog::NewL();
    75 	
    62 	
    76 	BaseConstructL();
    63 	BaseConstructL();
    77 	}
    64 	}
    78 
    65 
    79 
    66 
    80 CTestCase0462::~CTestCase0462()
    67 CTestCase0462::~CTestCase0462()
    81 	{
    68 	{
    82 	if(gVerboseOutput)
    69 	LOG_FUNC
    83 	    {
       
    84 	    OstTraceFunctionEntry0(CTESTCASE0462_DCTESTCASE0462);
       
    85 	    }
       
    86 
    70 
    87 	Cancel();
    71 	Cancel();
    88 	delete iWDTimer;
    72 	delete iWDTimer;
    89 	}
    73 	}
    90 
    74 
    91 
    75 
    92 void CTestCase0462::ExecuteTestCaseL()
    76 void CTestCase0462::ExecuteTestCaseL()
    93 	{
    77 	{
    94 	if(gVerboseOutput)
    78 	LOG_FUNC
    95 	    {
       
    96 	    OstTraceFunctionEntry0(CTESTCASE0462_EXECUTETESTCASEL);
       
    97 	    }
       
    98 	iCaseStep = ELoadLdd;
    79 	iCaseStep = ELoadLdd;
    99 	
    80 	
   100 	CActiveScheduler::Add(this);
    81 	CActiveScheduler::Add(this);
   101 	SelfComplete();
    82 	SelfComplete();
   102 
    83 
   104 
    85 
   105 
    86 
   106 void CTestCase0462::DescribePreconditions()
    87 void CTestCase0462::DescribePreconditions()
   107 	{
    88 	{
   108 	test.Printf(_L("Insert 'A' connector beforehand.\n"));
    89 	test.Printf(_L("Insert 'A' connector beforehand.\n"));
   109 	OstTrace0(TRACE_NORMAL, CTESTCASE0462_DESCRIBEPRECONDITIONS, "Insert 'A' connector beforehand.\n");
       
   110 	}
    90 	}
   111 
    91 
   112 	
    92 	
   113 void CTestCase0462::DoCancel()
    93 void CTestCase0462::DoCancel()
   114 	{
    94 	{
   115 	if(gVerboseOutput)
    95 	LOG_FUNC
   116 	    {
       
   117 	    OstTraceFunctionEntry0(CTESTCASE0462_DOCANCEL);
       
   118 	    }
       
   119 
    96 
   120 	// cancel our timer
    97 	// cancel our timer
   121 	iTimer.Cancel();
    98 	iTimer.Cancel();
   122 	}
    99 	}
   123 	
   100 	
   132 	
   109 	
   133 
   110 
   134 // handle event completion	
   111 // handle event completion	
   135 void CTestCase0462::RunStepL()
   112 void CTestCase0462::RunStepL()
   136 	{
   113 	{
   137 	if(gVerboseOutput)
   114 	LOG_FUNC
   138 	    {
       
   139 	    OstTraceFunctionEntry0(CTESTCASE0462_RUNSTEPL);
       
   140 	    }
       
   141 	// Obtain the completion code for this CActive obj.
   115 	// Obtain the completion code for this CActive obj.
   142 	TInt completionCode(iStatus.Int()); 
   116 	TInt completionCode(iStatus.Int()); 
   143 	// NOTE: Look at its iStatus.iFlags. 
   117 	// NOTE: Look at its iStatus.iFlags. 
   144 	// If it's 1, it's b -> you called SetActive() but the service provider didn't set it to KRequestPending or it got overwritten. 
   118 	// If it's 1, it's b -> you called SetActive() but the service provider didn't set it to KRequestPending or it got overwritten. 
   145 	// If it's 2, it's a -> you didn't called SetActive() when issuing a request.				
   119 	// If it's 2, it's a -> you didn't called SetActive() when issuing a request.				
   156 				SelfComplete();
   130 				SelfComplete();
   157 				break;
   131 				break;
   158 				}
   132 				}
   159 			// prompt to insert connector
   133 			// prompt to insert connector
   160 			test.Printf(KInsertAConnectorPrompt);
   134 			test.Printf(KInsertAConnectorPrompt);
   161 			OstTrace0(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP01, KInsertAConnectorPrompt);
       
   162 			test.Printf(KPressAnyKeyToContinue);
   135 			test.Printf(KPressAnyKeyToContinue);
   163 			OstTrace0(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP02, KPressAnyKeyToContinue);
       
   164 			RequestCharacter();			
   136 			RequestCharacter();			
   165 			break;
   137 			break;
   166 			
   138 			
   167 		case ELoadLdd:
   139 		case ELoadLdd:
   168 			if (!StepLoadLDD())
   140 			if (!StepLoadLDD())
   177 
   149 
   178 			// 2. wait on ID_PIN
   150 			// 2. wait on ID_PIN
   179 		case ERegisterForEvents:
   151 		case ERegisterForEvents:
   180 			// prompt to remove connector
   152 			// prompt to remove connector
   181 			test.Printf(KRemoveAConnectorPrompt);		
   153 			test.Printf(KRemoveAConnectorPrompt);		
   182 			OstTrace0(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP03, KRemoveAConnectorPrompt);		
       
   183 			if (iDequeAttempts > 3)
   154 			if (iDequeAttempts > 3)
   184 				{
   155 				{
   185 				return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events")));
   156 				return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events")));
   186 				}
   157 				}
   187 
   158 
   212 			
   183 			
   213 			// 4.
   184 			// 4.
   214 		case EGetAndCancelEvent:
   185 		case EGetAndCancelEvent:
   215 			OtgEventString(iOTGEvent, aDescription);
   186 			OtgEventString(iOTGEvent, aDescription);
   216 			test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode);
   187 			test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode);
   217 			OstTraceExt3(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP04, "Received event %d '%S' status(%d)", iOTGEvent, aDescription, completionCode);
       
   218 			if (RUsbOtgDriver::EEventAPlugRemoved == iOTGEvent)
   188 			if (RUsbOtgDriver::EEventAPlugRemoved == iOTGEvent)
   219 				{
   189 				{
   220 				otgQueueOtgEventRequest( iOTGEvent, iStatus);
   190 				otgQueueOtgEventRequest( iOTGEvent, iStatus);
   221 				// cancel it and then generate 6 more events
   191 				// cancel it and then generate 6 more events
   222 				otgCancelOtgEventRequest();
   192 				otgCancelOtgEventRequest();
   242 			break;
   212 			break;
   243 			
   213 			
   244 		case EInsertA: // 6. remove 'A'
   214 		case EInsertA: // 6. remove 'A'
   245 			iConsole->ReadCancel();
   215 			iConsole->ReadCancel();
   246 			test.Printf(KInsertAConnectorPrompt);
   216 			test.Printf(KInsertAConnectorPrompt);
   247 			OstTrace0(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP05, KInsertAConnectorPrompt);
       
   248 
   217 
   249 			iCaseStep = ERemoveA;
   218 			iCaseStep = ERemoveA;
   250 			test.Printf(KPressAnyKeyToContinue);
   219 			test.Printf(KPressAnyKeyToContinue);
   251 			OstTrace0(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP06, KPressAnyKeyToContinue);
       
   252 			RequestCharacter();			
   220 			RequestCharacter();			
   253 			break;
   221 			break;
   254 			
   222 			
   255 			// 7.
   223 			// 7.
   256 		case ERemoveA:
   224 		case ERemoveA:
   257 			iConsole->ReadCancel();
   225 			iConsole->ReadCancel();
   258 			test.Printf(KRemoveAConnectorPrompt);
   226 			test.Printf(KRemoveAConnectorPrompt);
   259 			OstTrace0(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP07, KRemoveAConnectorPrompt);
       
   260 			if (iRepeats-- >0)
   227 			if (iRepeats-- >0)
   261 				iCaseStep = EInsertA;
   228 				iCaseStep = EInsertA;
   262 			else
   229 			else
   263 				iCaseStep = ETallyEvents;
   230 				iCaseStep = ETallyEvents;
   264 			test.Printf(KPressAnyKeyToContinue);
   231 			test.Printf(KPressAnyKeyToContinue);
   265 			OstTrace0(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP08, KPressAnyKeyToContinue);
       
   266 			RequestCharacter();
   232 			RequestCharacter();
   267 			break;
   233 			break;
   268 			
   234 			
   269 			// 8.
   235 			// 8.
   270 		case ETallyEvents:
   236 		case ETallyEvents:
   283 			
   249 			
   284 			return TestPassed();
   250 			return TestPassed();
   285 
   251 
   286 		default:
   252 		default:
   287 			test.Printf(_L("<Error> unknown test step"));
   253 			test.Printf(_L("<Error> unknown test step"));
   288 			OstTrace0(TRACE_NORMAL, CTESTCASE0462_RUNSTEPL_DUP09, "<Error> unknown test step");
       
   289 			Cancel();
   254 			Cancel();
   290 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   255 			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   291 
   256 
   292 		}
   257 		}
   293 	}
   258 	}