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