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