kerneltest/e32test/usbho/t_otgdi/src/testcase0457.cpp
changeset 253 d37db4dcc88d
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
252:0a40b8675b23 253:d37db4dcc88d
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 #include <e32base.h>
    22 #include <e32base.h>
    23 #include <e32base_private.h>
    23 #include <e32base_private.h>
    24 #include <e32Test.h>	// RTest headder
    24 #include <e32Test.h>	// RTest headder
    25 #include "testcaseroot.h"
    25 #include "testcaseroot.h"
    26 #include "testcase0457.h"
    26 #include "testcase0457.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "testcase0457Traces.h"
       
    30 #endif
    27 
    31 
    28 
    32 
    29 
    33 
    30 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    34 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    31 // the class factory
    35 // the class factory
    35 // # times to repeat the steps
    39 // # times to repeat the steps
    36 #define OPEN_REPEATS		gOpenIterations
    40 #define OPEN_REPEATS		gOpenIterations
    37 
    41 
    38 CTestCase0457* CTestCase0457::NewL(TBool aHost)
    42 CTestCase0457* CTestCase0457::NewL(TBool aHost)
    39 	{
    43 	{
    40 	LOG_FUNC
    44 	if(gVerboseOutput)
       
    45 	    {
       
    46 	    OstTraceFunctionEntry0(CTESTCASE0457_NEWL);
       
    47 	    }
    41 	CTestCase0457* self = new (ELeave) CTestCase0457(aHost);
    48 	CTestCase0457* self = new (ELeave) CTestCase0457(aHost);
    42 	CleanupStack::PushL(self);
    49 	CleanupStack::PushL(self);
    43 	self->ConstructL();
    50 	self->ConstructL();
    44 	CleanupStack::Pop(self);
    51 	CleanupStack::Pop(self);
    45 	return self;
    52 	return self;
    47 	
    54 	
    48 
    55 
    49 CTestCase0457::CTestCase0457(TBool aHost)
    56 CTestCase0457::CTestCase0457(TBool aHost)
    50 :	CTestCaseRoot(KTestCaseId, aHost)
    57 :	CTestCaseRoot(KTestCaseId, aHost)
    51 	{	
    58 	{	
    52 	LOG_FUNC
    59 	if(gVerboseOutput)
       
    60 	    {
       
    61 	    OstTraceFunctionEntry0(CTESTCASE0457_CTESTCASE0457);
       
    62 	    }
    53 	} 
    63 	} 
    54 
    64 
    55 
    65 
    56 /**
    66 /**
    57  ConstructL
    67  ConstructL
    58 */
    68 */
    59 void CTestCase0457::ConstructL()
    69 void CTestCase0457::ConstructL()
    60 	{
    70 	{
    61 	LOG_FUNC
    71 	if(gVerboseOutput)
       
    72 	    {
       
    73 	    OstTraceFunctionEntry0(CTESTCASE0457_CONSTRUCTL);
       
    74 	    }
    62 	iRepeats = OPEN_REPEATS;
    75 	iRepeats = OPEN_REPEATS;
    63 	
    76 	
    64 	BaseConstructL();
    77 	BaseConstructL();
    65 	}
    78 	}
    66 
    79 
    67 
    80 
    68 CTestCase0457::~CTestCase0457()
    81 CTestCase0457::~CTestCase0457()
    69 	{
    82 	{
    70 	LOG_FUNC
    83 	if(gVerboseOutput)
       
    84 	    {
       
    85 	    OstTraceFunctionEntry0(CTESTCASE0457_DCTESTCASE0457);
       
    86 	    }
    71 
    87 
    72 	Cancel();
    88 	Cancel();
    73 	}
    89 	}
    74 
    90 
    75 
    91 
    76 void CTestCase0457::ExecuteTestCaseL()
    92 void CTestCase0457::ExecuteTestCaseL()
    77 	{
    93 	{
    78 	LOG_FUNC
    94 	if(gVerboseOutput)
       
    95 	    {
       
    96 	    OstTraceFunctionEntry0(CTESTCASE0457_EXECUTETESTCASEL);
       
    97 	    }
    79 	iCaseStep = EPreconditions;
    98 	iCaseStep = EPreconditions;
    80 	
    99 	
    81 	CActiveScheduler::Add(this);
   100 	CActiveScheduler::Add(this);
    82 	SelfComplete();
   101 	SelfComplete();
    83 	}
   102 	}
    84 
   103 
    85 
   104 
    86 void CTestCase0457::DescribePreconditions()
   105 void CTestCase0457::DescribePreconditions()
    87 	{
   106 	{
    88 	test.Printf(_L("Remove any USB plug beforehand.\n"));
   107 	test.Printf(_L("Remove any USB plug beforehand.\n"));
       
   108 	OstTrace0(TRACE_NORMAL, CTESTCASE0457_DESCRIBEPRECONDITIONS, "Remove any USB plug beforehand.\n");
    89 	}
   109 	}
    90 
   110 
    91 	
   111 	
    92 void CTestCase0457::DoCancel()
   112 void CTestCase0457::DoCancel()
    93 	{
   113 	{
    94 	LOG_FUNC
   114 	if(gVerboseOutput)
       
   115 	    {
       
   116 	    OstTraceFunctionEntry0(CTESTCASE0457_DOCANCEL);
       
   117 	    }
    95 
   118 
    96 	// cancel our timer
   119 	// cancel our timer
    97 	iTimer.Cancel();
   120 	iTimer.Cancel();
    98 	}
   121 	}
    99 
   122 
   100 
   123 
   101 // handle event completion	
   124 // handle event completion	
   102 void CTestCase0457::RunStepL()
   125 void CTestCase0457::RunStepL()
   103 	{
   126 	{
   104 	LOG_FUNC
   127 	if(gVerboseOutput)
       
   128 	    {
       
   129 	    OstTraceFunctionEntry0(CTESTCASE0457_RUNSTEPL);
       
   130 	    }
   105 
   131 
   106 	// Obtain the completion code for this CActive obj.
   132 	// Obtain the completion code for this CActive obj.
   107 	TInt completionCode(iStatus.Int()); 
   133 	TInt completionCode(iStatus.Int()); 
   108 	
   134 	
   109 	switch(iCaseStep)
   135 	switch(iCaseStep)
   110 		{
   136 		{
   111 		case EPreconditions:
   137 		case EPreconditions:
   112 			{
   138 			{
   113 			test.Printf(KPressAnyKeyToStart);
   139 			test.Printf(KPressAnyKeyToStart);
       
   140 			OstTrace0(TRACE_NORMAL, CTESTCASE0457_RUNSTEPL_DUP01, KPressAnyKeyToStart);
   114 			iCaseStep = ELoadLdd;
   141 			iCaseStep = ELoadLdd;
   115 			RequestCharacter();			
   142 			RequestCharacter();			
   116 			break;			
   143 			break;			
   117 			}
   144 			}
   118 
   145 
   119 		case ELoadLdd:
   146 		case ELoadLdd:
   120 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
   147 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
       
   148 			OstTraceExt2(TRACE_NORMAL, CTESTCASE0457_RUNSTEPL_DUP02, "Load the LDD iteration %d/%d\n", OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
   121 			if (!StepLoadLDD())
   149 			if (!StepLoadLDD())
   122 				{
   150 				{
   123 				break;
   151 				break;
   124 				}
   152 				}
   125 
   153 
   134 			SelfComplete();			
   162 			SelfComplete();			
   135 			break;
   163 			break;
   136 						
   164 						
   137 		case ELoopDecrement:
   165 		case ELoopDecrement:
   138 			test.Printf(_L("Repeat test\n"));
   166 			test.Printf(_L("Repeat test\n"));
       
   167 			OstTrace0(TRACE_NORMAL, CTESTCASE0457_RUNSTEPL_DUP03, "Repeat test\n");
   139 
   168 
   140 			if (--iRepeats)
   169 			if (--iRepeats)
   141 				iCaseStep = ELoadLdd;
   170 				iCaseStep = ELoadLdd;
   142 			else
   171 			else
   143 				iCaseStep = ELastStep;
   172 				iCaseStep = ELastStep;
   150 			return TestPassed();
   179 			return TestPassed();
   151 
   180 
   152 			
   181 			
   153 		default:
   182 		default:
   154 			test.Printf(_L("<Error> unknown test step"));
   183 			test.Printf(_L("<Error> unknown test step"));
       
   184 			OstTrace0(TRACE_NORMAL, CTESTCASE0457_RUNSTEPL_DUP04, "<Error> unknown test step");
   155 			Cancel();
   185 			Cancel();
   156 			TestPolicy().SignalTestComplete(KErrCorrupt);
   186 			TestPolicy().SignalTestComplete(KErrCorrupt);
   157 			break;
   187 			break;
   158 		}
   188 		}
   159 		
   189