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