lowlevellibsandfws/pluginfw/Framework/SuicideTests/SuicideUnitTests.cpp
changeset 0 e4d67989cc36
child 44 97b0fb8a2cc2
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 definition of the 
       
    15 // class CAllTransitionsUnitTest	
       
    16 // 
       
    17 //
       
    18 
       
    19 #include <e32uid.h>
       
    20 
       
    21 #include "TestUtilities.h"	// For __FILE__LINE__
       
    22 #include "Interface.h"
       
    23 #include <test_bed/datalogger.h>
       
    24 
       
    25 #include "SuicideUnitTests.h"
       
    26 #include "SuicideTransitions.h"
       
    27 #include "SuicideTransitionValidation.h"
       
    28 
       
    29 #include "TlsData.h"		// For GlobalData
       
    30 
       
    31 // ______________________________________________________________________________
       
    32 //
       
    33 _LIT(KInterfaceCreateAndDestroyUnitTest,"CSuicideInterfaceCreateAndDestroyUnitTest");
       
    34 
       
    35 CSuicideInterfaceCreateAndDestroyUnitTest* CSuicideInterfaceCreateAndDestroyUnitTest::NewL(CDataLogger& aDataLogger,
       
    36 											MUnitTestObserver& aObserver)
       
    37 	{
       
    38 	CSuicideInterfaceCreateAndDestroyUnitTest* self = 
       
    39 					new(ELeave) CSuicideInterfaceCreateAndDestroyUnitTest(aDataLogger,
       
    40 																aObserver);
       
    41 	CleanupStack::PushL(self);
       
    42 	// Chain to the base which calls the ConstructL
       
    43 	self->ConstructL();
       
    44 	CleanupStack::Pop();
       
    45 	return self; 
       
    46 	}
       
    47 
       
    48 TInt CSuicideInterfaceCreateAndDestroyUnitTest::RunError(TInt aError)
       
    49 	{
       
    50 	// The RunL left so chain to the base first and then cleanup
       
    51 	TInt error = CUnitTest::RunError(aError);	// Chain to base
       
    52 	delete iUTContext;
       
    53 	iUTContext = NULL;
       
    54 	delete iStateAccessor;
       
    55 	iStateAccessor = NULL;
       
    56 	delete iCtorValidator;
       
    57 	delete iDtorValidator;
       
    58 
       
    59 	return error;
       
    60 	}
       
    61 
       
    62 CSuicideInterfaceCreateAndDestroyUnitTest::~CSuicideInterfaceCreateAndDestroyUnitTest()
       
    63 	{
       
    64 	// Simply delete our test class instance
       
    65 	delete iUTContext;
       
    66 	delete iStateAccessor;
       
    67 	delete iCtorValidator;
       
    68 	delete iDtorValidator;
       
    69 
       
    70 	}
       
    71 
       
    72 CSuicideInterfaceCreateAndDestroyUnitTest::CSuicideInterfaceCreateAndDestroyUnitTest(CDataLogger& aDataLogger,
       
    73 																	MUnitTestObserver& aObserver)
       
    74 : CUnitTest(KInterfaceCreateAndDestroyUnitTest, aDataLogger, aObserver)
       
    75 	{
       
    76 	//Do nothing
       
    77 	}
       
    78 
       
    79 // Now the Individual transitions need to be added.
       
    80 void CSuicideInterfaceCreateAndDestroyUnitTest::ConstructL()
       
    81 	{
       
    82 	// Perform the base class initialization
       
    83 	UnitTestConstructL();
       
    84 
       
    85 	// Create the Unit test state accessor
       
    86 	iStateAccessor = new(ELeave) TSuicideInterface_StateAccessor();
       
    87 	
       
    88 	// context
       
    89 	iUTContext = new(ELeave) CSuicideInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
       
    90 
       
    91 	// Add the Transitions in the order they are to run
       
    92 	// C'tor first, D'tor last...
       
    93 	iCtorValidator = new(ELeave) TSuicideInterface_Ctor_TransitionValidator(*iUTContext);
       
    94 	AddTransitionL(new(ELeave)CSuicideInterfaceNewLTransition(*iUTContext,*iCtorValidator));
       
    95 	
       
    96 	iDtorValidator = new(ELeave) TSuicideInterface_Dtor_TransitionValidator(*iUTContext);
       
    97 	AddTransitionL(new(ELeave)CSuicideInterfaceDtorTransition(*iUTContext,*iDtorValidator));
       
    98 	}
       
    99 // ______________________________________________________________________________
       
   100 //
       
   101 _LIT(KInterfaceFireAndForgetUnitTest,"CSuicideInterfaceFireAndForgetUnitTest");
       
   102 
       
   103 CSuicideInterfaceFireAndForgetUnitTest* CSuicideInterfaceFireAndForgetUnitTest::NewL(CDataLogger& aDataLogger, 
       
   104 																					 MUnitTestObserver& aObserver)
       
   105 	{
       
   106 	CSuicideInterfaceFireAndForgetUnitTest* self = new(ELeave) CSuicideInterfaceFireAndForgetUnitTest(aDataLogger, aObserver);
       
   107 	CleanupStack::PushL(self);
       
   108 	// Chain to the base which calls the ConstructL
       
   109 	self->ConstructL();
       
   110 	CleanupStack::Pop();
       
   111 	return self; 
       
   112 	}
       
   113 
       
   114 TInt CSuicideInterfaceFireAndForgetUnitTest::RunError(TInt aError)
       
   115 	{
       
   116 	TInt error = CUnitTest::RunError(aError);	// Chain to base
       
   117 	delete iUTContext;
       
   118 	iUTContext = NULL;
       
   119 	delete iStateAccessor;
       
   120 	iStateAccessor = NULL;
       
   121 	delete iCtorValidator;
       
   122 	iCtorValidator = NULL;
       
   123 	delete iFireAndForgetValidator;
       
   124 	iFireAndForgetValidator = NULL;
       
   125 
       
   126 	return error;
       
   127 	}
       
   128 
       
   129 CSuicideInterfaceFireAndForgetUnitTest::~CSuicideInterfaceFireAndForgetUnitTest()
       
   130 	{
       
   131 	delete iUTContext;
       
   132 	delete iStateAccessor;
       
   133 	delete iCtorValidator;
       
   134 	delete iFireAndForgetValidator;
       
   135 
       
   136 	}
       
   137 
       
   138 CSuicideInterfaceFireAndForgetUnitTest::CSuicideInterfaceFireAndForgetUnitTest(CDataLogger& aDataLogger, MUnitTestObserver& aObserver)
       
   139 : CUnitTest(KInterfaceFireAndForgetUnitTest, aDataLogger, aObserver)
       
   140 	{
       
   141 	//Do nothing
       
   142 	}
       
   143 
       
   144 // Now the Individual transitions need to be added.
       
   145 void CSuicideInterfaceFireAndForgetUnitTest::ConstructL()
       
   146 	{
       
   147 	UnitTestConstructL();
       
   148 
       
   149 	// Create the Unit test state accessor
       
   150 	iStateAccessor = new(ELeave) TSuicideInterface_StateAccessor();
       
   151 	// context
       
   152 	iUTContext = new(ELeave) CSuicideInterface_UnitTestContext(iDataLogger, *iStateAccessor, *this);
       
   153 	// Add the Transitions in the order they are to run
       
   154 	// C'tor first, D'tor last...
       
   155 	iCtorValidator = new(ELeave) TSuicideInterface_Ctor_TransitionValidator(*iUTContext);
       
   156 	AddTransitionL(new(ELeave)CSuicideInterfaceNewLTransition(*iUTContext,*iCtorValidator));
       
   157 
       
   158 	iFireAndForgetValidator = new(ELeave) TSuicideInterface_FireAndForget_TransitionValidator(*iUTContext);
       
   159 	AddTransitionL(new(ELeave)CSuicideInterfaceFireAndForgetTransition(*iUTContext, *iFireAndForgetValidator));
       
   160 	}
       
   161