os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/inc/TestPolicy.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 #ifndef __TEST_POLICY_H
     2 #define __TEST_POLICY_H
     3 
     4 /*
     5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     6 * All rights reserved.
     7 * This component and the accompanying materials are made available
     8 * under the terms of the License "Eclipse Public License v1.0"
     9 * which accompanies this distribution, and is available
    10 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    11 *
    12 * Initial Contributors:
    13 * Nokia Corporation - initial contribution.
    14 *
    15 * Contributors:
    16 *
    17 * Description:
    18 * @file TestPolicy.h
    19 * @internalComponent
    20 * 
    21 *
    22 */
    23 
    24 
    25 
    26 #include <e32base.h>
    27 #include <d32usbdi_hubdriver.h>
    28 #include <e32test.h>
    29 
    30 extern RTest gtest;
    31 
    32 namespace NUnitTesting_USBDI
    33 	{
    34 
    35 // Forward declarations
    36 
    37 class CBaseTestCase;
    38 
    39 /**
    40 */
    41 class CBasicTestPolicy : public CActive
    42 	{
    43 public:
    44 	static CBasicTestPolicy* NewL();
    45 	
    46 	/**
    47 	Destructor
    48 	*/
    49 	
    50 	virtual ~CBasicTestPolicy();
    51 	
    52 	/**
    53 	Run the test case with the specified identity and receive notification of test case
    54 	success or failiure completion
    55 	@param aTestCaseId the identity of the test case to run
    56 	@param aStatus the request status of the entity that wants test case completion notification
    57 	*/
    58 	
    59 	virtual void RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aStatus);
    60 	
    61 	/**
    62 	*/
    63 	
    64 	virtual void SignalTestComplete(TInt aCompletionCode);
    65 
    66 protected:
    67 	CBasicTestPolicy();
    68 	void ConstructL();
    69 
    70 protected:
    71 	void DoCancel();
    72 	void RunL();
    73 	TInt RunError(TInt aError);
    74 
    75 protected: 
    76 	CBaseTestCase* iTestCase;
    77 	TRequestStatus* iNotifierStatus; 
    78 	};
    79 	
    80 /**
    81 */
    82 class CThreadTestPolicy : public CBasicTestPolicy
    83 	{
    84 public:
    85 	static CThreadTestPolicy* NewL();
    86 	
    87 	/**
    88 	Destructor
    89 	*/
    90 	
    91 	virtual ~CThreadTestPolicy();
    92 	
    93 	/**
    94 	Run the test case with the specified identity and receive notification of test case
    95 	success or failiure completion
    96 	@param aTestCaseId the identity of the test case to run
    97 	@param aStatus the request status of the entity that wants test case completion notification
    98 	*/
    99 	
   100 	virtual void RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aStatus);
   101 
   102 	/**
   103 	*/
   104 
   105 	virtual void SignalTestComplete(TInt aCompletionCode);
   106 	
   107 protected:
   108 	void DoCancel();
   109 	void RunL();
   110 	TInt RunError(TInt aError);
   111 
   112 private:
   113 	CThreadTestPolicy();
   114 
   115 	void ConstructL();
   116 	
   117 	static TInt ThreadFunction(TAny* aThreadParameter);
   118 	static TInt DoTestL(const TDesC& aTestCaseId);
   119 	
   120 private:
   121 	/**
   122 	Each test case executes its test code in a spawned thread, so iTestThread is 
   123 	the handle to the spawned test thread
   124 	*/
   125 	RThread iTestThread;
   126 	
   127 	HBufC* iTestCaseId;
   128 	};
   129 
   130 
   131 	}
   132 
   133 #endif