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