os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionTransitions.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2001-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 classes upon the CTransition class methods,
    15 // together with the derived transition used for testing.
    16 // 
    17 //
    18 
    19 // ______________________________________________________________________________
    20 //
    21 _LIT(KTargetNullMethodTransition,"CTarget_NullMethod_Transition");
    22 
    23 inline CTarget_NullMethod_Transition::CTarget_NullMethod_Transition(CUnitTestContext& aUTContext,
    24 													TTransitionValidator& aValidator)
    25 : CTransition(KTargetNullMethodTransition, aUTContext, aValidator)
    26 	{
    27 	// Do nothing here.
    28 	}
    29 
    30 inline void CTarget_NullMethod_Transition::TransitMethodL()
    31 	{
    32 	// There is no method to execute
    33 	// However exercise both possible results by 
    34 	// provoking a leave with the context's leave code
    35 	// on the second TransitMethodL call.
    36 	_LIT(KTargetNullMethodTransitMethod, "CTarget::NullMethod transition");
    37 	Context().DataLogger().LogInformation(KTargetNullMethodTransitMethod);
    38 	if(Context().iLeaveCode != KErrNone)
    39 		User::Leave(Context().iLeaveCode);
    40 	else
    41 		Context().iLeaveCode = KErrAbort;	// For next entry
    42 	}
    43 
    44 inline CTargetTransition_UnitTestContext& CTarget_NullMethod_Transition::Context() const
    45 	{
    46 	return REINTERPRET_CAST(CTargetTransition_UnitTestContext&,iUTContext);
    47 	}
    48 
    49 // ______________________________________________________________________________
    50 //
    51 inline CTargetTransition_UnitTestContext::CTargetTransition_UnitTestContext(CDataLogger& aDataLogger,
    52 												MStateAccessor& aStateAccessor,
    53 												MTransitionObserver& aObserver)
    54 : CUnitTestContext(aDataLogger, aStateAccessor, aObserver)
    55 	{
    56 	//Do nothing
    57 	}
    58 
    59 inline CTargetTransition_UnitTestContext::~CTargetTransition_UnitTestContext()
    60 	{
    61 	// Do Nothing
    62 	}
    63 
    64 // ______________________________________________________________________________
    65 //
    66 _LIT(KTransitionNewLTransition,"CTransition_NewL_Transition");
    67 
    68 inline CTransition_NewL_Transition::CTransition_NewL_Transition(CUnitTestContext& aUTContext,
    69 													TTransitionValidator& aValidator)
    70 : CTransitionType(KTransitionNewLTransition, aUTContext, aValidator)
    71 	{
    72 	// Do nothing here.
    73 	}
    74 
    75 inline void CTransition_NewL_Transition::TransitMethodL()
    76 	{
    77 	_LIT(KTransitionNewLTransitMethod, "CTransition::NewL transition");
    78 	Context().DataLogger().LogInformation(KTransitionNewLTransitMethod);
    79 	Context().iTargetTransition = new(ELeave)CTarget_NullMethod_Transition(*(Context().iTargetContext), *(Context().iTargetValidator));
    80 	}
    81 
    82 inline CTransition_UnitTestContext& CTransition_NewL_Transition::Context() const
    83 	{
    84 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
    85 	}
    86 
    87 // ______________________________________________________________________________
    88 //
    89 _LIT(KTransitionDtorTransition,"CTransition_Dtor_Transition");
    90 
    91 inline CTransition_Dtor_Transition::CTransition_Dtor_Transition(CUnitTestContext& aUTContext,
    92 													TTransitionValidator& aValidator)
    93 : CTransition(KTransitionDtorTransition, aUTContext, aValidator)
    94 	{
    95 	// Do nothing here.
    96 	}
    97 
    98 inline void CTransition_Dtor_Transition::TransitMethodL()
    99 	{
   100 	_LIT(KTransitionDtorTransitMethod, "CTransition::Dtor transition");
   101 	Context().DataLogger().LogInformation(KTransitionDtorTransitMethod);
   102 	delete Context().iTargetTransition;
   103 	Context().iTargetTransition = NULL;
   104 	}
   105 
   106 inline CTransition_UnitTestContext& CTransition_Dtor_Transition::Context() const
   107 	{
   108 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   109 	}
   110 
   111 // ______________________________________________________________________________
   112 //
   113 _LIT(KTransitionTransitMethodLTransition,"CTransition_TransitMethodL_Transition");
   114 
   115 inline CTransition_TransitMethodL_Transition::CTransition_TransitMethodL_Transition(CUnitTestContext& aUTContext,
   116 													TTransitionValidator& aValidator)
   117 : CTransitionType(KTransitionTransitMethodLTransition, aUTContext, aValidator)
   118 	{
   119 	// Do nothing here.
   120 	}
   121 
   122 inline void CTransition_TransitMethodL_Transition::TransitMethodL()
   123 	{
   124 	_LIT(KTransitionTransitMethodLTransitMethod, "CTransition::TransitMethodL transition");
   125 	Context().DataLogger().LogInformation(KTransitionTransitMethodLTransitMethod);
   126 	Context().iTargetTransition->TransitMethodL();
   127 	}
   128 
   129 inline CTransition_UnitTestContext& CTransition_TransitMethodL_Transition::Context() const
   130 	{
   131 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   132 	}
   133 
   134 // ______________________________________________________________________________
   135 //
   136 _LIT(KTransitionRepeatOnceTransition,"CTransition_RepeatOnce_Transition");
   137 
   138 inline CTransition_RepeatOnce_Transition::CTransition_RepeatOnce_Transition(CUnitTestContext& aUTContext,
   139 													TTransitionValidator& aValidator)
   140 : CTransition(KTransitionRepeatOnceTransition, aUTContext, aValidator)
   141 	{
   142 	// Do nothing here.
   143 	}
   144 
   145 inline void CTransition_RepeatOnce_Transition::TransitMethodL()
   146 	{
   147 	_LIT(KTransitionRepeatOnceTransitMethod, "CTransition::RepeatOnce transition");
   148 	Context().DataLogger().LogInformation(KTransitionRepeatOnceTransitMethod);
   149 	Context().iTargetTransition->RepeatOnce();
   150 	}
   151 
   152 inline CTransition_UnitTestContext& CTransition_RepeatOnce_Transition::Context() const
   153 	{
   154 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   155 	}
   156 
   157 // ______________________________________________________________________________
   158 //
   159 _LIT(KTransitionTransitionIdTransition,"CTransition_TransitionId_Transition");
   160 
   161 inline CTransition_TransitionId_Transition::CTransition_TransitionId_Transition(CUnitTestContext& aUTContext,
   162 													TTransitionValidator& aValidator)
   163 : CTransition(KTransitionTransitionIdTransition, aUTContext, aValidator)
   164 	{
   165 	// Do nothing here.
   166 	}
   167 
   168 inline void CTransition_TransitionId_Transition::TransitMethodL()
   169 	{
   170 	_LIT(KTransitionTransitionIdTransitMethod, "CTransition::TransitionId transition");
   171 	Context().DataLogger().LogInformation(KTransitionTransitionIdTransitMethod);
   172 	Context().iTransitionId = CONST_CAST(TDesC*, &(Context().iTargetTransition->TransitionId()));
   173 	}
   174 
   175 inline CTransition_UnitTestContext& CTransition_TransitionId_Transition::Context() const
   176 	{
   177 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   178 	}
   179 
   180 // ______________________________________________________________________________
   181 //
   182 _LIT(KTransitionTransitionInfoTransition,"CTransition_TransitionInfo_Transition");
   183 
   184 inline CTransition_TransitionInfo_Transition::CTransition_TransitionInfo_Transition(CUnitTestContext& aUTContext,
   185 													TTransitionValidator& aValidator)
   186 : CTransition(KTransitionTransitionInfoTransition, aUTContext, aValidator)
   187 	{
   188 	// Do nothing here.
   189 	}
   190 
   191 inline void CTransition_TransitionInfo_Transition::TransitMethodL()
   192 	{
   193 	_LIT(KTransitionTransitionInfoTransitMethod, "CTransition::TransitionInfo transition");
   194 	Context().DataLogger().LogInformation(KTransitionTransitionInfoTransitMethod);
   195 	Context().iTransitionInfo = CONST_CAST(TTransitionInfo*, &(Context().iTargetTransition->TransitionInfo()));
   196 	}
   197 
   198 inline CTransition_UnitTestContext& CTransition_TransitionInfo_Transition::Context() const
   199 	{
   200 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   201 	}
   202 
   203 // ______________________________________________________________________________
   204 //
   205 _LIT(KTransitionSetBlockingTransition,"CTransition_SetBlocking_Transition");
   206 
   207 inline CTransition_SetBlocking_Transition::CTransition_SetBlocking_Transition(CUnitTestContext& aUTContext,
   208 													TTransitionValidator& aValidator)
   209 : CTransition(KTransitionSetBlockingTransition, aUTContext, aValidator)
   210 	{
   211 	// Do nothing here.
   212 	}
   213 
   214 inline void CTransition_SetBlocking_Transition::TransitMethodL()
   215 	{
   216 	_LIT(KTransitionSetBlockingTransitMethod, "CTransition::SetBlocking transition");
   217 	Context().DataLogger().LogInformation(KTransitionSetBlockingTransitMethod);
   218 	Context().iTargetTransition->SetBlockingTransition(Context().iBlockingTransition);
   219 	}
   220 
   221 inline CTransition_UnitTestContext& CTransition_SetBlocking_Transition::Context() const
   222 	{
   223 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   224 	}
   225 
   226 // ______________________________________________________________________________
   227 //
   228 _LIT(KTransitionIsBlockingTransition,"CTransition_IsBlocking_Transition");
   229 
   230 inline CTransition_IsBlocking_Transition::CTransition_IsBlocking_Transition(CUnitTestContext& aUTContext,
   231 													TTransitionValidator& aValidator)
   232 : CTransition(KTransitionIsBlockingTransition, aUTContext, aValidator)
   233 	{
   234 	// Do nothing here.
   235 	}
   236 
   237 inline void CTransition_IsBlocking_Transition::TransitMethodL()
   238 	{
   239 	_LIT(KTransitionIsBlockingTransitMethod, "CTransition::IsBlocking transition");
   240 	Context().DataLogger().LogInformation(KTransitionIsBlockingTransitMethod);
   241 	Context().iBlockingTransition = !Context().iTargetTransition->IsBlockingTransition();
   242 	}
   243 
   244 inline CTransition_UnitTestContext& CTransition_IsBlocking_Transition::Context() const
   245 	{
   246 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   247 	}
   248 
   249 // ______________________________________________________________________________
   250 //
   251 _LIT(KTransitionGetErrorCodeTransition,"CTransition_GetErrorCode_Transition");
   252 
   253 inline CTransition_GetErrorCode_Transition::CTransition_GetErrorCode_Transition(CUnitTestContext& aUTContext,
   254 													TTransitionValidator& aValidator)
   255 : CTransition(KTransitionGetErrorCodeTransition, aUTContext, aValidator)
   256 	{
   257 	// Do nothing here.
   258 	}
   259 
   260 inline void CTransition_GetErrorCode_Transition::TransitMethodL()
   261 	{
   262 	_LIT(KTransitionGetErrorCodeTransitMethod, "CTransition::GetErrorCode transition");
   263 	Context().DataLogger().LogInformation(KTransitionGetErrorCodeTransitMethod);
   264 	Context().iTargetErrorCode = Context().iTargetTransition->GetErrorCode();
   265 	}
   266 
   267 inline CTransition_UnitTestContext& CTransition_GetErrorCode_Transition::Context() const
   268 	{
   269 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   270 	}
   271 
   272 // ______________________________________________________________________________
   273 //
   274 _LIT(KTransitionRunTransitionTransition,"CTransition_RunTransition_Transition");
   275 
   276 inline CTransition_RunTransition_Transition::CTransition_RunTransition_Transition(CUnitTestContext& aUTContext,
   277 													TTransitionValidator& aValidator)
   278 : CTransition(KTransitionRunTransitionTransition, aUTContext, aValidator)
   279 	{
   280 	// Do nothing here.
   281 	}
   282 
   283 inline void CTransition_RunTransition_Transition::TransitMethodL()
   284 	{
   285 	_LIT(KTransitionRunTransitionTransitMethod, "CTransition::RunTransition transition");
   286 	Context().DataLogger().LogInformation(KTransitionRunTransitionTransitMethod);
   287 	// Kick off this transition as an asynchronous call on the RunTransition
   288 	// So that this transition will complete when our target transition completes and signals its observer
   289 	iStatus = KRequestPending;
   290 	TRequestStatus* status = &iStatus;
   291 	Context().iTargetTransition->RunTransition(status);
   292 	}
   293 
   294 inline void CTransition_RunTransition_Transition::DoCancel()
   295 	{
   296 	_LIT(KTransitionRunTransitionTransitMethodCancel, "CTransition::RunTransition transition cancelled");
   297 	Context().DataLogger().LogInformation(KTransitionRunTransitionTransitMethodCancel);
   298 	Context().iTargetTransition->Cancel();
   299 	}
   300 
   301 inline CTransition_UnitTestContext& CTransition_RunTransition_Transition::Context() const
   302 	{
   303 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   304 	}
   305 
   306 // ______________________________________________________________________________
   307 //
   308 _LIT(KTransitionCancelTransition,"CTransition_Cancel_Transition");
   309 
   310 inline CTransition_Cancel_Transition::CTransition_Cancel_Transition(CUnitTestContext& aUTContext,
   311 													TTransitionValidator& aValidator)
   312 : CTransition(KTransitionCancelTransition, aUTContext, aValidator)
   313 	{
   314 	// Do nothing here.
   315 	}
   316 
   317 inline void CTransition_Cancel_Transition::TransitMethodL()
   318 	{
   319 	_LIT(KTransitionCancelTransitMethod, "CTransition::Cancel transition");
   320 	Context().DataLogger().LogInformation(KTransitionCancelTransitMethod);
   321 	Context().iTargetTransition->Cancel();
   322 	}
   323 
   324 inline CTransition_UnitTestContext& CTransition_Cancel_Transition::Context() const
   325 	{
   326 	return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
   327 	}
   328