lowlevellibsandfws/pluginfw/Framework/EcomTestUtils/EcomTestCompTestabilityUtils.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2005-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 //
       
    15 
       
    16 #include <e32base.h>
       
    17 #include <bautils.h>
       
    18 #include <f32file.h>
       
    19 #include "../EcomTestUtils/EcomTestCompTestabilityUtils.h"
       
    20 #include "../EcomTestUtils/EcomTestIniFileUtils.h"
       
    21 #include "../EcomTestUtils/EcomTestUtils.h"
       
    22 
       
    23 _LIT(KIniEcomTestBehaviourFileNameInit, "z:\\test\\data\\EComTestBehaviour.ini");
       
    24 _LIT(KIniEcomTestBehaviourFileNameFinal, "c:\\EComTestBehaviour.ini");
       
    25 
       
    26 //
       
    27 //
       
    28 //Test macroes and functions
       
    29 //
       
    30 //
       
    31 
       
    32 static  void Check(RTest& aTest, TInt aValue, TInt aExpected, TInt aLine)
       
    33 	{
       
    34 	if(aValue != aExpected)
       
    35 		{
       
    36 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
       
    37 		aTest(EFalse, aLine);
       
    38 		}
       
    39 	}
       
    40 #define TEST2(aTest, aValue, aExpected) ::Check(aTest, aValue, aExpected, __LINE__)
       
    41 
       
    42 //
       
    43 //
       
    44 //Helper functions
       
    45 //
       
    46 //
       
    47 /**
       
    48 Enable ECom test behaviour by copying the EComTestBehaviour.ini
       
    49 @param aTest the RTest that this method is called from
       
    50 @param	aFs A reference to an connected file server session.
       
    51 */
       
    52 void EnableEcomTestBehaviour(RTest& aTest, RFs& /*aFs*/)
       
    53 	{
       
    54 	TInt err = KErrNone;
       
    55 	TParse initFileName;
       
    56 	TParse finalFileName;
       
    57 
       
    58 	initFileName.Set(KIniEcomTestBehaviourFileNameInit, NULL, NULL);
       
    59 	finalFileName.Set(KIniEcomTestBehaviourFileNameFinal, NULL, NULL);
       
    60 	
       
    61 	//copy the file to enable test behaviour
       
    62 	TRAP(err, EComTestUtils::FileManCopyFileL(
       
    63 					initFileName.FullName(),
       
    64 	                finalFileName.FullName()));
       
    65 	TEST2(aTest, err, KErrNone);
       
    66 	}
       
    67 
       
    68 /**
       
    69 Enable ECom test behaviour by deleting the EComTestBehaviour.ini
       
    70 @param aTest the RTest that this method is called from
       
    71 @param	aFs A reference to an connected file server session.
       
    72 */
       
    73 void DisableEcomTestBehaviour(RTest& aTest, RFs& /*aFs*/)
       
    74 	{
       
    75 	TInt err = KErrNone;
       
    76 	TParse finalFileName;
       
    77 
       
    78 	finalFileName.Set(KIniEcomTestBehaviourFileNameFinal, NULL, NULL);
       
    79 	
       
    80 	//delete the file to disable test behaviour
       
    81 	TRAP(err, EComTestUtils::RfsDeleteFileL(finalFileName.FullName()));
       
    82 	TEST2(aTest, err, KErrNone);
       
    83 	}
       
    84