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