os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/TestManagerTest/TestManagerStateAccessor.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 CTestManager
    15 // 
    16 //
    17 
    18 // ______________________________________________________________________________
    19 //
    20 _LIT(KTTestManager_DumpName,"C:\\System\\Data\\Logs\\TTestManager_StateDump.bin");
    21 
    22 inline TInt TTestManager_StateAccessor::InvariantTest(TAny* aTestObject)
    23 	{
    24 	if(aTestObject)
    25 		{
    26 		CTestManager* theTestManager = REINTERPRET_CAST(CTestManager*, aTestObject);
    27 		if(theTestManager->iTestList == NULL)
    28 			return KErrArgument;
    29 		}
    30 	return KErrNone;
    31 	}
    32 
    33 inline TInt TTestManager_StateAccessor::Internalize(TAny* aTestObject)
    34 	{
    35 	TInt error = KErrNone;
    36 	if(aTestObject != NULL)
    37 		{
    38 		CTestManager* theTestManager = REINTERPRET_CAST(CTestManager*, aTestObject);
    39 		TRAP(error,InternalizeL(theTestManager));
    40 		}
    41 	return error;
    42 	}
    43 
    44 inline TInt TTestManager_StateAccessor::Externalize(TAny* aTestObject)
    45 	{
    46 	TInt error = KErrNone;
    47 	if(aTestObject != NULL)
    48 		{
    49 		CTestManager* theTestManager = REINTERPRET_CAST(CTestManager*, aTestObject);
    50 		TRAP(error,ExternalizeL(theTestManager));
    51 		}
    52 	return error;
    53 	}
    54 
    55 inline void TTestManager_StateAccessor::InternalizeL(RFileReadStream& /* aStream */, CTestManager* /* aLoadManager */)
    56 	{
    57 	// Not required
    58 	}
    59 
    60 inline void TTestManager_StateAccessor::ExternalizeL(RFileWriteStream& /* aStream */, CTestManager* /* aLoadManager */)
    61 	{
    62 	// Not required
    63 	}
    64 
    65 inline void TTestManager_StateAccessor::RunL(CTestManager& aTestMan)
    66 	{
    67 	aTestMan.RunL();
    68 	}
    69 
    70 inline void TTestManager_StateAccessor::TestComponentL(CTestManager& aTestMan, TInt& aComponentIndex)
    71 	{
    72 	aTestMan.TestComponentL(aComponentIndex);
    73 	}
    74 
    75 inline void TTestManager_StateAccessor::ActivateManager(CTestManager& aTestMan)
    76 	{
    77 	aTestMan.SetActive();
    78 	aTestMan.iStatus = KRequestPending;
    79 	}
    80 
    81 // internal helpers
    82 inline void TTestManager_StateAccessor::InternalizeL(CTestManager* aTestManager)
    83 	{
    84 	// Read in the dumped data
    85 	RFs fs;
    86 	User::LeaveIfError(fs.Connect());
    87 	CleanupClosePushL(fs);
    88 	// Read the object dump
    89 	TParse filename;
    90 	filename.Set(KTTestManager_DumpName(),NULL,NULL);
    91 	RFileReadStream stream;
    92 	User::LeaveIfError(stream.Open(fs,filename.FullName(), EFileRead));
    93 	CleanupClosePushL(stream);
    94 	InternalizeL(stream, aTestManager);
    95 	CleanupStack::PopAndDestroy(2);	// stream & fs
    96 	}
    97 
    98 inline void TTestManager_StateAccessor::ExternalizeL(CTestManager* aTestManager)
    99 	{
   100 	RFs fs;
   101 	User::LeaveIfError(fs.Connect());
   102 	CleanupClosePushL(fs);
   103 	// Write out the object dump
   104 	TParse filename;
   105 	filename.Set(KTTestManager_DumpName(),NULL,NULL);
   106 	RFileWriteStream stream;
   107 	User::LeaveIfError(stream.Replace(fs,filename.FullName(), EFileWrite));
   108 	CleanupClosePushL(stream);
   109 	ExternalizeL(stream, aTestManager);
   110 	CleanupStack::PopAndDestroy(2);	// stream & fs
   111 	}
   112