radioengine/settings/tsrc/src/SettingsTestModule.cpp
changeset 51 bbebb0235466
parent 34 bc10a61bd7d3
equal deleted inserted replaced
47:74b7c6e79031 51:bbebb0235466
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 * 
    13  * 
    14 * Description: This file contains testclass implementation.
    14  * Description: This file contains testclass implementation.
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 // INCLUDE FILES
    18 // System includes
    19 #include <Stiftestinterface.h>
    19 #include <Stiftestinterface.h>
    20 #include <SettingServerClient.h>
    20 #include <SettingServerClient.h>
       
    21 
       
    22 // User includes
    21 #include "SettingsTestModule.h"
    23 #include "SettingsTestModule.h"
    22 #include "trace.h"
    24 #include "trace.h"
    23 
    25 
    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 // -----------------------------------------------------------------------------
    26 // -----------------------------------------------------------------------------
    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 ===============================
    27 // ============================ MEMBER FUNCTIONS ===============================
    74 
    28 
    75 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    76 // CSettingTestModule::CPresetUtilityTestModule
    30 // CSettingTestModule::CPresetUtilityTestModule
    77 // C++ default constructor can NOT contain any code, that
    31 // C++ default constructor can NOT contain any code, that
    78 // might leave.
    32 // might leave.
    79 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    80 //
    34 //
    81 CSettingsTestModule::CSettingsTestModule( 
    35 CSettingsTestModule::CSettingsTestModule(CTestModuleIf& aTestModuleIf) :
    82     CTestModuleIf& aTestModuleIf ):
    36     CScriptBase(aTestModuleIf)
    83         CScriptBase( aTestModuleIf )
       
    84     {
    37     {
    85     FUNC_LOG;
    38     FUNC_LOG;
    86     }
    39     }
    87 
    40 
    88 // -----------------------------------------------------------------------------
       
    89 // CSettingsTestModule::ConstructL
    41 // CSettingsTestModule::ConstructL
    90 // Symbian 2nd phase constructor can leave.
    42 // Symbian 2nd phase constructor can leave.
    91 // -----------------------------------------------------------------------------
    43 // -----------------------------------------------------------------------------
    92 //
    44 //
    93 void CSettingsTestModule::ConstructL()
    45 void CSettingsTestModule::ConstructL()
    94     {
    46     {
    95     FUNC_LOG;
    47     FUNC_LOG;
    96     
    48 
    97     //Read logger settings to check whether test case name is to be
    49     //Read logger settings to check whether test case name is to be
    98     //appended to log file name.
    50     //appended to log file name.
    99     RSettingServer settingServer;
    51     RSettingServer settingServer;
   100     TInt ret = settingServer.Connect();
    52     TInt ret = settingServer.Connect();
   101     if(ret != KErrNone)
    53     if (ret != KErrNone)
   102         {
    54         {
   103         User::Leave(ret);
    55         User::Leave(ret);
   104         }
    56         }
   105     // Struct to StifLogger settigs.
    57     // Struct to StifLogger settigs.
   106     TLoggerSettings loggerSettings; 
    58     TLoggerSettings loggerSettings;
   107     // Parse StifLogger defaults from STIF initialization file.
    59     // Parse StifLogger defaults from STIF initialization file.
   108     ret = settingServer.GetLoggerSettings(loggerSettings);
    60     ret = settingServer.GetLoggerSettings(loggerSettings);
   109     if(ret != KErrNone)
    61     if (ret != KErrNone)
   110         {
    62         {
   111         User::Leave(ret);
    63         User::Leave(ret);
   112         } 
    64         }
   113     // Close Setting server session
    65     // Close Setting server session
   114     settingServer.Close();
    66     settingServer.Close();
   115 
    67 
   116     TFileName logFileName;
    68     TFileName logFileName;
   117     
    69 
   118     if(loggerSettings.iAddTestCaseTitle)
    70     if (loggerSettings.iAddTestCaseTitle)
   119         {
    71         {
   120         TName title;
    72         TName title;
   121         TestModuleIf().GetTestCaseTitleL(title);
    73         TestModuleIf().GetTestCaseTitleL(title);
   122         logFileName.Format(KSettingsTestModuleLogFileWithTitle, &title);
    74         logFileName.Format(KSettingsTestModuleLogFileWithTitle, &title);
   123         }
    75         }
   124     else
    76     else
   125         {
    77         {
   126         logFileName.Copy(KSettingsTestModuleLogFile);
    78         logFileName.Copy(KSettingsTestModuleLogFile);
   127         }
    79         }
   128 
    80 
   129     iLog = CStifLogger::NewL( KSettingsTestModuleLogPath, 
    81     iLog = CStifLogger::NewL(KSettingsTestModuleLogPath, logFileName,
   130                           logFileName,
    82             CStifLogger::ETxt, CStifLogger::EFile, EFalse);
   131                           CStifLogger::ETxt,
    83 
   132                           CStifLogger::EFile,
       
   133                           EFalse );
       
   134     
       
   135     SendTestClassVersion();
    84     SendTestClassVersion();
   136     }
    85     }
   137 
    86 
   138 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
   139 // CSettingsTestModule::NewL
    88 // CSettingsTestModule::NewL
   140 // Two-phased constructor.
    89 // Two-phased constructor.
   141 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
   142 //
    91 //
   143 CSettingsTestModule* CSettingsTestModule::NewL( 
    92 CSettingsTestModule* CSettingsTestModule::NewL(CTestModuleIf& aTestModuleIf)
   144     CTestModuleIf& aTestModuleIf )
       
   145     {
    93     {
   146     FUNC_LOG;
    94     FUNC_LOG;
   147     CSettingsTestModule* self = new (ELeave) CSettingsTestModule( aTestModuleIf );
    95     CSettingsTestModule* self = new (ELeave) CSettingsTestModule(
       
    96             aTestModuleIf);
   148 
    97 
   149     CleanupStack::PushL( self );
    98     CleanupStack::PushL(self);
   150     self->ConstructL();
    99     self->ConstructL();
   151     CleanupStack::Pop();
   100     CleanupStack::Pop();
   152 
   101 
   153     return self;
   102     return self;
   154 
   103 
   155     }
   104     }
   156 
   105 
   157 // Destructor
   106 // Destructor
   158 CSettingsTestModule::~CSettingsTestModule()
   107 CSettingsTestModule::~CSettingsTestModule()
   159     { 
   108     {
   160     FUNC_LOG;
   109     FUNC_LOG;
   161 
   110 
   162     // Delete resources allocated from test methods
   111     // Delete resources allocated from test methods
   163     Delete();
   112     Delete();
   164 
   113 
   165     // Delete logger
   114     // Delete logger
   166     delete iLog; 
   115     delete iLog;
   167 
   116 
   168     }
   117     }
   169 
   118 
   170 //-----------------------------------------------------------------------------
   119 //-----------------------------------------------------------------------------
   171 // CSettingsTestModule::SendTestClassVersion
   120 // CSettingsTestModule::SendTestClassVersion
   172 // Method used to send version of test class
   121 // Method used to send version of test class
   173 //-----------------------------------------------------------------------------
   122 //-----------------------------------------------------------------------------
   174 //
   123 //
   175 void CSettingsTestModule::SendTestClassVersion()
   124 void CSettingsTestModule::SendTestClassVersion()
   176 	{
   125     {
   177 	FUNC_LOG;
   126     FUNC_LOG;
   178 	TVersion moduleVersion;
   127     TVersion moduleVersion;
   179 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
   128     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
   180 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
   129     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
   181 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
   130     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
   182 	
       
   183 	TFileName moduleName;
       
   184 	moduleName = _L("SettingsTestModule.dll");
       
   185 
   131 
   186 	TBool newVersionOfMethod = ETrue;
   132     TFileName moduleName;
   187 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
   133     moduleName = _L("SettingsTestModule.dll");
   188 	}
   134 
       
   135     TBool newVersionOfMethod = ETrue;
       
   136     TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName,
       
   137             newVersionOfMethod);
       
   138     }
   189 
   139 
   190 // ========================== OTHER EXPORTED FUNCTIONS =========================
   140 // ========================== OTHER EXPORTED FUNCTIONS =========================
   191 
   141 
   192 // -----------------------------------------------------------------------------
   142 // -----------------------------------------------------------------------------
   193 // LibEntryL is a polymorphic Dll entry point.
   143 // LibEntryL is a polymorphic Dll entry point.
   194 // Returns: CScriptBase: New CScriptBase derived object
   144 // Returns: CScriptBase: New CScriptBase derived object
   195 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   196 //
   146 //
   197 EXPORT_C CScriptBase* LibEntryL( 
   147 EXPORT_C CScriptBase* LibEntryL(CTestModuleIf& aTestModuleIf) // Backpointer to STIF Test Framework
   198     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   199     {
   148     {
   200     FUNC_LOG;
   149     FUNC_LOG;
   201 
   150 
   202     return ( CScriptBase* ) CSettingsTestModule::NewL( aTestModuleIf );
   151     return (CScriptBase*) CSettingsTestModule::NewL(aTestModuleIf);
   203 
   152 
   204     }
   153     }
   205 
   154 
   206 
       
   207 //  End of File
   155 //  End of File