uiresources/src/testsdkskins.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  test AknsBasicBackgroundControlContext.h AknsControlContext.h
       
    15 *                     AknsDataContext.h AknsDrawUtils.h AknsItemData.h
       
    16 *                     AknsFrameBackgroundControlContext.h AknsItemID.h
       
    17 *                     AknsLayeredBackgroundControlContext.h
       
    18 *                     AknsListBoxBackgroundControlContext.h
       
    19 *                     AknsRlEffectContext.h AknsRlParameter.h
       
    20 *                     AknsSkinInstance.h AknsUtils.h AknsWallpaperUtils.h
       
    21 *
       
    22 */
       
    23 
       
    24 
       
    25 
       
    26 // INCLUDE FILES
       
    27 #include <stiftestinterface.h>
       
    28 #include <settingserverclient.h>
       
    29 #include <screensaverinternalpskeys.h>
       
    30 #include <e32property.h>
       
    31 
       
    32 #include "testsdkskins.h"
       
    33 
       
    34 // CONSTANTS
       
    35 _LIT( KModuleName, "testsdkskins.dll" );
       
    36 
       
    37 // ============================ MEMBER FUNCTIONS ===============================
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CTestSDKSkins::CTestSDKSkins
       
    41 // C++ default constructor can NOT contain any code, that
       
    42 // might leave.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CTestSDKSkins::CTestSDKSkins( CTestModuleIf& aTestModuleIf ):
       
    46     CScriptBase( aTestModuleIf )
       
    47     {
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CTestSDKSkins::~CTestSDKSkins
       
    52 // Destructor.
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CTestSDKSkins::~CTestSDKSkins()
       
    56     {
       
    57     // Delete logger
       
    58     delete iLog; 
       
    59 
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CTestSDKSkins::ConstructL
       
    64 // Symbian 2nd phase constructor can leave.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 void CTestSDKSkins::ConstructL()
       
    68     {
       
    69     //Read logger settings to check whether test case name is to be
       
    70     //appended to log file name.
       
    71     RSettingServer settingServer;
       
    72     CleanupClosePushL( settingServer );
       
    73     TInt ret = settingServer.Connect();
       
    74     if ( ret != KErrNone )
       
    75         {
       
    76         User::Leave(ret);
       
    77         }
       
    78     // Struct to StifLogger settigs.
       
    79     TLoggerSettings loggerSettings; 
       
    80     // Parse StifLogger defaults from STIF initialization file.
       
    81     ret = settingServer.GetLoggerSettings( loggerSettings );
       
    82     if ( ret != KErrNone )
       
    83         {
       
    84         User::Leave( ret );
       
    85         } 
       
    86     // Close Setting server session
       
    87     settingServer.Close();
       
    88     CleanupStack::PopAndDestroy( &settingServer );
       
    89 
       
    90     TFileName logFileName;
       
    91     
       
    92     if ( loggerSettings.iAddTestCaseTitle )
       
    93         {
       
    94         TName title;
       
    95         TestModuleIf().GetTestCaseTitleL( title );
       
    96         logFileName.Format( KtestsdkskinsLogFileWithTitle, &title );
       
    97         }
       
    98     else
       
    99         {
       
   100         logFileName.Copy( KtestsdkskinsLogFile );
       
   101         }
       
   102 
       
   103     iLog = CStifLogger::NewL( KtestsdkskinsLogPath, 
       
   104                           logFileName,
       
   105                           CStifLogger::ETxt,
       
   106                           CStifLogger::EFile,
       
   107                           EFalse );
       
   108     
       
   109     SendTestClassVersion();
       
   110     
       
   111     TurnOffScreenSaver();
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CTestSDKSkins::NewL
       
   116 // Two-phased constructor.
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 CTestSDKSkins* CTestSDKSkins::NewL( CTestModuleIf& aTestModuleIf )
       
   120     {
       
   121     CTestSDKSkins* self = new( ELeave ) CTestSDKSkins( aTestModuleIf );
       
   122 
       
   123     CleanupStack::PushL( self );
       
   124     self->ConstructL();
       
   125     CleanupStack::Pop( self );
       
   126 
       
   127     return self;
       
   128 
       
   129     }
       
   130 
       
   131 //-----------------------------------------------------------------------------
       
   132 // CTestSDKSkins::SendTestClassVersion
       
   133 // Method used to send version of test class
       
   134 //-----------------------------------------------------------------------------
       
   135 //
       
   136 void CTestSDKSkins::SendTestClassVersion()
       
   137     {
       
   138     TVersion moduleVersion;
       
   139     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   140     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   141     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   142 
       
   143     TFileName moduleName;
       
   144     moduleName = KModuleName;
       
   145 
       
   146     TBool newVersionOfMethod = ETrue;
       
   147     TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, 
       
   148         newVersionOfMethod );
       
   149     }
       
   150 
       
   151 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // LibEntryL is a polymorphic Dll entry point.
       
   155 // Returns: CScriptBase: New CScriptBase derived object
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 EXPORT_C CScriptBase* LibEntryL( 
       
   159     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   160     {
       
   161     return ( CScriptBase* ) CTestSDKSkins::NewL( aTestModuleIf );
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // Turn off ScreenSaver
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CTestSDKSkins::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 CTestSDKSkins::RestoreScreenSaver()
       
   183     {
       
   184     RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
       
   185         iOldScreenSaverProperty );
       
   186     User::ResetInactivityTime();
       
   187     }
       
   188 
       
   189 
       
   190 //  End of File