localconnectivityservice/generichid/tsrc/GenericHidTest/src/GenericHidTest.cpp
branchRCL_3
changeset 39 4096754ee773
parent 38 3dcb815346df
child 40 52a167391590
equal deleted inserted replaced
38:3dcb815346df 39:4096754ee773
     1 /*
       
     2 * Copyright (c) 2008-2009 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 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <Stiftestinterface.h>
       
    23 #include "GenericHidTest.h"
       
    24 #include <SettingServerClient.h>
       
    25 
       
    26 //#include "testlogger.h"
       
    27 
       
    28 // EXTERNAL DATA STRUCTURES
       
    29 //extern  ?external_data;
       
    30 
       
    31 // EXTERNAL FUNCTION PROTOTYPES  
       
    32 //extern ?external_function( ?arg_type,?arg_type );
       
    33 
       
    34 // CONSTANTS
       
    35 //const ?type ?constant_var = ?constant;
       
    36 
       
    37 // MACROS
       
    38 //#define ?macro ?macro_def
       
    39 
       
    40 // LOCAL CONSTANTS AND MACROS
       
    41 //const ?type ?constant_var = ?constant;
       
    42 //#define ?macro_name ?macro_def
       
    43 
       
    44 // MODULE DATA STRUCTURES
       
    45 //enum ?declaration
       
    46 //typedef ?declaration
       
    47 
       
    48 // LOCAL FUNCTION PROTOTYPES
       
    49 //?type ?function_name( ?arg_type, ?arg_type );
       
    50 
       
    51 // FORWARD DECLARATIONS
       
    52 //class ?FORWARD_CLASSNAME;
       
    53 
       
    54 // ============================= LOCAL FUNCTIONS ===============================
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // ?function_name ?description.
       
    58 // ?description
       
    59 // Returns: ?value_1: ?description
       
    60 //          ?value_n: ?description_line1
       
    61 //                    ?description_line2
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 /*
       
    65 ?type ?function_name(
       
    66     ?arg_type arg,  // ?description
       
    67     ?arg_type arg)  // ?description
       
    68     {
       
    69 
       
    70     ?code  // ?comment
       
    71 
       
    72     // ?comment
       
    73     ?code
       
    74     }
       
    75 */
       
    76 
       
    77 // ============================ MEMBER FUNCTIONS ===============================
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CGenericHidTest::CGenericHidTest
       
    81 // C++ default constructor can NOT contain any code, that
       
    82 // might leave.
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CGenericHidTest::CGenericHidTest( 
       
    86     CTestModuleIf& aTestModuleIf ):
       
    87         CScriptBase( aTestModuleIf )
       
    88     {
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CGenericHidTest::ConstructL
       
    93 // Symbian 2nd phase constructor can leave.
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CGenericHidTest::ConstructL()
       
    97     {
       
    98     //iTestLogger = CHidTestLogger::NewL( &TestModuleIf() ); 
       
    99     
       
   100     //Read logger settings to check whether test case name is to be
       
   101     //appended to log file name.
       
   102     RSettingServer settingServer;
       
   103     TInt ret = settingServer.Connect();
       
   104     if(ret != KErrNone)
       
   105         {
       
   106         User::Leave(ret);
       
   107         }
       
   108     // Struct to StifLogger settigs.
       
   109     TLoggerSettings loggerSettings; 
       
   110     // Parse StifLogger defaults from STIF initialization file.
       
   111     ret = settingServer.GetLoggerSettings(loggerSettings);
       
   112     if(ret != KErrNone)
       
   113         {
       
   114         User::Leave(ret);
       
   115         } 
       
   116     // Close Setting server session
       
   117     settingServer.Close();
       
   118 
       
   119     TFileName logFileName;
       
   120     
       
   121     if(loggerSettings.iAddTestCaseTitle)
       
   122         {
       
   123         TName title;
       
   124         TestModuleIf().GetTestCaseTitleL(title);
       
   125         logFileName.Format(KGenericHidTestLogFileWithTitle, &title);
       
   126         }
       
   127     else
       
   128         {
       
   129         logFileName.Copy(KGenericHidTestLogFile);
       
   130         }
       
   131 
       
   132     iLog = CStifLogger::NewL( KGenericHidTestLogPath, 
       
   133                           logFileName,
       
   134                           CStifLogger::ETxt,
       
   135                           CStifLogger::EFile,
       
   136                           EFalse ); 
       
   137     
       
   138     SendTestClassVersion();
       
   139     
       
   140     iParser = CParser::NewL();
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CGenericHidTest::NewL
       
   145 // Two-phased constructor.
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 CGenericHidTest* CGenericHidTest::NewL( 
       
   149     CTestModuleIf& aTestModuleIf )
       
   150     {
       
   151     CGenericHidTest* self = new (ELeave) CGenericHidTest( aTestModuleIf );
       
   152 
       
   153     CleanupStack::PushL( self );
       
   154     self->ConstructL();
       
   155     CleanupStack::Pop();
       
   156 
       
   157     return self;
       
   158 
       
   159     }
       
   160 
       
   161 // Destructor
       
   162 CGenericHidTest::~CGenericHidTest()
       
   163     { 
       
   164 
       
   165     // Delete resources allocated from test methods
       
   166     Delete();
       
   167 
       
   168     // Delete logger
       
   169     delete iLog;
       
   170     
       
   171     delete iParser;
       
   172 
       
   173     }
       
   174 
       
   175 //-----------------------------------------------------------------------------
       
   176 // CGenericHidTest::SendTestClassVersion
       
   177 // Method used to send version of test class
       
   178 //-----------------------------------------------------------------------------
       
   179 //
       
   180 void CGenericHidTest::SendTestClassVersion()
       
   181 	{
       
   182 	TVersion moduleVersion;
       
   183 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   184 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   185 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   186 	
       
   187 	TFileName moduleName;
       
   188 	moduleName = _L("GenericHidTest.dll");
       
   189 
       
   190 	TBool newVersionOfMethod = ETrue;
       
   191 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   192 	}
       
   193 
       
   194 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // LibEntryL is a polymorphic Dll entry point.
       
   198 // Returns: CScriptBase: New CScriptBase derived object
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 EXPORT_C CScriptBase* LibEntryL( 
       
   202     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   203     {
       
   204 
       
   205     return ( CScriptBase* ) CGenericHidTest::NewL( aTestModuleIf );
       
   206 
       
   207     }
       
   208 
       
   209 
       
   210 //  End of File