1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/FrameTests/MagicTransitions.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,279 @@
1.4 +// Copyright (c) 1997-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 +// This file contains the definitions for
1.18 +// the transition classes for testing the
1.19 +// CExampleInterface class.
1.20 +//
1.21 +//
1.22 +
1.23 +#include <e32uid.h>
1.24 +
1.25 +#include "TestUtilities.h" // For __FILE__LINE__
1.26 +#include "Interface.h"
1.27 +#include "MagicTransitions.h"
1.28 +
1.29 +
1.30 +// __________________________________________________________________________
1.31 +CExampleInterface_UnitTestContext::CExampleInterface_UnitTestContext(CDataLogger& aDataLogger,
1.32 + MStateAccessor& aAccessor,
1.33 + MTransitionObserver& aObserver)
1.34 +: CUnitTestContext(aDataLogger, aAccessor, aObserver), iExampleInterface(NULL)
1.35 + {
1.36 + // Do nothing
1.37 + }
1.38 +
1.39 +CExampleInterface_UnitTestContext::~CExampleInterface_UnitTestContext()
1.40 + {
1.41 + iListImplThread.Close();
1.42 + delete iExampleInterface;
1.43 + delete iSecondExampleInterface;
1.44 + iImplementations.ResetAndDestroy();
1.45 + }
1.46 +
1.47 +//Define the transition ids for all the transitions of the CExampleInterface class
1.48 +_LIT(KInterfaceNewLTransitionName, "CExampleInterfaceNewLTransition");
1.49 +_LIT(KInterfaceNewWPLTransitionName, "CExampleInterfaceNewWPLTransition");
1.50 +_LIT(KInterfaceNewResolveLTransitionName, "CExampleInterfaceNewResolveLTransition");
1.51 +_LIT(KInterfaceDoubleNewLTransitionName, "CExampleInterfaceDoubleNewLTransition");
1.52 +_LIT(KInterfaceDestroyTransitionName, "CExampleInterfaceDestroyTransition");
1.53 +_LIT(KInterfaceDtorTransitionName, "CExampleInterfaceDtorTransition");
1.54 +_LIT(KInterfaceDoubleDtorTransitionName, "CExampleInterfaceDoubleDtorTransition");
1.55 +_LIT(KInterfaceListImplementationsLTransitionName, "CExampleInterfaceListImplementationsLTransition");
1.56 +_LIT(KInterfacePersistLTransitionName, "CExampleInterfacePersistLTransition");
1.57 +_LIT(KInterfaceAsynchCreateTransitionName, "CExampleInterfaceAsynchCreateTransition");
1.58 +_LIT(KInterfaceDoMethodLTransitionName, "CExampleInterfaceDoMethodLTransition");
1.59 +_LIT(KInterfaceFireAndForgetTransitionName, "CExampleInterfaceFireAndForgetTransition");
1.60 +_LIT(KInterfaceListImplementationsLNewThreadTransitionName, "CExampleInterfaceListImplementationsLNewThreadTransition");
1.61 +
1.62 +// For each class method implement a transition class...
1.63 +// __________________________________________________________________________
1.64 +//Construction
1.65 +CExampleInterfaceNewLTransition::CExampleInterfaceNewLTransition(CUnitTestContext& aUTContext,
1.66 + TTransitionValidator& aValidator)
1.67 +: CTransitionType(KInterfaceNewLTransitionName, aUTContext, aValidator)
1.68 + {
1.69 + }
1.70 +
1.71 +void CExampleInterfaceNewLTransition::TransitMethodL()
1.72 + {
1.73 + _LIT(KExampleInterfaceNewLTransitMethod, "CExampleInterface::NewL transition");
1.74 + Context().DataLogger().LogInformation(KExampleInterfaceNewLTransitMethod);
1.75 +
1.76 + // Call the NewL method
1.77 + Context().iExampleInterface = CExampleInterface::NewL();
1.78 + }
1.79 +
1.80 +// Auto casting
1.81 +inline CExampleInterface_UnitTestContext& CExampleInterfaceNewLTransition::Context()
1.82 + {
1.83 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.84 + }
1.85 +
1.86 +// __________________________________________________________________________
1.87 +CExampleInterfaceNewWPLTransition::CExampleInterfaceNewWPLTransition(CUnitTestContext& aUTContext,
1.88 + TTransitionValidator& aValidator)
1.89 +: CTransitionType(KInterfaceNewWPLTransitionName, aUTContext, aValidator)
1.90 + {
1.91 + }
1.92 +
1.93 +void CExampleInterfaceNewWPLTransition::TransitMethodL()
1.94 + {
1.95 + // Call the NewL method which requires parameters
1.96 + const TInt KTestId = 0xBDE;
1.97 + _LIT(KTestIdDes,"0xBDE");
1.98 + Context().iExampleInterface = CExampleInterface::NewL(KTestId,KTestIdDes());
1.99 + }
1.100 +// Auto casting
1.101 +inline CExampleInterface_UnitTestContext& CExampleInterfaceNewWPLTransition::Context()
1.102 + {
1.103 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.104 + }
1.105 +
1.106 +// __________________________________________________________________________
1.107 +CExampleInterfaceNewResolveLTransition::CExampleInterfaceNewResolveLTransition(CUnitTestContext& aUTContext,
1.108 + TTransitionValidator& aValidator)
1.109 +: CTransitionType(KInterfaceNewResolveLTransitionName, aUTContext, aValidator)
1.110 + {
1.111 + }
1.112 +
1.113 +void CExampleInterfaceNewResolveLTransition::TransitMethodL()
1.114 + {
1.115 + // Call the NewL method which requires parameters
1.116 + _LIT8(KTestResolveType,"text/*");
1.117 + Context().iExampleInterface = CExampleInterface::NewL(KTestResolveType);
1.118 + }
1.119 +// Auto casting
1.120 +inline CExampleInterface_UnitTestContext& CExampleInterfaceNewResolveLTransition::Context()
1.121 + {
1.122 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.123 + }
1.124 +
1.125 +// __________________________________________________________________________
1.126 +//Construction
1.127 +CExampleInterfaceDoubleNewLTransition::CExampleInterfaceDoubleNewLTransition(CUnitTestContext& aUTContext,
1.128 + TTransitionValidator& aValidator)
1.129 +: CTransitionType(KInterfaceDoubleNewLTransitionName, aUTContext, aValidator)
1.130 + {
1.131 + }
1.132 +
1.133 +void CExampleInterfaceDoubleNewLTransition::TransitMethodL()
1.134 + {
1.135 + _LIT(KExampleInterfaceNewLTransitMethod, "CExampleInterface::NewL transition");
1.136 + Context().DataLogger().LogInformation(KExampleInterfaceNewLTransitMethod);
1.137 +
1.138 + CExampleInterface* objectTwo = CExampleInterface::NewL();
1.139 + CleanupStack::PushL(objectTwo);
1.140 + Context().iExampleInterface = CExampleInterface::NewL();
1.141 + Context().iSecondExampleInterface = objectTwo;
1.142 + CleanupStack::Pop(objectTwo);
1.143 + }
1.144 +
1.145 +// Auto casting
1.146 +inline CExampleInterface_UnitTestContext& CExampleInterfaceDoubleNewLTransition::Context()
1.147 + {
1.148 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.149 + }
1.150 +
1.151 +// __________________________________________________________________________
1.152 +//Destruction
1.153 +inline CExampleInterfaceDtorTransition::CExampleInterfaceDtorTransition(CUnitTestContext& aUTContext,
1.154 + TTransitionValidator& aValidator)
1.155 +: CTransitionType(KInterfaceDtorTransitionName, aUTContext, aValidator)
1.156 + {
1.157 + }
1.158 +
1.159 +inline void CExampleInterfaceDtorTransition::TransitMethodL()
1.160 + {
1.161 + // Call the d'tor method
1.162 + delete Context().iExampleInterface;
1.163 + Context().iExampleInterface = NULL;
1.164 + REComSession::FinalClose();
1.165 + }
1.166 +
1.167 +// Auto casting
1.168 +inline CExampleInterface_UnitTestContext& CExampleInterfaceDtorTransition::Context()
1.169 + {
1.170 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.171 + }
1.172 +
1.173 +// __________________________________________________________________________
1.174 +//Destruction
1.175 +inline CExampleInterfaceDoubleDtorTransition::CExampleInterfaceDoubleDtorTransition(CUnitTestContext& aUTContext,
1.176 + TTransitionValidator& aValidator)
1.177 +: CTransitionType(KInterfaceDoubleDtorTransitionName, aUTContext, aValidator)
1.178 + {
1.179 + }
1.180 +
1.181 +inline void CExampleInterfaceDoubleDtorTransition::TransitMethodL()
1.182 + {
1.183 + // Call the d'tor method
1.184 + delete Context().iExampleInterface;
1.185 + Context().iExampleInterface = NULL;
1.186 + delete Context().iSecondExampleInterface;
1.187 + Context().iSecondExampleInterface = NULL;
1.188 + }
1.189 +
1.190 +// Auto casting
1.191 +inline CExampleInterface_UnitTestContext& CExampleInterfaceDoubleDtorTransition::Context()
1.192 + {
1.193 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.194 + }
1.195 +
1.196 +// __________________________________________________________________________
1.197 +//Leaving method call
1.198 +inline CExampleInterfaceDoMethodLTransition::CExampleInterfaceDoMethodLTransition(CUnitTestContext& aUTContext,
1.199 + TTransitionValidator& aValidator)
1.200 +: CTransitionType(KInterfaceDoMethodLTransitionName, aUTContext, aValidator)
1.201 + {
1.202 + }
1.203 +
1.204 +inline void CExampleInterfaceDoMethodLTransition::TransitMethodL()
1.205 + {
1.206 + // Call the DoMethodL method
1.207 + Context().iExampleInterface->DoMethodL();
1.208 + }
1.209 +
1.210 +// Auto casting
1.211 +inline CExampleInterface_UnitTestContext& CExampleInterfaceDoMethodLTransition::Context()
1.212 + {
1.213 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.214 + }
1.215 +
1.216 +// __________________________________________________________________________
1.217 +//ListImplementationsL method call
1.218 +CExampleInterfaceListImplementationsLTransition::CExampleInterfaceListImplementationsLTransition(CUnitTestContext& aUTContext,
1.219 + TTransitionValidator& aValidator)
1.220 +: CTransitionType(KInterfaceListImplementationsLTransitionName, aUTContext, aValidator)
1.221 + {
1.222 + }
1.223 +
1.224 +void CExampleInterfaceListImplementationsLTransition::TransitMethodL()
1.225 + {
1.226 + // Call the ListImplementationsL method
1.227 + CExampleInterface::ListImplementationsL(Context().iImplementations);
1.228 + }
1.229 +
1.230 +// Auto casting
1.231 +inline CExampleInterface_UnitTestContext& CExampleInterfaceListImplementationsLTransition::Context()
1.232 + {
1.233 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.234 + }
1.235 +
1.236 +// __________________________________________________________________________
1.237 +//ListAllImplementationsL method call
1.238 +CExampleInterfaceListAllImplementationsLTransition::CExampleInterfaceListAllImplementationsLTransition(CUnitTestContext& aUTContext,
1.239 + TTransitionValidator& aValidator)
1.240 +: CTransitionType(KInterfaceListImplementationsLTransitionName, aUTContext, aValidator)
1.241 + {
1.242 + }
1.243 +
1.244 +void CExampleInterfaceListAllImplementationsLTransition::TransitMethodL()
1.245 + {
1.246 + // Call the ListImplementationsL method
1.247 + CExampleInterface::ListAllImplementationsL(Context().iImplementations);
1.248 + }
1.249 +
1.250 +// Auto casting
1.251 +inline CExampleInterface_UnitTestContext& CExampleInterfaceListAllImplementationsLTransition::Context()
1.252 + {
1.253 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.254 + }
1.255 +
1.256 +// __________________________________________________________________________
1.257 +//ListAllImplementationsL method call
1.258 +CExampleInterfaceListImplementationsLNewThreadTransition::CExampleInterfaceListImplementationsLNewThreadTransition(CUnitTestContext& aUTContext,
1.259 + TTransitionValidator& aValidator)
1.260 +: CTransitionType(KInterfaceListImplementationsLNewThreadTransitionName, aUTContext, aValidator)
1.261 + {
1.262 + }
1.263 +
1.264 +void CExampleInterfaceListImplementationsLNewThreadTransition::TransitMethodL()
1.265 + {
1.266 + // Start the new thread which will call the ListImplementationsL method
1.267 + Context().iListImplThread.Resume();
1.268 +
1.269 + // Stay here until that thread returns
1.270 + TExitType exit = EExitPending;
1.271 + while( exit == EExitPending)
1.272 + {
1.273 + exit = Context().iListImplThread.ExitType();
1.274 + }
1.275 + }
1.276 +
1.277 +// Auto casting
1.278 +inline CExampleInterface_UnitTestContext& CExampleInterfaceListImplementationsLNewThreadTransition::Context()
1.279 + {
1.280 + return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
1.281 + }
1.282 +