os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/UnitTestTest/UnitTestStateAccessor.inl
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // The implementation of the accessor class upon the CUnitTest
18 // ______________________________________________________________________________
20 _LIT(KTUnitTest_DumpName,"C:\\System\\Data\\Logs\\TUnitTest_StateDump.bin");
22 inline TInt TUnitTest_StateAccessor::InvariantTest(TAny* aTestObject)
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.")
33 inline TInt TUnitTest_StateAccessor::Internalize(TAny* aTestObject)
35 TInt error = KErrNone;
36 if(aTestObject != NULL)
38 CUnitTest* UnitTest = REINTERPRET_CAST(CUnitTest*, aTestObject);
39 TRAP(error,InternalizeL(UnitTest));
44 inline TInt TUnitTest_StateAccessor::Externalize(TAny* aTestObject)
46 TInt error = KErrNone;
47 if(aTestObject != NULL)
49 CUnitTest* UnitTest = REINTERPRET_CAST(CUnitTest*, aTestObject);
50 TRAP(error,ExternalizeL(UnitTest));
55 inline void TUnitTest_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CUnitTest* /* aLoadManager */)
60 inline void TUnitTest_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CUnitTest* /* aLoadManager */)
66 inline CUnitTestTestDerivation::CUnitTestTestDerivation(const TDesC& aName, CDataLogger& aDataLogger, MUnitTestObserver& aUnitTestObserver)
67 : CUnitTest(aName, aDataLogger, aUnitTestObserver)
71 inline void CUnitTestTestDerivation::ConstructL()
76 inline CUnitTestTestDerivation* TUnitTest_StateAccessor::CreateUnitTest(CUnitTest& /*aUnitTest*/,
78 CDataLogger& aDataLogger,
79 MUnitTestObserver& aUnitTestObserver)
81 return new(ELeave)CUnitTestTestDerivation(aName, aDataLogger, aUnitTestObserver);
85 inline void TUnitTest_StateAccessor::RunL(CUnitTest& aUnitTest)
90 inline void TUnitTest_StateAccessor::AddTransitionL(CUnitTest& aUnitTest, CTransition* aTransition)
92 aUnitTest.AddTransitionL(aTransition);
95 inline void TUnitTest_StateAccessor::AddBlockingTransitionL(CUnitTest& aUnitTest, CTransition* aTransition)
97 aUnitTest.AddBlockingTransitionL(aTransition);
100 inline void TUnitTest_StateAccessor::AddLeaveErrorCodeL(CUnitTest& aUnitTest, TInt& aLeaveErrorCode)
102 aUnitTest.AddLeaveErrorCodeL(aLeaveErrorCode);
107 inline void TUnitTest_StateAccessor::InternalizeL(CUnitTest* aUnitTest)
109 // Read in the dumped data
111 User::LeaveIfError(fs.Connect());
112 CleanupClosePushL(fs);
113 // Read the object dump
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
123 inline void TUnitTest_StateAccessor::ExternalizeL(CUnitTest* aUnitTest)
126 User::LeaveIfError(fs.Connect());
127 CleanupClosePushL(fs);
128 // Write out the object dump
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