os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionTransitionValidation.inl
First public contribution.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // The implementation of the transition validation classes upon the CTransition class methods.
18 // ______________________________________________________________________________
20 inline TTransition_Ctor_TransitionValidator::TTransition_Ctor_TransitionValidator(CUnitTestContext& aUTContext)
21 :TTransitionValidator(aUTContext)
26 _LIT(KCtorFailedInvariant,
27 "CTransition_Ctor_Transition invariant failure");
29 inline TBool TTransition_Ctor_TransitionValidator::ValidatePreConditions()
34 inline TBool TTransition_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
36 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
38 iUTContext.DataLogger().LogInformation(KCtorFailedInvariant);
44 // ______________________________________________________________________________
46 inline TTransition_Dtor_TransitionValidator::TTransition_Dtor_TransitionValidator(CUnitTestContext& aUTContext)
47 :TTransitionValidator(aUTContext)
52 _LIT(KDtorFailedInvariant,
53 "CTransition_Dtor_Transition invariant failure");
55 inline TBool TTransition_Dtor_TransitionValidator::ValidatePreConditions()
57 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
59 iUTContext.DataLogger().LogInformation(KDtorFailedInvariant);
65 inline TBool TTransition_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
70 // ______________________________________________________________________________
72 inline TTransition_TransitMethodL_TransitionValidator::TTransition_TransitMethodL_TransitionValidator(CUnitTestContext& aUTContext)
73 :TTransitionValidator(aUTContext)
78 _LIT(KTransitMethodLFailedInvariant,
79 "CTransition_TransitMethodL_Transition invariant failure");
81 inline TBool TTransition_TransitMethodL_TransitionValidator::ValidatePreConditions()
83 // For a c'tor this should be empty.
84 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
86 iUTContext.DataLogger().LogInformation(KTransitMethodLFailedInvariant);
92 inline TBool TTransition_TransitMethodL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
94 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
95 TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
96 if(stateAccessor.InvariantTest(context.iTargetTransition))
98 context.DataLogger().LogInformation(KTransitMethodLFailedInvariant);
101 return stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone;
104 // ______________________________________________________________________________
106 inline TTransition_RepeatOnce_TransitionValidator::TTransition_RepeatOnce_TransitionValidator(CUnitTestContext& aUTContext)
107 :TTransitionValidator(aUTContext)
112 _LIT(KRepeatOnceFailedInvariant,
113 "CTransition_RepeatOnce_Transition invariant failure");
115 inline TBool TTransition_RepeatOnce_TransitionValidator::ValidatePreConditions()
117 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
118 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
120 context.DataLogger().LogInformation(KRepeatOnceFailedInvariant);
123 return !REINTERPRET_CAST(TTransition_StateAccessor&,context.StateAccessor()).IsRepeated(context.iTargetTransition);
126 inline TBool TTransition_RepeatOnce_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
128 // For a c'tor this should be empty.
129 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
130 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
132 context.DataLogger().LogInformation(KRepeatOnceFailedInvariant);
135 return REINTERPRET_CAST(TTransition_StateAccessor&,context.StateAccessor()).IsRepeated(context.iTargetTransition);
138 // ______________________________________________________________________________
140 inline TTransition_TransitionId_TransitionValidator::TTransition_TransitionId_TransitionValidator(CUnitTestContext& aUTContext)
141 :TTransitionValidator(aUTContext)
146 _LIT(KTransitionIdFailedInvariant,
147 "CTransition_TransitionId_Transition invariant failure");
149 inline TBool TTransition_TransitionId_TransitionValidator::ValidatePreConditions()
151 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
152 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
154 context.DataLogger().LogInformation(KTransitionIdFailedInvariant);
160 inline TBool TTransition_TransitionId_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
162 // For a c'tor this should be empty.
163 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
164 TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
165 if(stateAccessor.InvariantTest(context.iTargetTransition))
167 context.DataLogger().LogInformation(KTransitionIdFailedInvariant);
170 // Compare the contents of the ids for a match
171 return *(context.iTransitionId) == *(stateAccessor.TransitionId(context.iTargetTransition));
174 // ______________________________________________________________________________
176 inline TTransition_TransitionInfo_TransitionValidator::TTransition_TransitionInfo_TransitionValidator(CUnitTestContext& aUTContext)
177 :TTransitionValidator(aUTContext)
182 _LIT(KTransitionInfoFailedInvariant,
183 "CTransition_TransitionInfo_Transition invariant failure");
185 inline TBool TTransition_TransitionInfo_TransitionValidator::ValidatePreConditions()
187 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
188 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
190 context.DataLogger().LogInformation(KTransitionInfoFailedInvariant);
196 inline TBool TTransition_TransitionInfo_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
198 // For a c'tor this should be empty.
199 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
200 TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
201 if(stateAccessor.InvariantTest(context.iTargetTransition))
203 context.DataLogger().LogInformation(KTransitionInfoFailedInvariant);
206 return context.iTransitionInfo == stateAccessor.TransitionInfo(context.iTargetTransition);
209 // ______________________________________________________________________________
211 inline TTransition_SetBlocking_TransitionValidator::TTransition_SetBlocking_TransitionValidator(CUnitTestContext& aUTContext)
212 :TTransitionValidator(aUTContext)
217 _LIT(KSetBlockingFailedInvariant,
218 "CTransition_SetBlocking_Transition invariant failure");
220 inline TBool TTransition_SetBlocking_TransitionValidator::ValidatePreConditions()
222 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
223 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
225 context.DataLogger().LogInformation(KSetBlockingFailedInvariant);
231 inline TBool TTransition_SetBlocking_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
233 // For a c'tor this should be empty.
234 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
235 TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
236 if(stateAccessor.InvariantTest(context.iTargetTransition))
238 context.DataLogger().LogInformation(KSetBlockingFailedInvariant);
241 return context.iBlockingTransition == stateAccessor.BlockingFlag(context.iTargetTransition);
243 // ______________________________________________________________________________
245 inline TTransition_IsBlocking_TransitionValidator::TTransition_IsBlocking_TransitionValidator(CUnitTestContext& aUTContext)
246 :TTransitionValidator(aUTContext)
251 _LIT(KIsBlockingFailedInvariant,
252 "CTransition_IsBlocking_Transition invariant failure");
254 inline TBool TTransition_IsBlocking_TransitionValidator::ValidatePreConditions()
256 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
257 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
259 context.DataLogger().LogInformation(KIsBlockingFailedInvariant);
265 inline TBool TTransition_IsBlocking_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
267 // For a c'tor this should be empty.
268 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
269 TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
270 if(stateAccessor.InvariantTest(context.iTargetTransition))
272 context.DataLogger().LogInformation(KIsBlockingFailedInvariant);
275 return context.iBlockingTransition != stateAccessor.BlockingFlag(context.iTargetTransition);
278 // ______________________________________________________________________________
280 inline TTransition_GetErrorCode_TransitionValidator::TTransition_GetErrorCode_TransitionValidator(CUnitTestContext& aUTContext)
281 :TTransitionValidator(aUTContext)
286 _LIT(KGetErrorCodeFailedInvariant,
287 "CTransition_GetErrorCode_Transition invariant failure");
289 inline TBool TTransition_GetErrorCode_TransitionValidator::ValidatePreConditions()
291 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
292 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
294 context.DataLogger().LogInformation(KGetErrorCodeFailedInvariant);
300 inline TBool TTransition_GetErrorCode_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
302 // For a c'tor this should be empty.
303 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
304 TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
305 if(stateAccessor.InvariantTest(context.iTargetTransition))
307 context.DataLogger().LogInformation(KGetErrorCodeFailedInvariant);
312 // ______________________________________________________________________________
314 inline TTransition_RunTransition_TransitionValidator::TTransition_RunTransition_TransitionValidator(CUnitTestContext& aUTContext)
315 :TTransitionValidator(aUTContext)
320 _LIT(KRunTransitionFailedInvariant,
321 "CTransition_RunTransition_Transition invariant failure");
323 inline TBool TTransition_RunTransition_TransitionValidator::ValidatePreConditions()
325 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
326 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
328 context.DataLogger().LogInformation(KRunTransitionFailedInvariant);
334 inline TBool TTransition_RunTransition_TransitionValidator::ValidatePostConditions(TTestBedAsyncState aAsyncState)
336 // For a c'tor this should be empty.
337 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
338 TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
339 if(stateAccessor.InvariantTest(context.iTargetTransition))
341 context.DataLogger().LogInformation(KRunTransitionFailedInvariant);
346 return (stateAccessor.Status(context.iTargetTransition).Int() == stateAccessor.ErrorCode(context.iTargetTransition) &&
347 stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone);
350 return stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone;
353 // ______________________________________________________________________________
355 inline TTransition_Cancel_TransitionValidator::TTransition_Cancel_TransitionValidator(CUnitTestContext& aUTContext)
356 :TTransitionValidator(aUTContext)
361 _LIT(KCancelFailedInvariant,
362 "CTransition_Cancel_Transition invariant failure");
364 inline TBool TTransition_Cancel_TransitionValidator::ValidatePreConditions()
366 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
367 if(context.StateAccessor().InvariantTest(context.iTargetTransition))
369 context.DataLogger().LogInformation(KCancelFailedInvariant);
375 inline TBool TTransition_Cancel_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
377 // For a c'tor this should be empty.
378 CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
379 TTransition_StateAccessor& stateAccessor = REINTERPRET_CAST(TTransition_StateAccessor&, context.StateAccessor());
380 if(stateAccessor.InvariantTest(context.iTargetTransition))
382 context.DataLogger().LogInformation(KCancelFailedInvariant);
385 return stateAccessor.Status(context.iTargetTransition).Int() == KErrCancel;
388 // ______________________________________________________________________________
390 inline TTransition_NULL_TransitionValidator::TTransition_NULL_TransitionValidator(CUnitTestContext& aUTContext)
391 :TTransitionValidator(aUTContext)
396 inline TBool TTransition_NULL_TransitionValidator::ValidatePreConditions()
402 inline TBool TTransition_NULL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)