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