os/ossrv/lowlevellibsandfws/pluginfw/Framework/SuicideTests/SuicideTransitions.inl
First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // This file contains the definitions for
15 // the transition classes for testing the
16 // CExampleInterface interface.
22 #include "TestUtilities.h" // For __FILE__LINE__
23 #include "Interface.h"
24 #include "SuicideTransitions.h"
26 // __________________________________________________________________________
27 CSuicideInterface_UnitTestContext::CSuicideInterface_UnitTestContext(CDataLogger& aDataLogger,
28 MStateAccessor& aAccessor,
29 MTransitionObserver& aObserver)
30 : CUnitTestContext(aDataLogger, aAccessor, aObserver), iExampleInterface(NULL)
35 CSuicideInterface_UnitTestContext::~CSuicideInterface_UnitTestContext()
37 delete iExampleInterface;
41 //Define the transition ids for all the transitions of the CExampleInterface class
42 _LIT(KInterfaceNewLTransitionName, "CSuicideInterfaceNewLTransition");
43 _LIT(KInterfaceDtorTransitionName, "CSuicideInterfaceDtorTransition");
44 _LIT(KInterfaceFireAndForgetTransitionName, "CSuicideInterfaceFireAndForgetTransition");
46 _LIT8(KInterfaceResolveMatchStr,"suicidal");
48 // For each class method implement a transition class...
49 // __________________________________________________________________________
51 CSuicideInterfaceNewLTransition::CSuicideInterfaceNewLTransition(CUnitTestContext& aUTContext,
52 TTransitionValidator& aValidator)
53 : CTransitionType(KInterfaceNewLTransitionName, aUTContext, aValidator)
57 void CSuicideInterfaceNewLTransition::TransitMethodL()
59 // Call the NewL method
60 Context().iExampleInterface = CExampleInterface::NewL(KInterfaceResolveMatchStr());
64 inline CSuicideInterface_UnitTestContext& CSuicideInterfaceNewLTransition::Context()
66 return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);
69 // __________________________________________________________________________
71 inline CSuicideInterfaceDtorTransition::CSuicideInterfaceDtorTransition(CUnitTestContext& aUTContext,
72 TTransitionValidator& aValidator)
73 : CTransition(KInterfaceDtorTransitionName, aUTContext, aValidator)
77 inline void CSuicideInterfaceDtorTransition::TransitMethodL()
79 // Call the d'tor method
80 delete Context().iExampleInterface;
81 Context().iExampleInterface = NULL;
82 REComSession::FinalClose();
86 inline CSuicideInterface_UnitTestContext& CSuicideInterfaceDtorTransition::Context()
88 return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);
91 // __________________________________________________________________________
92 //FireAndForget method call
93 CSuicideInterfaceFireAndForgetTransition::CSuicideInterfaceFireAndForgetTransition(CUnitTestContext& aUTContext,
94 TTransitionValidator& aValidator)
95 : CTransition(KInterfaceFireAndForgetTransitionName, aUTContext, aValidator)
99 void CSuicideInterfaceFireAndForgetTransition::TransitMethodL()
101 // Execute the creation method, and then remove the references
103 // This technically leaks the class but it is supposed to
104 // commit suicide and clean itself up, so its ok.
105 User::LeaveIfError(Context().iExampleInterface->FireAndForget());
106 Context().iExampleInterface = NULL;
110 inline CSuicideInterface_UnitTestContext& CSuicideInterfaceFireAndForgetTransition::Context()
112 return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);