os/ossrv/lowlevellibsandfws/pluginfw/Framework/FrameTests/MagicTransitions.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1997-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 // This file contains the definitions for
    15 // the transition classes for testing the
    16 // CExampleInterface class.
    17 // 
    18 //
    19  
    20 #include <e32uid.h>
    21 
    22 #include "TestUtilities.h"	// For __FILE__LINE__
    23 #include "Interface.h"
    24 #include "MagicTransitions.h"
    25 
    26 
    27 // __________________________________________________________________________
    28 CExampleInterface_UnitTestContext::CExampleInterface_UnitTestContext(CDataLogger& aDataLogger, 
    29 													MStateAccessor& aAccessor,
    30 													MTransitionObserver& aObserver)
    31 : CUnitTestContext(aDataLogger, aAccessor, aObserver), iExampleInterface(NULL)
    32 	{
    33 	// Do nothing
    34 	}
    35 
    36 CExampleInterface_UnitTestContext::~CExampleInterface_UnitTestContext()
    37 	{
    38 	iListImplThread.Close();
    39 	delete iExampleInterface;
    40 	delete iSecondExampleInterface;
    41 	iImplementations.ResetAndDestroy();
    42 	}
    43 
    44 //Define the transition ids for all the transitions of the CExampleInterface class
    45 _LIT(KInterfaceNewLTransitionName, "CExampleInterfaceNewLTransition");
    46 _LIT(KInterfaceNewWPLTransitionName, "CExampleInterfaceNewWPLTransition");
    47 _LIT(KInterfaceNewResolveLTransitionName, "CExampleInterfaceNewResolveLTransition");
    48 _LIT(KInterfaceDoubleNewLTransitionName, "CExampleInterfaceDoubleNewLTransition");
    49 _LIT(KInterfaceDestroyTransitionName, "CExampleInterfaceDestroyTransition");
    50 _LIT(KInterfaceDtorTransitionName, "CExampleInterfaceDtorTransition");
    51 _LIT(KInterfaceDoubleDtorTransitionName, "CExampleInterfaceDoubleDtorTransition");
    52 _LIT(KInterfaceListImplementationsLTransitionName, "CExampleInterfaceListImplementationsLTransition");
    53 _LIT(KInterfacePersistLTransitionName, "CExampleInterfacePersistLTransition");
    54 _LIT(KInterfaceAsynchCreateTransitionName, "CExampleInterfaceAsynchCreateTransition");
    55 _LIT(KInterfaceDoMethodLTransitionName, "CExampleInterfaceDoMethodLTransition");
    56 _LIT(KInterfaceFireAndForgetTransitionName,	"CExampleInterfaceFireAndForgetTransition");
    57 _LIT(KInterfaceListImplementationsLNewThreadTransitionName,	"CExampleInterfaceListImplementationsLNewThreadTransition");
    58 
    59 // For each class method implement a transition class...
    60 // __________________________________________________________________________
    61 //Construction
    62 CExampleInterfaceNewLTransition::CExampleInterfaceNewLTransition(CUnitTestContext& aUTContext,
    63 																TTransitionValidator& aValidator) 
    64 : CTransitionType(KInterfaceNewLTransitionName, aUTContext, aValidator)
    65 	{
    66 	}
    67 
    68 void CExampleInterfaceNewLTransition::TransitMethodL()
    69 	{
    70 	_LIT(KExampleInterfaceNewLTransitMethod, "CExampleInterface::NewL transition");
    71 	Context().DataLogger().LogInformation(KExampleInterfaceNewLTransitMethod);
    72 
    73 	// Call the NewL method
    74 	Context().iExampleInterface = CExampleInterface::NewL();
    75 	}
    76 
    77 // Auto casting
    78 inline CExampleInterface_UnitTestContext& CExampleInterfaceNewLTransition::Context()
    79 	{
    80 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
    81 	}
    82 
    83 // __________________________________________________________________________
    84 CExampleInterfaceNewWPLTransition::CExampleInterfaceNewWPLTransition(CUnitTestContext& aUTContext,
    85 																	TTransitionValidator& aValidator) 
    86 : CTransitionType(KInterfaceNewWPLTransitionName, aUTContext, aValidator)
    87 	{
    88 	}
    89 
    90 void CExampleInterfaceNewWPLTransition::TransitMethodL()
    91 	{
    92 	// Call the NewL method which requires parameters
    93 	const TInt KTestId = 0xBDE;
    94 	_LIT(KTestIdDes,"0xBDE");
    95 	Context().iExampleInterface = CExampleInterface::NewL(KTestId,KTestIdDes());
    96 	}
    97 // Auto casting
    98 inline CExampleInterface_UnitTestContext& CExampleInterfaceNewWPLTransition::Context()
    99 	{
   100 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   101 	}
   102 
   103 // __________________________________________________________________________
   104 CExampleInterfaceNewResolveLTransition::CExampleInterfaceNewResolveLTransition(CUnitTestContext& aUTContext,
   105 																	TTransitionValidator& aValidator) 
   106 : CTransitionType(KInterfaceNewResolveLTransitionName, aUTContext, aValidator)
   107 	{
   108 	}
   109 
   110 void CExampleInterfaceNewResolveLTransition::TransitMethodL()
   111 	{
   112 	// Call the NewL method which requires parameters
   113 	_LIT8(KTestResolveType,"text/*");
   114 	Context().iExampleInterface = CExampleInterface::NewL(KTestResolveType);
   115 	}
   116 // Auto casting
   117 inline CExampleInterface_UnitTestContext& CExampleInterfaceNewResolveLTransition::Context()
   118 	{
   119 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   120 	}
   121 
   122 // __________________________________________________________________________
   123 //Construction
   124 CExampleInterfaceDoubleNewLTransition::CExampleInterfaceDoubleNewLTransition(CUnitTestContext& aUTContext,
   125 																TTransitionValidator& aValidator) 
   126 : CTransitionType(KInterfaceDoubleNewLTransitionName, aUTContext, aValidator)
   127 	{
   128 	}
   129 
   130 void CExampleInterfaceDoubleNewLTransition::TransitMethodL()
   131 	{
   132 	_LIT(KExampleInterfaceNewLTransitMethod, "CExampleInterface::NewL transition");
   133 	Context().DataLogger().LogInformation(KExampleInterfaceNewLTransitMethod);
   134 
   135 	CExampleInterface* objectTwo = CExampleInterface::NewL();
   136 	CleanupStack::PushL(objectTwo);
   137 	Context().iExampleInterface = CExampleInterface::NewL();
   138 	Context().iSecondExampleInterface = objectTwo;
   139 	CleanupStack::Pop(objectTwo);
   140 	}
   141 
   142 // Auto casting
   143 inline CExampleInterface_UnitTestContext& CExampleInterfaceDoubleNewLTransition::Context()
   144 	{
   145 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   146 	}
   147 
   148 // __________________________________________________________________________
   149 //Destruction
   150 inline CExampleInterfaceDtorTransition::CExampleInterfaceDtorTransition(CUnitTestContext& aUTContext,
   151 																TTransitionValidator& aValidator)
   152 : CTransitionType(KInterfaceDtorTransitionName, aUTContext, aValidator)
   153 	{
   154 	}
   155 
   156 inline void CExampleInterfaceDtorTransition::TransitMethodL()
   157 	{
   158 	// Call the d'tor method
   159 	delete Context().iExampleInterface;
   160 	Context().iExampleInterface = NULL;
   161 	REComSession::FinalClose();
   162 	}
   163 
   164 // Auto casting
   165 inline CExampleInterface_UnitTestContext& CExampleInterfaceDtorTransition::Context()
   166 	{
   167 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   168 	}
   169 
   170 // __________________________________________________________________________
   171 //Destruction
   172 inline CExampleInterfaceDoubleDtorTransition::CExampleInterfaceDoubleDtorTransition(CUnitTestContext& aUTContext,
   173 																TTransitionValidator& aValidator)
   174 : CTransitionType(KInterfaceDoubleDtorTransitionName, aUTContext, aValidator)
   175 	{
   176 	}
   177 
   178 inline void CExampleInterfaceDoubleDtorTransition::TransitMethodL()
   179 	{
   180 	// Call the d'tor method
   181 	delete Context().iExampleInterface;
   182 	Context().iExampleInterface = NULL;
   183 	delete Context().iSecondExampleInterface;
   184 	Context().iSecondExampleInterface = NULL;
   185 	}
   186 
   187 // Auto casting
   188 inline CExampleInterface_UnitTestContext& CExampleInterfaceDoubleDtorTransition::Context()
   189 	{
   190 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   191 	}
   192 
   193 // __________________________________________________________________________
   194 //Leaving method call
   195 inline CExampleInterfaceDoMethodLTransition::CExampleInterfaceDoMethodLTransition(CUnitTestContext& aUTContext,
   196 																		TTransitionValidator& aValidator)
   197 : CTransitionType(KInterfaceDoMethodLTransitionName, aUTContext, aValidator)
   198 	{
   199 	}
   200 
   201 inline void CExampleInterfaceDoMethodLTransition::TransitMethodL()
   202 	{
   203 	// Call the DoMethodL method
   204 	Context().iExampleInterface->DoMethodL();
   205 	}
   206 
   207 // Auto casting
   208 inline CExampleInterface_UnitTestContext& CExampleInterfaceDoMethodLTransition::Context()
   209 	{
   210 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   211 	}
   212 
   213 // __________________________________________________________________________
   214 //ListImplementationsL method call
   215 CExampleInterfaceListImplementationsLTransition::CExampleInterfaceListImplementationsLTransition(CUnitTestContext& aUTContext,
   216 																								TTransitionValidator& aValidator)
   217 : CTransitionType(KInterfaceListImplementationsLTransitionName, aUTContext, aValidator)
   218 	{
   219 	}
   220 
   221 void CExampleInterfaceListImplementationsLTransition::TransitMethodL()
   222 	{
   223 	// Call the ListImplementationsL method
   224 	CExampleInterface::ListImplementationsL(Context().iImplementations);
   225 	}
   226 
   227 // Auto casting
   228 inline CExampleInterface_UnitTestContext& CExampleInterfaceListImplementationsLTransition::Context()
   229 	{
   230 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   231 	}
   232 
   233 // __________________________________________________________________________
   234 //ListAllImplementationsL method call
   235 CExampleInterfaceListAllImplementationsLTransition::CExampleInterfaceListAllImplementationsLTransition(CUnitTestContext& aUTContext,
   236 																								TTransitionValidator& aValidator)
   237 : CTransitionType(KInterfaceListImplementationsLTransitionName, aUTContext, aValidator)
   238 	{
   239 	}
   240 
   241 void CExampleInterfaceListAllImplementationsLTransition::TransitMethodL()
   242 	{
   243 	// Call the ListImplementationsL method
   244 	CExampleInterface::ListAllImplementationsL(Context().iImplementations);
   245 	}
   246 
   247 // Auto casting
   248 inline CExampleInterface_UnitTestContext& CExampleInterfaceListAllImplementationsLTransition::Context()
   249 	{
   250 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   251 	}
   252 
   253 // __________________________________________________________________________
   254 //ListAllImplementationsL method call
   255 CExampleInterfaceListImplementationsLNewThreadTransition::CExampleInterfaceListImplementationsLNewThreadTransition(CUnitTestContext& aUTContext,
   256 																								TTransitionValidator& aValidator)
   257 : CTransitionType(KInterfaceListImplementationsLNewThreadTransitionName, aUTContext, aValidator)
   258 	{
   259 	}
   260 
   261 void CExampleInterfaceListImplementationsLNewThreadTransition::TransitMethodL()
   262 	{
   263 	// Start the new thread which will call the ListImplementationsL method
   264 	Context().iListImplThread.Resume();
   265 
   266 	// Stay here until that thread returns
   267 	TExitType exit = EExitPending;
   268 	while( exit == EExitPending)
   269 		{
   270 		exit = Context().iListImplThread.ExitType();
   271 		}
   272 	}
   273 
   274 // Auto casting
   275 inline CExampleInterface_UnitTestContext& CExampleInterfaceListImplementationsLNewThreadTransition::Context()
   276 	{
   277 	return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext);
   278 	}
   279