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