classicui_plat/slider_api/tsrc/src/testsdkslider.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:  slider_api
       
    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 
       
    26 #include "testsdkslider.h"
       
    27 
       
    28 // CONSTANTS
       
    29 _LIT( KModuleName, "testsdkslider.dll" );
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CTestSDKSlider::CTestSDKSlider
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CTestSDKSlider::CTestSDKSlider( CTestModuleIf& aTestModuleIf ):
       
    40     CScriptBase( aTestModuleIf )
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CTestSDKSlider::ConstructL
       
    46 // Symbian 2nd phase constructor can leave.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CTestSDKSlider::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( KtestsdksliderLogFileWithTitle, &title );
       
    79         }
       
    80     else
       
    81         {
       
    82         logFileName.Copy( KtestsdksliderLogFile );
       
    83         }
       
    84 
       
    85     iLog = CStifLogger::NewL( KtestsdksliderLogPath, 
       
    86                           logFileName,
       
    87                           CStifLogger::ETxt,
       
    88                           CStifLogger::EFile,
       
    89                           EFalse );
       
    90     
       
    91     SendTestClassVersion();
       
    92     
       
    93     iOffset = CCoeEnv::Static()->AddResourceFileL( _L("C:\\resource\\testsdkslider.rsc") );
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CTestSDKSlider::NewL
       
    98 // Two-phased constructor.
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 CTestSDKSlider* CTestSDKSlider::NewL( CTestModuleIf& aTestModuleIf )
       
   102     {
       
   103     CTestSDKSlider* self = new( ELeave ) CTestSDKSlider( aTestModuleIf );
       
   104 
       
   105     CleanupStack::PushL( self );
       
   106     self->ConstructL();
       
   107     CleanupStack::Pop( self );
       
   108 
       
   109     return self;
       
   110 
       
   111     }
       
   112 
       
   113 // Destructor
       
   114 CTestSDKSlider::~CTestSDKSlider()
       
   115     { 
       
   116 
       
   117     // Delete resources allocated from test methods
       
   118     Delete();
       
   119 
       
   120     // Delete logger
       
   121     delete iLog; 
       
   122 
       
   123     CCoeEnv::Static()->DeleteResourceFile( iOffset );
       
   124     }
       
   125 
       
   126 //-----------------------------------------------------------------------------
       
   127 // CTestSDKSlider::SendTestClassVersion
       
   128 // Method used to send version of test class
       
   129 //-----------------------------------------------------------------------------
       
   130 //
       
   131 void CTestSDKSlider::SendTestClassVersion()
       
   132     {
       
   133     TVersion moduleVersion;
       
   134     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   135     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   136     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   137 
       
   138     TFileName moduleName;
       
   139     moduleName = KModuleName;
       
   140 
       
   141     TBool newVersionOfMethod = ETrue;
       
   142     TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, 
       
   143         newVersionOfMethod );
       
   144     }
       
   145 
       
   146 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // LibEntryL is a polymorphic Dll entry point.
       
   150 // Returns: CScriptBase: New CScriptBase derived object
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 EXPORT_C CScriptBase* LibEntryL( 
       
   154     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   155     {
       
   156     return ( CScriptBase* ) CTestSDKSlider::NewL( aTestModuleIf );
       
   157     }
       
   158 
       
   159 //  End of File