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