kerneltest/e32test/usbho/t_otgdi/src/testcase0457.cpp
changeset 0 a41df078684a
child 43 c1f20ce4abcf
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 'disconnected' 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 "testcase0457.h"
       
    27 
       
    28 
       
    29 
       
    30 // the name below is used to add a pointer to our construction method to a pointer MAP in 
       
    31 // the class factory
       
    32 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0457");
       
    33 const TTestCaseFactoryReceipt<CTestCase0457> CTestCase0457::iFactoryReceipt(KTestCaseId);	
       
    34 
       
    35 // # times to repeat the steps
       
    36 #define OPEN_REPEATS		gOpenIterations
       
    37 
       
    38 CTestCase0457* CTestCase0457::NewL(TBool aHost)
       
    39 	{
       
    40 	LOG_FUNC
       
    41 	CTestCase0457* self = new (ELeave) CTestCase0457(aHost);
       
    42 	CleanupStack::PushL(self);
       
    43 	self->ConstructL();
       
    44 	CleanupStack::Pop(self);
       
    45 	return self;
       
    46 	}
       
    47 	
       
    48 
       
    49 CTestCase0457::CTestCase0457(TBool aHost)
       
    50 :	CTestCaseRoot(KTestCaseId, aHost)
       
    51 	{	
       
    52 	LOG_FUNC
       
    53 	} 
       
    54 
       
    55 
       
    56 /**
       
    57  ConstructL
       
    58 */
       
    59 void CTestCase0457::ConstructL()
       
    60 	{
       
    61 	LOG_FUNC
       
    62 	iRepeats = OPEN_REPEATS;
       
    63 	
       
    64 	BaseConstructL();
       
    65 	}
       
    66 
       
    67 
       
    68 CTestCase0457::~CTestCase0457()
       
    69 	{
       
    70 	LOG_FUNC
       
    71 
       
    72 	Cancel();
       
    73 	}
       
    74 
       
    75 
       
    76 void CTestCase0457::ExecuteTestCaseL()
       
    77 	{
       
    78 	LOG_FUNC
       
    79 	iCaseStep = EPreconditions;
       
    80 	
       
    81 	CActiveScheduler::Add(this);
       
    82 	SelfComplete();
       
    83 	}
       
    84 
       
    85 
       
    86 void CTestCase0457::DescribePreconditions()
       
    87 	{
       
    88 	test.Printf(_L("Remove any USB plug beforehand.\n"));
       
    89 	}
       
    90 
       
    91 	
       
    92 void CTestCase0457::DoCancel()
       
    93 	{
       
    94 	LOG_FUNC
       
    95 
       
    96 	// cancel our timer
       
    97 	iTimer.Cancel();
       
    98 	}
       
    99 
       
   100 
       
   101 // handle event completion	
       
   102 void CTestCase0457::RunStepL()
       
   103 	{
       
   104 	LOG_FUNC
       
   105 
       
   106 	// Obtain the completion code for this CActive obj.
       
   107 	TInt completionCode(iStatus.Int()); 
       
   108 	
       
   109 	switch(iCaseStep)
       
   110 		{
       
   111 		case EPreconditions:
       
   112 			{
       
   113 			test.Printf(KPressAnyKeyToStart);
       
   114 			iCaseStep = ELoadLdd;
       
   115 			RequestCharacter();			
       
   116 			break;			
       
   117 			}
       
   118 
       
   119 		case ELoadLdd:
       
   120 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
       
   121 			if (!StepLoadLDD())
       
   122 				{
       
   123 				break;
       
   124 				}
       
   125 
       
   126 			iCaseStep = EUnloadLdd;
       
   127 			SelfComplete();
       
   128 			break;
       
   129 		case EUnloadLdd:
       
   130 			if (EFalse == StepUnloadLDD())
       
   131 				return TestFailed(KErrAbort,_L("Unload Ldd failure"));	
       
   132 			
       
   133 			iCaseStep = ELoopDecrement;
       
   134 			SelfComplete();			
       
   135 			break;
       
   136 						
       
   137 		case ELoopDecrement:
       
   138 			test.Printf(_L("Repeat test\n"));
       
   139 
       
   140 			if (--iRepeats)
       
   141 				iCaseStep = ELoadLdd;
       
   142 			else
       
   143 				iCaseStep = ELastStep;
       
   144 			SelfComplete();	
       
   145 		    break;
       
   146 		  
       
   147 		// Finnished 
       
   148 		case ELastStep:
       
   149 			// PASS
       
   150 			return TestPassed();
       
   151 
       
   152 			
       
   153 		default:
       
   154 			test.Printf(_L("<Error> unknown test step"));
       
   155 			Cancel();
       
   156 			TestPolicy().SignalTestComplete(KErrCorrupt);
       
   157 			break;
       
   158 		}
       
   159 		
       
   160 
       
   161 	}
       
   162 
       
   163