kerneltest/e32test/usbho/t_otgdi/src/testcase0469.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 "testcase0469.h"
    26 #include "testcase0469.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "testcase0469Traces.h"
       
    30 #endif
    27 
    31 
    28 #define _REPEATS (oOpenIterations*3)
    32 #define _REPEATS (oOpenIterations*3)
    29 
    33 
    30 
    34 
    31 
    35 
    34 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0469");
    38 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0469");
    35 const TTestCaseFactoryReceipt<CTestCase0469> CTestCase0469::iFactoryReceipt(KTestCaseId);	
    39 const TTestCaseFactoryReceipt<CTestCase0469> CTestCase0469::iFactoryReceipt(KTestCaseId);	
    36 
    40 
    37 CTestCase0469* CTestCase0469::NewL(TBool aHost)
    41 CTestCase0469* CTestCase0469::NewL(TBool aHost)
    38 	{
    42 	{
    39 	LOG_FUNC
    43 	if(gVerboseOutput)
       
    44 	    {
       
    45 	    OstTraceFunctionEntry0(CTESTCASE0469_NEWL);
       
    46 	    }
    40 	CTestCase0469* self = new (ELeave) CTestCase0469(aHost);
    47 	CTestCase0469* self = new (ELeave) CTestCase0469(aHost);
    41 	CleanupStack::PushL(self);
    48 	CleanupStack::PushL(self);
    42 	self->ConstructL();
    49 	self->ConstructL();
    43 	CleanupStack::Pop(self);
    50 	CleanupStack::Pop(self);
    44 	return self;
    51 	return self;
    45 	}
    52 	}
    46 	
    53 	
    47 CTestCase0469::CTestCase0469(TBool aHost)
    54 CTestCase0469::CTestCase0469(TBool aHost)
    48 	: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) 
    55 	: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) 
    49 	{
    56 	{
    50 	LOG_FUNC
    57 	if(gVerboseOutput)
       
    58 	    {
       
    59 	    OstTraceFunctionEntry0(CTESTCASE0469_CTESTCASE0469);
       
    60 	    }
    51 		
    61 		
    52 	} 
    62 	} 
    53 
    63 
    54 /**
    64 /**
    55  ConstructL
    65  ConstructL
    56 */
    66 */
    57 void CTestCase0469::ConstructL()
    67 void CTestCase0469::ConstructL()
    58 	{
    68 	{
    59 	LOG_FUNC
    69 	if(gVerboseOutput)
       
    70 	    {
       
    71 	    OstTraceFunctionEntry0(CTESTCASE0469_CONSTRUCTL);
       
    72 	    }
    60     iDualRoleCase = EFalse; // Not back to back
    73     iDualRoleCase = EFalse; // Not back to back
    61 	BaseConstructL();
    74 	BaseConstructL();
    62 	}
    75 	}
    63 
    76 
    64 
    77 
    65 CTestCase0469::~CTestCase0469()
    78 CTestCase0469::~CTestCase0469()
    66 	{
    79 	{
    67 	LOG_FUNC
    80 	if(gVerboseOutput)
       
    81 	    {
       
    82 	    OstTraceFunctionEntry0(CTESTCASE0469_DCTESTCASE0469);
       
    83 	    }
    68     iCollector.DestroyObservers();
    84     iCollector.DestroyObservers();
    69 	Cancel();
    85 	Cancel();
    70 	}
    86 	}
    71 
    87 
    72 
    88 
    73 void CTestCase0469::ExecuteTestCaseL()
    89 void CTestCase0469::ExecuteTestCaseL()
    74 	{
    90 	{
    75 	LOG_FUNC
    91 	if(gVerboseOutput)
       
    92 	    {
       
    93 	    OstTraceFunctionEntry0(CTESTCASE0469_EXECUTETESTCASEL);
       
    94 	    }
    76 	iCaseStep = EPreconditions;
    95 	iCaseStep = EPreconditions;
    77 	iRepeats = 3;
    96 	iRepeats = 3;
    78 	
    97 	
    79 	CActiveScheduler::Add(this);
    98 	CActiveScheduler::Add(this);
    80 	SelfComplete();
    99 	SelfComplete();
    81 	}
   100 	}
    82 
   101 
    83 	
   102 	
    84 void CTestCase0469::DoCancel()
   103 void CTestCase0469::DoCancel()
    85 	{
   104 	{
    86 	LOG_FUNC
   105 	if(gVerboseOutput)
       
   106 	    {
       
   107 	    OstTraceFunctionEntry0(CTESTCASE0469_DOCANCEL);
       
   108 	    }
    87 	// cancel our timer
   109 	// cancel our timer
    88 	iTimer.Cancel();
   110 	iTimer.Cancel();
    89 	}
   111 	}
    90 
   112 
    91 // handle event completion	
   113 // handle event completion	
    92 void CTestCase0469::RunStepL()
   114 void CTestCase0469::RunStepL()
    93 	{
   115 	{
    94 	LOG_FUNC
   116 	if(gVerboseOutput)
       
   117 	    {
       
   118 	    OstTraceFunctionEntry0(CTESTCASE0469_RUNSTEPL);
       
   119 	    }
    95 	// Obtain the completion code for this CActive obj.
   120 	// Obtain the completion code for this CActive obj.
    96 	TInt completionCode(iStatus.Int()); 
   121 	TInt completionCode(iStatus.Int()); 
    97 	TBuf<MAX_DSTRLEN> aDescription;
   122 	TBuf<MAX_DSTRLEN> aDescription;
    98     //	15 seconds, should be plenty of time for 3 cycles of plug pulling
   123     //	15 seconds, should be plenty of time for 3 cycles of plug pulling
    99     const TInt KTestCase0469Timeout = 15000;
   124     const TInt KTestCase0469Timeout = 15000;
   103     case EPreconditions:
   128     case EPreconditions:
   104         LOG_STEPNAME(_L("EPreconditions"))
   129         LOG_STEPNAME(_L("EPreconditions"))
   105         iCaseStep = ELoadLdd;
   130         iCaseStep = ELoadLdd;
   106         // prompt to insert connectors
   131         // prompt to insert connectors
   107         test.Printf(KInsertBCablePrompt);
   132         test.Printf(KInsertBCablePrompt);
       
   133         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP01, KInsertBCablePrompt);
   108         test.Printf(KRemoveAFromPC);
   134         test.Printf(KRemoveAFromPC);
       
   135         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP02, KRemoveAFromPC);
   109         test.Printf(KPressAnyKeyToContinue);
   136         test.Printf(KPressAnyKeyToContinue);
       
   137         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP03, KPressAnyKeyToContinue);
   110         RequestCharacter();			
   138         RequestCharacter();			
   111         break;
   139         break;
   112 			
   140 			
   113     case ELoadLdd:
   141     case ELoadLdd:
   114         LOG_STEPNAME(_L("ELoadLdd"))
   142         LOG_STEPNAME(_L("ELoadLdd"))
   147             return TestFailed(KErrAbort, _L("Timeout"));
   175             return TestFailed(KErrAbort, _L("Timeout"));
   148             }
   176             }
   149 
   177 
   150         if (iRepeats--)
   178         if (iRepeats--)
   151             {
   179             {
   152             RDebug::Printf("ELoopControl around again %d", iRepeats);
   180             OstTrace1(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP04, "ELoopControl around again %d", iRepeats);
   153             iCaseStep = ETestVbusRise;
   181             iCaseStep = ETestVbusRise;
   154             }
   182             }
   155         else
   183         else
   156             {
   184             {
   157             RDebug::Printf("ELoopControl we're done");
   185             OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP05, "ELoopControl we're done");
   158             iCaseStep = EUnloadLdd;
   186             iCaseStep = EUnloadLdd;
   159             }
   187             }
   160         SelfComplete();
   188         SelfComplete();
   161         break;
   189         break;
   162 
   190 
   170             }
   198             }
   171 
   199 
   172         iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised);
   200         iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised);
   173         iCaseStep = ETestVbusFall;
   201         iCaseStep = ETestVbusFall;
   174         test.Printf(KInsertAIntoPC);
   202         test.Printf(KInsertAIntoPC);
       
   203         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP06, KInsertAIntoPC);
   175         SetActive();
   204         SetActive();
   176         break;
   205         break;
   177 
   206 
   178     case ETestVbusFall:
   207     case ETestVbusFall:
   179         LOG_STEPNAME(_L("ETestVbusFall"))
   208         LOG_STEPNAME(_L("ETestVbusFall"))
   185             }
   214             }
   186 
   215 
   187         iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped);
   216         iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped);
   188         iCaseStep = ELoopControl;
   217         iCaseStep = ELoopControl;
   189         test.Printf(KRemoveAFromPC);
   218         test.Printf(KRemoveAFromPC);
       
   219         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP07, KRemoveAFromPC);
   190         SetActive();
   220         SetActive();
   191         break;
   221         break;
   192 
   222 
   193     case EUnloadLdd:
   223     case EUnloadLdd:
   194         LOG_STEPNAME(_L("EUnloadLdd"))
   224         LOG_STEPNAME(_L("EUnloadLdd"))
   195         iCollector.DestroyObservers();
   225         iCollector.DestroyObservers();
   196         RDebug::Printf("Destroyed observers");
   226         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP08, "Destroyed observers");
   197         if (EFalse == StepUnloadLDD())
   227         if (EFalse == StepUnloadLDD())
   198             return TestFailed(KErrAbort,_L("unload Ldd failure"));	
   228             return TestFailed(KErrAbort,_L("unload Ldd failure"));	
   199         RDebug::Printf("unloaded ldd");
   229         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP09, "unloaded ldd");
   200         if (!StepUnloadClient())
   230         if (!StepUnloadClient())
   201             return TestFailed(KErrAbort,_L("Client Unload Failure"));	
   231             return TestFailed(KErrAbort,_L("Client Unload Failure"));	
   202         RDebug::Printf("unloaded client");
   232         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP10, "unloaded client");
   203 
   233 
   204         iCaseStep = ELastStep;
   234         iCaseStep = ELastStep;
   205         SelfComplete();
   235         SelfComplete();
   206         break;
   236         break;
   207 			
   237 			
   210         TestPassed();
   240         TestPassed();
   211         break;
   241         break;
   212 			
   242 			
   213     default:
   243     default:
   214         test.Printf(_L("<Error> unknown test step"));
   244         test.Printf(_L("<Error> unknown test step"));
       
   245         OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP11, "<Error> unknown test step");
   215         Cancel();
   246         Cancel();
   216         return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   247         return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
   217 		}
   248 		}
   218 	}
   249 	}
   219 
   250