os/ossrv/stdcpp/tsrc/BC/apps/tutility/src/tutility.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/stdcpp/tsrc/BC/apps/tutility/src/tutility.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,201 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:       
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +// INCLUDE FILES
    1.24 +#include <Stiftestinterface.h>
    1.25 +#include "tutility.h"
    1.26 +//#include <SettingServerClient.h>
    1.27 +
    1.28 +// EXTERNAL DATA STRUCTURES
    1.29 +//extern  ?external_data;
    1.30 +
    1.31 +// EXTERNAL FUNCTION PROTOTYPES  
    1.32 +//extern ?external_function( ?arg_type,?arg_type );
    1.33 +
    1.34 +// CONSTANTS
    1.35 +//const ?type ?constant_var = ?constant;
    1.36 +
    1.37 +// MACROS
    1.38 +//#define ?macro ?macro_def
    1.39 +
    1.40 +// LOCAL CONSTANTS AND MACROS
    1.41 +//const ?type ?constant_var = ?constant;
    1.42 +//#define ?macro_name ?macro_def
    1.43 +
    1.44 +// MODULE DATA STRUCTURES
    1.45 +//enum ?declaration
    1.46 +//typedef ?declaration
    1.47 +
    1.48 +// LOCAL FUNCTION PROTOTYPES
    1.49 +//?type ?function_name( ?arg_type, ?arg_type );
    1.50 +
    1.51 +// FORWARD DECLARATIONS
    1.52 +//class ?FORWARD_CLASSNAME;
    1.53 +
    1.54 +// ============================= LOCAL FUNCTIONS ===============================
    1.55 +
    1.56 +// -----------------------------------------------------------------------------
    1.57 +// ?function_name ?description.
    1.58 +// ?description
    1.59 +// Returns: ?value_1: ?description
    1.60 +//          ?value_n: ?description_line1
    1.61 +//                    ?description_line2
    1.62 +// -----------------------------------------------------------------------------
    1.63 +//
    1.64 +/*
    1.65 +?type ?function_name(
    1.66 +    ?arg_type arg,  // ?description
    1.67 +    ?arg_type arg)  // ?description
    1.68 +    {
    1.69 +
    1.70 +    ?code  // ?comment
    1.71 +
    1.72 +    // ?comment
    1.73 +    ?code
    1.74 +    }
    1.75 +*/
    1.76 +
    1.77 +// ============================ MEMBER FUNCTIONS ===============================
    1.78 +
    1.79 +// -----------------------------------------------------------------------------
    1.80 +// Ctutility::Ctutility
    1.81 +// C++ default constructor can NOT contain any code, that
    1.82 +// might leave.
    1.83 +// -----------------------------------------------------------------------------
    1.84 +//
    1.85 +Ctutility::Ctutility( 
    1.86 +    CTestModuleIf& aTestModuleIf ):
    1.87 +        CScriptBase( aTestModuleIf )
    1.88 +    {
    1.89 +    }
    1.90 +
    1.91 +// -----------------------------------------------------------------------------
    1.92 +// Ctutility::ConstructL
    1.93 +// Symbian 2nd phase constructor can leave.
    1.94 +// -----------------------------------------------------------------------------
    1.95 +//
    1.96 +void Ctutility::ConstructL()
    1.97 +    {
    1.98 +    //Read logger settings to check whether test case name is to be
    1.99 +    //appended to log file name.
   1.100 + /*   RSettingServer settingServer;
   1.101 +    TInt ret = settingServer.Connect();
   1.102 +    if(ret != KErrNone)
   1.103 +        {
   1.104 +        User::Leave(ret);
   1.105 +        }
   1.106 +    // Struct to StifLogger settigs.
   1.107 +    TLoggerSettings loggerSettings; 
   1.108 +    // Parse StifLogger defaults from STIF initialization file.
   1.109 +    ret = settingServer.GetLoggerSettings(loggerSettings);
   1.110 +    if(ret != KErrNone)
   1.111 +        {
   1.112 +        User::Leave(ret);
   1.113 +        } 
   1.114 +    // Close Setting server session
   1.115 +    settingServer.Close();
   1.116 +
   1.117 +    TFileName logFileName;
   1.118 +    
   1.119 +    if(loggerSettings.iAddTestCaseTitle)
   1.120 +        {
   1.121 +        TName title;
   1.122 +        TestModuleIf().GetTestCaseTitleL(title);
   1.123 +        logFileName.Format(KtutilityLogFileWithTitle, &title);
   1.124 +        }
   1.125 +    else
   1.126 +        {
   1.127 +        logFileName.Copy(KtutilityLogFile);
   1.128 +        }
   1.129 +*/
   1.130 +    iLog = CStifLogger::NewL( KtutilityLogPath, 
   1.131 +                          KtutilityLogFile,
   1.132 +                          CStifLogger::ETxt,
   1.133 +                          CStifLogger::EFile,
   1.134 +                          EFalse );
   1.135 +		SendTestModuleVersion();
   1.136 +    }
   1.137 +
   1.138 +// -----------------------------------------------------------------------------
   1.139 +// Ctutility::NewL
   1.140 +// Two-phased constructor.
   1.141 +// -----------------------------------------------------------------------------
   1.142 +//
   1.143 +Ctutility* Ctutility::NewL( 
   1.144 +    CTestModuleIf& aTestModuleIf )
   1.145 +    {
   1.146 +    Ctutility* self = new (ELeave) Ctutility( aTestModuleIf );
   1.147 +
   1.148 +    CleanupStack::PushL( self );
   1.149 +    self->ConstructL();
   1.150 +    CleanupStack::Pop();
   1.151 +
   1.152 +    return self;
   1.153 +
   1.154 +    }
   1.155 +
   1.156 +// Destructor
   1.157 +Ctutility::~Ctutility()
   1.158 +    { 
   1.159 +
   1.160 +    // Delete resources allocated from test methods
   1.161 +    Delete();
   1.162 +
   1.163 +    // Delete logger
   1.164 +    delete iLog; 
   1.165 +
   1.166 +    }
   1.167 +
   1.168 +// ========================== OTHER EXPORTED FUNCTIONS =========================
   1.169 +
   1.170 +// -----------------------------------------------------------------------------
   1.171 +// LibEntryL is a polymorphic Dll entry point.
   1.172 +// Returns: CScriptBase: New CScriptBase derived object
   1.173 +// -----------------------------------------------------------------------------
   1.174 +//
   1.175 +EXPORT_C CScriptBase* LibEntryL( 
   1.176 +    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
   1.177 +    {
   1.178 +
   1.179 +    return ( CScriptBase* ) Ctutility::NewL( aTestModuleIf );
   1.180 +
   1.181 +    }
   1.182 +
   1.183 +//-----------------------------------------------------------------------------
   1.184 +// Ctutility::SendTestClassVersion
   1.185 +// Method used to send version of test class
   1.186 +//-----------------------------------------------------------------------------
   1.187 +//
   1.188 +void Ctutility::SendTestModuleVersion()
   1.189 +	{
   1.190 +	TVersion moduleVersion;
   1.191 +	moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR;
   1.192 +	moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR;
   1.193 +	moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD;
   1.194 +	
   1.195 +	TFileName moduleName;
   1.196 +	moduleName = _L("Ctutility.dll");
   1.197 +	
   1.198 +
   1.199 +	TBool newVersionOfMethod = ETrue;
   1.200 +	CTestModuleIf &test=TestModuleIf();
   1.201 +	test.SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
   1.202 +	test.SetBehavior(CTestModuleIf::ETestLeaksHandles);
   1.203 +	}
   1.204 +//  End of File