classicui_pub/aiw_criteria_api/tsrc/src/testsdkaiwcri.cpp
changeset 0 2f259fa3e83a
child 14 3320e4e6e8bb
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 aiw_criteria_api
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <stiftestinterface.h>
       
    23 #include <settingserverclient.h>
       
    24 #include <screensaverinternalpskeys.h>
       
    25 #include <e32property.h>
       
    26 
       
    27 #include "testsdkaiwcri.h"
       
    28 
       
    29 _LIT( KResourcePath, "C:\\resource\\testsdkaiwcri.rsc" );
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // Ctestsdkaiwcri::Ctestsdkaiwcri
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CTestSDKAiwCri::CTestSDKAiwCri( CTestModuleIf& aTestModuleIf ) :
       
    40     CScriptBase(aTestModuleIf)
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // Ctestsdkaiwcri::ConstructL
       
    46 // Symbian 2nd phase constructor can leave.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CTestSDKAiwCri::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( KtestsdkaiwcriLogFileWithTitle, &title );
       
    79         }
       
    80     else
       
    81         {
       
    82         logFileName.Copy( KtestsdkaiwcriLogFile );
       
    83         }
       
    84 
       
    85     iLog = CStifLogger::NewL( KtestsdkaiwcriLogPath, logFileName,
       
    86         CStifLogger::ETxt, CStifLogger::EFile, EFalse );
       
    87 
       
    88     iOffset = CCoeEnv::Static()->AddResourceFileL( KResourcePath );
       
    89 
       
    90     SendTestClassVersion();
       
    91 
       
    92     TurnOffScreenSaver();
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // Ctestsdkaiwcri::NewL
       
    97 // Two-phased constructor.
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 CTestSDKAiwCri* CTestSDKAiwCri::NewL( CTestModuleIf& aTestModuleIf )
       
   101     {
       
   102     CTestSDKAiwCri* self = new (ELeave) CTestSDKAiwCri( aTestModuleIf );
       
   103 
       
   104     CleanupStack::PushL( self );
       
   105     self->ConstructL();
       
   106     CleanupStack::Pop();
       
   107 
       
   108     return self;
       
   109 
       
   110     }
       
   111 
       
   112 // Destructor
       
   113 CTestSDKAiwCri::~CTestSDKAiwCri()
       
   114     {
       
   115 
       
   116     // Delete resources allocated from test methods
       
   117     Delete( );
       
   118 
       
   119     // Delete logger
       
   120     delete iLog;
       
   121 
       
   122     CCoeEnv::Static()->DeleteResourceFile( iOffset );
       
   123 
       
   124     RestoreScreenSaver();
       
   125 
       
   126     }
       
   127 
       
   128 //-----------------------------------------------------------------------------
       
   129 // Ctestsdkaiwcri::SendTestClassVersion
       
   130 // Method used to send version of test class
       
   131 //-----------------------------------------------------------------------------
       
   132 //
       
   133 void CTestSDKAiwCri::SendTestClassVersion()
       
   134     {
       
   135     TVersion moduleVersion;
       
   136     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   137     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   138     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   139 
       
   140     TFileName moduleName;
       
   141     moduleName = _L("testsdkaiwcri.dll");
       
   142 
       
   143     TBool newVersionOfMethod = ETrue;
       
   144     TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName,
       
   145         newVersionOfMethod );
       
   146     }
       
   147 
       
   148 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // LibEntryL is a polymorphic Dll entry point.
       
   152 // Returns: CScriptBase: New CScriptBase derived object
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 EXPORT_C CScriptBase* LibEntryL(
       
   156     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   157 
       
   158     {
       
   159 
       
   160     return ( CScriptBase* ) CTestSDKAiwCri::NewL( aTestModuleIf );
       
   161 
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // Turn off ScreenSaver
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CTestSDKAiwCri::TurnOffScreenSaver()
       
   169     {
       
   170     TInt err1 = RProperty::Get( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
       
   171         iOldScreenSaverProperty );
       
   172     TInt err2 = RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
       
   173         KScreenSaverAllowScreenSaver );    
       
   174     RDebug::Printf( "screensaver property=%d err1=%d err2=%d\n", 
       
   175         iOldScreenSaverProperty, err1, err2 );
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // Restore ScreenSaver
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 void CTestSDKAiwCri::RestoreScreenSaver()
       
   183     {
       
   184     RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
       
   185         iOldScreenSaverProperty );
       
   186     User::ResetInactivityTime();
       
   187     }
       
   188 
       
   189 //  End of File