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