os/ossrv/lowlevellibsandfws/pluginfw/Framework/SuicideTests/SuicideTransitions.inl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     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 interface.
    17 // 
    18 //
    19  
    20 #include <e32uid.h>
    21 
    22 #include "TestUtilities.h"	// For __FILE__LINE__
    23 #include "Interface.h"
    24 #include "SuicideTransitions.h"
    25 
    26 // __________________________________________________________________________
    27 CSuicideInterface_UnitTestContext::CSuicideInterface_UnitTestContext(CDataLogger& aDataLogger, 
    28 													MStateAccessor& aAccessor,
    29 													MTransitionObserver& aObserver)
    30 : CUnitTestContext(aDataLogger, aAccessor, aObserver), iExampleInterface(NULL)
    31 	{
    32 	// Do nothing
    33 	}
    34 
    35 CSuicideInterface_UnitTestContext::~CSuicideInterface_UnitTestContext()
    36 	{
    37 	delete iExampleInterface;
    38 	}
    39 
    40 
    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");
    45 
    46 _LIT8(KInterfaceResolveMatchStr,"suicidal");
    47 
    48 // For each class method implement a transition class...
    49 // __________________________________________________________________________
    50 //Construction
    51 CSuicideInterfaceNewLTransition::CSuicideInterfaceNewLTransition(CUnitTestContext& aUTContext,
    52 																TTransitionValidator& aValidator) 
    53 : CTransitionType(KInterfaceNewLTransitionName, aUTContext, aValidator)
    54 	{
    55 	}
    56 
    57 void CSuicideInterfaceNewLTransition::TransitMethodL()
    58 	{
    59 	// Call the NewL method
    60 	Context().iExampleInterface = CExampleInterface::NewL(KInterfaceResolveMatchStr());
    61 	}
    62 
    63 // Auto casting
    64 inline CSuicideInterface_UnitTestContext& CSuicideInterfaceNewLTransition::Context()
    65 	{
    66 	return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);
    67 	}
    68 
    69 // __________________________________________________________________________
    70 //Destruction
    71 inline CSuicideInterfaceDtorTransition::CSuicideInterfaceDtorTransition(CUnitTestContext& aUTContext,
    72 																TTransitionValidator& aValidator)
    73 : CTransition(KInterfaceDtorTransitionName, aUTContext, aValidator)
    74 	{
    75 	}
    76 
    77 inline void CSuicideInterfaceDtorTransition::TransitMethodL()
    78 	{
    79 	// Call the d'tor method
    80 	delete Context().iExampleInterface;
    81 	Context().iExampleInterface = NULL;
    82 	REComSession::FinalClose();
    83 	}
    84 
    85 // Auto casting
    86 inline CSuicideInterface_UnitTestContext& CSuicideInterfaceDtorTransition::Context()
    87 	{
    88 	return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);
    89 	}
    90 
    91 // __________________________________________________________________________
    92 //FireAndForget method call
    93 CSuicideInterfaceFireAndForgetTransition::CSuicideInterfaceFireAndForgetTransition(CUnitTestContext& aUTContext,
    94 																					TTransitionValidator& aValidator)
    95 : CTransition(KInterfaceFireAndForgetTransitionName, aUTContext, aValidator)
    96 	{
    97 	}
    98 
    99 void CSuicideInterfaceFireAndForgetTransition::TransitMethodL()
   100 	{
   101 	// Execute the creation method, and then remove the references
   102 	// in the context.
   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;
   107 	}
   108 
   109 // Auto casting
   110 inline CSuicideInterface_UnitTestContext& CSuicideInterfaceFireAndForgetTransition::Context()
   111 	{
   112 	return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);
   113 	}