os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistrarTest/RegistrarTransitionValidation.inl
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistrarTest/RegistrarTransitionValidation.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,198 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// The implementation of the validation classes for the CRegistar tests.
1.18 +//
1.19 +//
1.20 +
1.21 +// ______________________________________________________________________________
1.22 +//
1.23 +inline TRegistrar_Ctor_TransitionValidator::TRegistrar_Ctor_TransitionValidator(CUnitTestContext& aUTContext)
1.24 +:TTransitionValidator(aUTContext)
1.25 + {
1.26 + // Do nothing
1.27 + }
1.28 +
1.29 +inline TBool TRegistrar_Ctor_TransitionValidator::ValidatePreConditions()
1.30 + {
1.31 + return ETrue;
1.32 + }
1.33 +
1.34 +inline TBool TRegistrar_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
1.35 + {
1.36 + if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
1.37 + return EFalse;
1.38 + return ETrue;
1.39 + }
1.40 +
1.41 +// ______________________________________________________________________________
1.42 +//
1.43 +inline TRegistrar_Dtor_TransitionValidator::TRegistrar_Dtor_TransitionValidator(CUnitTestContext& aUTContext)
1.44 +:TTransitionValidator(aUTContext)
1.45 + {
1.46 + // Do nothing
1.47 + }
1.48 +
1.49 +inline TBool TRegistrar_Dtor_TransitionValidator::ValidatePreConditions()
1.50 + {
1.51 + if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
1.52 + return EFalse;
1.53 + return ETrue;
1.54 + }
1.55 +
1.56 +inline TBool TRegistrar_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
1.57 + {
1.58 + return ETrue;
1.59 + }
1.60 +
1.61 +// ______________________________________________________________________________
1.62 +//
1.63 +inline TRegistrar_Default_TransitionValidator::TRegistrar_Default_TransitionValidator(CUnitTestContext& aUTContext)
1.64 +:TTransitionValidator(aUTContext)
1.65 + {
1.66 + // Do nothing
1.67 + }
1.68 +
1.69 +inline TBool TRegistrar_Default_TransitionValidator::ValidatePreConditions()
1.70 + {
1.71 + if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
1.72 + return EFalse;
1.73 + return ETrue;
1.74 + }
1.75 +
1.76 +inline TBool TRegistrar_Default_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
1.77 + {
1.78 + if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
1.79 + return EFalse;
1.80 + return ETrue;
1.81 + }
1.82 +
1.83 +// ______________________________________________________________________________
1.84 +//
1.85 +inline TRegistrar_RegisterDiscoveryL_TransitionValidator::TRegistrar_RegisterDiscoveryL_TransitionValidator(CUnitTestContext& aUTContext)
1.86 +:TTransitionValidator(aUTContext)
1.87 + {
1.88 + // Do nothing
1.89 + }
1.90 +
1.91 +inline TBool TRegistrar_RegisterDiscoveryL_TransitionValidator::ValidatePreConditions()
1.92 + {
1.93 + // Only pre condition is that object is constructed
1.94 + if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
1.95 + return EFalse;
1.96 + return ETrue;
1.97 + }
1.98 +
1.99 +inline TBool TRegistrar_RegisterDiscoveryL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
1.100 + {
1.101 + if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&, iUTContext).iRegistrar))
1.102 + return EFalse;
1.103 + return ETrue;
1.104 + }
1.105 +
1.106 +// ______________________________________________________________________________
1.107 +//
1.108 +inline TRegistrar_DriveRemoved_TransitionValidator::TRegistrar_DriveRemoved_TransitionValidator(CUnitTestContext& aUTContext)
1.109 +:TTransitionValidator(aUTContext)
1.110 + {
1.111 + // Do nothing
1.112 + }
1.113 +
1.114 +inline TBool TRegistrar_DriveRemoved_TransitionValidator::ValidatePreConditions()
1.115 + {
1.116 + if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
1.117 + return EFalse;
1.118 + return ETrue;
1.119 + }
1.120 +
1.121 +inline TBool TRegistrar_DriveRemoved_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
1.122 + {
1.123 + //Do a list implementations and check that we get a list unavailable error
1.124 + CRegistrar_UnitTestContext& context = REINTERPRET_CAST(CRegistrar_UnitTestContext&, iUTContext);
1.125 +
1.126 + TRAPD(error, context.iRegistryData.ListImplementationsL(context.iInterfaceUid));
1.127 + if(error != KEComErrNoInterfaceIdentified)
1.128 + {
1.129 + return EFalse;
1.130 + }
1.131 +
1.132 + if(iUTContext.StateAccessor().InvariantTest(context.iRegistrar))
1.133 + return EFalse;
1.134 + return ETrue;
1.135 + }
1.136 +
1.137 +// ______________________________________________________________________________
1.138 +//
1.139 +inline TRegistrar_CheckRegWhileDiscovering_TransitionValidator::TRegistrar_CheckRegWhileDiscovering_TransitionValidator(CUnitTestContext& aUTContext)
1.140 +:TTransitionValidator(aUTContext)
1.141 + {
1.142 + // Do nothing
1.143 + }
1.144 +
1.145 +inline TBool TRegistrar_CheckRegWhileDiscovering_TransitionValidator::ValidatePreConditions()
1.146 + {
1.147 + if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistrar_UnitTestContext&,iUTContext).iRegistrar))
1.148 + return EFalse;
1.149 + return ETrue;
1.150 + }
1.151 +
1.152 +inline TBool TRegistrar_CheckRegWhileDiscovering_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
1.153 + {
1.154 + //Do a list implementations and check that we get a list unavailable error
1.155 + CRegistrar_UnitTestContext& context = REINTERPRET_CAST(CRegistrar_UnitTestContext&, iUTContext);
1.156 +
1.157 + TRAPD(error, context.iRegistryData.ListImplementationsL(context.iInterfaceUid));
1.158 + if(error != KEComErrListCurrentlyUnavailable)
1.159 + {
1.160 + _LIT(KCheckRegLeaveMessage, "In PostCondition - ListImplementationsL left with %d (expected KEComErrListCurrentlyUnavailable)");
1.161 + context.DataLogger().LogInformationWithParameters(KCheckRegLeaveMessage, error);
1.162 + return EFalse;
1.163 + }
1.164 +
1.165 + if(iUTContext.StateAccessor().InvariantTest(context.iRegistrar))
1.166 + return EFalse;
1.167 + return ETrue;
1.168 + }
1.169 +
1.170 +// ______________________________________________________________________________
1.171 +//
1.172 +inline TRegistrar_NewLHasContent_TransitionValidator::TRegistrar_NewLHasContent_TransitionValidator(CUnitTestContext& aUTContext)
1.173 +:TTransitionValidator(aUTContext)
1.174 + {
1.175 + // Do nothing
1.176 + }
1.177 +
1.178 +inline TBool TRegistrar_NewLHasContent_TransitionValidator::ValidatePreConditions()
1.179 + {
1.180 + return ETrue;
1.181 + }
1.182 +
1.183 +inline TBool TRegistrar_NewLHasContent_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
1.184 + {
1.185 + // If this validation fails it is probably because there are no registered
1.186 + // interfaces. This is most likely because the idx file is not valid.
1.187 +
1.188 + CRegistrar_UnitTestContext& context = REINTERPRET_CAST(CRegistrar_UnitTestContext&, iUTContext);
1.189 +
1.190 + TRAPD(error, context.iRegistryData.ListImplementationsL(context.iInterfaceUid));
1.191 + if(error == KEComErrNoInterfaceIdentified)
1.192 + {
1.193 + // Then the index hasn't been rebuilt so
1.194 + return EFalse;
1.195 + }
1.196 +
1.197 + if(iUTContext.StateAccessor().InvariantTest(context.iRegistrar))
1.198 + return EFalse;
1.199 + return ETrue;
1.200 + }
1.201 +