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