coreapplicationuis/accfwuinotifier/tsrc/AccFwUiNotifierTestModule/src/AccFwUiNotifierTestModule.cpp
changeset 77 b01c07dfcf84
equal deleted inserted replaced
74:1505405bc645 77:b01c07dfcf84
       
     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 "AccFwUiNotifierTestModule.h"
       
    21 #include <SettingServerClient.h>
       
    22 #include "AccFwUiNoteNotifier.h"
       
    23 
       
    24 #include <accfwnoteuinotifier.rsg>
       
    25 //#include <e32des8.h>
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 //extern  ?external_data;
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 //extern ?external_function( ?arg_type,?arg_type );
       
    32 
       
    33 // CONSTANTS
       
    34 // CONSTANTS
       
    35 
       
    36 
       
    37 // MACROS
       
    38 //#define ?macro ?macro_def
       
    39 
       
    40 // LOCAL CONSTANTS AND MACROS
       
    41 
       
    42 
       
    43 // MODULE DATA STRUCTURES
       
    44 //enum ?declaration
       
    45 //typedef ?declaration
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 //?type ?function_name( ?arg_type, ?arg_type );
       
    49 
       
    50 // FORWARD DECLARATIONS
       
    51 //class ?FORWARD_CLASSNAME;
       
    52 
       
    53 // ============================= LOCAL FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // ?function_name ?description.
       
    57 // ?description
       
    58 // Returns: ?value_1: ?description
       
    59 //          ?value_n: ?description_line1
       
    60 //                    ?description_line2
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 /*
       
    64 ?type ?function_name(
       
    65     ?arg_type arg,  // ?description
       
    66     ?arg_type arg)  // ?description
       
    67     {
       
    68 
       
    69     ?code  // ?comment
       
    70 
       
    71     // ?comment
       
    72     ?code
       
    73     }
       
    74 */
       
    75 
       
    76 // ============================ MEMBER FUNCTIONS ===============================
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CAccFwUiNotifierTestModule::CAccFwUiNotifierTestModule
       
    80 // C++ default constructor can NOT contain any code, that
       
    81 // might leave.
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CAccFwUiNotifierTestModule::CAccFwUiNotifierTestModule( 
       
    85     CTestModuleIf& aTestModuleIf ):
       
    86         CScriptBase( aTestModuleIf )
       
    87     {
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CAccFwUiNotifierTestModule::ConstructL
       
    92 // Symbian 2nd phase constructor can leave.
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CAccFwUiNotifierTestModule::ConstructL()
       
    96     {
       
    97     //Read logger settings to check whether test case name is to be
       
    98     //appended to log file name.
       
    99     RSettingServer settingServer;
       
   100     TInt ret = settingServer.Connect();
       
   101     if(ret != KErrNone)
       
   102         {
       
   103         User::Leave(ret);
       
   104         }
       
   105     // Struct to StifLogger settigs.
       
   106     TLoggerSettings loggerSettings; 
       
   107     // Parse StifLogger defaults from STIF initialization file.
       
   108     ret = settingServer.GetLoggerSettings(loggerSettings);
       
   109     if(ret != KErrNone)
       
   110         {
       
   111         User::Leave(ret);
       
   112         } 
       
   113     // Close Setting server session
       
   114     settingServer.Close();
       
   115 
       
   116     TFileName logFileName;
       
   117     
       
   118     if(loggerSettings.iAddTestCaseTitle)
       
   119         {
       
   120         TName title;
       
   121         TestModuleIf().GetTestCaseTitleL(title);
       
   122         logFileName.Format(KAccFwUiNotifierTestModuleLogFileWithTitle, &title);
       
   123         }
       
   124     else
       
   125         {
       
   126         logFileName.Copy(KAccFwUiNotifierTestModuleLogFile);
       
   127         }
       
   128 
       
   129     iLog = CStifLogger::NewL( KAccFwUiNotifierTestModuleLogPath, 
       
   130                           logFileName,
       
   131                           CStifLogger::ETxt,
       
   132                           CStifLogger::EFile,
       
   133                           EFalse );
       
   134     
       
   135     SendTestClassVersion();
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CAccFwUiNotifierTestModule::NewL
       
   140 // Two-phased constructor.
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 CAccFwUiNotifierTestModule* CAccFwUiNotifierTestModule::NewL( 
       
   144     CTestModuleIf& aTestModuleIf )
       
   145     {
       
   146     CAccFwUiNotifierTestModule* self = new (ELeave) CAccFwUiNotifierTestModule( aTestModuleIf );
       
   147 
       
   148     CleanupStack::PushL( self );
       
   149     self->ConstructL();
       
   150     CleanupStack::Pop();
       
   151 
       
   152     return self;
       
   153 
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CAccFwUiNotifierTestModule::Delete
       
   158 // Delete here all resources allocated and opened from test methods. 
       
   159 // Called from destructor. 
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CAccFwUiNotifierTestModule::Delete() 
       
   163     {
       
   164 
       
   165     }
       
   166 
       
   167 
       
   168 // Destructor
       
   169 CAccFwUiNotifierTestModule::~CAccFwUiNotifierTestModule()
       
   170     { 
       
   171 
       
   172     // Delete resources allocated from test methods
       
   173     Delete();
       
   174 
       
   175     // Delete logger
       
   176     delete iLog; 
       
   177 
       
   178     }
       
   179 
       
   180 //-----------------------------------------------------------------------------
       
   181 // CAccFwUiNotifierTestModule::SendTestClassVersion
       
   182 // Method used to send version of test class
       
   183 //-----------------------------------------------------------------------------
       
   184 //
       
   185 void CAccFwUiNotifierTestModule::SendTestClassVersion()
       
   186 	{
       
   187 	TVersion moduleVersion;
       
   188 	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
       
   189 	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
       
   190 	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
       
   191 	
       
   192 	TFileName moduleName;
       
   193 	moduleName = _L("AccFwUiNotifierTestModule.dll");
       
   194 
       
   195 	TBool newVersionOfMethod = ETrue;
       
   196 	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
       
   197 	}
       
   198 
       
   199 // ------------------------------------------------------------------------------
       
   200 // PanicClient
       
   201 // ------------------------------------------------------------------------------
       
   202 //
       
   203 void CAccFwUiNotifierTestModule::PanicClient(TInt aPanic)
       
   204     {
       
   205     _LIT(KAccFwUiNotifierTestModulePanic, "AccFwUiNotifierTestModule");
       
   206     User::Panic(KAccFwUiNotifierTestModulePanic, aPanic);
       
   207     }
       
   208 // -----------------------------------------------------------------------------
       
   209 // CAccFwUiNotifierTestModule::RunMethodL
       
   210 // Run specified method. Contains also table of test mothods and their names.
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 TInt CAccFwUiNotifierTestModule::RunMethodL( 
       
   214     CStifItemParser& aItem ) 
       
   215     {
       
   216 
       
   217     static TStifFunctionInfo const KFunctions[] =
       
   218         {  
       
   219         // Copy this line for every implemented function.
       
   220         // First string is the function name used in TestScripter script file.
       
   221         // Second is the actual implementation member function. 
       
   222         ENTRY( "CreateNotifierPlugin", CAccFwUiNotifierTestModule::CreateNotifierPlugin ),
       
   223         ENTRY( "TestSupportedAccessoryUiNoteL", CAccFwUiNotifierTestModule::TestSupportedAccessoryUiNoteL ),
       
   224         ENTRY( "TestUnsupportedAccessoryUiNoteL", CAccFwUiNotifierTestModule::TestUnsupportedAccessoryUiNoteL ),
       
   225         ENTRY( "TestUpdateNotifierL", CAccFwUiNotifierTestModule::TestUpdateNotifierL ),
       
   226         ENTRY( "TestStartNotifierL", CAccFwUiNotifierTestModule::TestStartNotifierL ),
       
   227     
       
   228         
       
   229         //ADD NEW ENTRY HERE
       
   230         // [test cases entries] - Do not remove
       
   231 
       
   232         };
       
   233 
       
   234     const TInt count = sizeof( KFunctions ) / 
       
   235                         sizeof( TStifFunctionInfo );
       
   236 
       
   237     return RunInternalL( KFunctions, count, aItem );
       
   238 
       
   239     }
       
   240 
       
   241 
       
   242 TInt CAccFwUiNotifierTestModule::CreateNotifierPlugin(CStifItemParser& /*aItem */)
       
   243     {
       
   244     RDebug::Print(_L("CAccFwUiNotifierTestModule::CreatePlugin"));
       
   245     TUid accfwuinotifierUID = {0x10205060};
       
   246     iNotifierPlugin = reinterpret_cast < CAccFwUiNoteNotifier* >(REComSession::CreateImplementationL (accfwuinotifierUID, idtorID ) );
       
   247 
       
   248     STIF_ASSERT_NOT_NULL( iNotifierPlugin );
       
   249     RDebug::Print(_L("iNotifierPlugin = %x"),iNotifierPlugin);
       
   250         
       
   251     return KErrNone;
       
   252     
       
   253     }
       
   254 
       
   255 TInt CAccFwUiNotifierTestModule::TestSupportedAccessoryUiNoteL(CStifItemParser& /*aItem*/ )
       
   256     {
       
   257     RDebug::Print(_L("CAccFwUiNotifierTestModule::AccessoryUiNote"));
       
   258     RNotifier notifier;
       
   259     notifier.Connect();
       
   260     TInt selectionListBitmask = 255;
       
   261 
       
   262     TInt reply = 0;
       
   263     
       
   264     
       
   265     TPckg<TInt> replyPck( reply);
       
   266     
       
   267     TPckg<TUint32> selectionBitmaskPackage( selectionListBitmask);
       
   268     //activate active object
       
   269     TRequestStatus status;
       
   270     status = KRequestPending;
       
   271     
       
   272     //open ui
       
   273     
       
   274     notifier.StartNotifierAndGetResponse( status, KAccFwUiNoteNotifierUid, selectionBitmaskPackage, replyPck);
       
   275     User::WaitForRequest( status);
       
   276     
       
   277     notifier.Close();
       
   278 
       
   279     return KErrNone;
       
   280     }
       
   281 
       
   282 TInt CAccFwUiNotifierTestModule::TestUnsupportedAccessoryUiNoteL(CStifItemParser& /*aItem*/ )
       
   283     {
       
   284      RDebug::Print(_L("CAccFwUiNotifierTestModule::AccessoryUiNote"));
       
   285      RNotifier notifier;
       
   286      notifier.Connect();
       
   287      //TInt selectionListBitmask = 255;
       
   288 
       
   289      TInt reply = 0;
       
   290      
       
   291      
       
   292      TPckg<TInt> replyPck( reply);
       
   293 
       
   294      //activate active object
       
   295      TRequestStatus status;
       
   296      status = KRequestPending;
       
   297      
       
   298      //open ui
       
   299      
       
   300      notifier.StartNotifierAndGetResponse( status, KAccFwUiNoteNotifierUid, KNullDesC8, replyPck);
       
   301      User::WaitForRequest( status);
       
   302 
       
   303      notifier.Close();
       
   304 
       
   305     return KErrNone;
       
   306     }
       
   307 
       
   308 TInt CAccFwUiNotifierTestModule::TestUpdateNotifierL(CStifItemParser& /*aItem*/ )
       
   309     {
       
   310     RDebug::Print(_L("CAccFwUiNotifierTestModule::TestUpdateNotifierL"));
       
   311     RNotifier notifier;
       
   312     notifier.Connect();
       
   313     //TInt selectionListBitmask = 255;
       
   314     
       
   315     TInt reply = 0;
       
   316     
       
   317     
       
   318     TPckg<TInt> replyPck( reply);
       
   319     
       
   320     //activate active object
       
   321     TRequestStatus status;
       
   322     status = KRequestPending;
       
   323     
       
   324     //open ui
       
   325     
       
   326     notifier.StartNotifierAndGetResponse( status, KAccFwUiNoteNotifierUid, KNullDesC8, replyPck);
       
   327     User::WaitForRequest( status);
       
   328     
       
   329     TBuf8<1> answer;
       
   330     TInt err = notifier.UpdateNotifier(KAccFwUiNoteNotifierUid, KNullDesC8, answer);
       
   331     if (err)
       
   332         {
       
   333         TBuf<4> error;
       
   334         error.Zero();
       
   335         error.AppendNum(err);
       
   336         //CEikonEnv::InfoWinL(_L("Error:"), error);
       
   337         }
       
   338 
       
   339     User::WaitForRequest( status);
       
   340     
       
   341     notifier.Close();
       
   342 
       
   343     return KErrNone;
       
   344     }
       
   345 
       
   346 TInt CAccFwUiNotifierTestModule::TestStartNotifierL(CStifItemParser& /*aItem*/ )
       
   347     {
       
   348     RDebug::Print(_L("CAccFwUiNotifierTestModule::TestStart2L-enter"));
       
   349     const TInt KGeneralBufferLength = 32;
       
   350     
       
   351     TBuf8<KGeneralBufferLength> responseBuffer;
       
   352      
       
   353      RNotifier notifier;
       
   354      User::LeaveIfError( notifier.Connect() );
       
   355      
       
   356      //Call Info() function.
       
   357      notifier.StartNotifier( KAccFwUiNoteNotifierUid,KNullDesC8, responseBuffer);
       
   358      
       
   359      notifier.Close();
       
   360 
       
   361     
       
   362     return KErrNone;
       
   363     }
       
   364 
       
   365 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // LibEntryL is a polymorphic Dll entry point.
       
   369 // Returns: CScriptBase: New CScriptBase derived object
       
   370 // -----------------------------------------------------------------------------
       
   371 //
       
   372 EXPORT_C CScriptBase* LibEntryL( 
       
   373     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   374     {
       
   375 
       
   376     return ( CScriptBase* ) CAccFwUiNotifierTestModule::NewL( aTestModuleIf );
       
   377 
       
   378     }
       
   379 
       
   380 // End of File