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.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// This file contains the definitions for
sl@0
    15
// the transition classes for testing the
sl@0
    16
// CExampleInterface interface.
sl@0
    17
// 
sl@0
    18
//
sl@0
    19
 
sl@0
    20
#include <e32uid.h>
sl@0
    21
sl@0
    22
#include "TestUtilities.h"	// For __FILE__LINE__
sl@0
    23
#include "Interface.h"
sl@0
    24
#include "SuicideTransitions.h"
sl@0
    25
sl@0
    26
// __________________________________________________________________________
sl@0
    27
CSuicideInterface_UnitTestContext::CSuicideInterface_UnitTestContext(CDataLogger& aDataLogger, 
sl@0
    28
													MStateAccessor& aAccessor,
sl@0
    29
													MTransitionObserver& aObserver)
sl@0
    30
: CUnitTestContext(aDataLogger, aAccessor, aObserver), iExampleInterface(NULL)
sl@0
    31
	{
sl@0
    32
	// Do nothing
sl@0
    33
	}
sl@0
    34
sl@0
    35
CSuicideInterface_UnitTestContext::~CSuicideInterface_UnitTestContext()
sl@0
    36
	{
sl@0
    37
	delete iExampleInterface;
sl@0
    38
	}
sl@0
    39
sl@0
    40
sl@0
    41
//Define the transition ids for all the transitions of the CExampleInterface class
sl@0
    42
_LIT(KInterfaceNewLTransitionName, "CSuicideInterfaceNewLTransition");
sl@0
    43
_LIT(KInterfaceDtorTransitionName, "CSuicideInterfaceDtorTransition");
sl@0
    44
_LIT(KInterfaceFireAndForgetTransitionName,	"CSuicideInterfaceFireAndForgetTransition");
sl@0
    45
sl@0
    46
_LIT8(KInterfaceResolveMatchStr,"suicidal");
sl@0
    47
sl@0
    48
// For each class method implement a transition class...
sl@0
    49
// __________________________________________________________________________
sl@0
    50
//Construction
sl@0
    51
CSuicideInterfaceNewLTransition::CSuicideInterfaceNewLTransition(CUnitTestContext& aUTContext,
sl@0
    52
																TTransitionValidator& aValidator) 
sl@0
    53
: CTransitionType(KInterfaceNewLTransitionName, aUTContext, aValidator)
sl@0
    54
	{
sl@0
    55
	}
sl@0
    56
sl@0
    57
void CSuicideInterfaceNewLTransition::TransitMethodL()
sl@0
    58
	{
sl@0
    59
	// Call the NewL method
sl@0
    60
	Context().iExampleInterface = CExampleInterface::NewL(KInterfaceResolveMatchStr());
sl@0
    61
	}
sl@0
    62
sl@0
    63
// Auto casting
sl@0
    64
inline CSuicideInterface_UnitTestContext& CSuicideInterfaceNewLTransition::Context()
sl@0
    65
	{
sl@0
    66
	return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);
sl@0
    67
	}
sl@0
    68
sl@0
    69
// __________________________________________________________________________
sl@0
    70
//Destruction
sl@0
    71
inline CSuicideInterfaceDtorTransition::CSuicideInterfaceDtorTransition(CUnitTestContext& aUTContext,
sl@0
    72
																TTransitionValidator& aValidator)
sl@0
    73
: CTransition(KInterfaceDtorTransitionName, aUTContext, aValidator)
sl@0
    74
	{
sl@0
    75
	}
sl@0
    76
sl@0
    77
inline void CSuicideInterfaceDtorTransition::TransitMethodL()
sl@0
    78
	{
sl@0
    79
	// Call the d'tor method
sl@0
    80
	delete Context().iExampleInterface;
sl@0
    81
	Context().iExampleInterface = NULL;
sl@0
    82
	REComSession::FinalClose();
sl@0
    83
	}
sl@0
    84
sl@0
    85
// Auto casting
sl@0
    86
inline CSuicideInterface_UnitTestContext& CSuicideInterfaceDtorTransition::Context()
sl@0
    87
	{
sl@0
    88
	return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);
sl@0
    89
	}
sl@0
    90
sl@0
    91
// __________________________________________________________________________
sl@0
    92
//FireAndForget method call
sl@0
    93
CSuicideInterfaceFireAndForgetTransition::CSuicideInterfaceFireAndForgetTransition(CUnitTestContext& aUTContext,
sl@0
    94
																					TTransitionValidator& aValidator)
sl@0
    95
: CTransition(KInterfaceFireAndForgetTransitionName, aUTContext, aValidator)
sl@0
    96
	{
sl@0
    97
	}
sl@0
    98
sl@0
    99
void CSuicideInterfaceFireAndForgetTransition::TransitMethodL()
sl@0
   100
	{
sl@0
   101
	// Execute the creation method, and then remove the references
sl@0
   102
	// in the context.
sl@0
   103
	// This technically leaks the class but it is supposed to
sl@0
   104
	// commit suicide and clean itself up, so its ok.
sl@0
   105
	User::LeaveIfError(Context().iExampleInterface->FireAndForget());
sl@0
   106
	Context().iExampleInterface = NULL;
sl@0
   107
	}
sl@0
   108
sl@0
   109
// Auto casting
sl@0
   110
inline CSuicideInterface_UnitTestContext& CSuicideInterfaceFireAndForgetTransition::Context()
sl@0
   111
	{
sl@0
   112
	return REINTERPRET_CAST(CSuicideInterface_UnitTestContext&,iUTContext);
sl@0
   113
	}