sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This file contains the definitions for sl@0: // the transition classes for testing the sl@0: // CExampleInterface class. sl@0: // sl@0: // sl@0: sl@0: #include sl@0: sl@0: #include "TestUtilities.h" // For __FILE__LINE__ sl@0: #include "Interface.h" sl@0: #include "MagicTransitions.h" sl@0: sl@0: sl@0: // __________________________________________________________________________ sl@0: CExampleInterface_UnitTestContext::CExampleInterface_UnitTestContext(CDataLogger& aDataLogger, sl@0: MStateAccessor& aAccessor, sl@0: MTransitionObserver& aObserver) sl@0: : CUnitTestContext(aDataLogger, aAccessor, aObserver), iExampleInterface(NULL) sl@0: { sl@0: // Do nothing sl@0: } sl@0: sl@0: CExampleInterface_UnitTestContext::~CExampleInterface_UnitTestContext() sl@0: { sl@0: iListImplThread.Close(); sl@0: delete iExampleInterface; sl@0: delete iSecondExampleInterface; sl@0: iImplementations.ResetAndDestroy(); sl@0: } sl@0: sl@0: //Define the transition ids for all the transitions of the CExampleInterface class sl@0: _LIT(KInterfaceNewLTransitionName, "CExampleInterfaceNewLTransition"); sl@0: _LIT(KInterfaceNewWPLTransitionName, "CExampleInterfaceNewWPLTransition"); sl@0: _LIT(KInterfaceNewResolveLTransitionName, "CExampleInterfaceNewResolveLTransition"); sl@0: _LIT(KInterfaceDoubleNewLTransitionName, "CExampleInterfaceDoubleNewLTransition"); sl@0: _LIT(KInterfaceDestroyTransitionName, "CExampleInterfaceDestroyTransition"); sl@0: _LIT(KInterfaceDtorTransitionName, "CExampleInterfaceDtorTransition"); sl@0: _LIT(KInterfaceDoubleDtorTransitionName, "CExampleInterfaceDoubleDtorTransition"); sl@0: _LIT(KInterfaceListImplementationsLTransitionName, "CExampleInterfaceListImplementationsLTransition"); sl@0: _LIT(KInterfacePersistLTransitionName, "CExampleInterfacePersistLTransition"); sl@0: _LIT(KInterfaceAsynchCreateTransitionName, "CExampleInterfaceAsynchCreateTransition"); sl@0: _LIT(KInterfaceDoMethodLTransitionName, "CExampleInterfaceDoMethodLTransition"); sl@0: _LIT(KInterfaceFireAndForgetTransitionName, "CExampleInterfaceFireAndForgetTransition"); sl@0: _LIT(KInterfaceListImplementationsLNewThreadTransitionName, "CExampleInterfaceListImplementationsLNewThreadTransition"); sl@0: sl@0: // For each class method implement a transition class... sl@0: // __________________________________________________________________________ sl@0: //Construction sl@0: CExampleInterfaceNewLTransition::CExampleInterfaceNewLTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceNewLTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: void CExampleInterfaceNewLTransition::TransitMethodL() sl@0: { sl@0: _LIT(KExampleInterfaceNewLTransitMethod, "CExampleInterface::NewL transition"); sl@0: Context().DataLogger().LogInformation(KExampleInterfaceNewLTransitMethod); sl@0: sl@0: // Call the NewL method sl@0: Context().iExampleInterface = CExampleInterface::NewL(); sl@0: } sl@0: sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceNewLTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: CExampleInterfaceNewWPLTransition::CExampleInterfaceNewWPLTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceNewWPLTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: void CExampleInterfaceNewWPLTransition::TransitMethodL() sl@0: { sl@0: // Call the NewL method which requires parameters sl@0: const TInt KTestId = 0xBDE; sl@0: _LIT(KTestIdDes,"0xBDE"); sl@0: Context().iExampleInterface = CExampleInterface::NewL(KTestId,KTestIdDes()); sl@0: } sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceNewWPLTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: CExampleInterfaceNewResolveLTransition::CExampleInterfaceNewResolveLTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceNewResolveLTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: void CExampleInterfaceNewResolveLTransition::TransitMethodL() sl@0: { sl@0: // Call the NewL method which requires parameters sl@0: _LIT8(KTestResolveType,"text/*"); sl@0: Context().iExampleInterface = CExampleInterface::NewL(KTestResolveType); sl@0: } sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceNewResolveLTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: //Construction sl@0: CExampleInterfaceDoubleNewLTransition::CExampleInterfaceDoubleNewLTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceDoubleNewLTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: void CExampleInterfaceDoubleNewLTransition::TransitMethodL() sl@0: { sl@0: _LIT(KExampleInterfaceNewLTransitMethod, "CExampleInterface::NewL transition"); sl@0: Context().DataLogger().LogInformation(KExampleInterfaceNewLTransitMethod); sl@0: sl@0: CExampleInterface* objectTwo = CExampleInterface::NewL(); sl@0: CleanupStack::PushL(objectTwo); sl@0: Context().iExampleInterface = CExampleInterface::NewL(); sl@0: Context().iSecondExampleInterface = objectTwo; sl@0: CleanupStack::Pop(objectTwo); sl@0: } sl@0: sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceDoubleNewLTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: //Destruction sl@0: inline CExampleInterfaceDtorTransition::CExampleInterfaceDtorTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceDtorTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: inline void CExampleInterfaceDtorTransition::TransitMethodL() sl@0: { sl@0: // Call the d'tor method sl@0: delete Context().iExampleInterface; sl@0: Context().iExampleInterface = NULL; sl@0: REComSession::FinalClose(); sl@0: } sl@0: sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceDtorTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: //Destruction sl@0: inline CExampleInterfaceDoubleDtorTransition::CExampleInterfaceDoubleDtorTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceDoubleDtorTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: inline void CExampleInterfaceDoubleDtorTransition::TransitMethodL() sl@0: { sl@0: // Call the d'tor method sl@0: delete Context().iExampleInterface; sl@0: Context().iExampleInterface = NULL; sl@0: delete Context().iSecondExampleInterface; sl@0: Context().iSecondExampleInterface = NULL; sl@0: } sl@0: sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceDoubleDtorTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: //Leaving method call sl@0: inline CExampleInterfaceDoMethodLTransition::CExampleInterfaceDoMethodLTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceDoMethodLTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: inline void CExampleInterfaceDoMethodLTransition::TransitMethodL() sl@0: { sl@0: // Call the DoMethodL method sl@0: Context().iExampleInterface->DoMethodL(); sl@0: } sl@0: sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceDoMethodLTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: //ListImplementationsL method call sl@0: CExampleInterfaceListImplementationsLTransition::CExampleInterfaceListImplementationsLTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceListImplementationsLTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: void CExampleInterfaceListImplementationsLTransition::TransitMethodL() sl@0: { sl@0: // Call the ListImplementationsL method sl@0: CExampleInterface::ListImplementationsL(Context().iImplementations); sl@0: } sl@0: sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceListImplementationsLTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: //ListAllImplementationsL method call sl@0: CExampleInterfaceListAllImplementationsLTransition::CExampleInterfaceListAllImplementationsLTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceListImplementationsLTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: void CExampleInterfaceListAllImplementationsLTransition::TransitMethodL() sl@0: { sl@0: // Call the ListImplementationsL method sl@0: CExampleInterface::ListAllImplementationsL(Context().iImplementations); sl@0: } sl@0: sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceListAllImplementationsLTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: sl@0: // __________________________________________________________________________ sl@0: //ListAllImplementationsL method call sl@0: CExampleInterfaceListImplementationsLNewThreadTransition::CExampleInterfaceListImplementationsLNewThreadTransition(CUnitTestContext& aUTContext, sl@0: TTransitionValidator& aValidator) sl@0: : CTransitionType(KInterfaceListImplementationsLNewThreadTransitionName, aUTContext, aValidator) sl@0: { sl@0: } sl@0: sl@0: void CExampleInterfaceListImplementationsLNewThreadTransition::TransitMethodL() sl@0: { sl@0: // Start the new thread which will call the ListImplementationsL method sl@0: Context().iListImplThread.Resume(); sl@0: sl@0: // Stay here until that thread returns sl@0: TExitType exit = EExitPending; sl@0: while( exit == EExitPending) sl@0: { sl@0: exit = Context().iListImplThread.ExitType(); sl@0: } sl@0: } sl@0: sl@0: // Auto casting sl@0: inline CExampleInterface_UnitTestContext& CExampleInterfaceListImplementationsLNewThreadTransition::Context() sl@0: { sl@0: return REINTERPRET_CAST(CExampleInterface_UnitTestContext&,iUTContext); sl@0: } sl@0: