mmshplugins/mmshaoplugin/tsrc/ut_aoplugin/src/ut_musaoplugin.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
    26 
    26 
    27 
    27 
    28 #include <alwaysonlinemanagercommon.h>
    28 #include <alwaysonlinemanagercommon.h>
    29 #include <alwaysonlinemanagerclient.h>
    29 #include <alwaysonlinemanagerclient.h>
    30 #include <digia/eunit/eunitmacros.h>
    30 #include <digia/eunit/eunitmacros.h>
    31 #include <digia/eunit/eunitdecorators.h>
    31 #include "FeatMgr.h"
       
    32 
       
    33 
    32 
    34 
    33 #pragma warn_illtokenpasting off
    35 #pragma warn_illtokenpasting off
    34 
    36 
    35 _LIT( KEmptyTelNumber, "");
    37 _LIT( KEmptyTelNumber, "");
    36 _LIT( KEmptyProviderName, "");
       
    37 
       
    38 _LIT(KTestTelNumber,"+3585050");
       
    39 
    38 
    40 
    39 
    41 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    42 // Symbian two-phase constructor.
    41 // Symbian two-phase constructor.
    43 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
   100 void UT_CMusAoPlugin::Teardown(  )
    99 void UT_CMusAoPlugin::Teardown(  )
   101     {
   100     {
   102     delete iPlugin;
   101     delete iPlugin;
   103     iPlugin = NULL ;
   102     iPlugin = NULL ;
   104     PropertyHelper::Close();
   103     PropertyHelper::Close();
   105     }
   104     
   106 
   105     }
       
   106 	
       
   107 	
       
   108 //// -----------------------------------------------------------------------------
       
   109 ////
       
   110 //// -----------------------------------------------------------------------------
       
   111 //// 
       
   112 void UT_CMusAoPlugin::NewLL()
       
   113 	{
       
   114 	
       
   115     TInt res = KErrNone;
       
   116     TInt ret = KErrNone;
       
   117 	FeatureManager::MultimediaSharingNotSupported();
       
   118 	iPlugin->DeleteProperties();
       
   119     delete iPlugin;
       
   120     iPlugin = NULL ;
       
   121 	iPlugin = CMusAoPlugin::NewL(); 
       
   122 	EUNIT_ASSERT( iPlugin );
       
   123     EUNIT_ASSERT( iPlugin->iTsyPropertyMonitor == NULL);
       
   124     EUNIT_ASSERT( iPlugin->iPropertyMonitor == NULL);
       
   125     // camera information property
       
   126     ret = RProperty::Get( NMusResourceApi::KCategoryUid,
       
   127             NMusResourceApi::KCameraInformation,
       
   128                           res );
       
   129     EUNIT_ASSERT_EQUALS( ret, KErrNotFound )
       
   130     ret = KErrNone;
       
   131 
       
   132     // call event
       
   133     ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   134                           NMusSessionInformationApi::KMusCallEvent,
       
   135                           res );
       
   136     EUNIT_ASSERT_EQUALS( ret, KErrNotFound )
       
   137     ret = KErrNone;
       
   138     
       
   139     // phone number
       
   140     TBuf<15> telnumber; // TODO change to des
       
   141     User::LeaveIfError( RProperty::Get(
       
   142                             NMusSessionInformationApi::KCategoryUid,
       
   143                             NMusSessionInformationApi::KMusTelNumber,
       
   144                             telnumber ) );
       
   145     EUNIT_ASSERT_EQUALS( telnumber.Compare( KEmptyTelNumber ), KErrNone )
       
   146     
       
   147     // Mus allowed
       
   148     ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   149                           NMusSessionInformationApi::KMUSForbidden,
       
   150                           res );
       
   151     EUNIT_ASSERT_EQUALS( ret, KErrNotFound )
       
   152     ret = KErrNone;
       
   153 
       
   154     // Call direction
       
   155     ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   156                           NMusSessionInformationApi::KMusCallDirection,
       
   157                           res );
       
   158     EUNIT_ASSERT_EQUALS( ret, KErrNotFound )
       
   159     FeatureManager::MultimediaSharingSupported();
       
   160 	}
   107 
   161 
   108 // -----------------------------------------------------------------------------
   162 // -----------------------------------------------------------------------------
   109 //
   163 //
   110 // -----------------------------------------------------------------------------
   164 // -----------------------------------------------------------------------------
   111 // 
   165 // 
   112 void UT_CMusAoPlugin::DefinePropertiesLL()
   166 void UT_CMusAoPlugin::DefinePropertiesLL()
   113     {
   167     {
   114 /* Test 1 */
   168 /* Test 1 */  
   115     TInt res = KErrNone;
       
   116     TInt err = KErrNone;   
       
   117     /* Set Product Mode variation key value to
   169     /* Set Product Mode variation key value to
   118        00 - VideoPlayer always available
   170        00 - VideoPlayer always available
   119        0-Keypad available dynamic
   171        0-Keypad available dynamic
   120        00-Keypad Usuable in portrait
   172        00-Keypad Usuable in portrait
   121        0-Camera available static
   173        0-Camera available static
   126     MultimediaSharingSettings::SetPropertyValueL(
   178     MultimediaSharingSettings::SetPropertyValueL(
   127     						MusSettingsKeys::KProductModeVariation,keyValue);     						    
   179     						MusSettingsKeys::KProductModeVariation,keyValue);     						    
   128     iPlugin->DefinePropertiesL();
   180     iPlugin->DefinePropertiesL();
   129     // It should not configure any PS keys for camera
   181     // It should not configure any PS keys for camera
   130     // Check the stub whether define is called.   
   182     // Check the stub whether define is called.   
   131     err = RProperty::Get( NMusResourceApi::KCategoryUid,
   183     TInt err = RProperty::Get( NMusResourceApi::KCategoryUid,
   132                     NMusResourceApi::KCameraAvailability,
   184                     NMusResourceApi::KCameraAvailability,
   133                     keyValue );
   185                     keyValue );
   134     EUNIT_ASSERT(keyValue == KErrNotFound );
   186     EUNIT_ASSERT(keyValue == KErrNotFound );
   135     // Keypad availability is static . 
   187     // Keypad availability is static . 
   136     // Check the stub whether define is called. 
   188     // Check the stub whether define is called. 
   176     
   228     
   177  /* Test 3 */
   229  /* Test 3 */
   178 
   230 
   179     iPlugin->DefinePropertiesL();                       
   231     iPlugin->DefinePropertiesL();                       
   180 
   232 
   181     res = KErrNone;
       
   182     // camera information property
   233     // camera information property
   183     res = RProperty::Get( NMusResourceApi::KCategoryUid,
   234     TInt res = RProperty::Get( NMusResourceApi::KCategoryUid,
   184                                         NMusResourceApi::KCameraInformation,
   235                                         NMusResourceApi::KCameraInformation,
   185                                         keyValue );
   236                                         keyValue );
   186     EUNIT_ASSERT_EQUALS( keyValue, NMusResourceApi::EUsePrimaryCamera )    
   237     EUNIT_ASSERT_EQUALS( keyValue, NMusResourceApi::EUsePrimaryCamera )    
   187     
   238     
   188     // call event
   239     // call event
   197                             NMusSessionInformationApi::KCategoryUid,
   248                             NMusSessionInformationApi::KCategoryUid,
   198                             NMusSessionInformationApi::KMusTelNumber,
   249                             NMusSessionInformationApi::KMusTelNumber,
   199                             telnumber ) );
   250                             telnumber ) );
   200     EUNIT_ASSERT_EQUALS( telnumber.Compare( KEmptyTelNumber ), KErrNone )
   251     EUNIT_ASSERT_EQUALS( telnumber.Compare( KEmptyTelNumber ), KErrNone )
   201 
   252 
   202     // callprovider
       
   203     TBuf<15> callprovider;
       
   204     User::LeaveIfError( RProperty::Get(
       
   205                             NMusSessionInformationApi::KCategoryUid,
       
   206                             NMusSessionInformationApi::KMUSCallProvider,
       
   207                             callprovider ) );
       
   208     EUNIT_ASSERT_EQUALS( callprovider.Compare( KEmptyProviderName ), KErrNone )
       
   209 
       
   210     
       
   211     
       
   212     
       
   213     // Mus allowed
   253     // Mus allowed
   214     RProperty::Get(NMusSessionInformationApi::KCategoryUid,
   254     RProperty::Get(NMusSessionInformationApi::KCategoryUid,
   215                    NMusSessionInformationApi::KMUSForbidden,
   255                    NMusSessionInformationApi::KMUSForbidden,
   216                    keyValue ) ;
   256                    keyValue ) ;
   217     EUNIT_ASSERT_EQUALS( keyValue, NMusSessionInformationApi::EMUSAllowed )    
   257     EUNIT_ASSERT_EQUALS( keyValue, NMusSessionInformationApi::EMUSAllowed )    
   360     // Call direction
   400     // Call direction
   361     ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
   401     ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
   362                           NMusSessionInformationApi::KMusCallDirection,
   402                           NMusSessionInformationApi::KMusCallDirection,
   363                           res );
   403                           res );
   364     EUNIT_ASSERT_EQUALS( ret, KErrNotFound )
   404     EUNIT_ASSERT_EQUALS( ret, KErrNotFound )
       
   405     
       
   406     // Call privacy
       
   407     ret = RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   408                           NMusSessionInformationApi::KMUSPrivacy,
       
   409                           res );
       
   410     EUNIT_ASSERT_EQUALS( ret, KErrNotFound )
       
   411 
   365 
   412 
   366     }
   413     }
   367 
   414 
   368 
   415 
   369 // -----------------------------------------------------------------------------
   416 // -----------------------------------------------------------------------------
   374     {
   421     {
   375     TAny* a = iPlugin->HandleServerCommandL( EAOManagerPluginStart, NULL );
   422     TAny* a = iPlugin->HandleServerCommandL( EAOManagerPluginStart, NULL );
   376     EUNIT_ASSERT( a )
   423     EUNIT_ASSERT( a )
   377     }
   424     }
   378 
   425 
   379 
       
   380 
       
   381 // -----------------------------------------------------------------------------
       
   382 // Test Starting MushClient
       
   383 // -----------------------------------------------------------------------------
       
   384 // 
       
   385 
       
   386 void UT_CMusAoPlugin::UT_StartMusClientL()
       
   387     {
       
   388     // Ensure MushAO Plugin Exisit
       
   389     EUNIT_ASSERT( iPlugin);
       
   390     // Mush Manager Client process is not Created
       
   391     EUNIT_ASSERT( !iPlugin->iManager );
       
   392     
       
   393     // Test1: Ensure Start really creates the MushClient process
       
   394     iPlugin->StartMusClientL();
       
   395     EUNIT_ASSERT( iPlugin->iManager );
       
   396     
       
   397     // Test2: Trying to Create Client process again if it already exisit.
       
   398     iPlugin->StartMusClientL();
       
   399     EUNIT_ASSERT( iPlugin->iManager );
       
   400     
       
   401     //Reset Plugin Data.
       
   402     iPlugin->StopMusClient();
       
   403     }
       
   404 
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // Test Starting MushClient
       
   408 // -----------------------------------------------------------------------------
       
   409 // 
       
   410 
       
   411 void UT_CMusAoPlugin::UT_StopMusClientL()
       
   412     {
       
   413     EUNIT_ASSERT( iPlugin);
       
   414     EUNIT_ASSERT( !iPlugin->iManager );
       
   415     
       
   416     // Test1: Deleteing Mush Cient when it does not exisit
       
   417     iPlugin->StopMusClient();
       
   418     EUNIT_ASSERT( !iPlugin->iManager );
       
   419 
       
   420     // Create Mush Client process
       
   421     iPlugin->StartMusClientL();
       
   422     EUNIT_ASSERT( iPlugin->iManager );
       
   423     
       
   424     // Test2: Deleting Mush Client when it Exisit.
       
   425     iPlugin->StopMusClient();
       
   426     EUNIT_ASSERT( !iPlugin->iManager );
       
   427     }
       
   428 
       
   429 
       
   430 // -----------------------------------------------------------------------------
       
   431 // From MMusCallStateObserver
       
   432 // Test MushCall State Changed
       
   433 // -----------------------------------------------------------------------------
       
   434 // 
       
   435 
       
   436 void UT_CMusAoPlugin::UT_MusCallStateChangedL()
       
   437     {
       
   438     TName cs_call_1(_L("cs_call_1"));
       
   439 
       
   440     // Test 1: Data Ready: Call Connected: -> Start Mush 
       
   441     
       
   442     // Add Some dummy CS Call
       
   443     // Set Call Connected:
       
   444     // Set the Required Data.
       
   445     iPlugin->iTsyPropertyMonitor->AddCallMonitorL( cs_call_1);
       
   446 
       
   447     User::LeaveIfError(RProperty::Set( 
       
   448                                NMusSessionInformationApi::KCategoryUid,
       
   449                                NMusSessionInformationApi::KMusCallEvent,
       
   450                                NMusSessionInformationApi::ECallConnected ));
       
   451     
       
   452     User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   453                                             NMusSessionInformationApi::KMusTelNumber,
       
   454                                             KTestTelNumber ));
       
   455 
       
   456     User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   457                                             NMusSessionInformationApi::KMusCallDirection,
       
   458                                             NMusSessionInformationApi::ECallOrginated ));
       
   459 
       
   460     // This can not be tested easily wit M-ALLOC 
       
   461     EUNIT_DISABLE_ALLOC_DECORATOR;
       
   462     iPlugin->MusCallStateChanged();
       
   463     
       
   464     EUNIT_ASSERT( iPlugin->iManager )
       
   465     EUNIT_ENABLE_ALLOC_DECORATOR;
       
   466     
       
   467     // Test 2: Data Not Ready: Call Connected: -> Stop Mush
       
   468     User::LeaveIfError(RProperty::Set( 
       
   469                                NMusSessionInformationApi::KCategoryUid,
       
   470                                NMusSessionInformationApi::KMusCallEvent,
       
   471                                NMusSessionInformationApi::ENoCall ));
       
   472     
       
   473     iPlugin->MusCallStateChanged();
       
   474     EUNIT_ASSERT( !iPlugin->iManager )
       
   475     }
       
   476 
   426 
   477 //  TEST TABLE
   427 //  TEST TABLE
   478 
   428 
   479 EUNIT_BEGIN_TEST_TABLE(
   429 EUNIT_BEGIN_TEST_TABLE(
   480     UT_CMusAoPlugin,
   430     UT_CMusAoPlugin,
   481     "UT_CMusAoPlugin",
   431     "UT_CMusAoPlugin",
   482     "UNIT")
   432     "UNIT")
   483 
   433 
   484 EUNIT_TEST(
   434 EUNIT_TEST(
       
   435     "UT_NewLL",
       
   436     "CMusAoPlugin",
       
   437     "NewL",
       
   438     "FUNCTIONALITY",
       
   439     SetupL, NewLL, Teardown)
       
   440         
       
   441 EUNIT_TEST(
   485     "DefinePropertiesLL",
   442     "DefinePropertiesLL",
   486     "CMusAoPlugin",
   443     "CMusAoPlugin",
   487     "DefinePropertiesL",
   444     "DefinePropertiesL",
   488     "FUNCTIONALITY",
   445     "FUNCTIONALITY",
   489     SetupL, DefinePropertiesLL, Teardown)
   446     SetupL, DefinePropertiesLL, Teardown)
   507     "CMusAoPlugin",
   464     "CMusAoPlugin",
   508     "DeleteProperties",
   465     "DeleteProperties",
   509     "FUNCTIONALITY",
   466     "FUNCTIONALITY",
   510     SetupL, DeletePropertiesL, Teardown)
   467     SetupL, DeletePropertiesL, Teardown)
   511     
   468     
       
   469     
       
   470 
   512 EUNIT_TEST(
   471 EUNIT_TEST(
   513     "HandleServerCommandL",
   472     "HandleServerCommandL",
   514     "CMusAoPlugin",
   473     "CMusAoPlugin",
   515     "HandleServerCommandL",
   474     "HandleServerCommandL",
   516     "FUNCTIONALITY",
   475     "FUNCTIONALITY",
   517     SetupL, UT_HandleServerCommandLL, Teardown)
   476     SetupL, UT_HandleServerCommandLL, Teardown)
   518 
   477 
   519 EUNIT_TEST(
   478 
   520     "StartMusClient",
       
   521     "CMusAoPlugin",
       
   522     "StartMusClient",
       
   523     "FUNCTIONALITY",
       
   524     SetupL, UT_StartMusClientL, Teardown)
       
   525 
       
   526 EUNIT_TEST(
       
   527     "StopMusClient",
       
   528     "CMusAoPlugin",
       
   529     "StopMusClient",
       
   530     "FUNCTIONALITY",
       
   531     SetupL, UT_StopMusClientL, Teardown)
       
   532     
       
   533 EUNIT_TEST(
       
   534     "MusCallStateChanged",
       
   535     "CMusAoPlugin",
       
   536     "MusCallStateChanged",
       
   537     "FUNCTIONALITY",
       
   538     SetupL, UT_MusCallStateChangedL, Teardown)
       
   539     
       
   540     
       
   541 EUNIT_END_TEST_TABLE
   479 EUNIT_END_TEST_TABLE
       
   480 
       
   481 
       
   482 
       
   483 
       
   484 
       
   485 
       
   486