os/kernelhwsrv/kerneltest/e32test/usbho/t_otgdi/src/testcase0456.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 'A'
    16 // 
    17 //
    18 
    19 
    20 #include <e32std.h>
    21 #include <e32std_private.h>
    22 #include <u32std.h> 	// unicode builds
    23 #include <e32base.h>
    24 #include <e32base_private.h>
    25 #include <e32Test.h>	// RTest headder
    26 #include "testcaseroot.h"
    27 #include "testcasefactory.h"
    28 #include "testcase0456.h"
    29 
    30 
    31 
    32 
    33 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    34 // the class factory
    35 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0456");
    36 const TTestCaseFactoryReceipt<CTestCase0456> CTestCase0456::iFactoryReceipt(KTestCaseId);	
    37 
    38 
    39 CTestCase0456* CTestCase0456::NewL(TBool aHost)
    40 	{
    41 	LOG_FUNC
    42 	CTestCase0456* self = new (ELeave) CTestCase0456(aHost);
    43 	CleanupStack::PushL(self);
    44 	self->ConstructL();
    45 	CleanupStack::Pop(self);
    46 	return self;
    47 	}
    48 	
    49 
    50 CTestCase0456::CTestCase0456(TBool aHost)
    51 :	CTestCaseRoot(KTestCaseId, aHost)
    52 	{	
    53 	LOG_FUNC
    54 	} 
    55 
    56 
    57 /**
    58  ConstructL
    59 */
    60 void CTestCase0456::ConstructL()
    61 	{
    62 	LOG_FUNC
    63 	iRepeats = OPEN_REPEATS;
    64 	
    65 	BaseConstructL();
    66 	}
    67 
    68 
    69 CTestCase0456::~CTestCase0456()
    70 	{
    71 	LOG_FUNC
    72 
    73 	Cancel();
    74 	}
    75 
    76 
    77 void CTestCase0456::ExecuteTestCaseL()
    78 	{
    79 	LOG_FUNC
    80 	iCaseStep = EPreconditions;
    81 	
    82 	CActiveScheduler::Add(this);
    83 	SelfComplete();
    84 	}
    85 
    86 
    87 void CTestCase0456::DescribePreconditions()
    88 	{
    89 	test.Printf(_L("Insert A connector beforehand.\n"));
    90 	}
    91 
    92 	
    93 void CTestCase0456::DoCancel()
    94 	{
    95 	LOG_FUNC
    96 
    97 	// cancel our timer
    98 	iTimer.Cancel();
    99 	}
   100 
   101 
   102 // handle event completion	
   103 void CTestCase0456::RunStepL()
   104 	{
   105 	LOG_FUNC
   106 
   107 	// Obtain the completion code for this CActive obj.
   108 	TInt completionCode(iStatus.Int()); 
   109 	
   110 	switch(iCaseStep)
   111 		{
   112 		case EPreconditions:
   113 			{
   114 			test.Printf(KPressAnyKeyToStart);
   115 			iCaseStep = ELoadLdd;
   116 			RequestCharacter();			
   117 			break;			
   118 			}
   119 			
   120 		
   121 		case ELoadLdd:
   122 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
   123 			if (!StepLoadLDD())
   124 				{
   125 				break;
   126 				}
   127 
   128 			iCaseStep = EUnloadLdd;
   129 			SelfComplete();
   130 			break;
   131 		case EUnloadLdd:
   132 			if (EFalse == StepUnloadLDD())
   133 				return TestFailed(KErrAbort,_L("Unload Ldd failure"));	
   134 			
   135 			iCaseStep = ELoopDecrement;
   136 			SelfComplete();			
   137 			break;
   138 						
   139 		case ELoopDecrement:
   140 			test.Printf(_L("Repeat test\n"));
   141 
   142 			if (--iRepeats)
   143 				iCaseStep = ELoadLdd;
   144 			else
   145 				iCaseStep = ELastStep;
   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