os/kernelhwsrv/kerneltest/e32test/usbho/t_otgdi/src/testcase0670.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.
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
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include <e32std_private.h>
sl@0
    20
#include <u32std.h> 	// unicode builds
sl@0
    21
#include <e32base.h>
sl@0
    22
#include <e32base_private.h>
sl@0
    23
#include <e32Test.h>	// RTest headder
sl@0
    24
#include "testcaseroot.h"
sl@0
    25
#include "testcasewd.h"
sl@0
    26
#include "testcase0670.h"
sl@0
    27
sl@0
    28
sl@0
    29
sl@0
    30
// the name below is used to add a pointer to our construction method to a pointer MAP in 
sl@0
    31
// the class factory
sl@0
    32
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0670");
sl@0
    33
const TTestCaseFactoryReceipt<CTestCase0670> CTestCase0670::iFactoryReceipt(KTestCaseId);	
sl@0
    34
sl@0
    35
CTestCase0670* CTestCase0670::NewL(TBool aHost)
sl@0
    36
	{
sl@0
    37
	LOG_FUNC
sl@0
    38
	CTestCase0670* self = new (ELeave) CTestCase0670(aHost);
sl@0
    39
	CleanupStack::PushL(self);
sl@0
    40
	self->ConstructL();
sl@0
    41
	CleanupStack::Pop(self);
sl@0
    42
	return self;
sl@0
    43
	}
sl@0
    44
	
sl@0
    45
sl@0
    46
CTestCase0670::CTestCase0670(TBool aHost)
sl@0
    47
:	CTestCaseRoot(KTestCaseId, aHost)
sl@0
    48
	{
sl@0
    49
	LOG_FUNC
sl@0
    50
		
sl@0
    51
	} 
sl@0
    52
sl@0
    53
sl@0
    54
/**
sl@0
    55
 ConstructL
sl@0
    56
*/
sl@0
    57
void CTestCase0670::ConstructL()
sl@0
    58
	{
sl@0
    59
	iWDTimer = CTestCaseWatchdog::NewL();
sl@0
    60
	
sl@0
    61
	BaseConstructL();
sl@0
    62
	}
sl@0
    63
sl@0
    64
sl@0
    65
CTestCase0670::~CTestCase0670()
sl@0
    66
	{
sl@0
    67
sl@0
    68
	Cancel();
sl@0
    69
	delete iWDTimer;	
sl@0
    70
	}
sl@0
    71
sl@0
    72
sl@0
    73
void CTestCase0670::ExecuteTestCaseL()
sl@0
    74
	{
sl@0
    75
	iCaseStep = EPreconditions;	
sl@0
    76
	iRepeats = KOperationRetriesMax;	// VBus event rise retries
sl@0
    77
	CActiveScheduler::Add(this);
sl@0
    78
	SelfComplete();
sl@0
    79
sl@0
    80
	}
sl@0
    81
sl@0
    82
	
sl@0
    83
void CTestCase0670::DoCancel()
sl@0
    84
	{
sl@0
    85
	LOG_FUNC
sl@0
    86
sl@0
    87
	// cancel our timer
sl@0
    88
	iTimer.Cancel();
sl@0
    89
	}
sl@0
    90
sl@0
    91
sl@0
    92
void CTestCase0670::CancelKB(CTestCaseRoot *pThis)
sl@0
    93
	{
sl@0
    94
	CTestCase0670 * p = REINTERPRET_CAST(CTestCase0670 *,pThis);
sl@0
    95
	
sl@0
    96
	// cancel the pending call
sl@0
    97
	p->iConsole->ReadCancel();
sl@0
    98
	}
sl@0
    99
sl@0
   100
sl@0
   101
void CTestCase0670::CancelDrive(CTestCaseRoot *pThis)
sl@0
   102
	{
sl@0
   103
	CTestCase0670 * p = REINTERPRET_CAST(CTestCase0670 *,pThis);
sl@0
   104
	// cancel any pending call, and then complete our active obj with a timeout value
sl@0
   105
	p->SelfComplete(KTestCaseWatchdogTO);	
sl@0
   106
	}
sl@0
   107
sl@0
   108
sl@0
   109
void CTestCase0670::DescribePreconditions()
sl@0
   110
	{
sl@0
   111
	// H4 width     ****************************
sl@0
   112
	test.Printf(_L("***************************\n"));
sl@0
   113
	test.Printf(_L("* This test uses a Mini-A *\n"));
sl@0
   114
	test.Printf(_L("* to Mini-B cable to link *\n"));
sl@0
   115
	test.Printf(_L("* the H4 board to the OPT *\n"));
sl@0
   116
	test.Printf(_L("* and makes use of the    *\n"));
sl@0
   117
	test.Printf(_L("*  USB OPT test code      *\n"));
sl@0
   118
	test.Printf(_L("***************************\n"));
sl@0
   119
	}
sl@0
   120
sl@0
   121
sl@0
   122
// handle event completion	
sl@0
   123
void CTestCase0670::RunStepL()
sl@0
   124
	{
sl@0
   125
	LOG_FUNC
sl@0
   126
	// Obtain the completion code for this CActive obj.
sl@0
   127
	TInt completionCode(iStatus.Int()); 
sl@0
   128
	TBuf<MAX_DSTRLEN> aDescription;
sl@0
   129
		
sl@0
   130
	switch(iCaseStep)
sl@0
   131
		{
sl@0
   132
		case EPreconditions:
sl@0
   133
			if (iAutomated)
sl@0
   134
				{
sl@0
   135
				return TestFailed(KErrAbort,_L("This Test Cannot Run in Automated Mode"));
sl@0
   136
				}
sl@0
   137
			SelfComplete();
sl@0
   138
			iCaseStep = ELoadWithOptTestMode;
sl@0
   139
			break;
sl@0
   140
sl@0
   141
		case ELoadWithOptTestMode:
sl@0
   142
			if (!StepLoadClient(0x0670/*use default settings for SRP/HNP support*/))
sl@0
   143
				{
sl@0
   144
				return TestFailed(KErrAbort,_L("Client Load Failure"));
sl@0
   145
				}
sl@0
   146
			StepSetOptActive();
sl@0
   147
			if (!StepLoadLDD())
sl@0
   148
				{
sl@0
   149
				return TestFailed(KErrAbort,_L("OTG Load Failure"));
sl@0
   150
				}
sl@0
   151
			iCaseStep = EConnectAtoB;
sl@0
   152
			SelfComplete();
sl@0
   153
			break;
sl@0
   154
			
sl@0
   155
		case EConnectAtoB:
sl@0
   156
			// H4 width     ****************************
sl@0
   157
			test.Printf(_L("\n"));
sl@0
   158
			test.Printf(_L("***********************\n"));
sl@0
   159
//			WAIT_ON_KEYOP( "Connect H4(A) to OPT(B)\n");
sl@0
   160
			test.Printf(_L("Connect H4(A) to OPT(B)\n"));
sl@0
   161
			test.Printf(KPressAnyKeyToContinue);
sl@0
   162
sl@0
   163
			iCaseStep = EStartOptTD4_5;
sl@0
   164
			RequestCharacter();	
sl@0
   165
			break;
sl@0
   166
sl@0
   167
		case EStartOptTD4_5:
sl@0
   168
			// H4 width     ****************************
sl@0
   169
			test.Printf(_L("On the OPT, select:\n"));
sl@0
   170
			test.Printf(_L("  Certified FS-A-UUT Test\n"));
sl@0
   171
			test.Printf(_L("  Test TD.4.5-2.9ms-100ms\n"));
sl@0
   172
			test.Printf(_L("  And then Click 'Run' "));
sl@0
   173
			test.Printf(_L("  When test starts, press any key"));
sl@0
   174
			iCaseStep = EPromptYOpt4_5;
sl@0
   175
			RequestCharacter();	
sl@0
   176
			break;
sl@0
   177
sl@0
   178
		case EPromptYOpt4_5:
sl@0
   179
			iCaseStep = EConfirmOpt4_5;
sl@0
   180
			test.Printf(_L("Did it PASS (Y/N)?"));
sl@0
   181
			RequestCharacter(); // 30 seconds for user input
sl@0
   182
			iWDTimer->IssueRequest(KDelayDurationForTest4_5, this, &CancelKB);
sl@0
   183
			break;
sl@0
   184
sl@0
   185
		case EConfirmOpt4_5:
sl@0
   186
			// Check watchdog timeout, assume it failed
sl@0
   187
			if (KTestCaseWatchdogTO == iStatus.Int())
sl@0
   188
				{
sl@0
   189
									// H4 width  ****************************
sl@0
   190
				return TestFailed(KErrAbort, _L("OPT timeout - Test Failed"));
sl@0
   191
				}
sl@0
   192
			iWDTimer->Cancel();
sl@0
   193
sl@0
   194
			// Check user response, look only for 'Y'
sl@0
   195
			if (('y' == iKeyCodeInput) ||('Y' == iKeyCodeInput))
sl@0
   196
				{
sl@0
   197
				iCaseStep = EUnloadLdd;
sl@0
   198
				SelfComplete();
sl@0
   199
				}
sl@0
   200
			else
sl@0
   201
				{
sl@0
   202
				return TestFailed(KErrAbort, _L("TD.4.5 - FAILED!"));
sl@0
   203
				}
sl@0
   204
			break;
sl@0
   205
sl@0
   206
		case EUnloadLdd:
sl@0
   207
			// unload otg
sl@0
   208
			if (!StepUnloadLDD())
sl@0
   209
				{
sl@0
   210
				return TestFailed(KErrAbort,_L("OTG Unload Failure"));	
sl@0
   211
				}
sl@0
   212
			// unload client
sl@0
   213
			if (!StepUnloadClient())
sl@0
   214
				{
sl@0
   215
				return TestFailed(KErrAbort,_L("Client Unload Failure"));	
sl@0
   216
				}
sl@0
   217
			iCaseStep = ELastStep;
sl@0
   218
			SelfComplete();
sl@0
   219
			break;
sl@0
   220
sl@0
   221
		case ELastStep:
sl@0
   222
			TestPassed();
sl@0
   223
			break;
sl@0
   224
			
sl@0
   225
		default:
sl@0
   226
			test.Printf(_L("<Error> unknown test step"));
sl@0
   227
			Cancel();
sl@0
   228
			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
sl@0
   229
		}
sl@0
   230
	}
sl@0
   231