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