classicui_plat/fonts_api/tsrc/src/testsdkfonts.cpp
branchRCL_3
changeset 19 aecbbf00d063
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
       
     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:  test fonts api
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <stiftestinterface.h>
       
    22 #include <settingserverclient.h>
       
    23 #include <e32property.h>
       
    24 
       
    25 #include "testsdkfonts.h"
       
    26 
       
    27 // CONSTANTS
       
    28 _LIT( KModuleName, "testsdkfonts.dll" );
       
    29 
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // Ctestsdkfonts::Ctestsdkfonts
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CTestSdkFonts::CTestSdkFonts( CTestModuleIf& aTestModuleIf ):
       
    40     CScriptBase( aTestModuleIf )
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // Ctestsdkfonts::~Ctestsdkfonts
       
    46 // Destructor.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CTestSdkFonts::~CTestSdkFonts()
       
    50     {
       
    51     // Delete logger
       
    52     delete iLog; 
       
    53     
       
    54     delete iFontAccess;
       
    55     iFontAccess=NULL;
       
    56 
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // Ctestsdkfonts::ConstructL
       
    61 // Symbian 2nd phase constructor can leave.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 void CTestSdkFonts::ConstructL()
       
    65     {
       
    66     //Read logger settings to check whether test case name is to be
       
    67     //appended to log file name.
       
    68     RSettingServer settingServer;
       
    69     CleanupClosePushL( settingServer );
       
    70     TInt ret = settingServer.Connect();
       
    71     if ( ret != KErrNone )
       
    72         {
       
    73         User::Leave(ret);
       
    74         }
       
    75     // Struct to StifLogger settigs.
       
    76     TLoggerSettings loggerSettings; 
       
    77     // Parse StifLogger defaults from STIF initialization file.
       
    78     ret = settingServer.GetLoggerSettings( loggerSettings );
       
    79     if ( ret != KErrNone )
       
    80         {
       
    81         User::Leave( ret );
       
    82         } 
       
    83     // Close Setting server session
       
    84     settingServer.Close();
       
    85     CleanupStack::PopAndDestroy( &settingServer );
       
    86 
       
    87     TFileName logFileName;
       
    88     
       
    89     if ( loggerSettings.iAddTestCaseTitle )
       
    90         {
       
    91         TName title;
       
    92         TestModuleIf().GetTestCaseTitleL( title );
       
    93         logFileName.Format( KtestsdkfontsLogFileWithTitle, &title );
       
    94         }
       
    95     else
       
    96         {
       
    97         logFileName.Copy( KtestsdkfontsLogFile );
       
    98         }
       
    99 
       
   100     iLog = CStifLogger::NewL( KtestsdkfontsLogPath, 
       
   101                           logFileName,
       
   102                           CStifLogger::ETxt,
       
   103                           CStifLogger::EFile,
       
   104                           EFalse );
       
   105     
       
   106     SendTestClassVersion();
       
   107     iFontAccess = new ( ELeave ) AknFontAccess;
       
   108     
       
   109     }
       
   110 
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CTestSdkFonts::NewL
       
   114 // Two-phased constructor.
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 CTestSdkFonts* CTestSdkFonts::NewL( CTestModuleIf& aTestModuleIf )
       
   118     {
       
   119     CTestSdkFonts* self = new( ELeave ) CTestSdkFonts( aTestModuleIf );
       
   120 
       
   121     CleanupStack::PushL( self );
       
   122     self->ConstructL();
       
   123     CleanupStack::Pop( self );
       
   124 
       
   125     return self;
       
   126 
       
   127     }
       
   128 
       
   129 //-----------------------------------------------------------------------------
       
   130 // CTestSdkFonts::SendTestClassVersion
       
   131 // Method used to send version of test class
       
   132 //-----------------------------------------------------------------------------
       
   133 //
       
   134 void CTestSdkFonts::SendTestClassVersion()
       
   135     {
       
   136     TVersion moduleVersion;
       
   137     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   138     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   139     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   140 
       
   141     TFileName moduleName;
       
   142     moduleName = KModuleName;
       
   143 
       
   144     TBool newVersionOfMethod = ETrue;
       
   145     TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, 
       
   146         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     return ( CScriptBase* ) CTestSdkFonts::NewL( aTestModuleIf );
       
   160     }
       
   161 
       
   162 //  End of File