sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // The definition of the accessor class upon the CUnitTest
sl@0: // 
sl@0: //
sl@0: 
sl@0: #ifndef __UNITTESTSTATEACCESSOR_H__
sl@0: #define __UNITTESTSTATEACCESSOR_H__
sl@0: 
sl@0: #include <e32base.h>
sl@0: #include <f32file.h>
sl@0: #include <s32stor.h>
sl@0: #include <s32file.h>
sl@0: 
sl@0: #include "TestUtilities.h"
sl@0: #include <ecom/test_bed/testbeddefinitions.h>
sl@0: #include "StateAccessor.h"
sl@0: #include <ecom/test_bed/unittest.h>
sl@0: 
sl@0: 
sl@0: class CUnitTestTestDerivation : public CUnitTest
sl@0: 	{
sl@0: public:
sl@0: 	inline CUnitTestTestDerivation(const TDesC& aName, CDataLogger& aDataLogger, MUnitTestObserver& aUnitTestObserver);
sl@0: 
sl@0: 	inline void ConstructL();
sl@0: 	};
sl@0: 
sl@0: // ______________________________________________________________________________
sl@0: //
sl@0: /**
sl@0: 	@internalComponent
sl@0: 	
sl@0: 	Comments : State accessor for the CUnitTest object under test.
sl@0:  */
sl@0: class TUnitTest_StateAccessor : public MStateAccessor
sl@0: 	{
sl@0: public:
sl@0: 	/**
sl@0: 		@fn				InvariantTest(TAny* aTestObject)
sl@0: 		Intended Usage	: Checks for Incariant violation by the CUnitTest class.
sl@0: 		@since			7.0
sl@0: 		@param			TAny* A pointer to the object under test.
sl@0: 		@return			TInt KErrNone if the invariants were valid, error code otherwise.
sl@0: 		@pre 			TUnitTest_StateAccessor is fully constructed.
sl@0: 		@post			The class under test is set to the state specified.
sl@0: 	 */
sl@0: 	inline TInt InvariantTest(TAny* aTestObject);
sl@0: 
sl@0: 	/**
sl@0: 		@fn				Internalize(TAny* aTestObject)
sl@0: 		Intended Usage	: Implemented by the developer to set the state of the object under test.
sl@0: 		@since			7.0
sl@0: 		@param			aTestObject The object to be tested
sl@0: 		@return			KErrNone if the internalize was successful.
sl@0: 		@return			One of the EPOC standard error codes indicating the reason
sl@0: 						for the failure	to load the object state.
sl@0: 		@pre 			TUnitTest_StateAccessor is fully constructed, and
sl@0: 						valid test object must be passed in.
sl@0: 		@post			The class under test is set to the state specified
sl@0: 	 */
sl@0: 	inline virtual TInt Internalize(TAny* aTestObject);
sl@0: 
sl@0: 	/**
sl@0: 		@fn				Externalize(TAny* aTestObject)
sl@0: 		Intended Usage	: Implemented by the developer to persist the state of the object under test.
sl@0: 		@since			7.0
sl@0: 		@param			aTestObject The object to be tested
sl@0: 		@return			KErrNone if the internalize was successful.
sl@0: 		@return			One of the EPOC standard error codes indicating the reason
sl@0: 						for the failure	to externalize the object.
sl@0: 		@pre 			TUnitTest_StateAccessor is fully constructed, and
sl@0: 						valid test object must be passed in.
sl@0: 		@post			Returns an error code dependant on the result of the test
sl@0: 	 */
sl@0: 	inline virtual TInt Externalize(TAny* aTestObject);
sl@0: 
sl@0: 	/**
sl@0: 		@fn				InternalizeL(RFileReadStream& aStream, CUnitTest* aUnitTest)
sl@0: 		Intended Usage	: Implemented by the developer to set the state of the object under test.
sl@0: 		Error Condition	: Leaves with an error code.
sl@0: 		@since			7.0
sl@0: 		@param			aStream The filestream to read from .
sl@0: 		@param			aUnitTest A pointer to the CUnitTest object under test.
sl@0: 		@return			None.
sl@0: 		@pre 			TUnitTest_StateAccessor is fully constructed.
sl@0: 		@post			The class under test is set to the state specified.
sl@0: 	 */
sl@0: 		inline void InternalizeL(RFileReadStream& aStream, CUnitTest* aUnitTest);
sl@0: 
sl@0: 	/**
sl@0: 		@fn				ExternalizeL(RFileWriteStream& aStream, CUnitTest* aUnitTest)
sl@0: 		Intended Usage	: Implemented by the developer to persist the state of the object under test.
sl@0: 		Error Condition	: Leaves with an error code.
sl@0: 		@since			7.0
sl@0: 		@param			aStream The filestream to persist into.
sl@0: 		@param			aUnitTest A pointer to the CUnitTest object under test.
sl@0: 		@return			None.
sl@0: 		@pre 			TUnitTest_StateAccessor is fully constructed.
sl@0: 		@post			No change to the class under test, its internal state.
sl@0: 						is persisted.
sl@0: 	*/
sl@0: 	inline void ExternalizeL(RFileWriteStream& aStream, CUnitTest* aUnitTest);
sl@0: 
sl@0: 	inline CUnitTestTestDerivation* CreateUnitTest(CUnitTest& aUnitTest, const TDesC& aName, CDataLogger& aDataLogger, MUnitTestObserver& aUnitTestObserver);
sl@0: 
sl@0: 	inline void RunL(CUnitTest& aUnitTest);
sl@0: 
sl@0: 	inline void AddTransitionL(CUnitTest& aUnitTest, CTransition* aTransition);
sl@0: 
sl@0: 	inline void AddBlockingTransitionL(CUnitTest& aUnitTest, CTransition* aTransition);
sl@0: 
sl@0: 	inline void AddLeaveErrorCodeL(CUnitTest& aUnitTest, TInt& aLeaveErrorCode);
sl@0: 
sl@0: private:
sl@0: 	/**
sl@0: 		@fn				InternalizeL(CUnitTest* aUnitTest)
sl@0: 		Intended Usage	: Implemented by the developer to set the state of the object under test.
sl@0: 		Error Condition	: Leaves with an error code.
sl@0: 		@since			7.0
sl@0: 		@param			TAny* A pointer to the object under test.
sl@0: 		@return			None.
sl@0: 		@pre 			TUnitTest_StateAccessor is fully constructed.
sl@0: 		@post			The class under test is set to the state specified.
sl@0: 	*/
sl@0: 	inline void InternalizeL(CUnitTest* aUnitTest);
sl@0: 
sl@0: 	/**
sl@0: 		@fn				ExternalizeL(CUnitTest* aUnitTest)
sl@0: 		Intended Usage	: Implemented by the developer to persist the state of the object under test.
sl@0: 		Error Condition	: Leaves with an error code.
sl@0: 		@since			7.0
sl@0: 		@param			TAny* A pointer to the object under test.
sl@0: 		@return			None.
sl@0: 		@pre 			TUnitTest_StateAccessor is fully constructed.
sl@0: 		@post			No change to the class under test, its internal state.
sl@0: 						is persisted.
sl@0: 	*/
sl@0: 	inline void ExternalizeL(CUnitTest* aUnitTest);
sl@0: 	};	// TUnitTest_StateAccessor
sl@0: 
sl@0: #include "UnitTestStateAccessor.inl"
sl@0: 
sl@0: #endif // __UNITTESTSTATEACCESSOR_H__
sl@0: