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