os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/UnitTestTest/UnitTestStateAccessor.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
// The implementation of the accessor class upon the CUnitTest
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
// ______________________________________________________________________________
sl@0
    19
//
sl@0
    20
_LIT(KTUnitTest_DumpName,"C:\\System\\Data\\Logs\\TUnitTest_StateDump.bin");
sl@0
    21
sl@0
    22
inline TInt TUnitTest_StateAccessor::InvariantTest(TAny* aTestObject)
sl@0
    23
	{
sl@0
    24
	if(aTestObject)
sl@0
    25
		{
sl@0
    26
		// CUnitTest* UnitTest = REINTERPRET_CAST(CUnitTest*, aTestObject);
sl@0
    27
		// Implement the correct Invariant test for CUnitTest.
sl@0
    28
//#pragma message( __FILE__LINE__ "TO DO : Implement the correct Invariant test for CUnitTest.")
sl@0
    29
		}
sl@0
    30
	return KErrNone;
sl@0
    31
	}
sl@0
    32
sl@0
    33
inline TInt TUnitTest_StateAccessor::Internalize(TAny* aTestObject)
sl@0
    34
	{
sl@0
    35
	TInt error = KErrNone;
sl@0
    36
	if(aTestObject != NULL)
sl@0
    37
		{
sl@0
    38
		CUnitTest* UnitTest = REINTERPRET_CAST(CUnitTest*, aTestObject);
sl@0
    39
		TRAP(error,InternalizeL(UnitTest));
sl@0
    40
		}
sl@0
    41
	return error;
sl@0
    42
	}
sl@0
    43
sl@0
    44
inline TInt TUnitTest_StateAccessor::Externalize(TAny* aTestObject)
sl@0
    45
	{
sl@0
    46
	TInt error = KErrNone;
sl@0
    47
	if(aTestObject != NULL)
sl@0
    48
		{
sl@0
    49
		CUnitTest* UnitTest = REINTERPRET_CAST(CUnitTest*, aTestObject);
sl@0
    50
		TRAP(error,ExternalizeL(UnitTest));
sl@0
    51
		}
sl@0
    52
	return error;
sl@0
    53
	}
sl@0
    54
sl@0
    55
inline void TUnitTest_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CUnitTest* /* aLoadManager */)
sl@0
    56
	{
sl@0
    57
	// Not required
sl@0
    58
	}
sl@0
    59
sl@0
    60
inline void TUnitTest_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CUnitTest* /* aLoadManager */)
sl@0
    61
	{
sl@0
    62
	// Not required
sl@0
    63
	}
sl@0
    64
sl@0
    65
sl@0
    66
inline CUnitTestTestDerivation::CUnitTestTestDerivation(const TDesC& aName, CDataLogger& aDataLogger, MUnitTestObserver& aUnitTestObserver)
sl@0
    67
	: CUnitTest(aName, aDataLogger, aUnitTestObserver)
sl@0
    68
	{
sl@0
    69
	}
sl@0
    70
sl@0
    71
inline void CUnitTestTestDerivation::ConstructL()
sl@0
    72
	{
sl@0
    73
	UnitTestConstructL();
sl@0
    74
	}
sl@0
    75
sl@0
    76
inline CUnitTestTestDerivation* TUnitTest_StateAccessor::CreateUnitTest(CUnitTest&			/*aUnitTest*/, 
sl@0
    77
																		const TDesC&		aName, 
sl@0
    78
																		CDataLogger&		aDataLogger, 
sl@0
    79
																		MUnitTestObserver&	aUnitTestObserver)
sl@0
    80
	{
sl@0
    81
	return new(ELeave)CUnitTestTestDerivation(aName, aDataLogger, aUnitTestObserver);
sl@0
    82
	}
sl@0
    83
sl@0
    84
sl@0
    85
inline void TUnitTest_StateAccessor::RunL(CUnitTest& aUnitTest)
sl@0
    86
	{
sl@0
    87
	aUnitTest.RunL();
sl@0
    88
	}
sl@0
    89
sl@0
    90
inline void TUnitTest_StateAccessor::AddTransitionL(CUnitTest& aUnitTest, CTransition* aTransition)
sl@0
    91
	{
sl@0
    92
	aUnitTest.AddTransitionL(aTransition);
sl@0
    93
	}
sl@0
    94
sl@0
    95
inline void TUnitTest_StateAccessor::AddBlockingTransitionL(CUnitTest& aUnitTest, CTransition* aTransition)
sl@0
    96
	{
sl@0
    97
	aUnitTest.AddBlockingTransitionL(aTransition);
sl@0
    98
	}
sl@0
    99
sl@0
   100
inline void TUnitTest_StateAccessor::AddLeaveErrorCodeL(CUnitTest& aUnitTest, TInt& aLeaveErrorCode)
sl@0
   101
	{
sl@0
   102
	aUnitTest.AddLeaveErrorCodeL(aLeaveErrorCode);
sl@0
   103
	}
sl@0
   104
sl@0
   105
sl@0
   106
// internal helpers
sl@0
   107
inline void TUnitTest_StateAccessor::InternalizeL(CUnitTest* aUnitTest)
sl@0
   108
	{
sl@0
   109
	// Read in the dumped data
sl@0
   110
	RFs fs;
sl@0
   111
	User::LeaveIfError(fs.Connect());
sl@0
   112
	CleanupClosePushL(fs);
sl@0
   113
	// Read the object dump
sl@0
   114
	TParse filename;
sl@0
   115
	filename.Set(KTUnitTest_DumpName(),NULL,NULL);
sl@0
   116
	RFileReadStream stream;
sl@0
   117
	User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead));
sl@0
   118
	CleanupClosePushL(stream);
sl@0
   119
	InternalizeL(stream, aUnitTest);
sl@0
   120
	CleanupStack::PopAndDestroy(2);	// stream & fs
sl@0
   121
	}
sl@0
   122
sl@0
   123
inline void TUnitTest_StateAccessor::ExternalizeL(CUnitTest* aUnitTest)
sl@0
   124
	{
sl@0
   125
	RFs fs;
sl@0
   126
	User::LeaveIfError(fs.Connect());
sl@0
   127
	CleanupClosePushL(fs);
sl@0
   128
	// Write out the object dump
sl@0
   129
	TParse filename;
sl@0
   130
	filename.Set(KTUnitTest_DumpName(),NULL,NULL);
sl@0
   131
	RFileWriteStream stream;
sl@0
   132
	User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite));
sl@0
   133
	CleanupClosePushL(stream);
sl@0
   134
	ExternalizeL(stream, aUnitTest);
sl@0
   135
	CleanupStack::PopAndDestroy(2);	// stream & fs
sl@0
   136
	}
sl@0
   137