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