os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionTransitions.inl
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TransitionTest/TransitionTransitions.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,328 @@
1.4 +// Copyright (c) 2001-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 classes upon the CTransition class methods,
1.18 +// together with the derived transition used for testing.
1.19 +//
1.20 +//
1.21 +
1.22 +// ______________________________________________________________________________
1.23 +//
1.24 +_LIT(KTargetNullMethodTransition,"CTarget_NullMethod_Transition");
1.25 +
1.26 +inline CTarget_NullMethod_Transition::CTarget_NullMethod_Transition(CUnitTestContext& aUTContext,
1.27 + TTransitionValidator& aValidator)
1.28 +: CTransition(KTargetNullMethodTransition, aUTContext, aValidator)
1.29 + {
1.30 + // Do nothing here.
1.31 + }
1.32 +
1.33 +inline void CTarget_NullMethod_Transition::TransitMethodL()
1.34 + {
1.35 + // There is no method to execute
1.36 + // However exercise both possible results by
1.37 + // provoking a leave with the context's leave code
1.38 + // on the second TransitMethodL call.
1.39 + _LIT(KTargetNullMethodTransitMethod, "CTarget::NullMethod transition");
1.40 + Context().DataLogger().LogInformation(KTargetNullMethodTransitMethod);
1.41 + if(Context().iLeaveCode != KErrNone)
1.42 + User::Leave(Context().iLeaveCode);
1.43 + else
1.44 + Context().iLeaveCode = KErrAbort; // For next entry
1.45 + }
1.46 +
1.47 +inline CTargetTransition_UnitTestContext& CTarget_NullMethod_Transition::Context() const
1.48 + {
1.49 + return REINTERPRET_CAST(CTargetTransition_UnitTestContext&,iUTContext);
1.50 + }
1.51 +
1.52 +// ______________________________________________________________________________
1.53 +//
1.54 +inline CTargetTransition_UnitTestContext::CTargetTransition_UnitTestContext(CDataLogger& aDataLogger,
1.55 + MStateAccessor& aStateAccessor,
1.56 + MTransitionObserver& aObserver)
1.57 +: CUnitTestContext(aDataLogger, aStateAccessor, aObserver)
1.58 + {
1.59 + //Do nothing
1.60 + }
1.61 +
1.62 +inline CTargetTransition_UnitTestContext::~CTargetTransition_UnitTestContext()
1.63 + {
1.64 + // Do Nothing
1.65 + }
1.66 +
1.67 +// ______________________________________________________________________________
1.68 +//
1.69 +_LIT(KTransitionNewLTransition,"CTransition_NewL_Transition");
1.70 +
1.71 +inline CTransition_NewL_Transition::CTransition_NewL_Transition(CUnitTestContext& aUTContext,
1.72 + TTransitionValidator& aValidator)
1.73 +: CTransitionType(KTransitionNewLTransition, aUTContext, aValidator)
1.74 + {
1.75 + // Do nothing here.
1.76 + }
1.77 +
1.78 +inline void CTransition_NewL_Transition::TransitMethodL()
1.79 + {
1.80 + _LIT(KTransitionNewLTransitMethod, "CTransition::NewL transition");
1.81 + Context().DataLogger().LogInformation(KTransitionNewLTransitMethod);
1.82 + Context().iTargetTransition = new(ELeave)CTarget_NullMethod_Transition(*(Context().iTargetContext), *(Context().iTargetValidator));
1.83 + }
1.84 +
1.85 +inline CTransition_UnitTestContext& CTransition_NewL_Transition::Context() const
1.86 + {
1.87 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.88 + }
1.89 +
1.90 +// ______________________________________________________________________________
1.91 +//
1.92 +_LIT(KTransitionDtorTransition,"CTransition_Dtor_Transition");
1.93 +
1.94 +inline CTransition_Dtor_Transition::CTransition_Dtor_Transition(CUnitTestContext& aUTContext,
1.95 + TTransitionValidator& aValidator)
1.96 +: CTransition(KTransitionDtorTransition, aUTContext, aValidator)
1.97 + {
1.98 + // Do nothing here.
1.99 + }
1.100 +
1.101 +inline void CTransition_Dtor_Transition::TransitMethodL()
1.102 + {
1.103 + _LIT(KTransitionDtorTransitMethod, "CTransition::Dtor transition");
1.104 + Context().DataLogger().LogInformation(KTransitionDtorTransitMethod);
1.105 + delete Context().iTargetTransition;
1.106 + Context().iTargetTransition = NULL;
1.107 + }
1.108 +
1.109 +inline CTransition_UnitTestContext& CTransition_Dtor_Transition::Context() const
1.110 + {
1.111 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.112 + }
1.113 +
1.114 +// ______________________________________________________________________________
1.115 +//
1.116 +_LIT(KTransitionTransitMethodLTransition,"CTransition_TransitMethodL_Transition");
1.117 +
1.118 +inline CTransition_TransitMethodL_Transition::CTransition_TransitMethodL_Transition(CUnitTestContext& aUTContext,
1.119 + TTransitionValidator& aValidator)
1.120 +: CTransitionType(KTransitionTransitMethodLTransition, aUTContext, aValidator)
1.121 + {
1.122 + // Do nothing here.
1.123 + }
1.124 +
1.125 +inline void CTransition_TransitMethodL_Transition::TransitMethodL()
1.126 + {
1.127 + _LIT(KTransitionTransitMethodLTransitMethod, "CTransition::TransitMethodL transition");
1.128 + Context().DataLogger().LogInformation(KTransitionTransitMethodLTransitMethod);
1.129 + Context().iTargetTransition->TransitMethodL();
1.130 + }
1.131 +
1.132 +inline CTransition_UnitTestContext& CTransition_TransitMethodL_Transition::Context() const
1.133 + {
1.134 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.135 + }
1.136 +
1.137 +// ______________________________________________________________________________
1.138 +//
1.139 +_LIT(KTransitionRepeatOnceTransition,"CTransition_RepeatOnce_Transition");
1.140 +
1.141 +inline CTransition_RepeatOnce_Transition::CTransition_RepeatOnce_Transition(CUnitTestContext& aUTContext,
1.142 + TTransitionValidator& aValidator)
1.143 +: CTransition(KTransitionRepeatOnceTransition, aUTContext, aValidator)
1.144 + {
1.145 + // Do nothing here.
1.146 + }
1.147 +
1.148 +inline void CTransition_RepeatOnce_Transition::TransitMethodL()
1.149 + {
1.150 + _LIT(KTransitionRepeatOnceTransitMethod, "CTransition::RepeatOnce transition");
1.151 + Context().DataLogger().LogInformation(KTransitionRepeatOnceTransitMethod);
1.152 + Context().iTargetTransition->RepeatOnce();
1.153 + }
1.154 +
1.155 +inline CTransition_UnitTestContext& CTransition_RepeatOnce_Transition::Context() const
1.156 + {
1.157 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.158 + }
1.159 +
1.160 +// ______________________________________________________________________________
1.161 +//
1.162 +_LIT(KTransitionTransitionIdTransition,"CTransition_TransitionId_Transition");
1.163 +
1.164 +inline CTransition_TransitionId_Transition::CTransition_TransitionId_Transition(CUnitTestContext& aUTContext,
1.165 + TTransitionValidator& aValidator)
1.166 +: CTransition(KTransitionTransitionIdTransition, aUTContext, aValidator)
1.167 + {
1.168 + // Do nothing here.
1.169 + }
1.170 +
1.171 +inline void CTransition_TransitionId_Transition::TransitMethodL()
1.172 + {
1.173 + _LIT(KTransitionTransitionIdTransitMethod, "CTransition::TransitionId transition");
1.174 + Context().DataLogger().LogInformation(KTransitionTransitionIdTransitMethod);
1.175 + Context().iTransitionId = CONST_CAST(TDesC*, &(Context().iTargetTransition->TransitionId()));
1.176 + }
1.177 +
1.178 +inline CTransition_UnitTestContext& CTransition_TransitionId_Transition::Context() const
1.179 + {
1.180 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.181 + }
1.182 +
1.183 +// ______________________________________________________________________________
1.184 +//
1.185 +_LIT(KTransitionTransitionInfoTransition,"CTransition_TransitionInfo_Transition");
1.186 +
1.187 +inline CTransition_TransitionInfo_Transition::CTransition_TransitionInfo_Transition(CUnitTestContext& aUTContext,
1.188 + TTransitionValidator& aValidator)
1.189 +: CTransition(KTransitionTransitionInfoTransition, aUTContext, aValidator)
1.190 + {
1.191 + // Do nothing here.
1.192 + }
1.193 +
1.194 +inline void CTransition_TransitionInfo_Transition::TransitMethodL()
1.195 + {
1.196 + _LIT(KTransitionTransitionInfoTransitMethod, "CTransition::TransitionInfo transition");
1.197 + Context().DataLogger().LogInformation(KTransitionTransitionInfoTransitMethod);
1.198 + Context().iTransitionInfo = CONST_CAST(TTransitionInfo*, &(Context().iTargetTransition->TransitionInfo()));
1.199 + }
1.200 +
1.201 +inline CTransition_UnitTestContext& CTransition_TransitionInfo_Transition::Context() const
1.202 + {
1.203 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.204 + }
1.205 +
1.206 +// ______________________________________________________________________________
1.207 +//
1.208 +_LIT(KTransitionSetBlockingTransition,"CTransition_SetBlocking_Transition");
1.209 +
1.210 +inline CTransition_SetBlocking_Transition::CTransition_SetBlocking_Transition(CUnitTestContext& aUTContext,
1.211 + TTransitionValidator& aValidator)
1.212 +: CTransition(KTransitionSetBlockingTransition, aUTContext, aValidator)
1.213 + {
1.214 + // Do nothing here.
1.215 + }
1.216 +
1.217 +inline void CTransition_SetBlocking_Transition::TransitMethodL()
1.218 + {
1.219 + _LIT(KTransitionSetBlockingTransitMethod, "CTransition::SetBlocking transition");
1.220 + Context().DataLogger().LogInformation(KTransitionSetBlockingTransitMethod);
1.221 + Context().iTargetTransition->SetBlockingTransition(Context().iBlockingTransition);
1.222 + }
1.223 +
1.224 +inline CTransition_UnitTestContext& CTransition_SetBlocking_Transition::Context() const
1.225 + {
1.226 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.227 + }
1.228 +
1.229 +// ______________________________________________________________________________
1.230 +//
1.231 +_LIT(KTransitionIsBlockingTransition,"CTransition_IsBlocking_Transition");
1.232 +
1.233 +inline CTransition_IsBlocking_Transition::CTransition_IsBlocking_Transition(CUnitTestContext& aUTContext,
1.234 + TTransitionValidator& aValidator)
1.235 +: CTransition(KTransitionIsBlockingTransition, aUTContext, aValidator)
1.236 + {
1.237 + // Do nothing here.
1.238 + }
1.239 +
1.240 +inline void CTransition_IsBlocking_Transition::TransitMethodL()
1.241 + {
1.242 + _LIT(KTransitionIsBlockingTransitMethod, "CTransition::IsBlocking transition");
1.243 + Context().DataLogger().LogInformation(KTransitionIsBlockingTransitMethod);
1.244 + Context().iBlockingTransition = !Context().iTargetTransition->IsBlockingTransition();
1.245 + }
1.246 +
1.247 +inline CTransition_UnitTestContext& CTransition_IsBlocking_Transition::Context() const
1.248 + {
1.249 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.250 + }
1.251 +
1.252 +// ______________________________________________________________________________
1.253 +//
1.254 +_LIT(KTransitionGetErrorCodeTransition,"CTransition_GetErrorCode_Transition");
1.255 +
1.256 +inline CTransition_GetErrorCode_Transition::CTransition_GetErrorCode_Transition(CUnitTestContext& aUTContext,
1.257 + TTransitionValidator& aValidator)
1.258 +: CTransition(KTransitionGetErrorCodeTransition, aUTContext, aValidator)
1.259 + {
1.260 + // Do nothing here.
1.261 + }
1.262 +
1.263 +inline void CTransition_GetErrorCode_Transition::TransitMethodL()
1.264 + {
1.265 + _LIT(KTransitionGetErrorCodeTransitMethod, "CTransition::GetErrorCode transition");
1.266 + Context().DataLogger().LogInformation(KTransitionGetErrorCodeTransitMethod);
1.267 + Context().iTargetErrorCode = Context().iTargetTransition->GetErrorCode();
1.268 + }
1.269 +
1.270 +inline CTransition_UnitTestContext& CTransition_GetErrorCode_Transition::Context() const
1.271 + {
1.272 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.273 + }
1.274 +
1.275 +// ______________________________________________________________________________
1.276 +//
1.277 +_LIT(KTransitionRunTransitionTransition,"CTransition_RunTransition_Transition");
1.278 +
1.279 +inline CTransition_RunTransition_Transition::CTransition_RunTransition_Transition(CUnitTestContext& aUTContext,
1.280 + TTransitionValidator& aValidator)
1.281 +: CTransition(KTransitionRunTransitionTransition, aUTContext, aValidator)
1.282 + {
1.283 + // Do nothing here.
1.284 + }
1.285 +
1.286 +inline void CTransition_RunTransition_Transition::TransitMethodL()
1.287 + {
1.288 + _LIT(KTransitionRunTransitionTransitMethod, "CTransition::RunTransition transition");
1.289 + Context().DataLogger().LogInformation(KTransitionRunTransitionTransitMethod);
1.290 + // Kick off this transition as an asynchronous call on the RunTransition
1.291 + // So that this transition will complete when our target transition completes and signals its observer
1.292 + iStatus = KRequestPending;
1.293 + TRequestStatus* status = &iStatus;
1.294 + Context().iTargetTransition->RunTransition(status);
1.295 + }
1.296 +
1.297 +inline void CTransition_RunTransition_Transition::DoCancel()
1.298 + {
1.299 + _LIT(KTransitionRunTransitionTransitMethodCancel, "CTransition::RunTransition transition cancelled");
1.300 + Context().DataLogger().LogInformation(KTransitionRunTransitionTransitMethodCancel);
1.301 + Context().iTargetTransition->Cancel();
1.302 + }
1.303 +
1.304 +inline CTransition_UnitTestContext& CTransition_RunTransition_Transition::Context() const
1.305 + {
1.306 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.307 + }
1.308 +
1.309 +// ______________________________________________________________________________
1.310 +//
1.311 +_LIT(KTransitionCancelTransition,"CTransition_Cancel_Transition");
1.312 +
1.313 +inline CTransition_Cancel_Transition::CTransition_Cancel_Transition(CUnitTestContext& aUTContext,
1.314 + TTransitionValidator& aValidator)
1.315 +: CTransition(KTransitionCancelTransition, aUTContext, aValidator)
1.316 + {
1.317 + // Do nothing here.
1.318 + }
1.319 +
1.320 +inline void CTransition_Cancel_Transition::TransitMethodL()
1.321 + {
1.322 + _LIT(KTransitionCancelTransitMethod, "CTransition::Cancel transition");
1.323 + Context().DataLogger().LogInformation(KTransitionCancelTransitMethod);
1.324 + Context().iTargetTransition->Cancel();
1.325 + }
1.326 +
1.327 +inline CTransition_UnitTestContext& CTransition_Cancel_Transition::Context() const
1.328 + {
1.329 + return REINTERPRET_CAST(CTransition_UnitTestContext&,iUTContext);
1.330 + }
1.331 +