kerneltest/e32test/usbho/t_otgdi/src/testcase0456.cpp
branchRCL_3
changeset 257 3e88ff8f41d5
parent 256 c1f20ce4abcf
equal deleted inserted replaced
256:c1f20ce4abcf 257:3e88ff8f41d5
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 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".
    24 #include <e32base_private.h>
    24 #include <e32base_private.h>
    25 #include <e32Test.h>	// RTest headder
    25 #include <e32Test.h>	// RTest headder
    26 #include "testcaseroot.h"
    26 #include "testcaseroot.h"
    27 #include "testcasefactory.h"
    27 #include "testcasefactory.h"
    28 #include "testcase0456.h"
    28 #include "testcase0456.h"
    29 #include "OstTraceDefinitions.h"
       
    30 #ifdef OST_TRACE_COMPILER_IN_USE
       
    31 #include "testcase0456Traces.h"
       
    32 #endif
       
    33 
    29 
    34 
    30 
    35 
    31 
    36 
    32 
    37 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    33 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    40 const TTestCaseFactoryReceipt<CTestCase0456> CTestCase0456::iFactoryReceipt(KTestCaseId);	
    36 const TTestCaseFactoryReceipt<CTestCase0456> CTestCase0456::iFactoryReceipt(KTestCaseId);	
    41 
    37 
    42 
    38 
    43 CTestCase0456* CTestCase0456::NewL(TBool aHost)
    39 CTestCase0456* CTestCase0456::NewL(TBool aHost)
    44 	{
    40 	{
    45 	if(gVerboseOutput)
    41 	LOG_FUNC
    46 	    {
       
    47 	    OstTraceFunctionEntry0(CTESTCASE0456_NEWL);
       
    48 	    }
       
    49 	CTestCase0456* self = new (ELeave) CTestCase0456(aHost);
    42 	CTestCase0456* self = new (ELeave) CTestCase0456(aHost);
    50 	CleanupStack::PushL(self);
    43 	CleanupStack::PushL(self);
    51 	self->ConstructL();
    44 	self->ConstructL();
    52 	CleanupStack::Pop(self);
    45 	CleanupStack::Pop(self);
    53 	return self;
    46 	return self;
    55 	
    48 	
    56 
    49 
    57 CTestCase0456::CTestCase0456(TBool aHost)
    50 CTestCase0456::CTestCase0456(TBool aHost)
    58 :	CTestCaseRoot(KTestCaseId, aHost)
    51 :	CTestCaseRoot(KTestCaseId, aHost)
    59 	{	
    52 	{	
    60 	if(gVerboseOutput)
    53 	LOG_FUNC
    61 	    {
       
    62 	    OstTraceFunctionEntry0(CTESTCASE0456_CTESTCASE0456);
       
    63 	    }
       
    64 	} 
    54 	} 
    65 
    55 
    66 
    56 
    67 /**
    57 /**
    68  ConstructL
    58  ConstructL
    69 */
    59 */
    70 void CTestCase0456::ConstructL()
    60 void CTestCase0456::ConstructL()
    71 	{
    61 	{
    72 	if(gVerboseOutput)
    62 	LOG_FUNC
    73 	    {
       
    74 	    OstTraceFunctionEntry0(CTESTCASE0456_CONSTRUCTL);
       
    75 	    }
       
    76 	iRepeats = OPEN_REPEATS;
    63 	iRepeats = OPEN_REPEATS;
    77 	
    64 	
    78 	BaseConstructL();
    65 	BaseConstructL();
    79 	}
    66 	}
    80 
    67 
    81 
    68 
    82 CTestCase0456::~CTestCase0456()
    69 CTestCase0456::~CTestCase0456()
    83 	{
    70 	{
    84 	if(gVerboseOutput)
    71 	LOG_FUNC
    85 	    {
       
    86 	    OstTraceFunctionEntry0(CTESTCASE0456_DCTESTCASE0456);
       
    87 	    }
       
    88 
    72 
    89 	Cancel();
    73 	Cancel();
    90 	}
    74 	}
    91 
    75 
    92 
    76 
    93 void CTestCase0456::ExecuteTestCaseL()
    77 void CTestCase0456::ExecuteTestCaseL()
    94 	{
    78 	{
    95 	if(gVerboseOutput)
    79 	LOG_FUNC
    96 	    {
       
    97 	    OstTraceFunctionEntry0(CTESTCASE0456_EXECUTETESTCASEL);
       
    98 	    }
       
    99 	iCaseStep = EPreconditions;
    80 	iCaseStep = EPreconditions;
   100 	
    81 	
   101 	CActiveScheduler::Add(this);
    82 	CActiveScheduler::Add(this);
   102 	SelfComplete();
    83 	SelfComplete();
   103 	}
    84 	}
   104 
    85 
   105 
    86 
   106 void CTestCase0456::DescribePreconditions()
    87 void CTestCase0456::DescribePreconditions()
   107 	{
    88 	{
   108 	test.Printf(_L("Insert A connector beforehand.\n"));
    89 	test.Printf(_L("Insert A connector beforehand.\n"));
   109 	OstTrace0(TRACE_NORMAL, CTESTCASE0456_DESCRIBEPRECONDITIONS, "Insert A connector beforehand.\n");
       
   110 	}
    90 	}
   111 
    91 
   112 	
    92 	
   113 void CTestCase0456::DoCancel()
    93 void CTestCase0456::DoCancel()
   114 	{
    94 	{
   115 	if(gVerboseOutput)
    95 	LOG_FUNC
   116 	    {
       
   117 	    OstTraceFunctionEntry0(CTESTCASE0456_DOCANCEL);
       
   118 	    }
       
   119 
    96 
   120 	// cancel our timer
    97 	// cancel our timer
   121 	iTimer.Cancel();
    98 	iTimer.Cancel();
   122 	}
    99 	}
   123 
   100 
   124 
   101 
   125 // handle event completion	
   102 // handle event completion	
   126 void CTestCase0456::RunStepL()
   103 void CTestCase0456::RunStepL()
   127 	{
   104 	{
   128 	if(gVerboseOutput)
   105 	LOG_FUNC
   129 	    {
       
   130 	    OstTraceFunctionEntry0(CTESTCASE0456_RUNSTEPL);
       
   131 	    }
       
   132 
   106 
   133 	// Obtain the completion code for this CActive obj.
   107 	// Obtain the completion code for this CActive obj.
   134 	TInt completionCode(iStatus.Int()); 
   108 	TInt completionCode(iStatus.Int()); 
   135 	
   109 	
   136 	switch(iCaseStep)
   110 	switch(iCaseStep)
   137 		{
   111 		{
   138 		case EPreconditions:
   112 		case EPreconditions:
   139 			{
   113 			{
   140 			test.Printf(KPressAnyKeyToStart);
   114 			test.Printf(KPressAnyKeyToStart);
   141 			OstTrace0(TRACE_NORMAL, CTESTCASE0456_RUNSTEPL_DUP01, KPressAnyKeyToStart);
       
   142 			iCaseStep = ELoadLdd;
   115 			iCaseStep = ELoadLdd;
   143 			RequestCharacter();			
   116 			RequestCharacter();			
   144 			break;			
   117 			break;			
   145 			}
   118 			}
   146 			
   119 			
   147 		
   120 		
   148 		case ELoadLdd:
   121 		case ELoadLdd:
   149 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
   122 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
   150 			OstTraceExt2(TRACE_NORMAL, CTESTCASE0456_RUNSTEPL_DUP02, "Load the LDD iteration %d/%d\n", OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
       
   151 			if (!StepLoadLDD())
   123 			if (!StepLoadLDD())
   152 				{
   124 				{
   153 				break;
   125 				break;
   154 				}
   126 				}
   155 
   127 
   164 			SelfComplete();			
   136 			SelfComplete();			
   165 			break;
   137 			break;
   166 						
   138 						
   167 		case ELoopDecrement:
   139 		case ELoopDecrement:
   168 			test.Printf(_L("Repeat test\n"));
   140 			test.Printf(_L("Repeat test\n"));
   169 			OstTrace0(TRACE_NORMAL, CTESTCASE0456_RUNSTEPL_DUP03, "Repeat test\n");
       
   170 
   141 
   171 			if (--iRepeats)
   142 			if (--iRepeats)
   172 				iCaseStep = ELoadLdd;
   143 				iCaseStep = ELoadLdd;
   173 			else
   144 			else
   174 				iCaseStep = ELastStep;
   145 				iCaseStep = ELastStep;
   181 			return TestPassed();
   152 			return TestPassed();
   182 
   153 
   183 			
   154 			
   184 		default:
   155 		default:
   185 			test.Printf(_L("<Error> unknown test step"));
   156 			test.Printf(_L("<Error> unknown test step"));
   186 			OstTrace0(TRACE_NORMAL, CTESTCASE0456_RUNSTEPL_DUP04, "<Error> unknown test step");
       
   187 			Cancel();
   157 			Cancel();
   188 			TestPolicy().SignalTestComplete(KErrCorrupt);
   158 			TestPolicy().SignalTestComplete(KErrCorrupt);
   189 			break;
   159 			break;
   190 		}
   160 		}
   191 		
   161