kerneltest/e32test/usbho/t_otgdi/src/testcase0458.cpp
changeset 0 a41df078684a
child 253 d37db4dcc88d
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @internalComponent
       
    15 // Open/Close 'powered peripheral' test
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32std_private.h>
       
    21 #include <u32std.h> 	// unicode builds
       
    22 #include <e32base.h>
       
    23 #include <e32base_private.h>
       
    24 #include <e32Test.h>	// RTest headder
       
    25 #include "testcaseroot.h"
       
    26 #include "testcase0458.h"
       
    27 
       
    28 
       
    29 
       
    30 
       
    31 // the name below is used to add a pointer to our construction method to a pointer MAP in 
       
    32 // the class factory
       
    33 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0458");
       
    34 const TTestCaseFactoryReceipt<CTestCase0458> CTestCase0458::iFactoryReceipt(KTestCaseId);	
       
    35 
       
    36 
       
    37 CTestCase0458* CTestCase0458::NewL(TBool aHost)
       
    38 	{
       
    39 	CTestCase0458* self = new (ELeave) CTestCase0458(aHost);
       
    40 	CleanupStack::PushL(self);
       
    41 	self->ConstructL();
       
    42 	CleanupStack::Pop(self);
       
    43 	return self;
       
    44 	}
       
    45 	
       
    46 
       
    47 CTestCase0458::CTestCase0458(TBool aHost)
       
    48 :	CTestCaseRoot(KTestCaseId, aHost)
       
    49 	{
       
    50 	} 
       
    51 
       
    52 
       
    53 /**
       
    54  ConstructL
       
    55 */
       
    56 void CTestCase0458::ConstructL()
       
    57 	{
       
    58 	LOG_FUNC
       
    59 	iRepeats = OPEN_REPEATS;
       
    60 	
       
    61 	BaseConstructL();
       
    62 	}
       
    63 
       
    64 
       
    65 CTestCase0458::~CTestCase0458()
       
    66 	{
       
    67 	LOG_FUNC
       
    68 
       
    69 	Cancel();
       
    70 	}
       
    71 
       
    72 
       
    73 void CTestCase0458::ExecuteTestCaseL()
       
    74 	{
       
    75 	LOG_FUNC
       
    76 	iCaseStep = EPreconditions;
       
    77 	
       
    78 	CActiveScheduler::Add(this);
       
    79 	SelfComplete();
       
    80 
       
    81 	}
       
    82 
       
    83 void CTestCase0458::DescribePreconditions()
       
    84 	{
       
    85 	test.Printf(_L("Insert 'B' connector from cable\n"));
       
    86 	test.Printf(_L("attached to powered host beforehand.\n"));
       
    87 	}
       
    88 
       
    89 	
       
    90 void CTestCase0458::DoCancel()
       
    91 	{
       
    92 	LOG_FUNC
       
    93 
       
    94 	// cancel our timer
       
    95 	iTimer.Cancel();
       
    96 	}
       
    97 
       
    98 
       
    99 // handle event completion	
       
   100 void CTestCase0458::RunStepL()
       
   101 	{
       
   102 	LOG_FUNC
       
   103 
       
   104 	// Obtain the completion code for this CActive obj.
       
   105 	TInt completionCode(iStatus.Int()); 
       
   106 	
       
   107 	switch(iCaseStep)
       
   108 		{
       
   109 		case EPreconditions:
       
   110 			{
       
   111 			test.Printf(KPressAnyKeyToStart);
       
   112 			iCaseStep = ELoadLdd;
       
   113 			RequestCharacter();			
       
   114 			break;			
       
   115 			}
       
   116 
       
   117 		case ELoadLdd:
       
   118 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
       
   119 			if (!StepLoadLDD())
       
   120 				{
       
   121 				break;
       
   122 				}
       
   123 
       
   124 			iCaseStep = EUnloadLdd;
       
   125 			SelfComplete();
       
   126 			break;
       
   127 		case EUnloadLdd:
       
   128 			if (EFalse == StepUnloadLDD())
       
   129 				return TestFailed(KErrAbort,_L("Unload Ldd failure"));	
       
   130 			
       
   131 			iCaseStep = ELoopDecrement;
       
   132 			SelfComplete();			
       
   133 			break;
       
   134 						
       
   135 		case ELoopDecrement:
       
   136 			test.Printf(_L("Repeat test\n"));
       
   137 
       
   138 			if (--iRepeats)
       
   139 				{
       
   140 				iCaseStep = ELoadLdd;
       
   141 				}
       
   142 			else
       
   143 				{
       
   144 				iCaseStep = ELastStep;
       
   145 				}
       
   146 			SelfComplete();	
       
   147 		    break;
       
   148 		  
       
   149 		// Finnished    
       
   150 		case ELastStep:
       
   151 			// PASS
       
   152 			return TestPassed();
       
   153 
       
   154 			
       
   155 		default:
       
   156 			test.Printf(_L("<Error> unknown test step"));
       
   157 			Cancel();
       
   158 			TestPolicy().SignalTestComplete(KErrCorrupt);
       
   159 			break;
       
   160 		}
       
   161 		
       
   162 	}
       
   163 
       
   164