kerneltest/e32test/usbho/t_otgdi/src/testcase0463.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".
    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 "testcase0463.h"
    26 #include "testcase0463.h"
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "testcase0463Traces.h"
       
    30 #endif
       
    31 
    27 
    32 
    28 
    33 
    29 
    34 
    30 
    35 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    31 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    38 const TTestCaseFactoryReceipt<CTestCase0463> CTestCase0463::iFactoryReceipt(KTestCaseId);	
    34 const TTestCaseFactoryReceipt<CTestCase0463> CTestCase0463::iFactoryReceipt(KTestCaseId);	
    39 
    35 
    40 
    36 
    41 CTestCase0463* CTestCase0463::NewL(TBool aHost)
    37 CTestCase0463* CTestCase0463::NewL(TBool aHost)
    42 	{
    38 	{
    43 	if(gVerboseOutput)
    39 	LOG_FUNC
    44 	    {
       
    45 	    OstTraceFunctionEntry0(CTESTCASE0463_NEWL);
       
    46 	    }
       
    47 	CTestCase0463* self = new (ELeave) CTestCase0463(aHost);
    40 	CTestCase0463* self = new (ELeave) CTestCase0463(aHost);
    48 	CleanupStack::PushL(self);
    41 	CleanupStack::PushL(self);
    49 	self->ConstructL();
    42 	self->ConstructL();
    50 	CleanupStack::Pop(self);
    43 	CleanupStack::Pop(self);
    51 	return self;
    44 	return self;
    53 	
    46 	
    54 
    47 
    55 CTestCase0463::CTestCase0463(TBool aHost)
    48 CTestCase0463::CTestCase0463(TBool aHost)
    56 :	CTestCaseRoot(KTestCaseId, aHost)
    49 :	CTestCaseRoot(KTestCaseId, aHost)
    57 	{	
    50 	{	
    58 	if(gVerboseOutput)
    51 	LOG_FUNC
    59 	    {
       
    60 	    OstTraceFunctionEntry0(CTESTCASE0463_CTESTCASE0463);
       
    61 	    }
       
    62 	} 
    52 	} 
    63 
    53 
    64 
    54 
    65 /**
    55 /**
    66  ConstructL
    56  ConstructL
    67 */
    57 */
    68 void CTestCase0463::ConstructL()
    58 void CTestCase0463::ConstructL()
    69 	{
    59 	{
    70 	if(gVerboseOutput)
    60 	LOG_FUNC
    71 	    {
       
    72 	    OstTraceFunctionEntry0(CTESTCASE0463_CONSTRUCTL);
       
    73 	    }
       
    74 	iRepeats = OOMOPEN_REPEATS;
    61 	iRepeats = OOMOPEN_REPEATS;
    75 	iAllocFailNumber = OOMOPEN_REPEATS + 1; // allocs 1..11 fail
    62 	iAllocFailNumber = OOMOPEN_REPEATS + 1; // allocs 1..11 fail
    76 	
    63 	
    77 	BaseConstructL();
    64 	BaseConstructL();
    78 	}
    65 	}
    79 
    66 
    80 
    67 
    81 CTestCase0463::~CTestCase0463()
    68 CTestCase0463::~CTestCase0463()
    82 	{
    69 	{
    83 	if(gVerboseOutput)
    70 	LOG_FUNC
    84 	    {
       
    85 	    OstTraceFunctionEntry0(CTESTCASE0463_DCTESTCASE0463);
       
    86 	    }
       
    87 
    71 
    88 	Cancel();
    72 	Cancel();
    89 	}
    73 	}
    90 
    74 
    91 
    75 
    92 void CTestCase0463::ExecuteTestCaseL()
    76 void CTestCase0463::ExecuteTestCaseL()
    93 	{
    77 	{
    94 	if(gVerboseOutput)
    78 	LOG_FUNC
    95 	    {
       
    96 	    OstTraceFunctionEntry0(CTESTCASE0463_EXECUTETESTCASEL);
       
    97 	    }
       
    98 	iCaseStep = EMarkStack;
    79 	iCaseStep = EMarkStack;
    99 	CActiveScheduler::Add(this);
    80 	CActiveScheduler::Add(this);
   100 
    81 
   101 	SelfComplete();
    82 	SelfComplete();
   102 	
    83 	
   103 	}
    84 	}
   104 
    85 
   105 void CTestCase0463::DescribePreconditions()
    86 void CTestCase0463::DescribePreconditions()
   106 	{
    87 	{
   107 	test.Printf(_L("Insert A connector beforehand.\n"));
    88 	test.Printf(_L("Insert A connector beforehand.\n"));
   108 	OstTrace0(TRACE_NORMAL, CTESTCASE0463_DESCRIBEPRECONDITIONS, "Insert A connector beforehand.\n");
       
   109 	}
    89 	}
   110 
    90 
   111 	
    91 	
   112 void CTestCase0463::DoCancel()
    92 void CTestCase0463::DoCancel()
   113 	{
    93 	{
   114 	if(gVerboseOutput)
    94 	LOG_FUNC
   115 	    {
       
   116 	    OstTraceFunctionEntry0(CTESTCASE0463_DOCANCEL);
       
   117 	    }
       
   118 
    95 
   119 	// cancel our timer
    96 	// cancel our timer
   120 	iTimer.Cancel();
    97 	iTimer.Cancel();
   121 	}
    98 	}
   122 
    99 
   123 
   100 
   124 // handle event completion	
   101 // handle event completion	
   125 void CTestCase0463::RunStepL()
   102 void CTestCase0463::RunStepL()
   126 	{
   103 	{
   127 	if(gVerboseOutput)
   104 	LOG_FUNC
   128 	    {
       
   129 	    OstTraceFunctionEntry0(CTESTCASE0463_RUNSTEPL);
       
   130 	    }
       
   131 
   105 
   132 	// Obtain the completion code for this CActive obj.
   106 	// Obtain the completion code for this CActive obj.
   133 	TInt completionCode(iStatus.Int()); 
   107 	TInt completionCode(iStatus.Int()); 
   134 	
   108 	
   135 	switch(iCaseStep)
   109 	switch(iCaseStep)
   141 			
   115 			
   142 		case ELoadLdd:
   116 		case ELoadLdd:
   143 			__UHEAP_SETFAIL(RHeap::EDeterministic, iAllocFailNumber);
   117 			__UHEAP_SETFAIL(RHeap::EDeterministic, iAllocFailNumber);
   144 			__UHEAP_MARK;
   118 			__UHEAP_MARK;
   145 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS);
   119 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS);
   146 			OstTraceExt2(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP01, "Load the LDD iteration %d/%d\n", OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS);
       
   147 			aIntegerP = new TInt;
   120 			aIntegerP = new TInt;
   148 			CleanupStack::PushL(aIntegerP);
   121 			CleanupStack::PushL(aIntegerP);
   149 			if (!StepLoadLDD())
   122 			if (!StepLoadLDD())
   150 				{
   123 				{
   151 				break;
   124 				break;
   168 		case EUnloadLdd:
   141 		case EUnloadLdd:
   169 			if (EFalse == StepUnloadLDD())
   142 			if (EFalse == StepUnloadLDD())
   170 				return TestFailed(KErrAbort,_L("Unload Ldd failure"));	
   143 				return TestFailed(KErrAbort,_L("Unload Ldd failure"));	
   171 			__UHEAP_MARKEND;
   144 			__UHEAP_MARKEND;
   172 			test.Printf(_L("Heap intact: Asize %d\n"), iAllocFailNumber);
   145 			test.Printf(_L("Heap intact: Asize %d\n"), iAllocFailNumber);
   173 			OstTrace1(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP03, "Heap intact: Asize %d\n", iAllocFailNumber);
       
   174 			iCaseStep = ELoopDecrement;
   146 			iCaseStep = ELoopDecrement;
   175 			SelfComplete();			
   147 			SelfComplete();			
   176 			break;
   148 			break;
   177 						
   149 						
   178 		case ELoopDecrement:
   150 		case ELoopDecrement:
   179 			test.Printf(_L("Repeat test\n"));
   151 			test.Printf(_L("Repeat test\n"));
   180 			OstTrace0(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP04, "Repeat test\n");
       
   181 			__UHEAP_RESET;
   152 			__UHEAP_RESET;
   182 			iAllocFailNumber--;
   153 			iAllocFailNumber--;
   183 			
   154 			
   184 			if (iRepeats--)
   155 			if (iRepeats--)
   185 				iCaseStep = ELoadLdd;
   156 				iCaseStep = ELoadLdd;
   193 			TestPolicy().SignalTestComplete(KErrNone);
   164 			TestPolicy().SignalTestComplete(KErrNone);
   194 			break;
   165 			break;
   195 			
   166 			
   196 		default:
   167 		default:
   197 			test.Printf(_L("<Error> unknown test step"));
   168 			test.Printf(_L("<Error> unknown test step"));
   198 			OstTrace0(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP05, "<Error> unknown test step");
       
   199 			Cancel();
   169 			Cancel();
   200 			TestPolicy().SignalTestComplete(KErrCorrupt);
   170 			TestPolicy().SignalTestComplete(KErrCorrupt);
   201 			break;
   171 			break;
   202 		}
   172 		}
   203 	}
   173 	}