lowlevellibsandfws/pluginfw/Test_Bed/UnitTestTest/UnitTestStateAccessor.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // The definition of the accessor class upon the CUnitTest
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __UNITTESTSTATEACCESSOR_H__
       
    19 #define __UNITTESTSTATEACCESSOR_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <f32file.h>
       
    23 #include <s32stor.h>
       
    24 #include <s32file.h>
       
    25 
       
    26 #include "TestUtilities.h"
       
    27 #include <ecom/test_bed/testbeddefinitions.h>
       
    28 #include "StateAccessor.h"
       
    29 #include <ecom/test_bed/unittest.h>
       
    30 
       
    31 
       
    32 class CUnitTestTestDerivation : public CUnitTest
       
    33 	{
       
    34 public:
       
    35 	inline CUnitTestTestDerivation(const TDesC& aName, CDataLogger& aDataLogger, MUnitTestObserver& aUnitTestObserver);
       
    36 
       
    37 	inline void ConstructL();
       
    38 	};
       
    39 
       
    40 // ______________________________________________________________________________
       
    41 //
       
    42 /**
       
    43 	@internalComponent
       
    44 	
       
    45 	Comments : State accessor for the CUnitTest object under test.
       
    46  */
       
    47 class TUnitTest_StateAccessor : public MStateAccessor
       
    48 	{
       
    49 public:
       
    50 	/**
       
    51 		@fn				InvariantTest(TAny* aTestObject)
       
    52 		Intended Usage	: Checks for Incariant violation by the CUnitTest class.
       
    53 		@since			7.0
       
    54 		@param			TAny* A pointer to the object under test.
       
    55 		@return			TInt KErrNone if the invariants were valid, error code otherwise.
       
    56 		@pre 			TUnitTest_StateAccessor is fully constructed.
       
    57 		@post			The class under test is set to the state specified.
       
    58 	 */
       
    59 	inline TInt InvariantTest(TAny* aTestObject);
       
    60 
       
    61 	/**
       
    62 		@fn				Internalize(TAny* aTestObject)
       
    63 		Intended Usage	: Implemented by the developer to set the state of the object under test.
       
    64 		@since			7.0
       
    65 		@param			aTestObject The object to be tested
       
    66 		@return			KErrNone if the internalize was successful.
       
    67 		@return			One of the EPOC standard error codes indicating the reason
       
    68 						for the failure	to load the object state.
       
    69 		@pre 			TUnitTest_StateAccessor is fully constructed, and
       
    70 						valid test object must be passed in.
       
    71 		@post			The class under test is set to the state specified
       
    72 	 */
       
    73 	inline virtual TInt Internalize(TAny* aTestObject);
       
    74 
       
    75 	/**
       
    76 		@fn				Externalize(TAny* aTestObject)
       
    77 		Intended Usage	: Implemented by the developer to persist the state of the object under test.
       
    78 		@since			7.0
       
    79 		@param			aTestObject The object to be tested
       
    80 		@return			KErrNone if the internalize was successful.
       
    81 		@return			One of the EPOC standard error codes indicating the reason
       
    82 						for the failure	to externalize the object.
       
    83 		@pre 			TUnitTest_StateAccessor is fully constructed, and
       
    84 						valid test object must be passed in.
       
    85 		@post			Returns an error code dependant on the result of the test
       
    86 	 */
       
    87 	inline virtual TInt Externalize(TAny* aTestObject);
       
    88 
       
    89 	/**
       
    90 		@fn				InternalizeL(RFileReadStream& aStream, CUnitTest* aUnitTest)
       
    91 		Intended Usage	: Implemented by the developer to set the state of the object under test.
       
    92 		Error Condition	: Leaves with an error code.
       
    93 		@since			7.0
       
    94 		@param			aStream The filestream to read from .
       
    95 		@param			aUnitTest A pointer to the CUnitTest object under test.
       
    96 		@return			None.
       
    97 		@pre 			TUnitTest_StateAccessor is fully constructed.
       
    98 		@post			The class under test is set to the state specified.
       
    99 	 */
       
   100 		inline void InternalizeL(RFileReadStream& aStream, CUnitTest* aUnitTest);
       
   101 
       
   102 	/**
       
   103 		@fn				ExternalizeL(RFileWriteStream& aStream, CUnitTest* aUnitTest)
       
   104 		Intended Usage	: Implemented by the developer to persist the state of the object under test.
       
   105 		Error Condition	: Leaves with an error code.
       
   106 		@since			7.0
       
   107 		@param			aStream The filestream to persist into.
       
   108 		@param			aUnitTest A pointer to the CUnitTest object under test.
       
   109 		@return			None.
       
   110 		@pre 			TUnitTest_StateAccessor is fully constructed.
       
   111 		@post			No change to the class under test, its internal state.
       
   112 						is persisted.
       
   113 	*/
       
   114 	inline void ExternalizeL(RFileWriteStream& aStream, CUnitTest* aUnitTest);
       
   115 
       
   116 	inline CUnitTestTestDerivation* CreateUnitTest(CUnitTest& aUnitTest, const TDesC& aName, CDataLogger& aDataLogger, MUnitTestObserver& aUnitTestObserver);
       
   117 
       
   118 	inline void RunL(CUnitTest& aUnitTest);
       
   119 
       
   120 	inline void AddTransitionL(CUnitTest& aUnitTest, CTransition* aTransition);
       
   121 
       
   122 	inline void AddBlockingTransitionL(CUnitTest& aUnitTest, CTransition* aTransition);
       
   123 
       
   124 	inline void AddLeaveErrorCodeL(CUnitTest& aUnitTest, TInt& aLeaveErrorCode);
       
   125 
       
   126 private:
       
   127 	/**
       
   128 		@fn				InternalizeL(CUnitTest* aUnitTest)
       
   129 		Intended Usage	: Implemented by the developer to set the state of the object under test.
       
   130 		Error Condition	: Leaves with an error code.
       
   131 		@since			7.0
       
   132 		@param			TAny* A pointer to the object under test.
       
   133 		@return			None.
       
   134 		@pre 			TUnitTest_StateAccessor is fully constructed.
       
   135 		@post			The class under test is set to the state specified.
       
   136 	*/
       
   137 	inline void InternalizeL(CUnitTest* aUnitTest);
       
   138 
       
   139 	/**
       
   140 		@fn				ExternalizeL(CUnitTest* aUnitTest)
       
   141 		Intended Usage	: Implemented by the developer to persist the state of the object under test.
       
   142 		Error Condition	: Leaves with an error code.
       
   143 		@since			7.0
       
   144 		@param			TAny* A pointer to the object under test.
       
   145 		@return			None.
       
   146 		@pre 			TUnitTest_StateAccessor is fully constructed.
       
   147 		@post			No change to the class under test, its internal state.
       
   148 						is persisted.
       
   149 	*/
       
   150 	inline void ExternalizeL(CUnitTest* aUnitTest);
       
   151 	};	// TUnitTest_StateAccessor
       
   152 
       
   153 #include "UnitTestStateAccessor.inl"
       
   154 
       
   155 #endif // __UNITTESTSTATEACCESSOR_H__
       
   156