lowlevellibsandfws/pluginfw/Framework/EcomTestUtils/EcomTestUtils.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2004-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 // Helper class for ECom test code. Allows various file manipulation operations
       
    15 // that require higher Capabilities than shoud be given to test harnesses.
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 #ifndef __ECOMTESTUTILS_H__
       
    21 #define __ECOMTESTUTILS_H__
       
    22 
       
    23 #include <e32test.h>
       
    24 
       
    25 // System includes
       
    26 #include <f32file.h>
       
    27 
       
    28 // Wait or sleep macros for current thread
       
    29 #define WAIT_FOR1s User::After(1000000)
       
    30 #define WAIT_FOR3s User::After(3000000)
       
    31 #define WAIT_FOR5s User::After(5000000)
       
    32 
       
    33 // Common ECOM Server strings
       
    34 _LIT(KEComZDriveDatFile, 		"C:\\private\\10009D8F\\ECom.ROM.Z.dat");
       
    35 _LIT(KEComCDriveDatFile, 		"C:\\private\\10009D8F\\ECom.dat");
       
    36 _LIT(KEComEDriveDatFile, 		"E:\\private\\10009D8F\\ECom.dat");
       
    37 
       
    38 
       
    39 _LIT(KEComServerProcessName,    "ecomserver");
       
    40 
       
    41 /**
       
    42 This enum is used to represent the rom build option i.e. NAND or default rom build
       
    43 */
       
    44 enum TRomBuildOption
       
    45 {
       
    46 	EDefaultRomBuild,
       
    47 	ENandRomBuild
       
    48 };
       
    49 
       
    50 /**
       
    51 Enum type to represent possible configurations of the hardware running the tests
       
    52 */
       
    53 enum THardwareConfiguration
       
    54 {
       
    55 	EPlatformWINSCW,
       
    56 	EPlatformH2RAM,
       
    57 	EPlatformH2NAND,
       
    58 	EPlatformH2NANDDP,
       
    59 	EPlatformH4RAM,
       
    60 	EPlatformH4MMC,//New hardware configuration for WDP enabled ROM on H4
       
    61 	EPlatformH4NAND,
       
    62 	EPlatformH4NANDDP,
       
    63 	EPlatformH6RAM,
       
    64 	EPlatformH6NAND,
       
    65 	EPlatformH6NANDDP,
       
    66 	EPlatformUnknown,
       
    67 };
       
    68 
       
    69 class EComTestUtils
       
    70 	{
       
    71 public:
       
    72 	IMPORT_C static void FileManCopyFileL(const TDesC& anOld,const TDesC& aNew);
       
    73 	IMPORT_C static void FileManDeleteFileL(const TDesC& aFile);
       
    74 	IMPORT_C static void MakeFileWriteableL(const TDesC& aFile);
       
    75 	IMPORT_C static void MakeFileReadOnlyL(const TDesC& aFile);
       
    76 	IMPORT_C static void RfsDeleteFileL(const TDesC& aFile);
       
    77 	IMPORT_C static void RfsReplaceFileL(const TDesC& anOld,const TDesC& aNew);
       
    78 	IMPORT_C static void KillProcessL(const TDesC& aProcessName);
       
    79 	IMPORT_C static void FileManRenameL(const TDesC& anOld,const TDesC& aNew);
       
    80 	IMPORT_C static void FileManDeleteDirL(const TDesC& aPath);
       
    81 	IMPORT_C static void SwitchToLanguageL(TLanguage aLang);
       
    82 	IMPORT_C static void RLoaderDeleteFileL(const TDesC& aFile);
       
    83 	IMPORT_C static TRomBuildOption RomBuildType(const RFs& aRfs);
       
    84 	IMPORT_C static THardwareConfiguration GetHardwareConfiguration();
       
    85 	};
       
    86 
       
    87 inline void KillEComServerL(RTest &aRTest)
       
    88 	{
       
    89 	aRTest.Printf(_L("Killing ECOM Server, waiting 1s...\n"));
       
    90 	TRAPD(err, EComTestUtils::KillProcessL(KEComServerProcessName));
       
    91 	if ((err != KErrNone) && (err != KErrNotFound))
       
    92 		User::Leave(err);
       
    93 	// Precaution delay, give the system a chance to settle afterwards
       
    94 	WAIT_FOR1s;	
       
    95 	}
       
    96 #define ECOMTU_KILL_SERVER_L(rt) KillEComServerL((rt))
       
    97 
       
    98 
       
    99 inline void Validate(RTest& aRTest, TInt aValue, TInt aExpected, TInt aLine)
       
   100 	{
       
   101 	if(aValue != aExpected)
       
   102 		{
       
   103 		RDebug::Print(_L("*** Expected integer/error: %d, got: %d\r\n"), aExpected, aValue);
       
   104 		aRTest(EFalse, aLine);
       
   105 		}
       
   106 	}
       
   107 
       
   108 #define TESTC(aRTest, aValue, aExpected) ::Validate(aRTest, aValue, aExpected, __LINE__)
       
   109 
       
   110 
       
   111 #endif
       
   112