os/ossrv/lowlevellibsandfws/pluginfw/Framework/SuicideTests/SuicideUnitTests.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/SuicideTests/SuicideUnitTests.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,164 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This file contains the definition of the 
    1.18 +// class CAllTransitionsUnitTest	
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <e32uid.h>
    1.23 +
    1.24 +#include "TestUtilities.h"	// For __FILE__LINE__
    1.25 +#include "Interface.h"
    1.26 +#include <test_bed/datalogger.h>
    1.27 +
    1.28 +#include "SuicideUnitTests.h"
    1.29 +#include "SuicideTransitions.h"
    1.30 +#include "SuicideTransitionValidation.h"
    1.31 +
    1.32 +#include "TlsData.h"		// For GlobalData
    1.33 +
    1.34 +// ______________________________________________________________________________
    1.35 +//
    1.36 +_LIT(KInterfaceCreateAndDestroyUnitTest,"CSuicideInterfaceCreateAndDestroyUnitTest");
    1.37 +
    1.38 +CSuicideInterfaceCreateAndDestroyUnitTest* CSuicideInterfaceCreateAndDestroyUnitTest::NewL(CDataLogger& aDataLogger,
    1.39 +											MUnitTestObserver& aObserver)
    1.40 +	{
    1.41 +	CSuicideInterfaceCreateAndDestroyUnitTest* self = 
    1.42 +					new(ELeave) CSuicideInterfaceCreateAndDestroyUnitTest(aDataLogger,
    1.43 +																aObserver);
    1.44 +	CleanupStack::PushL(self);
    1.45 +	// Chain to the base which calls the ConstructL
    1.46 +	self->ConstructL();
    1.47 +	CleanupStack::Pop();
    1.48 +	return self; 
    1.49 +	}
    1.50 +
    1.51 +TInt CSuicideInterfaceCreateAndDestroyUnitTest::RunError(TInt aError)
    1.52 +	{
    1.53 +	// The RunL left so chain to the base first and then cleanup
    1.54 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
    1.55 +	delete iUTContext;
    1.56 +	iUTContext = NULL;
    1.57 +	delete iStateAccessor;
    1.58 +	iStateAccessor = NULL;
    1.59 +	delete iCtorValidator;
    1.60 +	delete iDtorValidator;
    1.61 +	
    1.62 +	iCtorValidator = 0;
    1.63 +	iDtorValidator = 0;
    1.64 +
    1.65 +	return error;
    1.66 +	}
    1.67 +
    1.68 +CSuicideInterfaceCreateAndDestroyUnitTest::~CSuicideInterfaceCreateAndDestroyUnitTest()
    1.69 +	{
    1.70 +	// Simply delete our test class instance
    1.71 +	delete iUTContext;
    1.72 +	delete iStateAccessor;
    1.73 +	delete iCtorValidator;
    1.74 +	delete iDtorValidator;
    1.75 +
    1.76 +	}
    1.77 +
    1.78 +CSuicideInterfaceCreateAndDestroyUnitTest::CSuicideInterfaceCreateAndDestroyUnitTest(CDataLogger& aDataLogger,
    1.79 +																	MUnitTestObserver& aObserver)
    1.80 +: CUnitTest(KInterfaceCreateAndDestroyUnitTest, aDataLogger, aObserver)
    1.81 +	{
    1.82 +	//Do nothing
    1.83 +	}
    1.84 +
    1.85 +// Now the Individual transitions need to be added.
    1.86 +void CSuicideInterfaceCreateAndDestroyUnitTest::ConstructL()
    1.87 +	{
    1.88 +	// Perform the base class initialization
    1.89 +	UnitTestConstructL();
    1.90 +
    1.91 +	// Create the Unit test state accessor
    1.92 +	iStateAccessor = new(ELeave) TSuicideInterface_StateAccessor();
    1.93 +	
    1.94 +	// context
    1.95 +	iUTContext = new(ELeave) CSuicideInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
    1.96 +
    1.97 +	// Add the Transitions in the order they are to run
    1.98 +	// C'tor first, D'tor last...
    1.99 +	iCtorValidator = new(ELeave) TSuicideInterface_Ctor_TransitionValidator(*iUTContext);
   1.100 +	AddTransitionL(new(ELeave)CSuicideInterfaceNewLTransition(*iUTContext,*iCtorValidator));
   1.101 +	
   1.102 +	iDtorValidator = new(ELeave) TSuicideInterface_Dtor_TransitionValidator(*iUTContext);
   1.103 +	AddTransitionL(new(ELeave)CSuicideInterfaceDtorTransition(*iUTContext,*iDtorValidator));
   1.104 +	}
   1.105 +// ______________________________________________________________________________
   1.106 +//
   1.107 +_LIT(KInterfaceFireAndForgetUnitTest,"CSuicideInterfaceFireAndForgetUnitTest");
   1.108 +
   1.109 +CSuicideInterfaceFireAndForgetUnitTest* CSuicideInterfaceFireAndForgetUnitTest::NewL(CDataLogger& aDataLogger, 
   1.110 +																					 MUnitTestObserver& aObserver)
   1.111 +	{
   1.112 +	CSuicideInterfaceFireAndForgetUnitTest* self = new(ELeave) CSuicideInterfaceFireAndForgetUnitTest(aDataLogger, aObserver);
   1.113 +	CleanupStack::PushL(self);
   1.114 +	// Chain to the base which calls the ConstructL
   1.115 +	self->ConstructL();
   1.116 +	CleanupStack::Pop();
   1.117 +	return self; 
   1.118 +	}
   1.119 +
   1.120 +TInt CSuicideInterfaceFireAndForgetUnitTest::RunError(TInt aError)
   1.121 +	{
   1.122 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
   1.123 +	delete iUTContext;
   1.124 +	iUTContext = NULL;
   1.125 +	delete iStateAccessor;
   1.126 +	iStateAccessor = NULL;
   1.127 +	delete iCtorValidator;
   1.128 +	iCtorValidator = NULL;
   1.129 +	delete iFireAndForgetValidator;
   1.130 +	iFireAndForgetValidator = NULL;
   1.131 +
   1.132 +	return error;
   1.133 +	}
   1.134 +
   1.135 +CSuicideInterfaceFireAndForgetUnitTest::~CSuicideInterfaceFireAndForgetUnitTest()
   1.136 +	{
   1.137 +	delete iUTContext;
   1.138 +	delete iStateAccessor;
   1.139 +	delete iCtorValidator;
   1.140 +	delete iFireAndForgetValidator;
   1.141 +
   1.142 +	}
   1.143 +
   1.144 +CSuicideInterfaceFireAndForgetUnitTest::CSuicideInterfaceFireAndForgetUnitTest(CDataLogger& aDataLogger, MUnitTestObserver& aObserver)
   1.145 +: CUnitTest(KInterfaceFireAndForgetUnitTest, aDataLogger, aObserver)
   1.146 +	{
   1.147 +	//Do nothing
   1.148 +	}
   1.149 +
   1.150 +// Now the Individual transitions need to be added.
   1.151 +void CSuicideInterfaceFireAndForgetUnitTest::ConstructL()
   1.152 +	{
   1.153 +	UnitTestConstructL();
   1.154 +
   1.155 +	// Create the Unit test state accessor
   1.156 +	iStateAccessor = new(ELeave) TSuicideInterface_StateAccessor();
   1.157 +	// context
   1.158 +	iUTContext = new(ELeave) CSuicideInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
   1.159 +	// Add the Transitions in the order they are to run
   1.160 +	// C'tor first, D'tor last...
   1.161 +	iCtorValidator = new(ELeave) TSuicideInterface_Ctor_TransitionValidator(*iUTContext);
   1.162 +	AddTransitionL(new(ELeave)CSuicideInterfaceNewLTransition(*iUTContext,*iCtorValidator));
   1.163 +
   1.164 +	iFireAndForgetValidator = new(ELeave) TSuicideInterface_FireAndForget_TransitionValidator(*iUTContext);
   1.165 +	AddTransitionL(new(ELeave)CSuicideInterfaceFireAndForgetTransition(*iUTContext, *iFireAndForgetValidator));
   1.166 +	}
   1.167 +