CTransition Class Reference

class CTransition : public CActive

Comments : Base class from which test developers can derive their own transitions for both synchronous and asynchronous methods on the test class.

The default behaviour is to log its activity, and claim that the pre and post conditions are true. The TransitMethodL implementation does nothing. To write a complete test class method transition override:

1. The c'tor, (To obtain the test class reference, (or pointer reference for a NewL transit), and any parameters for the TransitMethodL).

2. SetStartStateL() to set the test class state, Using the TStateAccessor provided in the c'tor.

3. ValidatePreConditions() to test the test class state is valid.

4. TransitMethodL() to define the transition behaviour, calling the method to test with the appropriate parameters.

5. ValidatePostConditions(), to check the end state is valid.

The simplest case of implementation is to derive an empty class, that relies entirely upon the default behaviour, and implement the remaining methods as appropriate. (See the the EXAMPLE implementation.)

Inherits from

Constructor & Destructor Documentation

CTransition(const TDesC &, CUnitTestContext &, TTransitionValidator &)

IMPORT_C CTransition ( const TDesC & aTransitionId,
CUnitTestContext & aUTContext,
TTransitionValidator & aValidator
) [protected]
Intended Usage : Default Constructor
Since
7.0
Pre-condition
None
Post-condition
First phase of two phase construction is complete

Parameters

const TDesC & aTransitionId The identifier of this transition
CUnitTestContext & aUTContext The context within which this transition should run
TTransitionValidator & aValidator Provides Pre & Post condition validation

~CTransition()

IMPORT_C ~CTransition ( )
Intended Usage : Standardized virtual destruction method
Since
7.0
Pre-condition
The CTransition exists
Post-condition
The object has been destroyed

Member Functions Documentation

DoCancel()

IMPORT_C void DoCancel ( ) [protected, virtual]
Intended Usage : Standard Active Object method for cancelling the current request Error Condition :
Since
7.0
Pre-condition
None
Post-condition
Any outstanding requests are cancelled

GetErrorCode()

IMPORT_C TInt GetErrorCode ( ) const
Intended Usage : Returns the error code last recorded by the transition.
Since
7.0
Pre-condition
This object is fully constructed.

IsBlockingTransition()

IMPORT_C TBool IsBlockingTransition ( ) const
Intended Usage : A blocking transition is one which does not run until all outstanding asynchronous transitions have completed. This function returns whether this is a blocking transition. This function does not need to be used by test developers as it is taken care of in the transition and unittest base classes. Blocking transitions can be added using AddBlockingTransitionL() in CUnitTest::ConstructL() .
Since
7.0
Pre-condition
None

PostTransitionCleanup()

IMPORT_C void PostTransitionCleanup ( ) [protected, virtual]
Intended Usage : Called from the RunL immediately after TransitMethodL() executes
Since
7.0
Pre-condition
Must be called from RunL only after TransitMethodL() has completed.
Post-condition
Default behaviour is to do nothing. See the derived classes for additional functionality.

RepeatOnce()

IMPORT_C void RepeatOnce ( )
Intended Usage : Flag this transition to be repeated
Since
7.0
Pre-condition
None
Post-condition
The iRepeatThis flag is set to true.

RunError(TInt)

IMPORT_C TInt RunError ( TInt aErrorCode ) [protected, virtual]
Intended Usage : Called by the active scheduler if RunL leaves
Since
7.0
Pre-condition
This function is only called by the active scheduler if RunL leaves.
Post-condition
The owning CUnitTest has been informed that this CTransition left

Parameters

TInt aErrorCode The error code which RunL left with

RunL()

IMPORT_C void RunL ( ) [protected, virtual]
Intended Usage : Implementation of CActive pure virtual method. For each transition execution RunL is performed twice. The first time it calls TransitMethodL() which is the developer defined function which executes the test method. It then immediately sets itself active and attempts to complete. If TransitMethodL() called a synchronous function then iStatus will not be KRequestPending and the RunL will be called as soon as it is scheduled. If TransitMethodL() calls an asyncronous function then it will pass iStatus to the function and RunL will be called when the asynchronous function completes. Whichever method is used the second call of RunL() will complete the request of the CUnitTest which called this transition by setting its status word. If it has been requested that this transition is repeated then the status word will be set to KTestBedRepeatTest. Error Condition :
Since
7.0
Pre-condition
RunTransition() ensures the preconditions for this function
Post-condition
After 1st run - test method has been called After 2nd run - Unittest has been completed.

RunTransition(TRequestStatus *)

IMPORT_C void RunTransition ( TRequestStatus * aUnitTestStatus ) [virtual]
Intended Usage : Indicates that this transition should be run as soon as possible. This function calls ValidatePreConditions to ensure the object is in the appropriate start state and then sets the transition active causing its RunL function to be called. Error Condition :
Since
7.0
Pre-condition
The test object is in an appropriate state for this transition
Post-condition
The test object is in the end state of this transition

Parameters

TRequestStatus * aUnitTestStatus Status word of the calling CUnitTest

SetBlockingTransition(TBool)

IMPORT_C void SetBlockingTransition ( TBool aBlocking )
Intended Usage : A blocking transition is one which does not run until all outstanding asynchronous transitions have completed. This function does not need to be used by test developers as it is taken care of in the transition and unittest base classes. Blocking transitions can be added using AddBlockingTransitionL() in CUnitTest::ConstructL() .
Since
7.0
Pre-condition
This object is fully constructed
Post-condition
The blocking status of this CTransition is set

Parameters

TBool aBlocking Pass ETrue to set this as a blocking transition

SetStartStateL()

IMPORT_C void SetStartStateL ( ) [virtual]
Intended Usage : Sets the state of the test object to that specified Error Condition :
Since
7.0
Pre-condition
The CTransition is instantiated
Post-condition
The CTransition is in the state specified

TransitMethodL()

IMPORT_C void TransitMethodL ( ) [protected, pure virtual]
Intended Usage : Calls the method on the class being tested. If the call is to an asynchronous service provider you must set iStatus to KRequestPending as usual Error Condition :
Since
7.0
Pre-condition
Preconditions for this transition have been validated
Post-condition
The test method has been executed

TransitionId()

IMPORT_C const TDesC & TransitionId ( ) const
Intended Usage : Returns the transition identifier Error Condition :
Since
7.0
Pre-condition
The CTransition has been instantiated

TransitionInfo()

IMPORT_C const TTransitionInfo & TransitionInfo ( ) const
Intended Usage : Get information on this transition. Return struct contains the transition ID, the current iteration and the logging mechanism used by this transition Error Condition :
Since
7.0
Pre-condition
This CTransition is initialized

Member Data Documentation

TBool iAsyncTransition

TBool iAsyncTransition [protected]

Indicates that this transition is an asynchronous transition

TBool iBlockingTransition

TBool iBlockingTransition [protected]

Indicates that this transition should not execute until all previous async transitions have finished

TInt iLeaveError

TInt iLeaveError [protected]

indicates the code that the RunL left with when completing with a KErrTestBedLeft

TBool iRepeatThis

TBool iRepeatThis [protected]

Indicates that this transition should be re-run after the current run

TBool iTransitionFinished

TBool iTransitionFinished [protected]

Indicates that the transition has executed and can be completed

const TDesC & iTransitionId

const TDesC & iTransitionId [protected]

The transition identifier

TTransitionInfo iTransitionInfo

TTransitionInfo iTransitionInfo [protected]

Information on this transition including its ID, its iteration number and the data logger it is currently using

CUnitTestContext & iUTContext

CUnitTestContext & iUTContext [protected]

The context in which this transition is running (logging, state accessor & observer)

TRequestStatus * iUnitTestStatus

TRequestStatus * iUnitTestStatus [protected]

The iStatus of the UnitTest which owns me so that I can complete it

TTransitionValidator & iValidator

TTransitionValidator & iValidator [protected]

Used for checking the state of the test object - provides pre and post condition validation functions