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