mmsharing/mmshengine/tsrc/ut_engine/src/ut_musengsipprofilehandler.cpp
branchRCL_3
changeset 22 73a1feb507fb
parent 0 f0cf47e981f9
child 23 bc78a40cd63c
equal deleted inserted replaced
21:33a5d2bbf6fc 22:73a1feb507fb
    21 #include "mussipprofilehandler.h"
    21 #include "mussipprofilehandler.h"
    22 #include "musengstubs.h"
    22 #include "musengstubs.h"
    23 #include "musengtestdefs.h"
    23 #include "musengtestdefs.h"
    24 #include "sipprofilealrcontroller.h"
    24 #include "sipprofilealrcontroller.h"
    25 
    25 
    26 
       
    27 //  SYSTEM INCLUDES
    26 //  SYSTEM INCLUDES
    28 #include <sipprofile.h>
    27 #include <sipprofile.h>
    29 #include <digia/eunit/eunitmacros.h>
    28 #include <digia/eunit/eunitmacros.h>
    30 #include <uri8.h>
    29 #include <uri8.h>
    31 
    30 
    32 const TUint KSipProfileId( 1 );
    31 const TUint KSipProfileId( 1 );
    33 
    32 
    34 
       
    35 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    36 //
    34 //
    37 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    38 //
    36 //
    39 UT_CMusEngSipProfileHandler* UT_CMusEngSipProfileHandler::NewL()
    37 UT_CMusEngSipProfileHandler* UT_CMusEngSipProfileHandler::NewL()
    85     {
    83     {
    86     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
    84     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
    87     // It generates the test case table.
    85     // It generates the test case table.
    88     CEUnitTestSuiteClass::ConstructL();
    86     CEUnitTestSuiteClass::ConstructL();
    89     }
    87     }
    90     
    88 
    91 
    89 
    92 // -----------------------------------------------------------------------------
       
    93 // From MMusSipProfileUser
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 TBool UT_CMusEngSipProfileHandler::IsRoamingBetweenAPsAllowed()
       
    97     {
       
    98     return iRoamingBetweenAPsAllowed;
       
    99     }
       
   100     
       
   101    
       
   102 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
   103 //
    91 //
   104 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
   105 //
    93 //
   106 void UT_CMusEngSipProfileHandler::SetupL()
    94 void UT_CMusEngSipProfileHandler::SetupL()
   107     {
    95     {
   108     iProfileHandler = CMusSipProfileHandler::NewL( *this );
    96     iObserver = new( ELeave ) CMusEngObserverStub;
       
    97     iProfileHandler = CMusSipProfileHandler::NewL( *iObserver );
   109     }
    98     }
   110 
    99 
   111 
   100 
   112 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
   113 //
   102 //
   114 // -----------------------------------------------------------------------------
   103 // -----------------------------------------------------------------------------
   115 //
   104 //
   116 void UT_CMusEngSipProfileHandler::Teardown()
   105 void UT_CMusEngSipProfileHandler::Teardown()
   117     {
   106     {
   118     delete iProfileHandler;
   107     delete iProfileHandler;
   119     iRoamingBetweenAPsAllowed = EFalse;
   108     delete iObserver;
   120     }
   109     }
   121 
   110 
   122 
   111 
   123 
   112 
   124 // TEST CASES
   113 // TEST CASES
   125 
   114 
   126 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   127 //
   116 //
   128 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
   129 //
   118 //
   130 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_CreateSipProfileLL()
   119 void UT_CMusEngSipProfileHandler::UT_CreateSipProfileLL()
   131     {
   120     {
   132     // SIP profile ID zero
   121     // SIP profile ID zero
   133     iProfileHandler->CreateProfileL( 0 );
   122     iProfileHandler->CreateProfileL( 0 );
   134     EUNIT_ASSERT( iProfileHandler->iSipProfile != NULL )
   123     EUNIT_ASSERT( iProfileHandler->iSipProfile != NULL )
   135     EUNIT_ASSERT( iProfileHandler->iSipProfile == iProfileHandler->Profile() )
   124     EUNIT_ASSERT( iProfileHandler->iSipProfile == iProfileHandler->Profile() )
   146 
   135 
   147 // -----------------------------------------------------------------------------
   136 // -----------------------------------------------------------------------------
   148 //
   137 //
   149 // -----------------------------------------------------------------------------
   138 // -----------------------------------------------------------------------------
   150 //
   139 //
   151 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_ProfileIdL()
   140 void UT_CMusEngSipProfileHandler::UT_ProfileIdL()
   152     {
   141     {
   153     // SIP profile does not yet exist
   142     // SIP profile does not yet exist
   154     EUNIT_ASSERT_EQUALS( 0, iProfileHandler->ProfileId() )
   143     EUNIT_ASSERT_EQUALS( 0, iProfileHandler->ProfileId() )
   155     
   144     
   156     // SIP profile exists
   145     // SIP profile exists
   160 
   149 
   161 // -----------------------------------------------------------------------------
   150 // -----------------------------------------------------------------------------
   162 //
   151 //
   163 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   164 //
   153 //
   165 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_AlrEventL()
   154 void UT_CMusEngSipProfileHandler::UT_AlrEventL()
   166     {
   155     {
   167     const TUint32 KSnapId( 1 );
   156     const TUint32 KSnapId( 1 );
   168     const TUint32 KIapId( 1 );
   157     const TUint32 KIapId( 1 );
   169     
   158     
   170     // Event is other that EIapAvailable
   159     // Event is other that EIapAvailable
   227     EUNIT_ASSERT_EQUALS( 
   216     EUNIT_ASSERT_EQUALS( 
   228         KIapId, iProfileHandler->iProfileAlrController->iLastUsedIap )
   217         KIapId, iProfileHandler->iProfileAlrController->iLastUsedIap )
   229     iProfileHandler->iProfileAlrController->iLastUsedIap = 0;
   218     iProfileHandler->iProfileAlrController->iLastUsedIap = 0;
   230     
   219     
   231     // Event is EIapAvailable, SIP profile ID matches, roaming not allowed
   220     // Event is EIapAvailable, SIP profile ID matches, roaming not allowed
   232     iRoamingBetweenAPsAllowed = ETrue;
   221     iObserver->iRoamingBetweenAPsAllowed = ETrue;
   233     iProfileHandler->AlrEvent( 
   222     iProfileHandler->AlrEvent( 
   234         MSipProfileAlrObserver::EIapAvailable, 
   223         MSipProfileAlrObserver::EIapAvailable, 
   235         KSipProfileId, KSnapId, KIapId );
   224         KSipProfileId, KSnapId, KIapId );
   236     if ( !iProfileHandler->iProfileAlrController->iAllowMigrationCalled )
   225     if ( !iProfileHandler->iProfileAlrController->iAllowMigrationCalled )
   237         {
   226         {
   249 
   238 
   250 // -----------------------------------------------------------------------------
   239 // -----------------------------------------------------------------------------
   251 //
   240 //
   252 // -----------------------------------------------------------------------------
   241 // -----------------------------------------------------------------------------
   253 //
   242 //
   254 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_NullTestsL()
   243 void UT_CMusEngSipProfileHandler::UT_NullTestsL()
   255     {
   244     {
   256     // Dummies
   245     // Dummies
       
   246     
   257     CSIPTransactionBase transactionBase;
   247     CSIPTransactionBase transactionBase;
   258     CSIPServerTransaction serverTransaction;
   248     CSIPServerTransaction serverTransaction;
   259     CSIPDialog dialog;
   249     CSIPDialog dialog;
   260     CSIPClientTransaction clientTransaction;
   250     CSIPClientTransaction clientTransaction;
   261     CSIPDialogAssocBase dialogAssocBase;
   251     CSIPDialogAssocBase dialogAssocBase;
   262     CSIPRegistrationBinding registrationBinding;
   252     CSIPRegistrationBinding registrationBinding;
   263     CSIPRefresh refresh;
   253     CSIPRefresh refresh;
   264     
   254     
   265     // Tests
   255     // Tests
   266     iProfileHandler->ProfileRegistryEventOccurred( 0,
   256 
   267                                 MSIPProfileRegistryObserver::EProfileCreated );
       
   268     iProfileHandler->ProfileRegistryErrorOccurred( 0, 0 );
   257     iProfileHandler->ProfileRegistryErrorOccurred( 0, 0 );
   269     iProfileHandler->IncomingRequest( 0, NULL );
   258     iProfileHandler->IncomingRequest( 0, NULL );
   270     iProfileHandler->TimedOut( serverTransaction );
   259     iProfileHandler->TimedOut( serverTransaction );
   271     iProfileHandler->IncomingRequest( NULL );
   260     iProfileHandler->IncomingRequest( NULL );
   272     iProfileHandler->IncomingRequest( NULL, dialog );
   261     iProfileHandler->IncomingRequest( NULL, dialog );
   288 
   277 
   289 // -----------------------------------------------------------------------------
   278 // -----------------------------------------------------------------------------
   290 //
   279 //
   291 // -----------------------------------------------------------------------------
   280 // -----------------------------------------------------------------------------
   292 //
   281 //
   293 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_UserFromProfileLCL()
   282 void UT_CMusEngSipProfileHandler::UT_UserFromProfileLCL()
   294     {
   283     {
   295     iProfileHandler->CreateProfileL( KSipProfileId );
   284     iProfileHandler->CreateProfileL( KSipProfileId );
   296     CSIPProfile* profile = iProfileHandler->Profile();
   285     CSIPProfile* profile = iProfileHandler->Profile();
   297     delete profile->iArray;
   286     delete profile->iArray;
   298     profile->iArray = NULL;
   287     profile->iArray = NULL;
   311     EUNIT_ASSERT_EQUALS( KUserUri(), user->Uri().UriDes() )
   300     EUNIT_ASSERT_EQUALS( KUserUri(), user->Uri().UriDes() )
   312     
   301     
   313     CleanupStack::PopAndDestroy( user );
   302     CleanupStack::PopAndDestroy( user );
   314     }
   303     }
   315 
   304 
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 //
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 void UT_CMusEngSipProfileHandler::UT_IsRegisteredL()
       
   311     {
       
   312     EUNIT_ASSERT( !iProfileHandler->IsRegistered( ) )
       
   313     iProfileHandler->CreateProfileL( KSipProfileId );
       
   314     EUNIT_ASSERT( iProfileHandler->IsRegistered( ) )   
       
   315     }
       
   316 
       
   317 
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 // -----------------------------------------------------------------------------
       
   321 //
       
   322 void UT_CMusEngSipProfileHandler::UT_ProfileRegistryEventOccurredL()
       
   323     {    
       
   324     // No profile yet
       
   325     iProfileHandler->ProfileRegistryEventOccurred( 0,
       
   326                             MSIPProfileRegistryObserver::EProfileRegistered );
       
   327     EUNIT_ASSERT( iObserver->IsReseted() )
       
   328     
       
   329     // Create profile, but notify about registration of some other profile
       
   330     iProfileHandler->CreateProfileL( 1 );
       
   331     iProfileHandler->ProfileRegistryEventOccurred( 2,
       
   332                             MSIPProfileRegistryObserver::EProfileRegistered );
       
   333     EUNIT_ASSERT( iObserver->IsReseted() )
       
   334     
       
   335     // Normal case
       
   336     iProfileHandler->ProfileRegistryEventOccurred( 1,
       
   337                                 MSIPProfileRegistryObserver::EProfileRegistered );
       
   338     EUNIT_ASSERT( iObserver->iProfileRegisteredCalled )
       
   339     iObserver->Reset();
       
   340     
       
   341     // React exclusively to EProfileRegistered
       
   342     iProfileHandler->ProfileRegistryEventOccurred( 1,
       
   343                             MSIPProfileRegistryObserver::EProfileCreated );
       
   344     EUNIT_ASSERT( iObserver->IsReseted() )
       
   345     iProfileHandler->ProfileRegistryEventOccurred( 1,
       
   346                             MSIPProfileRegistryObserver::EProfileUpdated );
       
   347     EUNIT_ASSERT( iObserver->IsReseted() )
       
   348     iProfileHandler->ProfileRegistryEventOccurred( 1,
       
   349                             MSIPProfileRegistryObserver::EProfileDeregistered );
       
   350     EUNIT_ASSERT( iObserver->IsReseted() )
       
   351     iProfileHandler->ProfileRegistryEventOccurred( 1,
       
   352                             MSIPProfileRegistryObserver::EProfileDestroyed );
       
   353     EUNIT_ASSERT( iObserver->IsReseted() )
       
   354     }
       
   355 
       
   356 
   316 //  TEST TABLE
   357 //  TEST TABLE
   317 
   358 
   318 EUNIT_BEGIN_TEST_TABLE(
   359 EUNIT_BEGIN_TEST_TABLE(
   319     UT_CMusEngSipProfileHandler,
   360     UT_CMusEngSipProfileHandler,
   320     "UT_CMusEngSipProfileHandler",
   361     "UT_CMusEngSipProfileHandler",
   323 EUNIT_TEST(
   364 EUNIT_TEST(
   324     "CreateSipProfileL - test ",
   365     "CreateSipProfileL - test ",
   325     "CMusSipProfileHandler",
   366     "CMusSipProfileHandler",
   326     "CreateSipProfileL",
   367     "CreateSipProfileL",
   327     "FUNCTIONALITY",
   368     "FUNCTIONALITY",
   328     SetupL, UT_CMusEngSipProfileHandler_CreateSipProfileLL, Teardown)
   369     SetupL, UT_CreateSipProfileLL, Teardown)    
   329 
   370     
   330 EUNIT_TEST(
   371 EUNIT_TEST(
   331     "ProfileId - test ",
   372     "ProfileId - test ",
   332     "CMusSipProfileHandler",
   373     "CMusSipProfileHandler",
   333     "ProfileId",
   374     "ProfileId",
   334     "FUNCTIONALITY",
   375     "FUNCTIONALITY",
   335     SetupL, UT_CMusEngSipProfileHandler_ProfileIdL, Teardown)
   376     SetupL, UT_ProfileIdL, Teardown)
   336     
   377     
   337 EUNIT_TEST(
   378 EUNIT_TEST(
   338     "AlrEventL - test ",
   379     "AlrEventL - test ",
   339     "CMusEngSipProfileHandler",
   380     "CMusEngSipProfileHandler",
   340     "AlrEventL",
   381     "AlrEventL",
   341     "FUNCTIONALITY",
   382     "FUNCTIONALITY",
   342     SetupL, UT_CMusEngSipProfileHandler_AlrEventL, Teardown)
   383     SetupL, UT_AlrEventL, Teardown)
   343 
   384     
   344 EUNIT_TEST(
   385 EUNIT_TEST(
   345     "Null tests for NOP functions",
   386     "Null tests for NOP functions",
   346     "CMusEngSipProfileHandler",
   387     "CMusEngSipProfileHandler",
   347     "Several NOP functions",
   388     "Several NOP functions",
   348     "FUNCTIONALITY",
   389     "FUNCTIONALITY",
   349     SetupL, UT_CMusEngSipProfileHandler_NullTestsL, Teardown)
   390     SetupL, UT_NullTestsL, Teardown)
   350 
   391 
   351 EUNIT_TEST(
   392 EUNIT_TEST(
   352     "UserFromProfileLC - test ",
   393     "UserFromProfileLC - test ",
   353     "CMusEngOutSession",
   394     "CMusEngSipProfileHandler",
   354     "UserFromProfileLC",
   395     "UserFromProfileLC",
   355     "FUNCTIONALITY",
   396     "FUNCTIONALITY",
   356     SetupL, UT_CMusEngSipProfileHandler_UserFromProfileLCL, Teardown)
   397     SetupL, UT_UserFromProfileLCL, Teardown)
   357         
   398 
       
   399 EUNIT_TEST(
       
   400     "IsRegistered - test ",
       
   401     "CMusEngSipProfileHandler",
       
   402     "IsRegistered",
       
   403     "FUNCTIONALITY",
       
   404     SetupL, UT_IsRegisteredL, Teardown)
       
   405 
       
   406 EUNIT_TEST(
       
   407     "ProfileRegistryEventOccurred - test ",
       
   408     "CMusEngSipProfileHandler",
       
   409     "ProfileRegistryEventOccurred",
       
   410     "FUNCTIONALITY",
       
   411     SetupL, UT_ProfileRegistryEventOccurredL, Teardown)    
       
   412     
   358 EUNIT_END_TEST_TABLE
   413 EUNIT_END_TEST_TABLE
   359 
   414 
   360 //  END OF FILE
   415 //  END OF FILE
   361 
   416 
   362 
   417