sl@0: // Copyright (c) 2005-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 implementation of the transition validation classes upon the CTransition class methods. sl@0: // sl@0: // sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_Ctor_TransitionValidator::TTransition_Ctor_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KCtorFailedInvariant, sl@0: "CTransition_Ctor_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_Ctor_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition)) sl@0: { sl@0: iUTContext.DataLogger().LogInformation(KCtorFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_Dtor_TransitionValidator::TTransition_Dtor_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KDtorFailedInvariant, sl@0: "CTransition_Dtor_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_Dtor_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition)) sl@0: { sl@0: iUTContext.DataLogger().LogInformation(KDtorFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: return ETrue; sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_TransitMethodL_TransitionValidator::TTransition_TransitMethodL_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KTransitMethodLFailedInvariant, sl@0: "CTransition_TransitMethodL_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_TransitMethodL_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: // For a c'tor this should be empty. sl@0: if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition)) sl@0: { sl@0: iUTContext.DataLogger().LogInformation(KTransitMethodLFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_TransitMethodL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor()); sl@0: if(stateAccessor.InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KTransitMethodLFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone; sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_RepeatOnce_TransitionValidator::TTransition_RepeatOnce_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KRepeatOnceFailedInvariant, sl@0: "CTransition_RepeatOnce_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_RepeatOnce_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KRepeatOnceFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return !REINTERPRET_CAST(TTransition_StateAccessor&,context.StateAccessor()).IsRepeated(context.iTargetTransition); sl@0: } sl@0: sl@0: inline TBool TTransition_RepeatOnce_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: // For a c'tor this should be empty. sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KRepeatOnceFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return REINTERPRET_CAST(TTransition_StateAccessor&,context.StateAccessor()).IsRepeated(context.iTargetTransition); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_TransitionId_TransitionValidator::TTransition_TransitionId_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KTransitionIdFailedInvariant, sl@0: "CTransition_TransitionId_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_TransitionId_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KTransitionIdFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_TransitionId_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: // For a c'tor this should be empty. sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor()); sl@0: if(stateAccessor.InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KTransitionIdFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: // Compare the contents of the ids for a match sl@0: return *(context.iTransitionId) == *(stateAccessor.TransitionId(context.iTargetTransition)); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_TransitionInfo_TransitionValidator::TTransition_TransitionInfo_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KTransitionInfoFailedInvariant, sl@0: "CTransition_TransitionInfo_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_TransitionInfo_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KTransitionInfoFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_TransitionInfo_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: // For a c'tor this should be empty. sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor()); sl@0: if(stateAccessor.InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KTransitionInfoFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return context.iTransitionInfo == stateAccessor.TransitionInfo(context.iTargetTransition); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_SetBlocking_TransitionValidator::TTransition_SetBlocking_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KSetBlockingFailedInvariant, sl@0: "CTransition_SetBlocking_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_SetBlocking_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KSetBlockingFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_SetBlocking_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: // For a c'tor this should be empty. sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor()); sl@0: if(stateAccessor.InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KSetBlockingFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return context.iBlockingTransition == stateAccessor.BlockingFlag(context.iTargetTransition); sl@0: } sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_IsBlocking_TransitionValidator::TTransition_IsBlocking_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KIsBlockingFailedInvariant, sl@0: "CTransition_IsBlocking_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_IsBlocking_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KIsBlockingFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_IsBlocking_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: // For a c'tor this should be empty. sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor()); sl@0: if(stateAccessor.InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KIsBlockingFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return context.iBlockingTransition != stateAccessor.BlockingFlag(context.iTargetTransition); sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_GetErrorCode_TransitionValidator::TTransition_GetErrorCode_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KGetErrorCodeFailedInvariant, sl@0: "CTransition_GetErrorCode_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_GetErrorCode_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KGetErrorCodeFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_GetErrorCode_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: // For a c'tor this should be empty. sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor()); sl@0: if(stateAccessor.InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KGetErrorCodeFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_RunTransition_TransitionValidator::TTransition_RunTransition_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KRunTransitionFailedInvariant, sl@0: "CTransition_RunTransition_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_RunTransition_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KRunTransitionFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_RunTransition_TransitionValidator::ValidatePostConditions(TTestBedAsyncState aAsyncState) sl@0: { sl@0: // For a c'tor this should be empty. sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor()); sl@0: if(stateAccessor.InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KRunTransitionFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: if(aAsyncState) sl@0: { sl@0: return (stateAccessor.Status(context.iTargetTransition).Int() == stateAccessor.ErrorCode(context.iTargetTransition) && sl@0: stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone); sl@0: } sl@0: else sl@0: return stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone; sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_Cancel_TransitionValidator::TTransition_Cancel_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: _LIT(KCancelFailedInvariant, sl@0: "CTransition_Cancel_Transition invariant failure"); sl@0: sl@0: inline TBool TTransition_Cancel_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: if(context.StateAccessor().InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KCancelFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_Cancel_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: // For a c'tor this should be empty. sl@0: CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext); sl@0: TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor()); sl@0: if(stateAccessor.InvariantTest(context.iTargetTransition)) sl@0: { sl@0: context.DataLogger().LogInformation(KCancelFailedInvariant); sl@0: return EFalse; sl@0: } sl@0: return stateAccessor.Status(context.iTargetTransition).Int() == KErrCancel; sl@0: } sl@0: sl@0: // ______________________________________________________________________________ sl@0: // sl@0: inline TTransition_NULL_TransitionValidator::TTransition_NULL_TransitionValidator(CUnitTestContext& aUTContext) sl@0: :TTransitionValidator(aUTContext) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: inline TBool TTransition_NULL_TransitionValidator::ValidatePreConditions() sl@0: { sl@0: // Always sl@0: return ETrue; sl@0: } sl@0: sl@0: inline TBool TTransition_NULL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) sl@0: { sl@0: // Always sl@0: return ETrue; sl@0: }