os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionTransitionValidation.inl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // The implementation of the transition validation classes upon the CTransition class methods.
    15 // 
    16 //
    17 
    18 // ______________________________________________________________________________
    19 //
    20 inline TTransition_Ctor_TransitionValidator::TTransition_Ctor_TransitionValidator(CUnitTestContext& aUTContext)
    21 :TTransitionValidator(aUTContext)
    22 	{
    23 	// Do nothing
    24 	}
    25 
    26 _LIT(KCtorFailedInvariant,
    27 	"CTransition_Ctor_Transition invariant failure");
    28 
    29 inline TBool TTransition_Ctor_TransitionValidator::ValidatePreConditions()
    30 	{
    31 	return ETrue;
    32 	}
    33 
    34 inline TBool TTransition_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    35 	{
    36 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
    37 		{
    38 		iUTContext.DataLogger().LogInformation(KCtorFailedInvariant);
    39 		return EFalse;
    40 		}
    41 	return ETrue;
    42 	}
    43 
    44 // ______________________________________________________________________________
    45 //
    46 inline TTransition_Dtor_TransitionValidator::TTransition_Dtor_TransitionValidator(CUnitTestContext& aUTContext)
    47 :TTransitionValidator(aUTContext)
    48 	{
    49 	// Do nothing
    50 	}
    51 
    52 _LIT(KDtorFailedInvariant,
    53 	"CTransition_Dtor_Transition invariant failure");
    54 
    55 inline TBool TTransition_Dtor_TransitionValidator::ValidatePreConditions()
    56 	{
    57 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
    58 		{
    59 		iUTContext.DataLogger().LogInformation(KDtorFailedInvariant);
    60 		return EFalse;
    61 		}
    62 	return ETrue;
    63 	}
    64 
    65 inline TBool TTransition_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    66 	{
    67 	return ETrue;
    68 	}
    69 
    70 // ______________________________________________________________________________
    71 //
    72 inline TTransition_TransitMethodL_TransitionValidator::TTransition_TransitMethodL_TransitionValidator(CUnitTestContext& aUTContext)
    73 :TTransitionValidator(aUTContext)
    74 	{
    75 	// Do nothing
    76 	}
    77 
    78 _LIT(KTransitMethodLFailedInvariant,
    79 	"CTransition_TransitMethodL_Transition invariant failure");
    80 
    81 inline TBool TTransition_TransitMethodL_TransitionValidator::ValidatePreConditions()
    82 	{
    83 	// For a c'tor this should be empty.
    84 	if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext).iTargetTransition))
    85 		{
    86 		iUTContext.DataLogger().LogInformation(KTransitMethodLFailedInvariant);
    87 		return EFalse;
    88 		}
    89 	return ETrue;
    90 	}
    91 
    92 inline TBool TTransition_TransitMethodL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
    93 	{
    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))
    97 		{
    98 		context.DataLogger().LogInformation(KTransitMethodLFailedInvariant);
    99 		return EFalse;
   100 		}
   101 	return stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone;
   102 	}
   103 
   104 // ______________________________________________________________________________
   105 //
   106 inline TTransition_RepeatOnce_TransitionValidator::TTransition_RepeatOnce_TransitionValidator(CUnitTestContext& aUTContext)
   107 :TTransitionValidator(aUTContext)
   108 	{
   109 	// Do nothing
   110 	}
   111 
   112 _LIT(KRepeatOnceFailedInvariant,
   113 	"CTransition_RepeatOnce_Transition invariant failure");
   114 
   115 inline TBool TTransition_RepeatOnce_TransitionValidator::ValidatePreConditions()
   116 	{
   117 	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   118 	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   119 		{
   120 		context.DataLogger().LogInformation(KRepeatOnceFailedInvariant);
   121 		return EFalse;
   122 		}
   123 	return !REINTERPRET_CAST(TTransition_StateAccessor&,context.StateAccessor()).IsRepeated(context.iTargetTransition);
   124 	}
   125 
   126 inline TBool TTransition_RepeatOnce_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   127 	{
   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))
   131 		{
   132 		context.DataLogger().LogInformation(KRepeatOnceFailedInvariant);
   133 		return EFalse;
   134 		}
   135 	return REINTERPRET_CAST(TTransition_StateAccessor&,context.StateAccessor()).IsRepeated(context.iTargetTransition);
   136 	}
   137 
   138 // ______________________________________________________________________________
   139 //
   140 inline TTransition_TransitionId_TransitionValidator::TTransition_TransitionId_TransitionValidator(CUnitTestContext& aUTContext)
   141 :TTransitionValidator(aUTContext)
   142 	{
   143 	// Do nothing
   144 	}
   145 
   146 _LIT(KTransitionIdFailedInvariant,
   147 	"CTransition_TransitionId_Transition invariant failure");
   148 
   149 inline TBool TTransition_TransitionId_TransitionValidator::ValidatePreConditions()
   150 	{
   151 	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   152 	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   153 		{
   154 		context.DataLogger().LogInformation(KTransitionIdFailedInvariant);
   155 		return EFalse;
   156 		}
   157 	return ETrue;
   158 	}
   159 
   160 inline TBool TTransition_TransitionId_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   161 	{
   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))
   166 		{
   167 		context.DataLogger().LogInformation(KTransitionIdFailedInvariant);
   168 		return EFalse;
   169 		}
   170 	// Compare the contents of the ids for a match
   171 	return *(context.iTransitionId) == *(stateAccessor.TransitionId(context.iTargetTransition));
   172 	}
   173 
   174 // ______________________________________________________________________________
   175 //
   176 inline TTransition_TransitionInfo_TransitionValidator::TTransition_TransitionInfo_TransitionValidator(CUnitTestContext& aUTContext)
   177 :TTransitionValidator(aUTContext)
   178 	{
   179 	// Do nothing
   180 	}
   181 
   182 _LIT(KTransitionInfoFailedInvariant,
   183 	"CTransition_TransitionInfo_Transition invariant failure");
   184 
   185 inline TBool TTransition_TransitionInfo_TransitionValidator::ValidatePreConditions()
   186 	{
   187 	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   188 	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   189 		{
   190 		context.DataLogger().LogInformation(KTransitionInfoFailedInvariant);
   191 		return EFalse;
   192 		}
   193 	return ETrue;
   194 	}
   195 
   196 inline TBool TTransition_TransitionInfo_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   197 	{
   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))
   202 		{
   203 		context.DataLogger().LogInformation(KTransitionInfoFailedInvariant);
   204 		return EFalse;
   205 		}
   206 	return context.iTransitionInfo == stateAccessor.TransitionInfo(context.iTargetTransition);
   207 	}
   208 
   209 // ______________________________________________________________________________
   210 //
   211 inline TTransition_SetBlocking_TransitionValidator::TTransition_SetBlocking_TransitionValidator(CUnitTestContext& aUTContext)
   212 :TTransitionValidator(aUTContext)
   213 	{
   214 	// Do nothing
   215 	}
   216 
   217 _LIT(KSetBlockingFailedInvariant,
   218 	"CTransition_SetBlocking_Transition invariant failure");
   219 
   220 inline TBool TTransition_SetBlocking_TransitionValidator::ValidatePreConditions()
   221 	{
   222 	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   223 	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   224 		{
   225 		context.DataLogger().LogInformation(KSetBlockingFailedInvariant);
   226 		return EFalse;
   227 		}
   228 	return ETrue;
   229 	}
   230 
   231 inline TBool TTransition_SetBlocking_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   232 	{
   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))
   237 		{
   238 		context.DataLogger().LogInformation(KSetBlockingFailedInvariant);
   239 		return EFalse;
   240 		}
   241 	return context.iBlockingTransition == stateAccessor.BlockingFlag(context.iTargetTransition);
   242 	}
   243 // ______________________________________________________________________________
   244 //
   245 inline TTransition_IsBlocking_TransitionValidator::TTransition_IsBlocking_TransitionValidator(CUnitTestContext& aUTContext)
   246 :TTransitionValidator(aUTContext)
   247 	{
   248 	// Do nothing
   249 	}
   250 
   251 _LIT(KIsBlockingFailedInvariant,
   252 	"CTransition_IsBlocking_Transition invariant failure");
   253 
   254 inline TBool TTransition_IsBlocking_TransitionValidator::ValidatePreConditions()
   255 	{
   256 	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   257 	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   258 		{
   259 		context.DataLogger().LogInformation(KIsBlockingFailedInvariant);
   260 		return EFalse;
   261 		}
   262 	return ETrue;
   263 	}
   264 
   265 inline TBool TTransition_IsBlocking_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   266 	{
   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))
   271 		{
   272 		context.DataLogger().LogInformation(KIsBlockingFailedInvariant);
   273 		return EFalse;
   274 		}
   275 	return context.iBlockingTransition != stateAccessor.BlockingFlag(context.iTargetTransition);
   276 	}
   277 
   278 // ______________________________________________________________________________
   279 //
   280 inline TTransition_GetErrorCode_TransitionValidator::TTransition_GetErrorCode_TransitionValidator(CUnitTestContext& aUTContext)
   281 :TTransitionValidator(aUTContext)
   282 	{
   283 	// Do nothing
   284 	}
   285 
   286 _LIT(KGetErrorCodeFailedInvariant,
   287 	"CTransition_GetErrorCode_Transition invariant failure");
   288 
   289 inline TBool TTransition_GetErrorCode_TransitionValidator::ValidatePreConditions()
   290 	{
   291 	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   292 	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   293 		{
   294 		context.DataLogger().LogInformation(KGetErrorCodeFailedInvariant);
   295 		return EFalse;
   296 		}
   297 	return ETrue;
   298 	}
   299 
   300 inline TBool TTransition_GetErrorCode_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   301 	{
   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))
   306 		{
   307 		context.DataLogger().LogInformation(KGetErrorCodeFailedInvariant);
   308 		return EFalse;
   309 		}
   310 	return ETrue;
   311 	}
   312 // ______________________________________________________________________________
   313 //
   314 inline TTransition_RunTransition_TransitionValidator::TTransition_RunTransition_TransitionValidator(CUnitTestContext& aUTContext)
   315 :TTransitionValidator(aUTContext)
   316 	{
   317 	// Do nothing
   318 	}
   319 
   320 _LIT(KRunTransitionFailedInvariant,
   321 	"CTransition_RunTransition_Transition invariant failure");
   322 
   323 inline TBool TTransition_RunTransition_TransitionValidator::ValidatePreConditions()
   324 	{
   325 	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   326 	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   327 		{
   328 		context.DataLogger().LogInformation(KRunTransitionFailedInvariant);
   329 		return EFalse;
   330 		}
   331 	return ETrue;
   332 	}
   333 
   334 inline TBool TTransition_RunTransition_TransitionValidator::ValidatePostConditions(TTestBedAsyncState aAsyncState)
   335 	{
   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))
   340 		{
   341 		context.DataLogger().LogInformation(KRunTransitionFailedInvariant);
   342 		return EFalse;
   343 		}
   344 	if(aAsyncState)
   345 		{
   346 		return (stateAccessor.Status(context.iTargetTransition).Int() == stateAccessor.ErrorCode(context.iTargetTransition) &&
   347 				stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone);
   348 		}
   349 	else
   350 		return stateAccessor.ErrorCode(context.iTargetTransition) == KErrNone;
   351 	}
   352 
   353 // ______________________________________________________________________________
   354 //
   355 inline TTransition_Cancel_TransitionValidator::TTransition_Cancel_TransitionValidator(CUnitTestContext& aUTContext)
   356 :TTransitionValidator(aUTContext)
   357 	{
   358 	// Do nothing
   359 	}
   360 
   361 _LIT(KCancelFailedInvariant,
   362 	"CTransition_Cancel_Transition invariant failure");
   363 
   364 inline TBool TTransition_Cancel_TransitionValidator::ValidatePreConditions()
   365 	{
   366 	CTransition_UnitTestContext& context = REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   367 	if(context.StateAccessor().InvariantTest(context.iTargetTransition))
   368 		{
   369 		context.DataLogger().LogInformation(KCancelFailedInvariant);
   370 		return EFalse;
   371 		}
   372 	return ETrue;
   373 	}
   374 
   375 inline TBool TTransition_Cancel_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   376 	{
   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))
   381 		{
   382 		context.DataLogger().LogInformation(KCancelFailedInvariant);
   383 		return EFalse;
   384 		}
   385 	return stateAccessor.Status(context.iTargetTransition).Int() == KErrCancel;
   386 	}
   387 
   388 // ______________________________________________________________________________
   389 //
   390 inline TTransition_NULL_TransitionValidator::TTransition_NULL_TransitionValidator(CUnitTestContext& aUTContext)
   391 :TTransitionValidator(aUTContext)
   392 	{
   393 	// Do nothing
   394 	}
   395 
   396 inline TBool TTransition_NULL_TransitionValidator::ValidatePreConditions()
   397 	{
   398 	// Always
   399 	return ETrue;
   400 	}
   401 
   402 inline TBool TTransition_NULL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
   403 	{
   404 	// Always
   405 	return ETrue;
   406 	}