coreapplicationuis/rfsplugins/tsrc/rfspluginstest/TelephonyRFSPluginTestModule/src/TelephonyRFSPluginTestModule.cpp
changeset 69 dcd4152cfe55
equal deleted inserted replaced
65:8a530a83576a 69:dcd4152cfe55
       
     1 /*
       
     2 * Copyright (c) 2010 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: This file contains testclass implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <StifTestInterface.h>
       
    20 #include "TelephonyRFSPluginTestModule.h"
       
    21 #include <SettingServerClient.h>
       
    22 #include <rfsplugin.h>
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 //extern  ?external_data;
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 //extern ?external_function( ?arg_type,?arg_type );
       
    29 
       
    30 // CONSTANTS
       
    31 //const ?type ?constant_var = ?constant;
       
    32 
       
    33 // MACROS
       
    34 //#define ?macro ?macro_def
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 //const ?type ?constant_var = ?constant;
       
    38 //#define ?macro_name ?macro_def
       
    39 
       
    40 // MODULE DATA STRUCTURES
       
    41 //enum ?declaration
       
    42 //typedef ?declaration
       
    43 
       
    44 // LOCAL FUNCTION PROTOTYPES
       
    45 //?type ?function_name( ?arg_type, ?arg_type );
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 //class ?FORWARD_CLASSNAME;
       
    49 
       
    50 // ============================= LOCAL FUNCTIONS ===============================
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // ?function_name ?description.
       
    54 // ?description
       
    55 // Returns: ?value_1: ?description
       
    56 //          ?value_n: ?description_line1
       
    57 //                    ?description_line2
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 /*
       
    61 ?type ?function_name(
       
    62     ?arg_type arg,  // ?description
       
    63     ?arg_type arg)  // ?description
       
    64     {
       
    65 
       
    66     ?code  // ?comment
       
    67 
       
    68     // ?comment
       
    69     ?code
       
    70     }
       
    71 */
       
    72 
       
    73 // ============================ MEMBER FUNCTIONS ===============================
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CTelephonyRFSPluginTestModule::CTelephonyRFSPluginTestModule
       
    77 // C++ default constructor can NOT contain any code, that
       
    78 // might leave.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CTelephonyRFSPluginTestModule::CTelephonyRFSPluginTestModule( 
       
    82     CTestModuleIf& aTestModuleIf ):
       
    83         CScriptBase( aTestModuleIf )
       
    84     {
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CTelephonyRFSPluginTestModule::ConstructL
       
    89 // Symbian 2nd phase constructor can leave.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CTelephonyRFSPluginTestModule::ConstructL()
       
    93     {
       
    94     //Read logger settings to check whether test case name is to be
       
    95     //appended to log file name.
       
    96     RSettingServer settingServer;
       
    97     TInt ret = settingServer.Connect();
       
    98     if(ret != KErrNone)
       
    99         {
       
   100         User::Leave(ret);
       
   101         }
       
   102     // Struct to StifLogger settigs.
       
   103     TLoggerSettings loggerSettings; 
       
   104     // Parse StifLogger defaults from STIF initialization file.
       
   105     ret = settingServer.GetLoggerSettings(loggerSettings);
       
   106     if(ret != KErrNone)
       
   107         {
       
   108         User::Leave(ret);
       
   109         } 
       
   110     // Close Setting server session
       
   111     settingServer.Close();
       
   112 
       
   113     TFileName logFileName;
       
   114     
       
   115     if(loggerSettings.iAddTestCaseTitle)
       
   116         {
       
   117         TName title;
       
   118         TestModuleIf().GetTestCaseTitleL(title);
       
   119         logFileName.Format(KTelephonyRFSPluginTestModuleLogFileWithTitle, &title);
       
   120         }
       
   121     else
       
   122         {
       
   123         logFileName.Copy(KTelephonyRFSPluginTestModuleLogFile);
       
   124         }
       
   125 
       
   126     iLog = CStifLogger::NewL( KTelephonyRFSPluginTestModuleLogPath, 
       
   127                           logFileName,
       
   128                           CStifLogger::ETxt,
       
   129                           CStifLogger::EFile,
       
   130                           EFalse );
       
   131     
       
   132     SendTestClassVersion();
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CTelephonyRFSPluginTestModule::NewL
       
   137 // Two-phased constructor.
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 CTelephonyRFSPluginTestModule* CTelephonyRFSPluginTestModule::NewL( 
       
   141     CTestModuleIf& aTestModuleIf )
       
   142     {
       
   143     CTelephonyRFSPluginTestModule* self = new (ELeave) CTelephonyRFSPluginTestModule( aTestModuleIf );
       
   144 
       
   145     CleanupStack::PushL( self );
       
   146     self->ConstructL();
       
   147     CleanupStack::Pop();
       
   148 
       
   149     return self;
       
   150 
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CTelephonyRFSPluginTestModule::Delete
       
   155 // Delete here all resources allocated and opened from test methods. 
       
   156 // Called from destructor. 
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CTelephonyRFSPluginTestModule::Delete() 
       
   160     {
       
   161 
       
   162     }
       
   163 
       
   164 // Destructor
       
   165 CTelephonyRFSPluginTestModule::~CTelephonyRFSPluginTestModule()
       
   166     { 
       
   167 
       
   168     // Delete resources allocated from test methods
       
   169     Delete();
       
   170     
       
   171     delete iPlugin;
       
   172     REComSession::FinalClose();
       
   173 
       
   174     // Delete logger
       
   175     delete iLog; 
       
   176 
       
   177     }
       
   178 
       
   179 //-----------------------------------------------------------------------------
       
   180 // CTelephonyRFSPluginTestModule::SendTestClassVersion
       
   181 // Method used to send version of test class
       
   182 //-----------------------------------------------------------------------------
       
   183 //
       
   184 void CTelephonyRFSPluginTestModule::SendTestClassVersion()
       
   185 	{
       
   186 	TVersion moduleVersion;
       
   187 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   188 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   189 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   190 	
       
   191 	TFileName moduleName;
       
   192 	moduleName = _L("TelephonyRFSPluginTestModule.dll");
       
   193 
       
   194 	TBool newVersionOfMethod = ETrue;
       
   195 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   196 	}
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CTelephonyRFSPluginTestModule::RunMethodL
       
   200 // Run specified method. Contains also table of test mothods and their names.
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 TInt CTelephonyRFSPluginTestModule::RunMethodL( 
       
   204     CStifItemParser& aItem ) 
       
   205     {
       
   206 
       
   207     static TStifFunctionInfo const KFunctions[] =
       
   208         {  
       
   209         // Copy this line for every implemented function.
       
   210         // First string is the function name used in TestScripter script file.
       
   211         // Second is the actual implementation member function. 
       
   212         ENTRY( "CreatePlugin", CTelephonyRFSPluginTestModule::CreatePlugin ),
       
   213         ENTRY( "DestroyPlugin", CTelephonyRFSPluginTestModule::DestroyPlugin ),
       
   214         ENTRY( "RestoreFactorySettings", CTelephonyRFSPluginTestModule::RestoreFactorySettings ),
       
   215         ENTRY( "GetScript", CTelephonyRFSPluginTestModule::GetScript ),
       
   216         ENTRY( "ExecuteCustomCommand", CTelephonyRFSPluginTestModule::ExecuteCustomCommand ),
       
   217         //ADD NEW ENTRY HERE
       
   218         // [test cases entries] - Do not remove
       
   219 
       
   220         };
       
   221 
       
   222     const TInt count = sizeof( KFunctions ) / 
       
   223                         sizeof( TStifFunctionInfo );
       
   224 
       
   225     return RunInternalL( KFunctions, count, aItem );
       
   226 
       
   227     }
       
   228 
       
   229 TInt CTelephonyRFSPluginTestModule::CreatePlugin(CStifItemParser& /*aItem */)
       
   230     {
       
   231     STIF_ASSERT_NOT_LEAVES(iPlugin = CRFSPlugin::NewL( TUid::Uid( 0x2000F8B6 ) ) );
       
   232     STIF_ASSERT_NOT_NULL( iPlugin );
       
   233     
       
   234     return KErrNone;
       
   235     
       
   236     }
       
   237 TInt CTelephonyRFSPluginTestModule::DestroyPlugin(CStifItemParser& /*aItem*/ )
       
   238     {
       
   239     delete iPlugin;
       
   240     iPlugin = NULL;
       
   241         
       
   242     return KErrNone;
       
   243     }
       
   244 
       
   245 TInt CTelephonyRFSPluginTestModule::RestoreFactorySettings(CStifItemParser& /*aItem*/ )
       
   246     {
       
   247     STIF_ASSERT_NOT_LEAVES( iPlugin->RestoreFactorySettingsL( ENormalRfs ) );
       
   248     STIF_ASSERT_NOT_LEAVES( iPlugin->RestoreFactorySettingsL( EDeepRfs ) );
       
   249     STIF_ASSERT_NOT_LEAVES( iPlugin->RestoreFactorySettingsL( EInitRfs ) );
       
   250     STIF_ASSERT_NOT_LEAVES( iPlugin->RestoreFactorySettingsL( static_cast<TRfsReason>( 100 ) ) );
       
   251     return KErrNone;
       
   252     }
       
   253 
       
   254 TInt CTelephonyRFSPluginTestModule::GetScript(CStifItemParser& /*aItem*/ )
       
   255     {
       
   256     TBuf<256> path;
       
   257      //TBuf<256> buf;
       
   258      //buf.Copy(KExpectedScript);
       
   259      STIF_ASSERT_NOT_LEAVES( iPlugin->GetScriptL( ENormalRfs, path ) );
       
   260      RDebug::Print(_L( "Script = '%S'"), &path );
       
   261      //STIF_ASSERT_EQUALS( buf, path );
       
   262 
       
   263      STIF_ASSERT_NOT_LEAVES( iPlugin->GetScriptL( EDeepRfs, path ) );
       
   264      RDebug::Print(_L( "Script = '%S'"), &path );
       
   265      //STIF_ASSERT_EQUALS( buf, path );
       
   266 
       
   267      STIF_ASSERT_NOT_LEAVES( iPlugin->GetScriptL( EInitRfs, path ) );
       
   268      RDebug::Print(_L( "Script = '%S'"), &path );
       
   269      //STIF_ASSERT_EQUALS( buf, path );
       
   270 
       
   271      STIF_ASSERT_NOT_LEAVES( iPlugin->GetScriptL( static_cast<TRfsReason>( 100 ), path ) );
       
   272      RDebug::Print(_L( "Script = '%S'"), &path );
       
   273      //STIF_ASSERT_EQUALS( buf, path );
       
   274 
       
   275     return KErrNone;
       
   276     }
       
   277 
       
   278 TInt CTelephonyRFSPluginTestModule::ExecuteCustomCommand(CStifItemParser& /*aItem*/ )
       
   279     {
       
   280     TBuf<256> param1( KNullDesC );
       
   281      STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( ENormalRfs, param1 ) );
       
   282      TBuf<1> param2( KNullDesC );
       
   283      STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( EDeepRfs, param2 ) );
       
   284      STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( EInitRfs, param2 ) );
       
   285      STIF_ASSERT_NOT_LEAVES( iPlugin->ExecuteCustomCommandL( static_cast<TRfsReason>( 100 ), param2 ) );
       
   286     return KErrNone;
       
   287     }
       
   288 
       
   289 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // LibEntryL is a polymorphic Dll entry point.
       
   293 // Returns: CScriptBase: New CScriptBase derived object
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 EXPORT_C CScriptBase* LibEntryL( 
       
   297     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   298     {
       
   299 
       
   300     return ( CScriptBase* ) CTelephonyRFSPluginTestModule::NewL( aTestModuleIf );
       
   301 
       
   302     }
       
   303 
       
   304 // End of File