usbengines/usbwatcher/tsrc/UsbWatcherTest/inc/UsbWatcherTest.h
branchRCL_3
changeset 92 dde4619868dc
parent 86 703a2b94c06c
child 95 55a3258355ea
equal deleted inserted replaced
86:703a2b94c06c 92:dde4619868dc
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef TEMPLATESTUBSCRIPTUsbWatcherTest_H
       
    20 #define TEMPLATESTUBSCRIPTUsbWatcherTest_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <StifLogger.h>
       
    24 #include <TestScripterInternal.h>
       
    25 #include <StifTestModule.h>
       
    26 #include <TestclassAssert.h>
       
    27 
       
    28 #include <usbwatcher.h>
       
    29 #include <UsbWatcherInternalCRKeys.h>
       
    30 #include <usbpersonalityids.h>
       
    31 #include <centralrepository.h>
       
    32 #include "usbwatchershared.h"
       
    33 //  INCLUDES FOR STUBS
       
    34 #include <stubber.h>
       
    35 #include <apibehavior.h>
       
    36 #include <usbmandll_stub.h>
       
    37 #include <usbman.h>
       
    38 
       
    39 // CONSTANTS
       
    40 // Logging path
       
    41 //_LIT( KUsbWatcherTestLogPath, "\\logs\\testframework\\UsbWatcherTest\\" );
       
    42 
       
    43 // Logging path for ATS - for phone builds comment this line
       
    44 _LIT( KUsbWatcherTestLogPath, "e:\\testing\\stiflogs\\" ); 
       
    45 
       
    46 // Log file
       
    47 _LIT( KUsbWatcherTestLogFile, "UsbWatcherTest.txt" ); 
       
    48 _LIT( KUsbWatcherTestLogFileWithTitle, "UsbWatcherTest_[%S].txt" );
       
    49 
       
    50 // MACROS
       
    51 #define TEST_CLASS_VERSION_MAJOR 0
       
    52 #define TEST_CLASS_VERSION_MINOR 0
       
    53 #define TEST_CLASS_VERSION_BUILD 0
       
    54 
       
    55 // Macros used to extract test block parameters
       
    56 #define TESTENTRY( A, B )\
       
    57     if ( !iTestBlockParams.iTestBlockName.Compare( TPtrC( ( TText* ) L ##A ) ) )\
       
    58         { iTestBlockFunction = &B; iTestBlockFound = ETrue; }\
       
    59     if ( !iTestBlockParams.iTestBlockName.Compare( TPtrC( ( TText* ) L ##A ) ) )
       
    60 
       
    61 #define TESTPARAM( A, B )\
       
    62     GetTestBlockParamL( ( TGetTestBlockParamOperation ) A, ( TTestBlockParamName ) B );
       
    63 
       
    64 // FUNCTION PROTOTYPES
       
    65 
       
    66 // FORWARD DECLARATIONS
       
    67 
       
    68 // DATA TYPES
       
    69 
       
    70 // Enum type used to determine test block execution result
       
    71 enum TUsbWatcherTestResult
       
    72     {
       
    73     ETestCasePassed,
       
    74     ETestCaseFailed
       
    75     };
       
    76 
       
    77 // Enum type indicating test block parameter which should be used to store
       
    78 // data extracted from test script
       
    79 enum TTestBlockParamName
       
    80     {
       
    81     eTestOption1,
       
    82     eTestOption2,
       
    83     eTestOption3,    
       
    84     eTestIntOption1,
       
    85     eTestIntOption2,
       
    86     eTestIntOption3,   
       
    87     eTestCharOption1,
       
    88     eTestCharOption2,
       
    89     eTestCharOption3
       
    90     };
       
    91 
       
    92 // Enum type used to indicate which get parameter function should be used
       
    93 enum TGetTestBlockParamOperation
       
    94     {
       
    95     eGetString,
       
    96     eGetInt,
       
    97     eGetChar
       
    98     };
       
    99 
       
   100 // CLASS DECLARATION
       
   101 /**
       
   102 *  TUsbWatcherTestBlockParams test class for storing test block parameters.
       
   103 */
       
   104 NONSHARABLE_CLASS( TUsbWatcherTestBlockParams )
       
   105     {
       
   106     public:
       
   107         TPtrC iTestBlockName;
       
   108         
       
   109         TPtrC iTestOption1;
       
   110         TPtrC iTestOption2;
       
   111         TPtrC iTestOption3;
       
   112         
       
   113         TInt iTestIntOption1;
       
   114         TInt iTestIntOption2;
       
   115         TInt iTestIntOption3;
       
   116         
       
   117         TChar iTestCharOption1;
       
   118         TChar iTestCharOption2;
       
   119         TChar iTestCharOption3;
       
   120     };
       
   121 
       
   122 /**
       
   123 *  CUsbWatcherTest test class for STIF Test Framework TestScripter.
       
   124 */
       
   125 NONSHARABLE_CLASS( CUsbWatcherTest ) : public CScriptBase
       
   126     {
       
   127     public:  // Constructors and destructor
       
   128 
       
   129         /**
       
   130         * Two-phased constructor.
       
   131         */
       
   132         static CUsbWatcherTest* NewL( CTestModuleIf& aTestModuleIf );
       
   133 
       
   134         /**
       
   135         * Destructor.
       
   136         */
       
   137         virtual ~CUsbWatcherTest();
       
   138 
       
   139     public: // New functions
       
   140     public: // Functions from base classes
       
   141 
       
   142         /**
       
   143         * From CScriptBase Runs a script line.
       
   144         * @since ?Series60_version
       
   145         * @param aItem Script line containing method name and parameters
       
   146         * @return Symbian OS error code
       
   147         */
       
   148         virtual TInt RunMethodL( CStifItemParser& aItem );
       
   149 
       
   150     protected:  // New functions
       
   151     protected:  // Functions from base classes
       
   152     private:
       
   153 
       
   154         /**
       
   155         * C++ default constructor.
       
   156         */
       
   157         CUsbWatcherTest( CTestModuleIf& aTestModuleIf );
       
   158 
       
   159         /**
       
   160         * By default Symbian 2nd phase constructor is private.
       
   161         */
       
   162         void ConstructL();
       
   163 
       
   164         /**
       
   165         * Frees all resources allocated from test methods.
       
   166         * @since ?Series60_version
       
   167         */
       
   168         void TestDelete();
       
   169         
       
   170         /**
       
   171         * Constructs all test resources for test methods.
       
   172         */
       
   173         void TestConstructL();
       
   174         
       
   175         /**
       
   176         * Extracts test block parameters from script file
       
   177         */
       
   178         void TestBlocksInfoL();
       
   179         
       
   180         /**
       
   181         * Executes test block
       
   182         */
       
   183         TInt ExecuteTestBlock( CStifItemParser& aItem );
       
   184         
       
   185         /**
       
   186         * Executes proper get parameter function indicated by its arguments
       
   187         */
       
   188         void GetTestBlockParamL( TGetTestBlockParamOperation aOperation,
       
   189                                 TTestBlockParamName aParamName );
       
   190         
       
   191         /**
       
   192          * Method used to log version of test class
       
   193          */
       
   194         void SendTestClassVersion();
       
   195 
       
   196         // ADD NEW METHOD DEC HERE
       
   197         // [TestMethods] - Do not remove 
       
   198         void ExampleTestL( TUsbWatcherTestBlockParams& aParams, 
       
   199                             TUsbWatcherTestResult& aTestResult );
       
   200 
       
   201         /**
       
   202         * Test methods are listed below. 
       
   203         */
       
   204 
       
   205         void InitializationTestL( TUsbWatcherTestBlockParams& aParams, 
       
   206                             TUsbWatcherTestResult& aTestResult );
       
   207         
       
   208         void PersonalityManagementTestL( TUsbWatcherTestBlockParams& aParams, 
       
   209                             TUsbWatcherTestResult& aTestResult );
       
   210         
       
   211         void PersonalitySwitchTestL( TUsbWatcherTestBlockParams& aParams, 
       
   212                             TUsbWatcherTestResult& aTestResult );  
       
   213         
       
   214         void BranchTestL( TUsbWatcherTestBlockParams& aParams, 
       
   215                             TUsbWatcherTestResult& aTestResult ); 
       
   216         
       
   217         TInt BackupPersonalitySetting();
       
   218         TInt RestorePersonalitySetting();
       
   219         
       
   220         TInt GetPersonalityIdFromString( TPtrC& aUsbPersonalityName, TInt& aUsbPersonalityId );
       
   221         TUsbWatcherTestResult SetPersonalityTest( TInt aNewPersonalityId, TBool aCableConnected );
       
   222         TUsbWatcherTestResult CancelSetPersonalityTest( TInt aNewPersonalityId, TBool aCableConnected );
       
   223         TUsbWatcherTestResult SetPreviousPersonalityTest( TInt aNewPersonalityId, TBool aCableConnected );
       
   224         TUsbWatcherTestResult SetPreviousPersonalityOnDiscTest( TInt aNewPersonalityId, TBool aCableConnected );
       
   225         TUsbWatcherTestResult SetPreviousPersonalitySyncTest( TInt aNewPersonalityId, TBool aCableConnected );
       
   226         TUsbWatcherTestResult CancelSetPreviousPersonalityTest( TInt aNewPersonalityId, TBool aCableConnected );
       
   227         TUsbWatcherTestResult SetUnknownPersonalityTest();
       
   228         TUsbWatcherTestResult InterruptPersonalitySetTest( TInt aNewPersonalityId );
       
   229         
       
   230         TUsbWatcherTestResult FastPersonalitySwitchTest();
       
   231         TUsbWatcherTestResult DelayedPersonalitySwitchTest();
       
   232         
       
   233         TUsbWatcherTestResult SetSamePersonalityTest();
       
   234         TUsbWatcherTestResult SetPersonalityBlockingOn();
       
   235         TUsbWatcherTestResult SetPersonalityAskOnConnectionOff();
       
   236         
       
   237 	
       
   238     public:     // Data
       
   239     protected:  // Data
       
   240     private:    // Data
       
   241         
       
   242         // Member object used to store test block parameters
       
   243         TUsbWatcherTestBlockParams iTestBlockParams;
       
   244         
       
   245         // Used to indicate if test block with specified parameters exist
       
   246         TBool iTestBlockFound;
       
   247         
       
   248         // Function pointer used to call proper test block methods
       
   249         void ( CUsbWatcherTest::*iTestBlockFunction )
       
   250             ( TUsbWatcherTestBlockParams&, TUsbWatcherTestResult& );
       
   251         
       
   252         // Not own
       
   253         CStifItemParser* iItem;
       
   254         CStubber * iStubber;
       
   255         RUsbWatcher* iWatcher;
       
   256         RUsb* iUsbMan;
       
   257         CRepository* iCenRep;
       
   258 
       
   259         // Reserved pointer for future extension
       
   260         //TAny* iReserved;
       
   261 
       
   262         // ADD NEW DATA DEC HERE
       
   263         
       
   264         TInt iPersonalityIdBackup;
       
   265 
       
   266         
       
   267     public:     // Friend classes
       
   268     protected:  // Friend classes
       
   269     private:    // Friend classes
       
   270         
       
   271     };
       
   272 #endif      // TEMPLATESTUBSCRIPTUsbWatcherTest_H
       
   273 
       
   274 // End of File