loc_plat/location_centre_api/tsrc/src/testlc.cpp
branchRCL_3
changeset 16 4721bd00d3da
parent 14 3a25f69541ff
child 21 e15b7f06eba6
equal deleted inserted replaced
14:3a25f69541ff 16:4721bd00d3da
     1 /*
       
     2 * Copyright (c) 2007 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:  Test Class which has the list of test cases
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <Stiftestinterface.h>
       
    22 #include "testlc.h"
       
    23 #include <SettingServerClient.h>
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CTestLc::CTestLc
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CTestLc::CTestLc( 
       
    34     CTestModuleIf& aTestModuleIf ):
       
    35         CScriptBase( aTestModuleIf )
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CTestLc::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CTestLc::ConstructL()
       
    45     {
       
    46     //Read logger settings to check whether test case name is to be
       
    47     //appended to log file name.
       
    48     RSettingServer settingServer;
       
    49     TInt ret = settingServer.Connect();
       
    50     if(ret != KErrNone)
       
    51         {
       
    52         User::Leave(ret);
       
    53         }
       
    54     // Struct to StifLogger settigs.
       
    55     TLoggerSettings loggerSettings; 
       
    56     // Parse StifLogger defaults from STIF initialization file.
       
    57     ret = settingServer.GetLoggerSettings(loggerSettings);
       
    58     if(ret != KErrNone)
       
    59         {
       
    60         User::Leave(ret);
       
    61         } 
       
    62     // Close Setting server session
       
    63     settingServer.Close();
       
    64 
       
    65     TFileName logFileName;
       
    66     
       
    67     if(loggerSettings.iAddTestCaseTitle)
       
    68         {
       
    69         TName title;
       
    70         TestModuleIf().GetTestCaseTitleL(title);
       
    71         logFileName.Format(KtestlcLogFileWithTitle, &title);
       
    72         }
       
    73     else
       
    74         {
       
    75         logFileName.Copy(KtestlcLogFile);
       
    76         }
       
    77 
       
    78     iLog = CStifLogger::NewL( KtestlcLogPath, 
       
    79                           logFileName,
       
    80                           CStifLogger::ETxt,
       
    81                           CStifLogger::EFile,
       
    82                           EFalse );
       
    83 
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CTestLc::NewL
       
    88 // Two-phased constructor.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CTestLc* CTestLc::NewL( 
       
    92     CTestModuleIf& aTestModuleIf )
       
    93     {
       
    94     CTestLc* self = new (ELeave) CTestLc( aTestModuleIf );
       
    95 
       
    96     CleanupStack::PushL( self );
       
    97     self->ConstructL();
       
    98     CleanupStack::Pop();
       
    99 
       
   100     return self;
       
   101 
       
   102     }
       
   103 
       
   104 // Destructor
       
   105 CTestLc::~CTestLc()
       
   106     { 
       
   107 
       
   108     // Delete resources allocated from test methods
       
   109     Delete();
       
   110 
       
   111     // Delete logger
       
   112     delete iLog; 
       
   113 
       
   114     }
       
   115 
       
   116 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // LibEntryL is a polymorphic Dll entry point.
       
   120 // Returns: CScriptBase: New CScriptBase derived object
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 EXPORT_C CScriptBase* LibEntryL( 
       
   124     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   125     {
       
   126 
       
   127     return ( CScriptBase* ) CTestLc::NewL( aTestModuleIf );
       
   128 
       
   129     }
       
   130 
       
   131 
       
   132 //  End of File