os/ossrv/stdcpp/tsrc/BC/apps/BCException/src/BCException.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/BCException/src/BCException.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,199 @@
     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 +// INCLUDE FILES
    1.23 +#include <Stiftestinterface.h>
    1.24 +#include "BCException.h"
    1.25 +#include <SettingServerClient.h>
    1.26 +
    1.27 +// EXTERNAL DATA STRUCTURES
    1.28 +//extern  ?external_data;
    1.29 +
    1.30 +// EXTERNAL FUNCTION PROTOTYPES  
    1.31 +//extern ?external_function( ?arg_type,?arg_type );
    1.32 +
    1.33 +// CONSTANTS
    1.34 +//const ?type ?constant_var = ?constant;
    1.35 +
    1.36 +// MACROS
    1.37 +//#define ?macro ?macro_def
    1.38 +
    1.39 +// LOCAL CONSTANTS AND MACROS
    1.40 +//const ?type ?constant_var = ?constant;
    1.41 +//#define ?macro_name ?macro_def
    1.42 +
    1.43 +// MODULE DATA STRUCTURES
    1.44 +//enum ?declaration
    1.45 +//typedef ?declaration
    1.46 +
    1.47 +// LOCAL FUNCTION PROTOTYPES
    1.48 +//?type ?function_name( ?arg_type, ?arg_type );
    1.49 +
    1.50 +// FORWARD DECLARATIONS
    1.51 +//class ?FORWARD_CLASSNAME;
    1.52 +
    1.53 +// ============================= LOCAL FUNCTIONS ===============================
    1.54 +
    1.55 +// -----------------------------------------------------------------------------
    1.56 +// ?function_name ?description.
    1.57 +// ?description
    1.58 +// Returns: ?value_1: ?description
    1.59 +//          ?value_n: ?description_line1
    1.60 +//                    ?description_line2
    1.61 +// -----------------------------------------------------------------------------
    1.62 +//
    1.63 +/*
    1.64 +?type ?function_name(
    1.65 +    ?arg_type arg,  // ?description
    1.66 +    ?arg_type arg)  // ?description
    1.67 +    {
    1.68 +
    1.69 +    ?code  // ?comment
    1.70 +
    1.71 +    // ?comment
    1.72 +    ?code
    1.73 +    }
    1.74 +*/
    1.75 +
    1.76 +// ============================ MEMBER FUNCTIONS ===============================
    1.77 +
    1.78 +// -----------------------------------------------------------------------------
    1.79 +// CBCException::CBCException
    1.80 +// C++ default constructor can NOT contain any code, that
    1.81 +// might leave.
    1.82 +// -----------------------------------------------------------------------------
    1.83 +//
    1.84 +CBCException::CBCException( 
    1.85 +    CTestModuleIf& aTestModuleIf ):
    1.86 +        CScriptBase( aTestModuleIf )
    1.87 +    {
    1.88 +    }
    1.89 +
    1.90 +// -----------------------------------------------------------------------------
    1.91 +// CBCException::ConstructL
    1.92 +// Symbian 2nd phase constructor can leave.
    1.93 +// -----------------------------------------------------------------------------
    1.94 +//
    1.95 +void CBCException::ConstructL()
    1.96 +    {
    1.97 +    //Read logger settings to check whether test case name is to be
    1.98 +    //appended to log file name.
    1.99 +    RSettingServer settingServer;
   1.100 +    TInt ret = settingServer.Connect();
   1.101 +    if(ret != KErrNone)
   1.102 +        {
   1.103 +        User::Leave(ret);
   1.104 +        }
   1.105 +    // Struct to StifLogger settigs.
   1.106 +    TLoggerSettings loggerSettings; 
   1.107 +    // Parse StifLogger defaults from STIF initialization file.
   1.108 +    ret = settingServer.GetLoggerSettings(loggerSettings);
   1.109 +    if(ret != KErrNone)
   1.110 +        {
   1.111 +        User::Leave(ret);
   1.112 +        } 
   1.113 +    // Close Setting server session
   1.114 +    settingServer.Close();
   1.115 +
   1.116 +    TFileName logFileName;
   1.117 +    
   1.118 +    if(loggerSettings.iAddTestCaseTitle)
   1.119 +        {
   1.120 +        TName title;
   1.121 +        TestModuleIf().GetTestCaseTitleL(title);
   1.122 +        logFileName.Format(KBCExceptionLogFileWithTitle, &title);
   1.123 +        }
   1.124 +    else
   1.125 +        {
   1.126 +        logFileName.Copy(KBCExceptionLogFile);
   1.127 +        }
   1.128 +
   1.129 +    iLog = CStifLogger::NewL( KBCExceptionLogPath, 
   1.130 +                          logFileName,
   1.131 +                          CStifLogger::ETxt,
   1.132 +                          CStifLogger::EFile,
   1.133 +                          EFalse );
   1.134 +    
   1.135 +    SendTestClassVersion();
   1.136 +    }
   1.137 +
   1.138 +// -----------------------------------------------------------------------------
   1.139 +// CBCException::NewL
   1.140 +// Two-phased constructor.
   1.141 +// -----------------------------------------------------------------------------
   1.142 +//
   1.143 +CBCException* CBCException::NewL( 
   1.144 +    CTestModuleIf& aTestModuleIf )
   1.145 +    {
   1.146 +    CBCException* self = new (ELeave) CBCException( 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 +CBCException::~CBCException()
   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 +//-----------------------------------------------------------------------------
   1.169 +// CBCException::SendTestClassVersion
   1.170 +// Method used to send version of test class
   1.171 +//-----------------------------------------------------------------------------
   1.172 +//
   1.173 +void CBCException::SendTestClassVersion()
   1.174 +	{
   1.175 +	TVersion moduleVersion;
   1.176 +	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
   1.177 +	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
   1.178 +	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
   1.179 +	
   1.180 +	TFileName moduleName;
   1.181 +	moduleName = _L("BCException.dll");
   1.182 +
   1.183 +	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName);
   1.184 +	}
   1.185 +
   1.186 +// ========================== OTHER EXPORTED FUNCTIONS =========================
   1.187 +
   1.188 +// -----------------------------------------------------------------------------
   1.189 +// LibEntryL is a polymorphic Dll entry point.
   1.190 +// Returns: CScriptBase: New CScriptBase derived object
   1.191 +// -----------------------------------------------------------------------------
   1.192 +//
   1.193 +EXPORT_C CScriptBase* LibEntryL( 
   1.194 +    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
   1.195 +    {
   1.196 +
   1.197 +    return ( CScriptBase* ) CBCException::NewL( aTestModuleIf );
   1.198 +
   1.199 +    }
   1.200 +
   1.201 +
   1.202 +//  End of File