gsprofilesrv_pub/profiles_engine_wrapper_api/tsrc/BC/ProfilesEngineWrapperAPI/src/ProEngWrapAPI.cpp
changeset 0 8c5d936e5675
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     1 /*
       
     2 * Copyright (c) 2002-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:        ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 // INCLUDE FILES
       
    27 #include <Stiftestinterface.h>
       
    28 #include "ProEngWrapAPI.h"
       
    29 #include <SettingServerClient.h>
       
    30 
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CProEngWrapAPI::CProEngWrapAPI
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CProEngWrapAPI::CProEngWrapAPI( 
       
    41     CTestModuleIf& aTestModuleIf ):
       
    42         CScriptBase( aTestModuleIf )
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CProEngWrapAPI::ConstructL
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CProEngWrapAPI::ConstructL()
       
    52     {
       
    53     //Read logger settings to check whether test case name is to be
       
    54     //appended to log file name.
       
    55     RSettingServer settingServer;
       
    56     iSchedulerUtility = CSchedulerUtility::NewL(); 
       
    57     User::LeaveIfError( iFs.Connect() );
       
    58     TInt ret = settingServer.Connect();
       
    59     if(ret != KErrNone)
       
    60         {
       
    61         User::Leave(ret);
       
    62         }
       
    63     // Struct to StifLogger settigs.
       
    64     TLoggerSettings loggerSettings; 
       
    65     // Parse StifLogger defaults from STIF initialization file.
       
    66     ret = settingServer.GetLoggerSettings(loggerSettings);
       
    67     if(ret != KErrNone)
       
    68         {
       
    69         User::Leave(ret);
       
    70         } 
       
    71     // Close Setting server session
       
    72     settingServer.Close();
       
    73 
       
    74     TFileName logFileName;
       
    75     
       
    76     if(loggerSettings.iAddTestCaseTitle)
       
    77         {
       
    78         TName title;
       
    79         TestModuleIf().GetTestCaseTitleL(title);
       
    80         logFileName.Format(KProEngWrapAPILogFileWithTitle, &title);
       
    81         }
       
    82     else
       
    83         {
       
    84         logFileName.Copy(KProEngWrapAPILogFile);
       
    85         }
       
    86 
       
    87     iLog = CStifLogger::NewL( KProEngWrapAPILogPath, 
       
    88                           logFileName,
       
    89                           CStifLogger::ETxt,
       
    90                           CStifLogger::EFile,
       
    91                           EFalse );
       
    92     
       
    93     
       
    94     SendTestClassVersion();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CProEngWrapAPI::NewL
       
    99 // Two-phased constructor.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 CProEngWrapAPI* CProEngWrapAPI::NewL( 
       
   103     CTestModuleIf& aTestModuleIf )
       
   104     {
       
   105     CProEngWrapAPI* self = new (ELeave) CProEngWrapAPI( aTestModuleIf );
       
   106 
       
   107     CleanupStack::PushL( self );
       
   108     self->ConstructL();
       
   109     CleanupStack::Pop();
       
   110    
       
   111  //   CTestModuleIf &testMod = TestModuleIf();
       
   112  //   testMod.SetBehaviour(ETestLeaksMem);
       
   113 
       
   114     return self;
       
   115 
       
   116     }
       
   117 
       
   118 // Destructor
       
   119 CProEngWrapAPI::~CProEngWrapAPI()
       
   120     { 
       
   121 
       
   122     // Delete resources allocated from test methods
       
   123     Delete();
       
   124    //CSchedulerUtility::Release(); 
       
   125     if(iSchedulerUtility)
       
   126         {
       
   127         delete iSchedulerUtility;
       
   128         iSchedulerUtility = NULL;
       
   129         }
       
   130 
       
   131    iFs.Close() ;  
       
   132        
       
   133     // Delete logger
       
   134     delete iLog; 
       
   135 
       
   136     }
       
   137 
       
   138 //-----------------------------------------------------------------------------
       
   139 // CProEngWrapAPI::SendTestClassVersion
       
   140 // Method used to send version of test class
       
   141 //-----------------------------------------------------------------------------
       
   142 //
       
   143 void CProEngWrapAPI::SendTestClassVersion()
       
   144 	{
       
   145 	TVersion moduleVersion;
       
   146 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   147 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   148 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   149 	
       
   150 	TFileName moduleName;
       
   151 	moduleName = _L("ProEngWrapAPI.dll");
       
   152 
       
   153 	TBool newVersionOfMethod = ETrue;
       
   154 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   155 	
       
   156     TestModuleIf().SetBehavior(CTestModuleIf::ETestLeaksHandles);
       
   157 	}
       
   158 
       
   159 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // LibEntryL is a polymorphic Dll entry point.
       
   163 // Returns: CScriptBase: New CScriptBase derived object
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C CScriptBase* LibEntryL( 
       
   167     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   168     {
       
   169 
       
   170     return ( CScriptBase* ) CProEngWrapAPI::NewL( aTestModuleIf );
       
   171 
       
   172     }
       
   173 
       
   174 
       
   175 //  End of File