classicui_plat/keylock_api/tsrc/src/testsdkkeylock.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 AknKeyLock.h
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <stiftestinterface.h>
       
    21 #include <settingserverclient.h>
       
    22 
       
    23 #include "testsdkkeylock.h"
       
    24 CTestSDKKeyLock::CTestSDKKeyLock( CTestModuleIf& aTestModuleIf ): 
       
    25                  CScriptBase( aTestModuleIf )
       
    26     {
       
    27     }
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CTestSDKKeyLock::ConstructL
       
    31 // Symbian 2nd phase constructor can leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 void CTestSDKKeyLock::ConstructL()
       
    35     {
       
    36     //Read logger settings to check whether test case name is to be
       
    37     //appended to log file name.
       
    38     RSettingServer settingServer;
       
    39     CleanupClosePushL( settingServer );
       
    40     TInt ret = settingServer.Connect();
       
    41     if( ret != KErrNone )
       
    42         {
       
    43         User::Leave( ret );
       
    44         }
       
    45     // Struct to StifLogger settigs.
       
    46     TLoggerSettings loggerSettings; 
       
    47     // Parse StifLogger defaults from STIF initialization file.
       
    48     ret = settingServer.GetLoggerSettings( loggerSettings );
       
    49     if( ret != KErrNone )
       
    50         {
       
    51         User::Leave( ret );
       
    52         } 
       
    53     // Close Setting server session
       
    54     CleanupStack::PopAndDestroy( &settingServer );
       
    55 
       
    56     TFileName logFileName;
       
    57     
       
    58     if( loggerSettings.iAddTestCaseTitle )
       
    59         {
       
    60         TName title;
       
    61         TestModuleIf().GetTestCaseTitleL( title );
       
    62         logFileName.Format( KtestsdkkeylockLogFileWithTitle, &title );
       
    63         }
       
    64     else
       
    65         {
       
    66         logFileName.Copy( KtestsdkkeylockLogFile );
       
    67         }
       
    68 
       
    69     iLog = CStifLogger::NewL( KtestsdkkeylockLogPath, 
       
    70                           logFileName,
       
    71                           CStifLogger::ETxt,
       
    72                           CStifLogger::EFile,
       
    73                           EFalse );
       
    74     
       
    75     SendTestClassVersion();
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CTestSDKKeyLock::NewL
       
    80 // Two-phased constructor.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CTestSDKKeyLock* CTestSDKKeyLock::NewL( 
       
    84     CTestModuleIf& aTestModuleIf )
       
    85     {
       
    86     CTestSDKKeyLock* self = new(ELeave) CTestSDKKeyLock( aTestModuleIf );
       
    87 
       
    88     CleanupStack::PushL( self );
       
    89     self->ConstructL();
       
    90     CleanupStack::Pop( self );
       
    91 
       
    92     return self;
       
    93 
       
    94     }
       
    95 
       
    96 // Destructor
       
    97 CTestSDKKeyLock::~CTestSDKKeyLock()
       
    98     { 
       
    99 
       
   100     // Delete resources allocated from test methods
       
   101     Delete();
       
   102 
       
   103     // Delete logger
       
   104     delete iLog; 
       
   105 
       
   106     }
       
   107 
       
   108 //-----------------------------------------------------------------------------
       
   109 // CTestSDKKeyLock::SendTestClassVersion
       
   110 // Method used to send version of test class
       
   111 //-----------------------------------------------------------------------------
       
   112 //
       
   113 void CTestSDKKeyLock::SendTestClassVersion()
       
   114     {
       
   115     TVersion moduleVersion;
       
   116     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   117     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   118     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   119     
       
   120     _LIT( KFileName, "testsdkk.dll" );
       
   121     TFileName moduleName( KFileName );
       
   122 
       
   123     TBool newVersionOfMethod = ETrue;
       
   124     TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   125     }
       
   126 
       
   127 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // LibEntryL is a polymorphic Dll entry point.
       
   131 // Returns: CScriptBase: New CScriptBase derived object
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C CScriptBase* LibEntryL( 
       
   135     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   136     {
       
   137 
       
   138     return ( CScriptBase* ) CTestSDKKeyLock::NewL( aTestModuleIf );
       
   139 
       
   140     }
       
   141 //  End of File
       
   142