classicui_pub/popups_api/tsrc/src/testsdkpopups.cpp
changeset 0 2f259fa3e83a
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 aknPopup.h aknpopupfader.h AknPopupField.h AknPopupFieldList.h 
       
    15 *                     AknPopupFieldText.h aknPopupHeadingPane.h aknpopuplayout.h 
       
    16 *                     AknPopupSettingPage.h
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <stiftestinterface.h>
       
    24 #include <settingserverclient.h>
       
    25 #include <screensaverinternalpskeys.h>
       
    26 #include <e32property.h>
       
    27 #include <coemain.h>
       
    28 #include <coeaui.h>
       
    29 #include <aknlists.h>
       
    30 #include <aknpopup.h>
       
    31 #include <aknpopupheadingpane.h>
       
    32 #include <aknsfld.h>
       
    33 #include <testsdkpopups.rsg>
       
    34 
       
    35 #include "testsdkpopups.h"
       
    36 
       
    37 // CONSTANTS
       
    38 _LIT( KModuleName, "testsdkpopups.dll" );
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CTestSDKPopups::CTestSDKPopups
       
    44 // C++ default constructor can NOT contain any code, that
       
    45 // might leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CTestSDKPopups::CTestSDKPopups( CTestModuleIf& aTestModuleIf ):
       
    49     CScriptBase( aTestModuleIf )
       
    50     {
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CTestSDKPopups::ConstructL
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CTestSDKPopups::ConstructL()
       
    59     {
       
    60     
       
    61     //Read logger settings to check whether test case name is to be
       
    62     //appended to log file name.
       
    63     RSettingServer settingServer;
       
    64     CleanupClosePushL( settingServer );
       
    65     TInt ret = settingServer.Connect();
       
    66     if ( ret != KErrNone )
       
    67         {
       
    68         User::Leave(ret);
       
    69         }
       
    70     // Struct to StifLogger settigs.
       
    71     TLoggerSettings loggerSettings; 
       
    72     // Parse StifLogger defaults from STIF initialization file.
       
    73     ret = settingServer.GetLoggerSettings( loggerSettings );
       
    74     if ( ret != KErrNone )
       
    75         {
       
    76         User::Leave( ret );
       
    77         } 
       
    78     // Close Setting server session
       
    79     settingServer.Close();
       
    80     CleanupStack::PopAndDestroy( &settingServer );
       
    81 
       
    82     TFileName logFileName;
       
    83     
       
    84     if ( loggerSettings.iAddTestCaseTitle )
       
    85         {
       
    86         TName title;
       
    87         TestModuleIf().GetTestCaseTitleL( title );
       
    88         logFileName.Format( KtestsdkpopupsLogFileWithTitle, &title );
       
    89         }
       
    90     else
       
    91         {
       
    92         logFileName.Copy( KtestsdkpopupsLogFile );
       
    93         }
       
    94 
       
    95     iLog = CStifLogger::NewL( KtestsdkpopupsLogPath, 
       
    96                           logFileName,
       
    97                           CStifLogger::ETxt,
       
    98                           CStifLogger::EFile,
       
    99                           EFalse );
       
   100     iOffset = CCoeEnv::Static()->AddResourceFileL(_L("C:\\resource\\testsdkpopups.rsc"));
       
   101     SendTestClassVersion();
       
   102     
       
   103     TurnOffScreenSaver();
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CTestSDKPopups::NewL
       
   108 // Two-phased constructor.
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 CTestSDKPopups* CTestSDKPopups::NewL( CTestModuleIf& aTestModuleIf )
       
   112     {
       
   113     CTestSDKPopups* self = new( ELeave ) CTestSDKPopups( aTestModuleIf );
       
   114 
       
   115     CleanupStack::PushL( self );
       
   116     self->ConstructL();
       
   117     CleanupStack::Pop( self );
       
   118 
       
   119     return self;
       
   120 
       
   121     }
       
   122 
       
   123 // Destructor
       
   124 CTestSDKPopups::~CTestSDKPopups()
       
   125     { 
       
   126 
       
   127     // Delete resources allocated from test methods
       
   128     Delete();
       
   129 
       
   130     // Delete logger
       
   131     delete iLog; 
       
   132 
       
   133     CCoeEnv::Static()->DeleteResourceFile( iOffset );
       
   134 
       
   135     RestoreScreenSaver();
       
   136 
       
   137     }
       
   138 
       
   139 //-----------------------------------------------------------------------------
       
   140 // CTestSDKPopups::SendTestClassVersion
       
   141 // Method used to send version of test class
       
   142 //-----------------------------------------------------------------------------
       
   143 //
       
   144 void CTestSDKPopups::SendTestClassVersion()
       
   145     {
       
   146     TVersion moduleVersion;
       
   147     moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   148     moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   149     moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   150 
       
   151     TFileName moduleName;
       
   152     moduleName = KModuleName;
       
   153 
       
   154     TBool newVersionOfMethod = ETrue;
       
   155     TestModuleIf().SendTestModuleVersion( moduleVersion, moduleName, 
       
   156         newVersionOfMethod );
       
   157     }
       
   158 
       
   159 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // LibEntryL is a polymorphic Dll entry point.
       
   163 // Returns: CScriptBase: New CScriptBase derived object
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C CScriptBase* LibEntryL( 
       
   167     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   168     {
       
   169     return ( CScriptBase* ) CTestSDKPopups::NewL( aTestModuleIf );
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // Turn off ScreenSaver
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 void CTestSDKPopups::TurnOffScreenSaver()
       
   177     {
       
   178     TInt err1 = RProperty::Get( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
       
   179         iOldScreenSaverProperty );
       
   180     TInt err2 = RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
       
   181         KScreenSaverAllowScreenSaver );    
       
   182     RDebug::Printf( "screensaver property=%d err1=%d err2=%d\n", 
       
   183         iOldScreenSaverProperty, err1, err2 );
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // Restore ScreenSaver
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 void CTestSDKPopups::RestoreScreenSaver()
       
   191     {
       
   192     RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 
       
   193         iOldScreenSaverProperty );
       
   194     User::ResetInactivityTime();
       
   195     }
       
   196 
       
   197 
       
   198 //  End of File