mds_plat/metadata_engine_api/tsrc/src/MdETestScripter.cpp
changeset 60 79f826a55db2
equal deleted inserted replaced
58:fe894bb075c2 60:79f826a55db2
       
     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:  
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <StifTestInterface.h>
       
    20 #include <SettingServerClient.h>
       
    21 #include <pathinfo.h>
       
    22 #include <mdesession.h>
       
    23 #include "MdETestScripter.h"
       
    24 #include "MdETestScripterAO.h"
       
    25 
       
    26 // ============================= LOCAL FUNCTIONS ===============================
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CMdETestScripter::CMdETestScripter
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CMdETestScripter::CMdETestScripter( CTestModuleIf& aTestModuleIf ):
       
    37         CScriptBase( aTestModuleIf )
       
    38     {
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CMdETestScripter::ConstructL
       
    43 // Symbian 2nd phase constructor can leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CMdETestScripter::ConstructL()
       
    47     {
       
    48     //Read logger settings to check whether test case name is to be
       
    49     //appended to log file name.
       
    50     RSettingServer settingServer;
       
    51     TInt ret = settingServer.Connect();
       
    52     if(ret != KErrNone)
       
    53         {
       
    54         User::Leave(ret);
       
    55         }
       
    56     // Struct to StifLogger settigs.
       
    57     TLoggerSettings loggerSettings; 
       
    58     // Parse StifLogger defaults from STIF initialization file.
       
    59     ret = settingServer.GetLoggerSettings(loggerSettings);
       
    60     if(ret != KErrNone)
       
    61         {
       
    62         User::Leave(ret);
       
    63         } 
       
    64     // Close Setting server session
       
    65     settingServer.Close();
       
    66 
       
    67     TFileName logFileName;
       
    68     
       
    69     if(loggerSettings.iAddTestCaseTitle)
       
    70         {
       
    71         TName title;
       
    72         TestModuleIf().GetTestCaseTitleL(title);
       
    73         logFileName.Format(KMdETestScripterLogFileWithTitle, &title);
       
    74         }
       
    75     else
       
    76         {
       
    77         logFileName.Copy(KMdETestScripterLogFile);
       
    78         }
       
    79 
       
    80 #if ( defined (__WINS__) || defined (__WINSCW__) )
       
    81     iFilePath.Copy( PathInfo::PhoneMemoryRootPath().Left( KPathPrefixLength ));
       
    82 #else
       
    83     iFilePath.Copy( PathInfo::MemoryCardRootPath ().Left( KPathPrefixLength ));
       
    84 #endif
       
    85     iFilePath.Append( KMdETestDataPath );
       
    86 	iFilePath.ZeroTerminate();
       
    87 
       
    88     iLog = CStifLogger::NewL( KMdETestScripterLogPath, 
       
    89                           logFileName,
       
    90                           CStifLogger::ETxt,
       
    91                           CStifLogger::EFile,
       
    92                           EFalse );
       
    93     iObjectDefNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
    94     iRelationDefNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
    95 	iEventDefNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
    96 	iPropertyDefNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
    97 	iNamespaceDefNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
    98 	
       
    99 	iObjectNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   100     iRelationNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   101     iEventNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   102     
       
   103     iPropertyNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   104     
       
   105 	iRelationConditionNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   106 	iObjectConditionNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   107 	iEventConditionNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   108 			
       
   109 	iPropertyConditionNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   110 	iLogicConditionNameArray = new (ELeave )CDesCArrayFlat( 8 );
       
   111 
       
   112 	iMdeSession = CMdESession::NewL( *this );
       
   113 	iAsyncHandler = CMdETestScripterAO::NewL();
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CMdETestScripter::NewL
       
   118 // Two-phased constructor.
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 CMdETestScripter* CMdETestScripter::NewL( 
       
   122     CTestModuleIf& aTestModuleIf )
       
   123     {
       
   124     CMdETestScripter* self = new (ELeave) CMdETestScripter( aTestModuleIf );
       
   125 
       
   126     CleanupStack::PushL( self );
       
   127     self->ConstructL();
       
   128     CleanupStack::Pop();
       
   129 
       
   130     return self;
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // ~CMdETestScripter()
       
   135 // Destructor.
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 CMdETestScripter::~CMdETestScripter()
       
   139     { 
       
   140     // Delete resources allocated from test methods
       
   141     Delete();
       
   142 
       
   143     // Delete logger
       
   144     delete iLog; 
       
   145     }
       
   146 
       
   147 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // LibEntryL is a polymorphic Dll entry point.
       
   151 // Returns: CScriptBase: New CScriptBase derived object
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 EXPORT_C CScriptBase* LibEntryL( 
       
   155     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   156     {
       
   157     return ( CScriptBase* ) CMdETestScripter::NewL( aTestModuleIf );
       
   158     }
       
   159 
       
   160 //  End of File