os/ossrv/stdcpp/tsrc/BC/apps/BCCppWrap/src/BCCppWrap.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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:       
    15 *
    16 */
    17 
    18 
    19 // INCLUDE FILES
    20 #include <Stiftestinterface.h>
    21 #include "BCCppWrap.h"
    22 #include <SettingServerClient.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 // CBCCppWrap::CBCCppWrap
    77 // C++ default constructor can NOT contain any code, that
    78 // might leave.
    79 // -----------------------------------------------------------------------------
    80 //
    81 CBCCppWrap::CBCCppWrap( 
    82     CTestModuleIf& aTestModuleIf ):
    83         CScriptBase( aTestModuleIf )
    84     {
    85     }
    86 
    87 // -----------------------------------------------------------------------------
    88 // CBCCppWrap::ConstructL
    89 // Symbian 2nd phase constructor can leave.
    90 // -----------------------------------------------------------------------------
    91 //
    92 void CBCCppWrap::ConstructL()
    93     {
    94     //Read logger settings to check whether test case name is to be
    95     //appended to log file name.
    96     RSettingServer settingServer;
    97     TInt ret = settingServer.Connect();
    98     if(ret != KErrNone)
    99         {
   100         User::Leave(ret);
   101         }
   102     // Struct to StifLogger settigs.
   103     TLoggerSettings loggerSettings; 
   104     // Parse StifLogger defaults from STIF initialization file.
   105     ret = settingServer.GetLoggerSettings(loggerSettings);
   106     if(ret != KErrNone)
   107         {
   108         User::Leave(ret);
   109         } 
   110     // Close Setting server session
   111     settingServer.Close();
   112 
   113     TFileName logFileName;
   114     
   115     if(loggerSettings.iAddTestCaseTitle)
   116         {
   117         TName title;
   118         TestModuleIf().GetTestCaseTitleL(title);
   119         logFileName.Format(KBCCppWrapLogFileWithTitle, &title);
   120         }
   121     else
   122         {
   123         logFileName.Copy(KBCCppWrapLogFile);
   124         }
   125 
   126     iLog = CStifLogger::NewL( KBCCppWrapLogPath, 
   127                           logFileName,
   128                           CStifLogger::ETxt,
   129                           CStifLogger::EFile,
   130                           EFalse );
   131     
   132     SendTestClassVersion();
   133     }
   134 
   135 // -----------------------------------------------------------------------------
   136 // CBCCppWrap::NewL
   137 // Two-phased constructor.
   138 // -----------------------------------------------------------------------------
   139 //
   140 CBCCppWrap* CBCCppWrap::NewL( 
   141     CTestModuleIf& aTestModuleIf )
   142     {
   143     CBCCppWrap* self = new (ELeave) CBCCppWrap( aTestModuleIf );
   144 
   145     CleanupStack::PushL( self );
   146     self->ConstructL();
   147     CleanupStack::Pop();
   148 
   149     return self;
   150 
   151     }
   152 
   153 // Destructor
   154 CBCCppWrap::~CBCCppWrap()
   155     { 
   156 
   157     // Delete resources allocated from test methods
   158     Delete();
   159 
   160     // Delete logger
   161     delete iLog; 
   162 
   163     }
   164 
   165 //-----------------------------------------------------------------------------
   166 // CBCCppWrap::SendTestClassVersion
   167 // Method used to send version of test class
   168 //-----------------------------------------------------------------------------
   169 //
   170 void CBCCppWrap::SendTestClassVersion()
   171 	{
   172 	TVersion moduleVersion;
   173 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
   174 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
   175 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
   176 	
   177 	TFileName moduleName;
   178 	moduleName = _L("BCCppWrap.dll");
   179 
   180 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName);
   181 	}
   182 
   183 // ========================== OTHER EXPORTED FUNCTIONS =========================
   184 
   185 // -----------------------------------------------------------------------------
   186 // LibEntryL is a polymorphic Dll entry point.
   187 // Returns: CScriptBase: New CScriptBase derived object
   188 // -----------------------------------------------------------------------------
   189 //
   190 EXPORT_C CScriptBase* LibEntryL( 
   191     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
   192     {
   193 
   194     return ( CScriptBase* ) CBCCppWrap::NewL( aTestModuleIf );
   195 
   196     }
   197 
   198 
   199 //  End of File