os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionTransitionValidation.inl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionTransitionValidation.inl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,406 @@
     1.4 +// Copyright (c) 2005-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 transition validation classes upon the CTransition class methods.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +// ______________________________________________________________________________
    1.22 +//
    1.23 +inline TTransition_Ctor_TransitionValidator::TTransition_Ctor_TransitionValidator(CUnitTestContext& aUTContext)
    1.24 +:TTransitionValidator(aUTContext)
    1.25 +	{
    1.26 +	// Do nothing
    1.27 +	}
    1.28 +
    1.29 +_LIT(KCtorFailedInvariant,
    1.30 +	"CTransition_Ctor_Transition invariant failure");
    1.31 +
    1.32 +inline TBool TTransition_Ctor_TransitionValidator::ValidatePreConditions()
    1.33 +	{
    1.34 +	return ETrue;
    1.35 +	}
    1.36 +
    1.37 +inline TBool TTransition_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    1.38 +	{
    1.39 +	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
    1.40 +		{
    1.41 +		iUTContext.DataLogger().LogInformation(KCtorFailedInvariant);
    1.42 +		return EFalse;
    1.43 +		}
    1.44 +	return ETrue;
    1.45 +	}
    1.46 +
    1.47 +// ______________________________________________________________________________
    1.48 +//
    1.49 +inline TTransition_Dtor_TransitionValidator::TTransition_Dtor_TransitionValidator(CUnitTestContext& aUTContext)
    1.50 +:TTransitionValidator(aUTContext)
    1.51 +	{
    1.52 +	// Do nothing
    1.53 +	}
    1.54 +
    1.55 +_LIT(KDtorFailedInvariant,
    1.56 +	"CTransition_Dtor_Transition invariant failure");
    1.57 +
    1.58 +inline TBool TTransition_Dtor_TransitionValidator::ValidatePreConditions()
    1.59 +	{
    1.60 +	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
    1.61 +		{
    1.62 +		iUTContext.DataLogger().LogInformation(KDtorFailedInvariant);
    1.63 +		return EFalse;
    1.64 +		}
    1.65 +	return ETrue;
    1.66 +	}
    1.67 +
    1.68 +inline TBool TTransition_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    1.69 +	{
    1.70 +	return ETrue;
    1.71 +	}
    1.72 +
    1.73 +// ______________________________________________________________________________
    1.74 +//
    1.75 +inline TTransition_TransitMethodL_TransitionValidator::TTransition_TransitMethodL_TransitionValidator(CUnitTestContext& aUTContext)
    1.76 +:TTransitionValidator(aUTContext)
    1.77 +	{
    1.78 +	// Do nothing
    1.79 +	}
    1.80 +
    1.81 +_LIT(KTransitMethodLFailedInvariant,
    1.82 +	"CTransition_TransitMethodL_Transition invariant failure");
    1.83 +
    1.84 +inline TBool TTransition_TransitMethodL_TransitionValidator::ValidatePreConditions()
    1.85 +	{
    1.86 +	// For a c'tor this should be empty.
    1.87 +	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
    1.88 +		{
    1.89 +		iUTContext.DataLogger().LogInformation(KTransitMethodLFailedInvariant);
    1.90 +		return EFalse;
    1.91 +		}
    1.92 +	return ETrue;
    1.93 +	}
    1.94 +
    1.95 +inline TBool TTransition_TransitMethodL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    1.96 +	{
    1.97 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
    1.98 +	TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
    1.99 +	if(stateAccessor.InvariantTest(context.iTargetTransition))
   1.100 +		{
   1.101 +		context.DataLogger().LogInformation(KTransitMethodLFailedInvariant);
   1.102 +		return EFalse;
   1.103 +		}
   1.104 +	return stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone;
   1.105 +	}
   1.106 +
   1.107 +// ______________________________________________________________________________
   1.108 +//
   1.109 +inline TTransition_RepeatOnce_TransitionValidator::TTransition_RepeatOnce_TransitionValidator(CUnitTestContext& aUTContext)
   1.110 +:TTransitionValidator(aUTContext)
   1.111 +	{
   1.112 +	// Do nothing
   1.113 +	}
   1.114 +
   1.115 +_LIT(KRepeatOnceFailedInvariant,
   1.116 +	"CTransition_RepeatOnce_Transition invariant failure");
   1.117 +
   1.118 +inline TBool TTransition_RepeatOnce_TransitionValidator::ValidatePreConditions()
   1.119 +	{
   1.120 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.121 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.122 +		{
   1.123 +		context.DataLogger().LogInformation(KRepeatOnceFailedInvariant);
   1.124 +		return EFalse;
   1.125 +		}
   1.126 +	return !REINTERPRET_CAST(TTransition_StateAccessor&,context.StateAccessor()).IsRepeated(context.iTargetTransition);
   1.127 +	}
   1.128 +
   1.129 +inline TBool TTransition_RepeatOnce_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   1.130 +	{
   1.131 +	// For a c'tor this should be empty.
   1.132 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.133 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.134 +		{
   1.135 +		context.DataLogger().LogInformation(KRepeatOnceFailedInvariant);
   1.136 +		return EFalse;
   1.137 +		}
   1.138 +	return REINTERPRET_CAST(TTransition_StateAccessor&,context.StateAccessor()).IsRepeated(context.iTargetTransition);
   1.139 +	}
   1.140 +
   1.141 +// ______________________________________________________________________________
   1.142 +//
   1.143 +inline TTransition_TransitionId_TransitionValidator::TTransition_TransitionId_TransitionValidator(CUnitTestContext& aUTContext)
   1.144 +:TTransitionValidator(aUTContext)
   1.145 +	{
   1.146 +	// Do nothing
   1.147 +	}
   1.148 +
   1.149 +_LIT(KTransitionIdFailedInvariant,
   1.150 +	"CTransition_TransitionId_Transition invariant failure");
   1.151 +
   1.152 +inline TBool TTransition_TransitionId_TransitionValidator::ValidatePreConditions()
   1.153 +	{
   1.154 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.155 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.156 +		{
   1.157 +		context.DataLogger().LogInformation(KTransitionIdFailedInvariant);
   1.158 +		return EFalse;
   1.159 +		}
   1.160 +	return ETrue;
   1.161 +	}
   1.162 +
   1.163 +inline TBool TTransition_TransitionId_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   1.164 +	{
   1.165 +	// For a c'tor this should be empty.
   1.166 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.167 +	TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
   1.168 +	if(stateAccessor.InvariantTest(context.iTargetTransition))
   1.169 +		{
   1.170 +		context.DataLogger().LogInformation(KTransitionIdFailedInvariant);
   1.171 +		return EFalse;
   1.172 +		}
   1.173 +	// Compare the contents of the ids for a match
   1.174 +	return *(context.iTransitionId) == *(stateAccessor.TransitionId(context.iTargetTransition));
   1.175 +	}
   1.176 +
   1.177 +// ______________________________________________________________________________
   1.178 +//
   1.179 +inline TTransition_TransitionInfo_TransitionValidator::TTransition_TransitionInfo_TransitionValidator(CUnitTestContext& aUTContext)
   1.180 +:TTransitionValidator(aUTContext)
   1.181 +	{
   1.182 +	// Do nothing
   1.183 +	}
   1.184 +
   1.185 +_LIT(KTransitionInfoFailedInvariant,
   1.186 +	"CTransition_TransitionInfo_Transition invariant failure");
   1.187 +
   1.188 +inline TBool TTransition_TransitionInfo_TransitionValidator::ValidatePreConditions()
   1.189 +	{
   1.190 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.191 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.192 +		{
   1.193 +		context.DataLogger().LogInformation(KTransitionInfoFailedInvariant);
   1.194 +		return EFalse;
   1.195 +		}
   1.196 +	return ETrue;
   1.197 +	}
   1.198 +
   1.199 +inline TBool TTransition_TransitionInfo_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   1.200 +	{
   1.201 +	// For a c'tor this should be empty.
   1.202 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.203 +	TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
   1.204 +	if(stateAccessor.InvariantTest(context.iTargetTransition))
   1.205 +		{
   1.206 +		context.DataLogger().LogInformation(KTransitionInfoFailedInvariant);
   1.207 +		return EFalse;
   1.208 +		}
   1.209 +	return context.iTransitionInfo == stateAccessor.TransitionInfo(context.iTargetTransition);
   1.210 +	}
   1.211 +
   1.212 +// ______________________________________________________________________________
   1.213 +//
   1.214 +inline TTransition_SetBlocking_TransitionValidator::TTransition_SetBlocking_TransitionValidator(CUnitTestContext& aUTContext)
   1.215 +:TTransitionValidator(aUTContext)
   1.216 +	{
   1.217 +	// Do nothing
   1.218 +	}
   1.219 +
   1.220 +_LIT(KSetBlockingFailedInvariant,
   1.221 +	"CTransition_SetBlocking_Transition invariant failure");
   1.222 +
   1.223 +inline TBool TTransition_SetBlocking_TransitionValidator::ValidatePreConditions()
   1.224 +	{
   1.225 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.226 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.227 +		{
   1.228 +		context.DataLogger().LogInformation(KSetBlockingFailedInvariant);
   1.229 +		return EFalse;
   1.230 +		}
   1.231 +	return ETrue;
   1.232 +	}
   1.233 +
   1.234 +inline TBool TTransition_SetBlocking_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   1.235 +	{
   1.236 +	// For a c'tor this should be empty.
   1.237 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.238 +	TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
   1.239 +	if(stateAccessor.InvariantTest(context.iTargetTransition))
   1.240 +		{
   1.241 +		context.DataLogger().LogInformation(KSetBlockingFailedInvariant);
   1.242 +		return EFalse;
   1.243 +		}
   1.244 +	return context.iBlockingTransition == stateAccessor.BlockingFlag(context.iTargetTransition);
   1.245 +	}
   1.246 +// ______________________________________________________________________________
   1.247 +//
   1.248 +inline TTransition_IsBlocking_TransitionValidator::TTransition_IsBlocking_TransitionValidator(CUnitTestContext& aUTContext)
   1.249 +:TTransitionValidator(aUTContext)
   1.250 +	{
   1.251 +	// Do nothing
   1.252 +	}
   1.253 +
   1.254 +_LIT(KIsBlockingFailedInvariant,
   1.255 +	"CTransition_IsBlocking_Transition invariant failure");
   1.256 +
   1.257 +inline TBool TTransition_IsBlocking_TransitionValidator::ValidatePreConditions()
   1.258 +	{
   1.259 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.260 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.261 +		{
   1.262 +		context.DataLogger().LogInformation(KIsBlockingFailedInvariant);
   1.263 +		return EFalse;
   1.264 +		}
   1.265 +	return ETrue;
   1.266 +	}
   1.267 +
   1.268 +inline TBool TTransition_IsBlocking_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   1.269 +	{
   1.270 +	// For a c'tor this should be empty.
   1.271 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.272 +	TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
   1.273 +	if(stateAccessor.InvariantTest(context.iTargetTransition))
   1.274 +		{
   1.275 +		context.DataLogger().LogInformation(KIsBlockingFailedInvariant);
   1.276 +		return EFalse;
   1.277 +		}
   1.278 +	return context.iBlockingTransition != stateAccessor.BlockingFlag(context.iTargetTransition);
   1.279 +	}
   1.280 +
   1.281 +// ______________________________________________________________________________
   1.282 +//
   1.283 +inline TTransition_GetErrorCode_TransitionValidator::TTransition_GetErrorCode_TransitionValidator(CUnitTestContext& aUTContext)
   1.284 +:TTransitionValidator(aUTContext)
   1.285 +	{
   1.286 +	// Do nothing
   1.287 +	}
   1.288 +
   1.289 +_LIT(KGetErrorCodeFailedInvariant,
   1.290 +	"CTransition_GetErrorCode_Transition invariant failure");
   1.291 +
   1.292 +inline TBool TTransition_GetErrorCode_TransitionValidator::ValidatePreConditions()
   1.293 +	{
   1.294 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.295 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.296 +		{
   1.297 +		context.DataLogger().LogInformation(KGetErrorCodeFailedInvariant);
   1.298 +		return EFalse;
   1.299 +		}
   1.300 +	return ETrue;
   1.301 +	}
   1.302 +
   1.303 +inline TBool TTransition_GetErrorCode_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   1.304 +	{
   1.305 +	// For a c'tor this should be empty.
   1.306 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.307 +	TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
   1.308 +	if(stateAccessor.InvariantTest(context.iTargetTransition))
   1.309 +		{
   1.310 +		context.DataLogger().LogInformation(KGetErrorCodeFailedInvariant);
   1.311 +		return EFalse;
   1.312 +		}
   1.313 +	return ETrue;
   1.314 +	}
   1.315 +// ______________________________________________________________________________
   1.316 +//
   1.317 +inline TTransition_RunTransition_TransitionValidator::TTransition_RunTransition_TransitionValidator(CUnitTestContext& aUTContext)
   1.318 +:TTransitionValidator(aUTContext)
   1.319 +	{
   1.320 +	// Do nothing
   1.321 +	}
   1.322 +
   1.323 +_LIT(KRunTransitionFailedInvariant,
   1.324 +	"CTransition_RunTransition_Transition invariant failure");
   1.325 +
   1.326 +inline TBool TTransition_RunTransition_TransitionValidator::ValidatePreConditions()
   1.327 +	{
   1.328 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.329 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.330 +		{
   1.331 +		context.DataLogger().LogInformation(KRunTransitionFailedInvariant);
   1.332 +		return EFalse;
   1.333 +		}
   1.334 +	return ETrue;
   1.335 +	}
   1.336 +
   1.337 +inline TBool TTransition_RunTransition_TransitionValidator::ValidatePostConditions(TTestBedAsyncState aAsyncState)
   1.338 +	{
   1.339 +	// For a c'tor this should be empty.
   1.340 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.341 +	TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
   1.342 +	if(stateAccessor.InvariantTest(context.iTargetTransition))
   1.343 +		{
   1.344 +		context.DataLogger().LogInformation(KRunTransitionFailedInvariant);
   1.345 +		return EFalse;
   1.346 +		}
   1.347 +	if(aAsyncState)
   1.348 +		{
   1.349 +		return (stateAccessor.Status(context.iTargetTransition).Int() == stateAccessor.ErrorCode(context.iTargetTransition) &&
   1.350 +				stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone);
   1.351 +		}
   1.352 +	else
   1.353 +		return stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone;
   1.354 +	}
   1.355 +
   1.356 +// ______________________________________________________________________________
   1.357 +//
   1.358 +inline TTransition_Cancel_TransitionValidator::TTransition_Cancel_TransitionValidator(CUnitTestContext& aUTContext)
   1.359 +:TTransitionValidator(aUTContext)
   1.360 +	{
   1.361 +	// Do nothing
   1.362 +	}
   1.363 +
   1.364 +_LIT(KCancelFailedInvariant,
   1.365 +	"CTransition_Cancel_Transition invariant failure");
   1.366 +
   1.367 +inline TBool TTransition_Cancel_TransitionValidator::ValidatePreConditions()
   1.368 +	{
   1.369 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.370 +	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   1.371 +		{
   1.372 +		context.DataLogger().LogInformation(KCancelFailedInvariant);
   1.373 +		return EFalse;
   1.374 +		}
   1.375 +	return ETrue;
   1.376 +	}
   1.377 +
   1.378 +inline TBool TTransition_Cancel_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   1.379 +	{
   1.380 +	// For a c'tor this should be empty.
   1.381 +	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   1.382 +	TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
   1.383 +	if(stateAccessor.InvariantTest(context.iTargetTransition))
   1.384 +		{
   1.385 +		context.DataLogger().LogInformation(KCancelFailedInvariant);
   1.386 +		return EFalse;
   1.387 +		}
   1.388 +	return stateAccessor.Status(context.iTargetTransition).Int() == KErrCancel;
   1.389 +	}
   1.390 +
   1.391 +// ______________________________________________________________________________
   1.392 +//
   1.393 +inline TTransition_NULL_TransitionValidator::TTransition_NULL_TransitionValidator(CUnitTestContext& aUTContext)
   1.394 +:TTransitionValidator(aUTContext)
   1.395 +	{
   1.396 +	// Do nothing
   1.397 +	}
   1.398 +
   1.399 +inline TBool TTransition_NULL_TransitionValidator::ValidatePreConditions()
   1.400 +	{
   1.401 +	// Always
   1.402 +	return ETrue;
   1.403 +	}
   1.404 +
   1.405 +inline TBool TTransition_NULL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   1.406 +	{
   1.407 +	// Always
   1.408 +	return ETrue;
   1.409 +	}