mmsharing/mmshengine/tsrc/ut_engine/src/ut_musengmcesession.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
    26 #include "musengclipsession.h"
    26 #include "musengclipsession.h"
    27 #include "musengreceivesession.h"
    27 #include "musengreceivesession.h"
    28 #include "musengsessiondurationtimer.h"
    28 #include "musengsessiondurationtimer.h"
    29 #include "musengtelephoneutils.h"
    29 #include "musengtelephoneutils.h"
    30 #include "musengmceutils.h"
    30 #include "musengmceutils.h"
    31 #include "mussessionproperties.h"
       
    32 #include "contactenginestub.h"
       
    33 #include "musenglivevideoplayer.h"
       
    34 
    31 
    35 //  SYSTEM INCLUDES
    32 //  SYSTEM INCLUDES
    36 #include <lcsourcefilecontrol.h>
    33 
    37 #include <digia/eunit/eunitmacros.h>
    34 #include <digia/eunit/eunitmacros.h>
    38 #include <mceinsession.h>
    35 #include <mceinsession.h>
    39 #include <mcevideostream.h>
    36 #include <mcevideostream.h>
    40 #include <mcedisplaysink.h>
    37 #include <mcedisplaysink.h>
    41 #include <mcertpsource.h>
    38 #include <mcertpsource.h>
    43 #include <mceaudiostream.h>
    40 #include <mceaudiostream.h>
    44 #include <mcertpsink.h>
    41 #include <mcertpsink.h>
    45 #include <mcevideocodec.h>
    42 #include <mcevideocodec.h>
    46 #include <mceaudiocodec.h>
    43 #include <mceaudiocodec.h>
    47 #include <audiopreference.h>
    44 #include <audiopreference.h>
       
    45 #include <mceh263codec.h>
    48 #include <mceavccodec.h>
    46 #include <mceavccodec.h>
    49 #include <mceh263codec.h>
    47 
    50 #include <mcecamerasource.h>
       
    51 #include <mcefilesource.h>
       
    52 #include <telmicmutestatuspskeys.h>
       
    53 
       
    54 // CONSTANTS
       
    55 
       
    56 _LIT8( KMusAvcBitrateLevel1TestText, "TestTextForAvcBrL1Level" );
       
    57 _LIT8( KMusAvcBitrateLevel1bTestText, "TestTextForAvcBrL1bLevel" );
       
    58 _LIT8( KMusAvcBitrateLevel1_1TestText, "TestTextForAvcBrL1_1Level" );
       
    59 _LIT8( KMusAvcBitrateLevel1_2TestText, "TestTextForAvcBrL1_2Level" );
       
    60 _LIT8( KMusAvcBitrateLevel1_3TestText, "TestTextForAvcBrL1_3Level" );
       
    61 _LIT8( KMusAvcBitrateLevel2TestText, "TestTextForAvcBrL2Level" );
       
    62 
       
    63 _LIT8( KMusAvcBitrateLevel_1b_ConfigKey, "AvcBrL1b=TestTextForAvcBrL1bLevel;" );
       
    64 
       
    65 _LIT8( KMusAvcBitrateLevel_1_1_ConfigKey, 
       
    66 "AvcBrL1_1=TestTextForAvcBrL1_1Level;");
       
    67 
       
    68 _LIT8( KMusAvcBitrateLevels_1_1_And_1b_ConfigKeys, 
       
    69 "AvcBrL1_1=TestTextForAvcBrL1_1Level;\
       
    70 AvcBrL1b=TestTextForAvcBrL1bLevel;" );
       
    71 
       
    72 _LIT8( KMusAvcAllLevelsConcatenation,
       
    73 "AvcBrL1=TestTextForAvcBrL1Level;\
       
    74 AvcBrL1b=TestTextForAvcBrL1bLevel;\
       
    75 AvcBrL1_1=TestTextForAvcBrL1_1Level;\
       
    76 AvcBrL1_2=TestTextForAvcBrL1_2Level;\
       
    77 AvcBrL1_3=TestTextForAvcBrL1_3Level;\
       
    78 AvcBrL2=TestTextForAvcBrL2Level;" );
       
    79 
    48 
    80 
    49 
    81 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    82 //
    51 //
    83 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
   139 //
   108 //
   140 // -----------------------------------------------------------------------------
   109 // -----------------------------------------------------------------------------
   141 //
   110 //
   142 void UT_CMusEngMceSession::SetupL(  )
   111 void UT_CMusEngMceSession::SetupL(  )
   143     {
   112     {
   144     iLcSessionObserver = new( ELeave )CLcSessionObserverStub;
   113     iObserver = new( ELeave ) CMusEngObserverStub;
   145     iLcUiProvider = new( ELeave )CLcUiProviderStub;
   114     iLiveSession = CMusEngLiveSession::NewL( KNullDesC,
   146 
   115                                              TRect(0,0, 100,100),
   147     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
   116                                              *iObserver,
   148                                         NMusSessionApi::KRemoteSipAddress,
   117                                              *iObserver,
   149                                         KTestRecipientSipUri ) );    
   118                                              *iObserver );
   150     
   119     
   151     iLiveSession = CMusEngLiveSession::NewL();
   120     iSomeOtherSession = CMusEngLiveSession::NewL( KNullDesC,
   152     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
   121                                                   TRect(0,0, 100,100),
   153     iLiveSession->SetLcUiProvider( iLcUiProvider );    
   122                                                   *iObserver,
   154     
   123                                                   *iObserver,
   155     iSomeOtherSession = CMusEngLiveSession::NewL();
   124                                                   *iObserver );
   156     iSomeOtherSession->SetLcSessionObserver( iLcSessionObserver );
       
   157     iSomeOtherSession->SetLcUiProvider( iLcUiProvider );
       
   158     
       
   159     ESTABLISH_OUT_SESSION( iSomeOtherSession );
   125     ESTABLISH_OUT_SESSION( iSomeOtherSession );
   160    
   126     
   161     iClipSession = CMusEngClipSession::NewL();
   127     iClipSession = CMusEngClipSession::NewL( TRect(0,0, 100,100),
   162     iClipSession->SetLcSessionObserver( iLcSessionObserver );
   128                                              *iObserver,
   163     iClipSession->SetLcUiProvider( iLcUiProvider );
   129                                              *iObserver,
   164     MLcSourceFileControl* sourceFileControl =
   130                                              *iObserver );                                             
   165         iClipSession->LocalVideoPlayer()->LcSourceFileControl();
   131     iClipSession->SetClipL( KTestVideoFileName() );
   166     sourceFileControl->SetLcFileNameL( KTestAvcVideoFileName() );
   132 
   167 
   133     TBuf<50> videoCodec;
   168     delete iClipSession->iVideoCodecList;
   134     videoCodec.Copy( KMceSDPNameH264() );
   169     iClipSession->iVideoCodecList = NULL;
   135     iClipSession->SetSupportedVideoCodecListL(videoCodec);
   170     iClipSession->iVideoCodecList = KMceSDPNameH264().AllocL();
       
   171     
   136     
   172     // Construct and establish an incoming session
   137     // Construct and establish an incoming session
   173     iReceiveSession = CMusEngReceiveSession::NewL();
   138     iReceiveSession = CMusEngReceiveSession::NewL( TRect(0,0, 100,100), 
   174     iReceiveSession->SetLcSessionObserver( iLcSessionObserver ); 
   139                                                    *iObserver,
       
   140                                                    *iObserver );
   175     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
   141     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
   176                                                     KTestOriginator() );
   142                                                     KTestOriginator() );
   177                                                     
   143                                                     
   178     CMceVideoStream* videoStream = CMceVideoStream::NewLC();
   144     CMceVideoStream* videoStream = CMceVideoStream::NewLC();
   179     
   145     
   185                                                     
   151                                                     
   186     iReceiveSession->iManager->iInSessionObserver->IncomingSession( 
   152     iReceiveSession->iManager->iInSessionObserver->IncomingSession( 
   187                                                         inSession, 
   153                                                         inSession, 
   188                                                         &iContainer );
   154                                                         &iContainer );
   189     iReceiveSession->iSession->iState = CMceSession::EProceeding;
   155     iReceiveSession->iSession->iState = CMceSession::EProceeding;
   190     iReceiveSession->EstablishLcSessionL();
   156     iReceiveSession->AcceptInvitationL( ETrue );
   191    
   157     
   192     iLcSessionObserver->Reset();
   158     iObserver->Reset();
   193     }
   159     }
       
   160 
   194 
   161 
   195 // -----------------------------------------------------------------------------
   162 // -----------------------------------------------------------------------------
   196 //
   163 //
   197 // -----------------------------------------------------------------------------
   164 // -----------------------------------------------------------------------------
   198 //
   165 //
   199 void UT_CMusEngMceSession::Teardown(  )
   166 void UT_CMusEngMceSession::Teardown(  )
   200     {
   167     {
   201     delete iLiveSession;
   168     delete iLiveSession;
   202     delete iClipSession;
   169     delete iClipSession;
   203     delete iReceiveSession;
   170     delete iReceiveSession;
   204     delete iLcSessionObserver;
   171     delete iObserver;
   205     delete iLcUiProvider;
       
   206     delete iSomeOtherSession;
   172     delete iSomeOtherSession;
   207     PropertyHelper::Close();
   173     
   208     // Delete static data from CenRep stub
       
   209     CRepository::iStaticWriteAvcKeysToStaticData = EFalse;
       
   210     CRepository::DeleteStubAvcConfigKeys();
       
   211     CRepository::ResetStubGlobal();
       
   212     CRepository::iForceFailWithCode = KErrNone;
       
   213     }
   174     }
   214 
   175 
   215 
   176 
   216 
   177 
   217 // TEST CASES
   178 // TEST CASES
   218 
   179 
   219 // -----------------------------------------------------------------------------
   180 
   220 //
   181 // -----------------------------------------------------------------------------
   221 // -----------------------------------------------------------------------------
   182 //
   222 //
   183 // -----------------------------------------------------------------------------
   223 void UT_CMusEngMceSession::UT_LcSessionStateL()
   184 //
   224     {
   185 void UT_CMusEngMceSession::UT_CMusEngMceSession_TerminateLL()
   225     // No MCE session -> MLcSession::EUninitialized
   186     {
   226     EUNIT_ASSERT_EQUALS( MLcSession::EUninitialized, 
   187     TRAPD( error, iLiveSession->TerminateL() );
   227                          iLiveSession->LcSessionState() )
   188     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
   228                          
   189     EUNIT_ASSERT( error == KErrNotReady );
   229     // MLcSession::EOpen
   190     
   230     ESTABLISH_OUT_SESSION( iLiveSession )
   191     ESTABLISH_OUT_SESSION( iLiveSession );
   231     EUNIT_ASSERT_EQUALS( TInt( CMceSession::EEstablished ),
   192     
   232                          TInt( iLiveSession->iSession->iState ) )  
   193     EUNIT_ASSERT( iLiveSession->iSession->iState == CMceSession::EEstablished );
   233     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EOpen ), 
   194     
   234                          TInt( iLiveSession->LcSessionState() ) )
   195     iLiveSession->TerminateL();
   235 
   196     
   236     // MLcSession::EInitialized
   197     EUNIT_ASSERT( iLiveSession->iSession->iState == CMceSession::ETerminating );
   237     iLiveSession->iSession->iState = CMceSession::EIdle;
   198     
   238     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EInitialized ), 
   199     }
   239                          TInt( iLiveSession->LcSessionState() ) )
   200 
   240 
       
   241     // MLcSession::EReceived
       
   242     iLiveSession->iSession->iState = CMceSession::EIncoming;
       
   243     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EReceived ),
       
   244                          TInt( iLiveSession->LcSessionState() ) )
       
   245 
       
   246     iLiveSession->iSession->iState = CMceSession::EProceeding; 
       
   247     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EReceived ), 
       
   248                          TInt( iLiveSession->LcSessionState() ) )
       
   249     
       
   250     iLiveSession->iSession->iState = CMceSession::EReserving; 
       
   251     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EReceived ), 
       
   252                          TInt( iLiveSession->LcSessionState() ) )   
       
   253     
       
   254     // MLcSession::EOpening
       
   255     iLiveSession->iSession->iState = CMceSession::EOffering;
       
   256     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EOpening ), 
       
   257                          TInt( iLiveSession->LcSessionState() ) )
       
   258     
       
   259     iLiveSession->iSession->iState = CMceSession::EAnswering;
       
   260     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EOpening ), 
       
   261                          TInt( iLiveSession->LcSessionState() ) )
       
   262 
       
   263     // MLcSession::EClosing
       
   264     iLiveSession->iSession->iState = CMceSession::ECancelling; 
       
   265     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EClosing ), 
       
   266                          TInt( iLiveSession->LcSessionState() ) )
       
   267     
       
   268     iLiveSession->iSession->iState = CMceSession::ETerminating; 
       
   269     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EClosing ), 
       
   270                          TInt( iLiveSession->LcSessionState() ) )
       
   271     
       
   272     // MLcSession::EClosed
       
   273     iLiveSession->iSession->iState = CMceSession::ETerminated;
       
   274     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EClosed ), 
       
   275                          TInt( iLiveSession->LcSessionState() ) )   
       
   276     }
       
   277 
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 void UT_CMusEngMceSession::UT_RemoteVideoPlayerL()
       
   283     {
       
   284     EUNIT_ASSERT( iLiveSession->CMusEngMceSession::RemoteVideoPlayer() == NULL )
       
   285     }
       
   286 
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 void UT_CMusEngMceSession::UT_LocalVideoPlayerL()
       
   292     {
       
   293     EUNIT_ASSERT( iLiveSession->CMusEngMceSession::LocalVideoPlayer() == NULL )
       
   294     }
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 void UT_CMusEngMceSession::UT_LocalDisplayNameL()
       
   301     {
       
   302     EUNIT_ASSERT_EQUALS( KNullDesC(), iLiveSession->LocalDisplayName() )
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 // -----------------------------------------------------------------------------
       
   308 //
       
   309 void UT_CMusEngMceSession::UT_RemoteDisplayNameL()
       
   310     {
       
   311     // Clear the thread common storage to ensrue its not polluted. 
       
   312     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
   313                                    NMusSessionApi::KContactName,
       
   314                                    KNullDesC) );
       
   315     
       
   316     EUNIT_ASSERT_EQUALS( KNullDesC(), iLiveSession->RemoteDisplayName() )
       
   317     }
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 void UT_CMusEngMceSession::UT_RemoteDetailsL()
       
   324     {
       
   325     // Clear the thread common storage to ensrue its not polluted. 
       
   326     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
   327                                    NMusSessionApi::KTelNumber,
       
   328                                    KNullDesC) );
       
   329     
       
   330     EUNIT_ASSERT_EQUALS( KNullDesC(), iLiveSession->RemoteDetails() )
       
   331     
       
   332     _LIT( KMusTestDetails, "1222233499" );
       
   333     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
   334                                    NMusSessionApi::KTelNumber,
       
   335                                    KMusTestDetails) );
       
   336     EUNIT_ASSERT_EQUALS( KMusTestDetails(), iLiveSession->RemoteDetails() )
       
   337     }
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 void UT_CMusEngMceSession::UT_SetParameterL()
       
   344     {
       
   345     const TInt dummy( 0 );
       
   346     EUNIT_ASSERT_EQUALS( KErrNotSupported, 
       
   347                          iLiveSession->SetParameter( dummy, dummy ) )
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 void UT_CMusEngMceSession::UT_ParameterValueL()
       
   355     {
       
   356     const TInt dummy( 0 );
       
   357     EUNIT_ASSERT_EQUALS( KErrNotSupported, 
       
   358                          iLiveSession->ParameterValue( dummy ) )
       
   359     }
       
   360 
       
   361 
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 // -----------------------------------------------------------------------------
       
   365 //
       
   366 void UT_CMusEngMceSession::UT_IsLcAudioMutedL()
       
   367     {
       
   368     // No MCE session
       
   369     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->IsLcAudioMutedL(), KErrNotReady )
       
   370     
       
   371     ESTABLISH_OUT_SESSION( iLiveSession )
       
   372     
       
   373     // No audio
       
   374     EUNIT_ASSERT( iLiveSession->IsLcAudioMutedL() )
       
   375     
       
   376     // Contains audio, but explicitly muted
       
   377     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
       
   378     iLiveSession->iSession->AddStreamL( audioStream );
       
   379     CleanupStack::Pop( audioStream );
       
   380     iLiveSession->iExplicitlyMuted = ETrue;
       
   381     EUNIT_ASSERT( iLiveSession->IsLcAudioMutedL() )
       
   382     
       
   383     // Contains audio, not muted
       
   384     iLiveSession->iExplicitlyMuted = EFalse;
       
   385     EUNIT_ASSERT( !iLiveSession->IsLcAudioMutedL() )
       
   386     }
       
   387 
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392 void UT_CMusEngMceSession::UT_MuteLcAudioL()
       
   393     {
       
   394     // No MCE session
       
   395     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->IsLcAudioMutedL(), KErrNotReady )
       
   396     
       
   397     ESTABLISH_OUT_SESSION( iLiveSession )
       
   398     
       
   399     // Mute 
       
   400     iLiveSession->MuteLcAudioL( ETrue );
       
   401     EUNIT_ASSERT( iLiveSession->iExplicitlyMuted )
       
   402     EUNIT_ASSERT( iLiveSession->IsLcAudioMutedL() )
       
   403     
       
   404     // Unmute
       
   405     iLiveSession->MuteLcAudioL( EFalse );
       
   406     EUNIT_ASSERT( !iLiveSession->iExplicitlyMuted )
       
   407     }
       
   408 
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 void UT_CMusEngMceSession::UT_MuteLcMicL()
       
   414     {
       
   415     // Mute
       
   416     iLiveSession->MuteLcMicL( ETrue );
       
   417     User::LeaveIfError( RProperty::Set( KPSUidTelMicrophoneMuteStatus,
       
   418                                         KTelMicrophoneMuteState,
       
   419                                         EPSTelMicMuteOn ) );  
       
   420     EUNIT_ASSERT( iLiveSession->IsLcMicMutedL() )
       
   421     
       
   422     // Unmute
       
   423     iLiveSession->MuteLcMicL( EFalse );
       
   424     User::LeaveIfError( RProperty::Set( KPSUidTelMicrophoneMuteStatus,
       
   425                                         KTelMicrophoneMuteState,
       
   426                                         EPSTelMicMuteOff ) );    
       
   427     EUNIT_ASSERT( !iLiveSession->IsLcMicMutedL() )
       
   428     }
       
   429 
       
   430 // -----------------------------------------------------------------------------
       
   431 //
       
   432 // -----------------------------------------------------------------------------
       
   433 //
       
   434 void UT_CMusEngMceSession::UT_EnableLcLoudspeakerL()
       
   435     {
       
   436     // Check that enabling the loudspeaker is allowed
       
   437     EUNIT_ASSERT( iLiveSession->IsEnablingLcLoudspeakerAllowed() )
       
   438     
       
   439     // Disable 
       
   440     iLiveSession->EnableLcLoudspeakerL( EFalse );
       
   441     EUNIT_ASSERT( !iLiveSession->IsLcLoudspeakerEnabled() )
       
   442     
       
   443     // Enable
       
   444     iLiveSession->EnableLcLoudspeakerL( ETrue );
       
   445     EUNIT_ASSERT( iLiveSession->IsLcLoudspeakerEnabled() )
       
   446     }
       
   447 
       
   448 // -----------------------------------------------------------------------------
       
   449 //
       
   450 // -----------------------------------------------------------------------------
       
   451 //
       
   452 void UT_CMusEngMceSession::UT_SetLcVolumeL()
       
   453     {
       
   454     ESTABLISH_OUT_SESSION( iLiveSession )
       
   455     
       
   456     // Set volume
       
   457     const TInt volume( 5 );
       
   458     iLiveSession->SetLcVolumeL( volume );
       
   459     EUNIT_ASSERT_EQUALS( volume, iLiveSession->LcVolumeL() );
       
   460     
       
   461     // Increase volume
       
   462     iLiveSession->IncreaseLcVolumeL();
       
   463     EUNIT_ASSERT_EQUALS( volume+1, iLiveSession->LcVolumeL() );
       
   464     
       
   465     // Decrease volume
       
   466     iLiveSession->DecreaseLcVolumeL();
       
   467     EUNIT_ASSERT_EQUALS( volume, iLiveSession->LcVolumeL() );    
       
   468     }
       
   469 
   201 
   470 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   471 //
   203 //
   472 // -----------------------------------------------------------------------------
   204 // -----------------------------------------------------------------------------
   473 //  
   205 //  
   474 void UT_CMusEngMceSession::UT_GetSessionTimeL()
   206 void UT_CMusEngMceSession::UT_CMusEngMceSession_GetSessionTimeL()
   475     {
   207     {
   476     EUNIT_ASSERT( iLiveSession->GetSessionTime() < TTimeIntervalSeconds( 0 ) );
   208     EUNIT_ASSERT( iLiveSession->GetSessionTime() < TTimeIntervalSeconds( 0 ) );
   477     
   209     
   478     // Invite
   210     // Invite
   479     iLiveSession->EstablishLcSessionL();
   211     iLiveSession->InviteL( KTestRecipientSipUri );
   480     
   212     
   481     EUNIT_ASSERT( iLiveSession->GetSessionTime() < TTimeIntervalSeconds( 0 ) );
   213     EUNIT_ASSERT( iLiveSession->GetSessionTime() < TTimeIntervalSeconds( 0 ) );
   482     
   214     
   483     // Simulate establishment
   215     // Simulate establishment
   484     iLiveSession->iSession->iState = CMceSession::EEstablished;
   216     iLiveSession->iSession->iState = CMceSession::EEstablished;
   485     iLiveSession->iStartTime.HomeTime();
   217     iLiveSession->iStartTime.HomeTime();
   486     
   218     
   487     TTimeIntervalSeconds sessionTime = iLiveSession->GetSessionTime();
   219     TTimeIntervalSeconds sessionTime = iLiveSession->GetSessionTime();
   488     EUNIT_ASSERT( sessionTime >= TTimeIntervalSeconds( 0 ) );
   220     EUNIT_ASSERT( sessionTime >= TTimeIntervalSeconds( 0 ) );
   489     }
   221     }
   490 
   222     
   491 // -----------------------------------------------------------------------------
   223 void UT_CMusEngMceSession::UT_CMusEngMceSession_IsDisplayEnabledLL()
   492 //
   224     {
   493 // -----------------------------------------------------------------------------
   225     TRAPD( error, iLiveSession->IsDisplayEnabledL() );
   494 //
   226     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
   495 void UT_CMusEngMceSession::UT_HandleTerminationL()
   227     EUNIT_ASSERT( error == KErrNotReady );
       
   228 
       
   229     ESTABLISH_OUT_SESSION( iLiveSession );
       
   230      
       
   231     //Enable
       
   232     CMceDisplaySink* display = 
       
   233                     MusEngMceUtils::GetDisplayL( *(iLiveSession->iSession) );
       
   234     display->iIsEnabled = ETrue;
       
   235     EUNIT_ASSERT( iLiveSession->IsDisplayEnabledL() );
       
   236     
       
   237     //Disable
       
   238     display->iIsEnabled = EFalse;
       
   239     EUNIT_ASSERT( !iLiveSession->IsDisplayEnabledL() );
       
   240     
       
   241     // Display is reported as disabled when session state is terminated or idle
       
   242     iLiveSession->iSession->iState = CMceSession::ETerminated;
       
   243     display->iIsEnabled = ETrue;
       
   244     EUNIT_ASSERT( !iLiveSession->IsDisplayEnabledL() );
       
   245     iLiveSession->iSession->iState = CMceSession::EIdle;
       
   246     EUNIT_ASSERT( !iLiveSession->IsDisplayEnabledL() );
       
   247     }
       
   248 	
       
   249 	
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 void UT_CMusEngMceSession::UT_CMusEngMceSession_ConnectionActiveL()
       
   255     {
       
   256     EUNIT_ASSERT( !iLiveSession->ConnectionActive() );
       
   257     
       
   258     ESTABLISH_OUT_SESSION( iLiveSession );
       
   259     
       
   260     EUNIT_ASSERT( iLiveSession->ConnectionActive() );
       
   261     }
       
   262 
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 void UT_CMusEngMceSession::UT_CMusEngMceSession_ContainsAudioLL()
       
   269     {
       
   270     // Try without session, fails
       
   271     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->ContainsAudioL(), KErrNotReady )
       
   272     
       
   273     // Establish session without audio
       
   274     ESTABLISH_OUT_SESSION( iLiveSession )
       
   275     
       
   276     EUNIT_ASSERT( !iLiveSession->ContainsAudioL() )
       
   277     
       
   278     // Establish session with audio
       
   279     ESTABLISH_OUT_SESSION( iClipSession )
       
   280     
       
   281     EUNIT_ASSERT( iClipSession->ContainsAudioL() )
       
   282     }
       
   283 
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 void UT_CMusEngMceSession::UT_CMusEngMceSession_IsMutedLL()
       
   290     {
       
   291     // Try without session, fails
       
   292     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->IsMutedL(), KErrNotReady )
       
   293     
       
   294     // Establish session without audio
       
   295     ESTABLISH_OUT_SESSION( iLiveSession )
       
   296     
       
   297     EUNIT_ASSERT( iLiveSession->IsMutedL() )
       
   298     
       
   299     // Establish session with audio
       
   300     ESTABLISH_OUT_SESSION( iClipSession )
       
   301     
       
   302     EUNIT_ASSERT( !iClipSession->IsMutedL() )  // Not muted although disabled
       
   303     
       
   304     iClipSession->EnableDisplayL( ETrue ); // Enabled also speaker
       
   305     
       
   306     EUNIT_ASSERT( !iClipSession->IsMutedL() )  // Enabled and not muted
       
   307 
       
   308     iClipSession->MuteL();
       
   309     
       
   310     EUNIT_ASSERT( iClipSession->IsMutedL() ) // Explicitly muted
       
   311     
       
   312     iClipSession->UnmuteL();
       
   313     
       
   314     EUNIT_ASSERT( !iClipSession->IsMutedL() ) // Explicitly unmuted
       
   315     }
       
   316 
       
   317 
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 // -----------------------------------------------------------------------------
       
   321 //
       
   322 void UT_CMusEngMceSession::UT_CMusEngMceSession_OrientationLL()
       
   323     {
       
   324     // Try without session, fails
       
   325     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->OrientationL(), KErrNotReady )
       
   326     
       
   327     // Establish a session and try all the MCE rotation values
       
   328     ESTABLISH_OUT_SESSION( iLiveSession )
       
   329     
       
   330     CMceDisplaySink* display = 
       
   331                     MusEngMceUtils::GetDisplayL( *iLiveSession->iSession );
       
   332 
       
   333     display->iRotation = CMceDisplaySink::ENone;
       
   334     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   335                          CMusEngMceSession::EPortrait )
       
   336     
       
   337     display->iRotation = CMceDisplaySink::EClockwise90Degree;
       
   338     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   339                          CMusEngMceSession::ELandscape )
       
   340     
       
   341     display->iRotation = CMceDisplaySink::EClockwise180Degree;
       
   342     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   343                          CMusEngMceSession::ELandscape )
       
   344     
       
   345     display->iRotation = CMceDisplaySink::EClockwise270Degree;
       
   346     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   347                          CMusEngMceSession::ELandscape )
       
   348             
       
   349     }
       
   350     
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 void UT_CMusEngMceSession::UT_CMusEngMceSession_SetOrientationLL()
       
   357     {
       
   358     // Try without session, fails
       
   359     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->SetOrientationL( 
       
   360                                                 CMusEngMceSession::EPortrait ), 
       
   361                                  KErrNotReady )
       
   362 
       
   363     // Establish a session
       
   364     ESTABLISH_OUT_SESSION( iLiveSession )
       
   365     
       
   366     CMceDisplaySink* display = 
       
   367                     MusEngMceUtils::GetDisplayL( *iLiveSession->iSession );
       
   368     
       
   369     // Check the initial state
       
   370     display->iRotation = CMceDisplaySink::ENone;
       
   371     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   372                          CMusEngMceSession::EPortrait )      
       
   373                          
       
   374     // Successfully change orientation
       
   375     
       
   376     iLiveSession->SetOrientationL( CMusEngMceSession::ELandscape );
       
   377     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   378                          CMusEngMceSession::ELandscape )
       
   379     
       
   380     iLiveSession->SetOrientationL( CMusEngMceSession::EPortrait );
       
   381     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   382                          CMusEngMceSession::EPortrait )                     
       
   383                          
       
   384     }
       
   385         
       
   386 
       
   387 // -----------------------------------------------------------------------------
       
   388 //
       
   389 // -----------------------------------------------------------------------------
       
   390 //
       
   391 void UT_CMusEngMceSession::UT_CMusEngMceSession_VolumeUpLL()
       
   392     {    
       
   393     // Try without session, fails
       
   394     TRAPD( error, iLiveSession->VolumeUpL() );
       
   395     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   396     EUNIT_ASSERT( error == KErrNotReady );
       
   397     
       
   398     // Test only usage of CMceSpeaker, phone part is tested in base class
       
   399     
       
   400     // Check that nothing crashes without any speakers    
       
   401     iReceiveSession->VolumeUpL();
       
   402     
       
   403     // Establish session
       
   404     ESTABLISH_OUT_SESSION( iClipSession )
       
   405     
       
   406     TInt initialVolume = iClipSession->VolumeL();
       
   407     
       
   408     iClipSession->VolumeUpL();
       
   409 
       
   410     // Check that all speaker volumes are adjusted and store one speaker pointer
       
   411     
       
   412     CMceSpeakerSink* speaker = NULL;
       
   413     
       
   414     CMceSession* session = iClipSession->iSession;
       
   415     
       
   416     for ( TInt i = 0; i < session->Streams().Count(); ++i )
       
   417         {
       
   418         for ( TInt j = 0; j < session->Streams()[i]->Sinks().Count(); ++j )
       
   419             {
       
   420             if ( session->Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
   421                 {
       
   422                 speaker = static_cast<CMceSpeakerSink*>(
       
   423                                             session->Streams()[i]->Sinks()[j] );
       
   424                 EUNIT_ASSERT( speaker->VolumeL() == initialVolume + 1 );
       
   425                 }
       
   426             }
       
   427         } 
       
   428 
       
   429     while ( iClipSession->VolumeL() < speaker->MaxVolumeL() )
       
   430         {
       
   431         iClipSession->VolumeUpL();
       
   432         }
       
   433 
       
   434     iClipSession->VolumeUpL(); // Does not do anything to volume
       
   435     
       
   436     EUNIT_ASSERT( iClipSession->VolumeL() == speaker->MaxVolumeL() );
       
   437     
       
   438     }
       
   439 
       
   440 
       
   441 // -----------------------------------------------------------------------------
       
   442 //
       
   443 // -----------------------------------------------------------------------------
       
   444 //
       
   445 void UT_CMusEngMceSession::UT_CMusEngMceSession_VolumeDownLL()
       
   446     {
       
   447         // Try without session, fails
       
   448     TRAPD( error, iLiveSession->VolumeDownL() );
       
   449     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   450     EUNIT_ASSERT( error == KErrNotReady );
       
   451     
       
   452     // Test only usage of CMceSpeaker, phone part is tested in base class
       
   453     
       
   454     // Check that nothing crashes without any speakers    
       
   455     iReceiveSession->VolumeUpL();
       
   456     
       
   457     // Establish session
       
   458     ESTABLISH_OUT_SESSION( iClipSession )
       
   459     
       
   460     TInt initialVolume = iClipSession->VolumeL();
       
   461     
       
   462     iClipSession->VolumeDownL();
       
   463 
       
   464     // Check that all speaker volumes are adjusted and store one speaker pointer
       
   465     
       
   466     CMceSpeakerSink* speaker = NULL;
       
   467     
       
   468     CMceSession* session = iClipSession->iSession;
       
   469     
       
   470     for ( TInt i = 0; i < session->Streams().Count(); ++i )
       
   471         {
       
   472         for ( TInt j = 0; j < session->Streams()[i]->Sinks().Count(); ++j )
       
   473             {
       
   474             if ( session->Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
   475                 {
       
   476                 speaker = static_cast<CMceSpeakerSink*>(
       
   477                                             session->Streams()[i]->Sinks()[j] );
       
   478                 EUNIT_ASSERT( speaker->VolumeL() == initialVolume - 1 );
       
   479                 }
       
   480             }
       
   481         } 
       
   482 
       
   483     while ( iClipSession->VolumeL() > 0 )
       
   484         {
       
   485         iClipSession->VolumeDownL();
       
   486         }
       
   487 
       
   488     iClipSession->VolumeDownL(); // Does not do anything to volume
       
   489     
       
   490     EUNIT_ASSERT_EQUALS( iClipSession->VolumeL(), 0 );
       
   491         
       
   492     }
       
   493 
       
   494 
       
   495 // -----------------------------------------------------------------------------
       
   496 //
       
   497 // -----------------------------------------------------------------------------
       
   498 //
       
   499 void UT_CMusEngMceSession::UT_CMusEngMceSession_SetVolumeLL()
       
   500     {    
       
   501     // Try without session, fails
       
   502     TInt newVolume = KTelephonyVolumeDefaultValue + 1;
       
   503     
       
   504     TRAPD( error, iLiveSession->SetVolumeL( newVolume ) );
       
   505     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   506     EUNIT_ASSERT( error == KErrNotReady );
       
   507     
       
   508     // Test only usage of CMceSpeaker, phone part is tested in base class
       
   509     
       
   510     // Check that nothing crashes without any speakers    
       
   511     iReceiveSession->SetVolumeL( newVolume );
       
   512     
       
   513     // Establish session
       
   514     ESTABLISH_OUT_SESSION( iClipSession )
       
   515     
       
   516     TInt initialVolume = iClipSession->VolumeL();
       
   517     
       
   518     iClipSession->SetVolumeL( newVolume );
       
   519 
       
   520     // Check that all speaker volumes are adjusted and store one speaker pointer
       
   521     
       
   522     CMceSpeakerSink* speaker = NULL;
       
   523     
       
   524     CMceSession* session = iClipSession->iSession;
       
   525     
       
   526     for ( TInt i = 0; i < session->Streams().Count(); ++i )
       
   527         {
       
   528         for ( TInt j = 0; j < session->Streams()[i]->Sinks().Count(); ++j )
       
   529             {
       
   530             if ( session->Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
   531                 {
       
   532                 speaker = static_cast<CMceSpeakerSink*>(
       
   533                                             session->Streams()[i]->Sinks()[j] );
       
   534                 EUNIT_ASSERT( speaker->VolumeL() == newVolume );
       
   535                 }
       
   536             }
       
   537         } 
       
   538 
       
   539     newVolume = speaker->MaxVolumeL() + 1;
       
   540     iClipSession->SetVolumeL( newVolume );
       
   541     EUNIT_ASSERT( iClipSession->VolumeL() == speaker->MaxVolumeL() );
       
   542     
       
   543     newVolume = -1;
       
   544     iClipSession->SetVolumeL( newVolume );
       
   545     EUNIT_ASSERT( iClipSession->VolumeL() == 0 );
       
   546     
       
   547     // Test situation where MCE max volume is bigger than MUS max vol
       
   548     SetMaxVolForSpeakersL(*session, KMusEngMaxVolume * 10);
       
   549     newVolume = 5;
       
   550     iClipSession->SetVolumeL( newVolume );
       
   551     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   552     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 10 );
       
   553     newVolume = 1;
       
   554     iClipSession->SetVolumeL( newVolume );
       
   555     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   556     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 10 );
       
   557     newVolume = KMusEngMaxVolume;
       
   558     iClipSession->SetVolumeL( newVolume );
       
   559     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   560     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 10 );
       
   561     
       
   562     SetMaxVolForSpeakersL(*session, KMusEngMaxVolume * 1000);
       
   563     newVolume = 7;
       
   564     iClipSession->SetVolumeL( newVolume );
       
   565     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   566     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 1000 );
       
   567     newVolume = 1;
       
   568     iClipSession->SetVolumeL( newVolume );
       
   569     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   570     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 1000 );
       
   571     newVolume = KMusEngMaxVolume;
       
   572     iClipSession->SetVolumeL( newVolume );
       
   573     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   574     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 1000 );
       
   575     
       
   576     
       
   577     // Test situation where MCE max volume is smaller than MUS max vol
       
   578     SetMaxVolForSpeakersL(*session, KMusEngMaxVolume / 2);
       
   579     newVolume = 3;
       
   580     iClipSession->SetVolumeL( newVolume );
       
   581     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   582     EUNIT_ASSERT( speaker->VolumeL() == newVolume / 2 );
       
   583     newVolume = 1;
       
   584     iClipSession->SetVolumeL( newVolume );
       
   585     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   586     EUNIT_ASSERT( speaker->VolumeL() == 1 );
       
   587     newVolume = KMusEngMaxVolume;
       
   588     iClipSession->SetVolumeL( newVolume );
       
   589     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   590     EUNIT_ASSERT( speaker->VolumeL() == newVolume / 2 );
       
   591     }
       
   592 
       
   593 // -----------------------------------------------------------------------------
       
   594 //
       
   595 // -----------------------------------------------------------------------------
       
   596 //
       
   597 void UT_CMusEngMceSession::UT_CMusEngMceSession_EnableDisplayL()
       
   598     {
       
   599     TRAPD( error, iLiveSession->EnableDisplayL( ETrue ) );
       
   600     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   601     EUNIT_ASSERT( error == KErrNotReady );
       
   602     
       
   603     ESTABLISH_OUT_SESSION( iLiveSession );
       
   604     
       
   605     CMceDisplaySink* display = 
       
   606                     MusEngMceUtils::GetDisplayL( *(iLiveSession->iSession) );
       
   607     
       
   608     // Disable
       
   609     iLiveSession->EnableDisplayL( EFalse );
       
   610     
       
   611     EUNIT_ASSERT( !display->iIsEnabled );
       
   612     
       
   613     // Try to disable again, request should be ignored
       
   614     
       
   615     iLiveSession->EnableDisplayL( EFalse );
       
   616     
       
   617     EUNIT_ASSERT( !display->iIsEnabled );
       
   618 
       
   619     // Enable
       
   620     
       
   621     iLiveSession->EnableDisplayL( ETrue );
       
   622     
       
   623     EUNIT_ASSERT( display->iIsEnabled );
       
   624     
       
   625     // Try to enable again, request should be ignored
       
   626     
       
   627     iLiveSession->EnableDisplayL( ETrue );
       
   628     
       
   629     EUNIT_ASSERT( display->iIsEnabled );
       
   630     }
       
   631 
       
   632 
       
   633 // -----------------------------------------------------------------------------
       
   634 //
       
   635 // -----------------------------------------------------------------------------
       
   636 //
       
   637 void UT_CMusEngMceSession::UT_CMusEngMceSession_MuteLL()
       
   638     {
       
   639     TRAPD( error, iClipSession->MuteL() );
       
   640     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   641     EUNIT_ASSERT( error == KErrNotReady );
       
   642     
       
   643     ESTABLISH_OUT_SESSION_AND_START_STREAMING( iClipSession );
       
   644     
       
   645     const RPointerArray<CMceMediaStream> streams = 
       
   646                                             iClipSession->iSession->Streams();
       
   647     
       
   648     iClipSession->MuteL();
       
   649     
       
   650     // Check that all audio speaker sinks are disabled and only those                                        
       
   651     for ( TInt i = 0; i < streams.Count(); ++i )
       
   652         {
       
   653         for ( TInt j = 0; j < streams[i]->Sinks().Count(); ++j )
       
   654             {
       
   655             CMceMediaSink* sink = streams[i]->Sinks()[j];
       
   656             if ( sink->Type() == KMceSpeakerSink  &&
       
   657                  streams[i]->Type() == KMceAudio )
       
   658                 {
       
   659                 EUNIT_ASSERT( sink->IsEnabled() == EFalse )
       
   660                 }    
       
   661             else
       
   662                 {
       
   663                 EUNIT_ASSERT( sink->IsEnabled() == ETrue )
       
   664                 } 
       
   665             }        
       
   666         }
       
   667     
       
   668     EUNIT_ASSERT( iClipSession->iExplicitlyMuted ) 
       
   669     
       
   670     // Try to mute again, request should be ignored without actions or leaving
       
   671 
       
   672     iClipSession->MuteL();
       
   673 
       
   674     }
       
   675     
       
   676 
       
   677 // -----------------------------------------------------------------------------
       
   678 // Relies on previous test
       
   679 // -----------------------------------------------------------------------------
       
   680 //
       
   681 void UT_CMusEngMceSession::UT_CMusEngMceSession_UnmuteLL()
       
   682     {
       
   683     TRAPD( error, iClipSession->UnmuteL() );
       
   684     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   685     EUNIT_ASSERT( error == KErrNotReady );
       
   686     
       
   687     ESTABLISH_OUT_SESSION( iClipSession );
       
   688     
       
   689     const RPointerArray<CMceMediaStream> streams = 
       
   690                                             iClipSession->iSession->Streams();
       
   691     
       
   692     iClipSession->MuteL();
       
   693     
       
   694     iClipSession->UnmuteL();
       
   695     
       
   696     // Check that all audio speaker sinks are enabled
       
   697                                             
       
   698     for ( TInt i = 0; i < streams.Count(); ++i )
       
   699         {
       
   700         for ( TInt j = 0; j < streams[i]->Sinks().Count(); ++j )
       
   701             {
       
   702             if ( streams[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
   703                 {
       
   704                 EUNIT_ASSERT( streams[i]->Sinks()[j]->IsEnabled() == ETrue )
       
   705                 }
       
   706             }        
       
   707         }
       
   708     
       
   709     EUNIT_ASSERT( !iClipSession->iExplicitlyMuted ) 
       
   710     
       
   711     // Try to unmute again, request should be ignored without actions or leaving
       
   712 
       
   713     iClipSession->UnmuteL();
       
   714     }
       
   715     
       
   716 
       
   717 // -----------------------------------------------------------------------------
       
   718 //
       
   719 // -----------------------------------------------------------------------------
       
   720 //
       
   721 void UT_CMusEngMceSession::UT_CMusEngMceSession_HandleTerminationL()
   496     { 
   722     { 
   497     // Try different values
   723     // Try different values
   498     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCodeNoCodeSet,
   724     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCodeNoCodeSet,
   499                                                         KNullDesC8() );
   725                                                         KNullDesC8() );
   500     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
   726     EUNIT_ASSERT( iObserver->iSessionTerminatedCalled );
   501                          TInt( CLcSessionObserverStub::ESessionStateChanged ) )
   727     iObserver->Reset();
   502     iLcSessionObserver->Reset();
       
   503 
   728 
   504     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCode200OK,
   729     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCode200OK,
   505                                                         KNullDesC8() );
   730                                                         KNullDesC8() );
   506     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
   731     EUNIT_ASSERT( iObserver->iSessionTerminatedCalled );
   507                          TInt( CLcSessionObserverStub::ESessionStateChanged ) )
   732     iObserver->Reset();
   508     iLcSessionObserver->Reset();
       
   509 
   733 
   510     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCodeUnknown,
   734     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCodeUnknown,
   511                                                         KNullDesC8() );
   735                                                         KNullDesC8() );
   512     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
   736     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
   513                          TInt( CLcSessionObserverStub::ESessionFailed ) )
   737     iObserver->Reset();
   514     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
   738     
   515     iLcSessionObserver->Reset();
   739     }
   516     }
   740 
   517 
   741 
   518 // -----------------------------------------------------------------------------
   742 // -----------------------------------------------------------------------------
   519 //
   743 //
   520 // -----------------------------------------------------------------------------
   744 // -----------------------------------------------------------------------------
   521 //
   745 //
   522 void UT_CMusEngMceSession::UT_AdjustVideoCodecL()
   746 void UT_CMusEngMceSession::UT_CMusEngMceSession_AdjustVideoCodecLL()
   523     {
   747     {
   524     CRepository::SetStubAvcConfigKeysL( KNullDesC8() );
   748     // CMusEngMceSession::AdjustVideoCodecL does nothing, so NULL test is enough
   525         
   749     CMceVideoCodec* codec = 
   526     CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( KMceSDPNameH263() );
   750                 iLiveSession->iManager->SupportedVideoCodecs()[0]->CloneL();
   527     CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() );
   751     CleanupStack::PushL( codec );
   528     CMceVideoCodec* codecAvcFromFile = CMceAvcCodec::NewLC( KMceSDPNameH264() );
   752     iLiveSession->CMusEngMceSession::AdjustVideoCodecL( *codec );
   529     
   753     CleanupStack::PopAndDestroy( codec );
   530     iLiveSession->CMusEngMceSession::AdjustVideoCodecL( *codecH263,
   754     }
   531                                                         KMceCameraSource );
   755 
   532     EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo )
   756 
   533 
   757 // -----------------------------------------------------------------------------
   534     iLiveSession->CMusEngMceSession::AdjustVideoCodecL( *codecAvcFromFile,
   758 //
   535                                                         KMceFileSource);  
   759 // -----------------------------------------------------------------------------
   536     EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo )
   760 //
   537     
   761 void UT_CMusEngMceSession::UT_CMusEngMceSession_AdjustAudioCodecLL()
   538     iLiveSession->CMusEngMceSession::AdjustVideoCodecL( *codecAvc,
       
   539                                                         KMceCameraSource );  
       
   540     EUNIT_ASSERT( iLiveSession->iStoreEncoderConfigInfo )
       
   541     
       
   542     CleanupStack::PopAndDestroy( codecAvcFromFile );
       
   543     CleanupStack::PopAndDestroy( codecAvc );
       
   544     CleanupStack::PopAndDestroy( codecH263 );
       
   545     }
       
   546 
       
   547 // -----------------------------------------------------------------------------
       
   548 //
       
   549 // -----------------------------------------------------------------------------
       
   550 //
       
   551 void UT_CMusEngMceSession::UT_AdjustAudioCodecL()
       
   552     {
   762     {
   553     CMceAudioCodec* codec = 
   763     CMceAudioCodec* codec = 
   554                 iLiveSession->iManager->SupportedAudioCodecs()[0]->CloneL();
   764                 iLiveSession->iManager->SupportedAudioCodecs()[0]->CloneL();
   555     CleanupStack::PushL( codec );
   765     CleanupStack::PushL( codec );
   556     iLiveSession->CMusEngMceSession::AdjustAudioCodecL( *codec );
   766     iLiveSession->CMusEngMceSession::AdjustAudioCodecL( *codec );
   557     
   767     
   558     EUNIT_ASSERT( codec->iMMFPriority == KAudioPrioritySwisPlayback )
   768     EUNIT_ASSERT( codec->iMMFPriority == KAudioPrioritySwisPlayback )
   559     EUNIT_ASSERT( codec->iMMFPriorityPreference == KAudioPrefSwisPlayback )
   769     EUNIT_ASSERT( codec->iMMFPriorityPreference == KAudioPrefSwisPlayback )
   560     
   770     
   561     CleanupStack::PopAndDestroy( codec );
   771     CleanupStack::PopAndDestroy( codec );
   562     }   
   772     }
   563         
   773         
   564 // -----------------------------------------------------------------------------
   774         
   565 //
   775 // -----------------------------------------------------------------------------
   566 // -----------------------------------------------------------------------------
   776 //
   567 //
   777 // -----------------------------------------------------------------------------
   568 void UT_CMusEngMceSession::UT_RectChangedL()
   778 //
   569     {
   779 void UT_CMusEngMceSession::UT_CMusEngMceSession_RectChangedLL()
       
   780     {
       
   781     
   570     // Does nothing before session establishment
   782     // Does nothing before session establishment
   571     
   783     
   572     iLiveSession->RectChangedL();
   784     iLiveSession->RectChangedL();
   573     
   785     
   574     ESTABLISH_OUT_SESSION( iLiveSession );
   786     ESTABLISH_OUT_SESSION( iLiveSession );
   577     iLiveSession->SetRectL( TRect( 100, 200, 300, 400 ) ); 
   789     iLiveSession->SetRectL( TRect( 100, 200, 300, 400 ) ); 
   578     
   790     
   579     // Display size has been updated
   791     // Display size has been updated
   580     
   792     
   581     CMceDisplaySink* display = 
   793     CMceDisplaySink* display = 
   582         MusEngMceUtils::GetDisplayL( *( iLiveSession->iSession ) );
   794                 MusEngMceUtils::GetDisplayL( *( iLiveSession->iSession ) );
   583     
   795     
   584     EUNIT_ASSERT( display->DisplayRectL() == iLiveSession->Rect() )
   796     EUNIT_ASSERT( display->DisplayRectL() == iLiveSession->Rect() );
   585     
   797     
   586     // Terminate session and try again, rect must not be changed
   798     // Terminate session and try again, rect must not be changed
   587     
   799     
   588     iLiveSession->iSession->iState = CMceSession::ETerminated;
   800     iLiveSession->iSession->iState = CMceSession::ETerminated;
   589     
   801     
   590     TRect newRect( 200, 300, 400, 500 );
   802     TRect newRect( 200, 300, 400, 500 );
   591     
   803     
   592     iLiveSession->SetRectL( newRect ); 
   804     iLiveSession->SetRectL( newRect ); 
   593     
   805     
   594     EUNIT_ASSERT( display->DisplayRectL() != newRect )
   806     EUNIT_ASSERT( display->DisplayRectL() != newRect )
   595     }
   807     
   596 
   808     
   597 // -----------------------------------------------------------------------------
   809     }
   598 //
   810 
   599 // -----------------------------------------------------------------------------
   811 
   600 //
   812 // -----------------------------------------------------------------------------
   601 void UT_CMusEngMceSession::UT_SetSessionSdpLinesL()
   813 //
       
   814 // -----------------------------------------------------------------------------
       
   815 //
       
   816 void UT_CMusEngMceSession::UT_CMusEngMceSession_SetSessionSdpLinesLL()
   602     {
   817     {
   603     // set operator variant off
   818     // set operator variant off
   604     iReceiveSession->iOperatorVariant = EFalse;
   819     MultimediaSharingSettings::SetOperatorVariantSettingL(
   605     CRepository::SetStubGlobal( MusSettingsKeys::KVideoBandwidth,
   820                      MusSettingsKeys::EStandard );
   606                                 128 );
       
   607                      
   821                      
   608     // 1. There is b=AS line at session level
   822     // There is no sdp lines in session, right one is added
   609     // => Xapplication, b=AS and b=TIAS set to session level  
   823 
   610     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
   824     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
   611                                                     KTestOriginator );
   825                                                     KTestOriginator );
   612     CleanupStack::PushL( inSession );    
   826     CleanupStack::PushL( inSession );
   613     EUNIT_ASSERT( !inSession->iSessionSDPLines );
   827     
   614     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
   828     iReceiveSession->SetSessionSdpLinesL( *inSession );
   615     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineBandwidthField() );
   829     
   616         
   830     MDesC8Array* sdpLines = inSession->SessionSDPLinesL();
   617     iReceiveSession->SetSessionSdpLinesL( *inSession, ETrue );
   831     CleanupDeletePushL( sdpLines );
   618     
   832     
   619     MDesC8Array* sdpLines = inSession->iSessionSDPLines;    
       
   620     EUNIT_ASSERT( sdpLines );
       
   621     EUNIT_ASSERT( sdpLines->MdcaCount() == 3 );
       
   622     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
       
   623     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ).Find( 
       
   624             KMusEngSessionSdpLineBandwidthLine() ) == 0 );
       
   625     EUNIT_ASSERT( sdpLines->MdcaPoint( 2 ).Find( 
       
   626             KMusEngSessionSdpLineTiasLine() ) == 0 );
       
   627     
       
   628     
       
   629     // 2. There are b=TIAS sdp line at session  
       
   630     // => Xapplication, b=AS and b=TIAS set to session level
       
   631     delete inSession->iSessionSDPLines;
       
   632     inSession->iSessionSDPLines = NULL;
       
   633     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
       
   634     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineTiasLine() );
       
   635         
       
   636     iReceiveSession->SetSessionSdpLinesL( *inSession, ETrue );
       
   637     
       
   638     sdpLines = inSession->iSessionSDPLines;    
       
   639     EUNIT_ASSERT( sdpLines );
       
   640     EUNIT_ASSERT( sdpLines->MdcaCount() == 3 );
       
   641     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
       
   642     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ).Find( 
       
   643             KMusEngSessionSdpLineBandwidthLine() ) == 0 );
       
   644     EUNIT_ASSERT( sdpLines->MdcaPoint( 2 ).Find( 
       
   645             KMusEngSessionSdpLineTiasLine() ) == 0 );
       
   646             
       
   647     // 3. Simulating outcoming session, i.e. 2d param aForceBandwidthLine is EFalse  
       
   648     // => only Xapplication SDP line is set
       
   649     delete inSession->iSessionSDPLines;
       
   650     inSession->iSessionSDPLines = NULL;
       
   651          
       
   652     iReceiveSession->SetSessionSdpLinesL( *inSession, EFalse );
       
   653      
       
   654     sdpLines = inSession->iSessionSDPLines;    
       
   655     EUNIT_ASSERT( sdpLines );
   833     EUNIT_ASSERT( sdpLines );
   656     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
   834     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
   657     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
   835     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
   658     
   836     
   659     // 4. No KVideoBandwidth entry in CenRep => TIAS usage should be disabled
   837     CleanupStack::PopAndDestroy(); // sdplines
   660     // There is AS and TIAS at session level => AS is taken at session level
   838 
   661     CRepository::iForceFailWithCode = KErrNotFound;
   839     // There is one line ready, replace it with right one
   662     delete inSession->iSessionSDPLines;
   840     CDesC8Array* newSdpLines = new ( ELeave ) CDesC8ArrayFlat( 3 );
   663     inSession->iSessionSDPLines = NULL;
   841     CleanupStack::PushL( newSdpLines );
   664     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
   842     newSdpLines->AppendL( KTestRecipientRandomText8() );
   665     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineTiasLine() );
   843     inSession->SetSessionSDPLinesL( newSdpLines );
   666     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineBandwidthField() );
   844     CleanupStack::Pop( newSdpLines );
   667         
   845     
   668     iReceiveSession->SetSessionSdpLinesL( *inSession, ETrue );
   846     iReceiveSession->SetSessionSdpLinesL( *inSession );
   669     
   847     
   670     sdpLines = inSession->iSessionSDPLines;    
   848     sdpLines = inSession->SessionSDPLinesL();
       
   849     CleanupDeletePushL( sdpLines );
       
   850       
   671     EUNIT_ASSERT( sdpLines );
   851     EUNIT_ASSERT( sdpLines );
   672     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
   852     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
   673     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
   853     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
   674     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineBandwidthField() );
   854     
   675     
   855     CleanupStack::PopAndDestroy(); // sdplines
       
   856     
       
   857 
   676     CleanupStack::PopAndDestroy( inSession );
   858     CleanupStack::PopAndDestroy( inSession );
   677     }
   859 
   678 
   860     // for operator variant testing
   679 // -----------------------------------------------------------------------------
       
   680 //
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 void UT_CMusEngMceSession::UT_SetSessionSdpLines_OperatorL()
       
   684     {
       
   685     // set operator variant
   861     // set operator variant
   686     iReceiveSession->iOperatorVariant = ETrue;
   862     iReceiveSession->iOperatorVariant = ETrue;
   687 
   863 
   688     // 1. There is b=TIAS sdp line in session => only application and  
   864     // There is no sdp lines in session, right ones are added to session and media level
   689     // type lines are set, no bandwidth related attributes
   865     inSession = CMceInSession::NewL( *iReceiveSession->iManager,
   690     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
   866                                                     KTestOriginator );
   691                                      KTestOriginator );
   867     CleanupStack::PushL( inSession );
   692     CleanupStack::PushL( inSession );        
   868     
   693     
   869     iReceiveSession->SetSessionSdpLinesL( *inSession );
   694     EUNIT_ASSERT( !inSession->iSessionSDPLines );
   870     
   695     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
   871     sdpLines = inSession->SessionSDPLinesL();
   696     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineTiasLine() );
   872     CleanupDeletePushL( sdpLines );
   697         
   873     
   698     iReceiveSession->SetSessionSdpLinesL( *inSession, ETrue );
       
   699     
       
   700     MDesC8Array* sdpLines = inSession->iSessionSDPLines;    
       
   701     EUNIT_ASSERT( sdpLines );
       
   702     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
       
   703     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineApplication() );
       
   704     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineType() );    
       
   705 
       
   706     // 2. There are b=AS and b=TIAS sdp lines in session => application and  
       
   707     // type SDP lines as well as b=AS bandwidth attributes are set
       
   708     delete inSession->iSessionSDPLines;
       
   709     inSession->iSessionSDPLines = NULL;
       
   710     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 2 );
       
   711     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineBandwidthField() );
       
   712     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineTiasLine() );
       
   713         
       
   714     iReceiveSession->SetSessionSdpLinesL( *inSession, ETrue );
       
   715     
       
   716     sdpLines = inSession->iSessionSDPLines;    
       
   717     EUNIT_ASSERT( sdpLines );
       
   718     EUNIT_ASSERT( sdpLines->MdcaCount() == 3 );
       
   719     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineApplication() );
       
   720     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineType() );
       
   721     EUNIT_ASSERT( sdpLines->MdcaPoint( 2 ) == KMusEngSessionSdpLineBandwidthField() );
       
   722         
       
   723     
       
   724     // 3. Simulating outcoming session, i.e. 2d param aForceBandwidthLine is EFalse  
       
   725     // => only application and type SDP lines are set
       
   726     delete inSession->iSessionSDPLines;
       
   727     inSession->iSessionSDPLines = NULL;
       
   728         
       
   729     iReceiveSession->SetSessionSdpLinesL( *inSession, EFalse );
       
   730     
       
   731     sdpLines = inSession->iSessionSDPLines;    
       
   732     EUNIT_ASSERT( sdpLines );
   874     EUNIT_ASSERT( sdpLines );
   733     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
   875     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
   734     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineApplication() );
   876     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineApplication() );
   735     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineType() );
   877     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineType() );
   736         
   878     
   737     CleanupStack::PopAndDestroy( inSession );   
   879     CleanupStack::PopAndDestroy(); // sdplines
   738     }
   880     
   739 
   881     MDesC8Array* mediaSdpLines = 
   740 // -----------------------------------------------------------------------------
   882         iReceiveSession->iSession->Streams()[ 0 ]->MediaAttributeLinesL();
   741 //
   883     CleanupDeletePushL( mediaSdpLines );
   742 // -----------------------------------------------------------------------------
   884     TBool bandwidthFoundFromMediaLevel = EFalse;
   743 //
   885     for ( TInt i = 0; mediaSdpLines && i < mediaSdpLines->MdcaCount(); i++ )
   744 void UT_CMusEngMceSession::UT_SetMediaSdpLinesL()
   886         {
   745     {
   887         if ( mediaSdpLines->MdcaPoint( i ).Compare( 
   746     // set operator variant off
   888                 KMusEngSessionSdpLineBandwidthField() ) == 0 )
   747     iReceiveSession->iOperatorVariant = EFalse;
   889             {
   748     CRepository::SetStubGlobal( MusSettingsKeys::KVideoBandwidth,
   890             bandwidthFoundFromMediaLevel = ETrue;
   749                                 128 );
   891             }
   750 
   892         }
   751     // 1. There is no b=AS, b=TIAS sdp lines at session level
   893     EUNIT_ASSERT( bandwidthFoundFromMediaLevel );
   752     // => b=AS and b=TIAS are taken at media level
   894     CleanupStack::PopAndDestroy( mediaSdpLines );
   753     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
   895 
   754                                                     KTestOriginator );
   896     // There is one line ready, replace it with right ones
   755     CleanupStack::PushL( inSession );
   897     newSdpLines = new ( ELeave ) CDesC8ArrayFlat( 3 );
   756     
   898     CleanupStack::PushL( newSdpLines );
   757     CMceVideoStream* videoStream = CMceVideoStream::NewLC();        
   899     newSdpLines->AppendL( KTestRecipientRandomText8() );
   758     videoStream->SetSourceL( CMceRtpSource::NewLC() );
   900     inSession->SetSessionSDPLinesL( newSdpLines );
   759     CleanupStack::Pop(); //rtpSource        
   901     CleanupStack::Pop( newSdpLines );
   760     videoStream->AddSinkL( CMceDisplaySink::NewLC( *iReceiveSession->iManager ) );
   902     
   761     CleanupStack::Pop(); //displaySink
   903     iReceiveSession->SetSessionSdpLinesL( *inSession );
   762         
   904     
   763     inSession->AddStreamL( videoStream );
   905     sdpLines = inSession->SessionSDPLinesL();
   764     CleanupStack::Pop( videoStream );
   906     CleanupDeletePushL( sdpLines );
   765 
   907       
   766     iReceiveSession->SetMediaSdpLinesL( *videoStream, ETrue );
       
   767     
       
   768     MDesC8Array* sdpLines = inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   769     EUNIT_ASSERT( sdpLines );
   908     EUNIT_ASSERT( sdpLines );
   770     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
   909     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
   771     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ).Find( 
   910     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineApplication() );
   772             KMusEngSessionSdpLineBandwidthLine() ) == 0 );
   911     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineType() );
   773     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ).Find( 
   912     
   774             KMusEngSessionSdpLineTiasLine() ) == 0 );
   913     CleanupStack::PopAndDestroy(); // sdplines
   775     
   914     
   776     
       
   777     // 2. There is b=AS sdp line at session and media level
       
   778     // => b=AS and b=TIAS are taken at media level
       
   779     delete inSession->iSessionSDPLines;
       
   780     inSession->iSessionSDPLines = NULL;
       
   781     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
       
   782     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineBandwidthField() );
       
   783     
       
   784     iReceiveSession->SetMediaSdpLinesL( *videoStream, ETrue );
       
   785     
       
   786     sdpLines = inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   787     EUNIT_ASSERT( sdpLines );
       
   788     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
       
   789     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ).Find( 
       
   790             KMusEngSessionSdpLineBandwidthLine() ) == 0 );
       
   791     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ).Find( 
       
   792             KMusEngSessionSdpLineTiasLine() ) == 0 );
       
   793 
       
   794     // 3. Simulating outcoming session, i.e. 2d param aForceBandwidthLine is EFalse
       
   795     // => no bandwidth attributes at media level
       
   796     delete inSession->iSessionSDPLines;
       
   797     inSession->iSessionSDPLines = NULL;
       
   798      
       
   799     delete inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   800     inSession->Streams()[ 0 ]->iMediaSDPLines = NULL;
       
   801      
       
   802     iReceiveSession->SetMediaSdpLinesL( *videoStream, EFalse );
       
   803      
       
   804     sdpLines = inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   805     EUNIT_ASSERT( sdpLines );
       
   806     EUNIT_ASSERT( sdpLines->MdcaCount() == 0 );
       
   807 
       
   808     // 4. No KVideoBandwidth entry in CenRep => TIAS usage should be disabled
       
   809     // There is no bandwidth attributes in session => AS is taken at meida level
       
   810     CRepository::iForceFailWithCode = KErrNotFound;
       
   811     delete inSession->iSessionSDPLines;
       
   812     inSession->iSessionSDPLines = NULL;
       
   813         
       
   814     iReceiveSession->SetMediaSdpLinesL( *videoStream, ETrue );
       
   815     
       
   816     sdpLines = inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   817     EUNIT_ASSERT( sdpLines );
       
   818     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
       
   819     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineBandwidthField() );
       
   820 
   915 
   821     CleanupStack::PopAndDestroy( inSession );
   916     CleanupStack::PopAndDestroy( inSession );
   822     }
   917 
   823 
   918 
   824 // -----------------------------------------------------------------------------
   919     // set operator variant off
   825 //
   920     MultimediaSharingSettings::SetOperatorVariantSettingL(
   826 // -----------------------------------------------------------------------------
   921                      MusSettingsKeys::EStandard );
   827 //
   922     }
   828 void UT_CMusEngMceSession::UT_SetMediaSdpLines_OperatorL()
   923 
   829     {
   924 
   830     // set operator variant
   925 // -----------------------------------------------------------------------------
   831     iReceiveSession->iOperatorVariant = ETrue;
   926 //
   832 
   927 // -----------------------------------------------------------------------------
   833     // 1. There is no b=AS sdp line at session level
   928 //
   834     // => b=AS is taken at media level
   929 void UT_CMusEngMceSession::UT_CMusEngMceSession_AdjustStreamsAndCodecsLL()
   835     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
       
   836                                                     KTestOriginator );
       
   837     CleanupStack::PushL( inSession );
       
   838   
       
   839     CMceVideoStream* videoStream = CMceVideoStream::NewLC();        
       
   840     videoStream->SetSourceL( CMceRtpSource::NewLC() );
       
   841     CleanupStack::Pop(); //rtpSource        
       
   842     videoStream->AddSinkL( CMceDisplaySink::NewLC( *iReceiveSession->iManager ) );
       
   843     CleanupStack::Pop(); //displaySink
       
   844         
       
   845     inSession->AddStreamL( videoStream );
       
   846     CleanupStack::Pop( videoStream );
       
   847 
       
   848     EUNIT_ASSERT( !inSession->iSessionSDPLines );   
       
   849     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
       
   850     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineTiasLine() );
       
   851         
       
   852     iReceiveSession->SetMediaSdpLinesL( *videoStream, ETrue );
       
   853     
       
   854     MDesC8Array* sdpLines = inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   855     EUNIT_ASSERT( sdpLines );
       
   856     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
       
   857     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineBandwidthField() );
       
   858     
       
   859     
       
   860     // 2. There is b=AS sdp line at session and media level
       
   861     // => b=AS is not taken at media level
       
   862     delete inSession->iSessionSDPLines;
       
   863     inSession->iSessionSDPLines = NULL;
       
   864     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
       
   865     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineBandwidthField() );
       
   866     
       
   867     delete inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   868     inSession->Streams()[ 0 ]->iMediaSDPLines = NULL;
       
   869     inSession->Streams()[ 0 ]->iMediaSDPLines =  
       
   870                 new ( ELeave ) CDesC8ArrayFlat( 1 ); 
       
   871     inSession->Streams()[ 0 ]->iMediaSDPLines->AppendL( 
       
   872                 KMusEngSessionSdpLineBandwidthField() );
       
   873     
       
   874     iReceiveSession->SetMediaSdpLinesL( *videoStream, ETrue );
       
   875     
       
   876     EUNIT_ASSERT( inSession->Streams()[ 0 ]->iMediaSDPLines );
       
   877     EUNIT_ASSERT( inSession->Streams()[ 0 ]->iMediaSDPLines->MdcaCount() == 0 );
       
   878 
       
   879 
       
   880     // 3. Simulating outcoming session, i.e. 2d param aForceBandwidthLine is EFalse
       
   881     // => b=AS is taken at media level
       
   882     delete inSession->iSessionSDPLines;
       
   883     inSession->iSessionSDPLines = NULL;
       
   884      
       
   885     delete inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   886     inSession->Streams()[ 0 ]->iMediaSDPLines = NULL;
       
   887      
       
   888     iReceiveSession->SetMediaSdpLinesL( *videoStream, EFalse );
       
   889      
       
   890     sdpLines = inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   891     EUNIT_ASSERT( sdpLines );
       
   892     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
       
   893     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineBandwidthField() );
       
   894     
       
   895     CleanupStack::PopAndDestroy( inSession );
       
   896     }
       
   897 
       
   898 
       
   899 // -----------------------------------------------------------------------------
       
   900 //
       
   901 // -----------------------------------------------------------------------------
       
   902 //
       
   903 void UT_CMusEngMceSession::UT_AdjustStreamsAndCodecsL()
       
   904     {
   930     {
   905     // Check that function cannot be called before creating the session
   931     // Check that function cannot be called before creating the session
   906     TRAPD( error, iClipSession->AdjustStreamsAndCodecsL() );
   932     TRAPD( error, iClipSession->AdjustStreamsAndCodecsL() );
   907     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
   933     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
   908     EUNIT_ASSERT( error == KErrNotReady );
   934     EUNIT_ASSERT( error == KErrNotReady );
  1003     for ( TInt i = 0; i < videoStream->Codecs().Count(); i++ )
  1029     for ( TInt i = 0; i < videoStream->Codecs().Count(); i++ )
  1004         {
  1030         {
  1005         EUNIT_ASSERT( 
  1031         EUNIT_ASSERT( 
  1006             videoStream->Codecs()[ i ]->MaxBitRate() == 128000 );
  1032             videoStream->Codecs()[ i ]->MaxBitRate() == 128000 );
  1007         }
  1033         }
       
  1034     
       
  1035     // Test for Configuration based codec removal. Magic uid not set.    
       
  1036     CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() );    
       
  1037     videoStream->AddCodecL( codecAvc );
       
  1038     CleanupStack::Pop( codecAvc );         
       
  1039     iClipSession->AdjustStreamsAndCodecsL();   
       
  1040     TBool avcCodecFound(EFalse);
       
  1041     for ( TInt i = 0; i < videoStream->Codecs().Count(); i++ )
       
  1042       {      
       
  1043       if( !videoStream->Codecs()[ i ]->SdpName().CompareF( KMceSDPNameH264 ) )
       
  1044         {
       
  1045         avcCodecFound = ETrue;
       
  1046         }      
       
  1047       }
       
  1048     // AVC should present
       
  1049     EUNIT_ASSERT(avcCodecFound);
       
  1050     
       
  1051     // Test for Configuration based codec removal. Magic uid set.
       
  1052     // Store the real value and revert back later , so that other tests will not be affected.
       
  1053     TUid uid = MultimediaSharingSettings::EncodingDeviceL();    
       
  1054     TInt32 KMusDisableAVC = 0x0fffffff;
       
  1055     MultimediaSharingSettings::SetPropertyValueL( MusSettingsKeys::KEncodingDevice,KMusDisableAVC);
       
  1056     codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() );    
       
  1057     videoStream->AddCodecL( codecAvc );
       
  1058     CleanupStack::Pop( codecAvc );  
       
  1059     codecH2632000 = CMceH263Codec::NewLC( KMceSDPNameH2632000() );
       
  1060     videoStream->AddCodecL( codecH2632000 );
       
  1061     CleanupStack::Pop( codecH2632000 );
       
  1062     iClipSession->AdjustStreamsAndCodecsL();    
       
  1063     for ( TInt i = 0; i < videoStream->Codecs().Count(); i++ )
       
  1064        {
       
  1065        // H264 ( AVC ) codec should be removed
       
  1066        EUNIT_ASSERT( 
       
  1067                    videoStream->Codecs()[ i ]->SdpName().CompareF( KMceSDPNameH264 ) );
       
  1068        }
       
  1069     
       
  1070     
       
  1071     MultimediaSharingSettings::SetPropertyValueL( MusSettingsKeys::KEncodingDevice,uid.iUid);
       
  1072     
       
  1073     
  1008     }
  1074     }
  1009 
  1075 
  1010 
  1076 
  1011 // -----------------------------------------------------------------------------
  1077 // -----------------------------------------------------------------------------
  1012 //
  1078 //
  1013 // -----------------------------------------------------------------------------
  1079 // -----------------------------------------------------------------------------
  1014 //  
  1080 //  
  1015 void UT_CMusEngMceSession::UT_IncomingSessionL()
  1081 void UT_CMusEngMceSession::UT_CMusEngMceSession_IncomingSessionL()
  1016     {
  1082     {
  1017     // New session should get rejected and deleted in any case, first failure
  1083     // New session should get rejected and deleted in any case, first failure
  1018     CMceInSession* inSession = CMceInSession::NewL( 
  1084     CMceInSession* inSession = CMceInSession::NewL( 
  1019                                       *iLiveSession->iManager, KNullDesC8 );
  1085                                       *iLiveSession->iManager, KNullDesC8 );
  1020     CleanupStack::PushL( inSession );
  1086     CleanupStack::PushL( inSession );
  1032 
  1098 
  1033 // -----------------------------------------------------------------------------
  1099 // -----------------------------------------------------------------------------
  1034 //
  1100 //
  1035 // -----------------------------------------------------------------------------
  1101 // -----------------------------------------------------------------------------
  1036 //  
  1102 //  
  1037 void UT_CMusEngMceSession::UT_IncomingUpdateL()
  1103 void UT_CMusEngMceSession::UT_CMusEngMceSession_IncomingUpdateL()
  1038     {
  1104     {
  1039     CMceInSession* inSession = CMceInSession::NewL( 
  1105     CMceInSession* inSession = CMceInSession::NewL( 
  1040                                       *iLiveSession->iManager, KNullDesC8 );
  1106                                       *iLiveSession->iManager, KNullDesC8 );
  1041     
  1107     
  1042     // Try to update before having a session, session gets rejected and deleted
  1108     // Try to update before having a session, session gets rejected and deleted
  1070 
  1136 
  1071 // -----------------------------------------------------------------------------
  1137 // -----------------------------------------------------------------------------
  1072 //
  1138 //
  1073 // -----------------------------------------------------------------------------
  1139 // -----------------------------------------------------------------------------
  1074 //  
  1140 //  
  1075 void UT_CMusEngMceSession::UT_StreamStateChangedL()
  1141 void UT_CMusEngMceSession::UT_CMusEngMceSession_StreamStateChangedL()
  1076     {
  1142     {
  1077     // Try without a session, nothing happens
  1143     // Try without a session, nothing happens
  1078     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
  1144     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
  1079     iLiveSession->CMusEngMceSession::StreamStateChanged( *audioStream );
  1145     iLiveSession->CMusEngMceSession::StreamStateChanged( *audioStream );
  1080     CleanupStack::PopAndDestroy( audioStream );
  1146     CleanupStack::PopAndDestroy( audioStream );
  1081     
  1147     
  1082     // Simulate sending invite
  1148     // Simulate sending invite
  1083     iLiveSession->EstablishLcSessionL();
  1149     iLiveSession->InviteL( KTestRecipientSipUri() );
  1084     
  1150     
  1085     // No observer set, so expect nothing to be done, cannot be asserted
  1151     // No observer set, so expect nothing to be done, cannot be asserted
  1086     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
  1152     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
  1087 
  1153 
  1088     // Try all the stream states
  1154     // Try all the stream states
  1089     
  1155     
  1090     // EUninitialized, stream is created, unexpected change, nothing happens
  1156     // EUninitialized, stream is created, unexpected change, nothing happens
  1091     changedStream->iState = CMceMediaStream::EUninitialized;
  1157     changedStream->iState = CMceMediaStream::EUninitialized;
  1092     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1158     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1093     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1159     EUNIT_ASSERT( iObserver->IsReseted() );
  1094     
  1160     
  1095     // EInitialized, stream is initialized
  1161     // EInitialized, stream is initialized
  1096     changedStream->iState = CMceMediaStream::EInitialized;
  1162     changedStream->iState = CMceMediaStream::EInitialized;
  1097     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1163     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1098     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1164     EUNIT_ASSERT( iObserver->IsReseted() );
  1099     
  1165     
  1100     // EBuffering, stream is buffering
  1166     // EBuffering, stream is buffering
  1101     changedStream->iState = CMceMediaStream::EBuffering;
  1167     changedStream->iState = CMceMediaStream::EBuffering;
  1102     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1168     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1103     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1169     EUNIT_ASSERT( iObserver->IsReseted() );
  1104     
  1170     
  1105     // EIdle, stream is not receiving RTP
  1171     // EIdle, stream is not receiving RTP
  1106     changedStream->iState = CMceMediaStream::EIdle;
  1172     changedStream->iState = CMceMediaStream::EIdle;
  1107     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1173     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1108     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1174     EUNIT_ASSERT( iObserver->iStreamIdleCalled );
  1109     
  1175     
  1110     // EStreaming, stream is streaming
  1176     // EStreaming, stream is streaming
  1111     changedStream->iState = CMceMediaStream::EStreaming;
  1177     changedStream->iState = CMceMediaStream::EStreaming;
  1112     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1178     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1113     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1179     EUNIT_ASSERT( iObserver->iStreamStreamingCalled );
  1114                          TInt( CLcSessionObserverStub::EPlayerStateChanged ) )
  1180     iObserver->Reset();
  1115     iLcSessionObserver->Reset();
       
  1116     
  1181     
  1117     // EStreaming, stream is streaming, other than video out- or instream
  1182     // EStreaming, stream is streaming, other than video out- or instream
  1118     changedStream->iState = CMceMediaStream::EStreaming;
  1183     changedStream->iState = CMceMediaStream::EStreaming;
  1119     iLiveSession->CMusEngMceSession::StreamStateChanged( 
  1184     iLiveSession->CMusEngMceSession::StreamStateChanged( 
  1120                                 *iLiveSession->iSession->Streams()[1] );
  1185                                 *iLiveSession->iSession->Streams()[1] );
  1121     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1186     EUNIT_ASSERT( iObserver->IsReseted() );
  1122     iLcSessionObserver->Reset();
  1187     iObserver->Reset();
  1123     
  1188     
  1124     // EDisabled, stream is explicitly disabled
  1189     // EDisabled, stream is explicitly disabled
  1125     changedStream->iState = CMceMediaStream::EDisabled;
  1190     changedStream->iState = CMceMediaStream::EDisabled;
  1126     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1191     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1127     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1192     EUNIT_ASSERT( iObserver->IsReseted() );
  1128     
  1193     
  1129     // ENoResources, stream has no needed resources to stream
  1194     // ENoResources, stream has no needed resources to stream
  1130     changedStream->iState = CMceMediaStream::ENoResources;
  1195     changedStream->iState = CMceMediaStream::ENoResources;
  1131     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1196     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1132     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1197     EUNIT_ASSERT( iObserver->IsReseted() );
  1133     
  1198     
  1134     // ETranscodingRequired, stream requires non-realtime transcoding
  1199     // ETranscodingRequired, stream requires non-realtime transcoding
  1135     changedStream->iState = CMceMediaStream::ETranscodingRequired;
  1200     changedStream->iState = CMceMediaStream::ETranscodingRequired;
  1136     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1201     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1137     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1202     EUNIT_ASSERT( iObserver->IsReseted() );
  1138     
  1203     
  1139     // ETranscoding, stream is transcoding in non-realtime
  1204     // ETranscoding, stream is transcoding in non-realtime
  1140     changedStream->iState = CMceMediaStream::ETranscoding;
  1205     changedStream->iState = CMceMediaStream::ETranscoding;
  1141     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1206     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1142     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1207     EUNIT_ASSERT( iObserver->IsReseted() );
  1143     
  1208     
  1144     }
  1209     }
  1145     
  1210     
  1146 
  1211 
  1147 // -----------------------------------------------------------------------------
  1212 // -----------------------------------------------------------------------------
  1148 // All the possibilities are tested in order to make sure unit tests are changed
  1213 // All the possibilities are tested in order to make sure unit tests are changed
  1149 // when function is changed
  1214 // when function is changed
  1150 // -----------------------------------------------------------------------------
  1215 // -----------------------------------------------------------------------------
  1151 //  
  1216 //  
  1152 void UT_CMusEngMceSession::UT_StreamStateChangedWithSourceL()
  1217 void UT_CMusEngMceSession::UT_CMusEngMceSession_StreamStateChangedWithSourceL()
  1153     {
  1218     {
  1154     // Try without a session, nothing happens
  1219     // Try without a session, nothing happens
  1155     iLiveSession->CMusEngMceSession::StreamStateChanged( 
  1220     iLiveSession->CMusEngMceSession::StreamStateChanged( 
  1156                                         *CMceAudioStream::NewLC(),
  1221                                         *CMceAudioStream::NewLC(),
  1157                                         *CMceRtpSource::NewLC() );
  1222                                         *CMceRtpSource::NewLC() );
  1158                                         
  1223                                         
  1159     CleanupStack::PopAndDestroy(); // rtp                                    
  1224     CleanupStack::PopAndDestroy(); // rtp                                    
  1160     CleanupStack::PopAndDestroy(); // audiostream
  1225     CleanupStack::PopAndDestroy(); // audiostream
  1161     
  1226     
  1162     // Simulate sending invite
  1227     // Simulate sending invite
  1163     iLiveSession->EstablishLcSessionL();
  1228     iLiveSession->InviteL( KTestRecipientSipUri() );
  1164     
  1229     
  1165     // Try all the stream states
  1230     // Try all the stream states
  1166     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
  1231     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
  1167     
  1232     
  1168     // EUninitialized, stream is created, unexpected change, nothing happens
  1233     // EUninitialized, stream is created, unexpected change, nothing happens
  1169     changedStream->iState = CMceMediaStream::EUninitialized;
  1234     changedStream->iState = CMceMediaStream::EUninitialized;
  1170     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1235     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1171     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1236     EUNIT_ASSERT( iObserver->IsReseted() );
  1172     
  1237     
  1173     // EInitialized, stream is initialized
  1238     // EInitialized, stream is initialized
  1174     changedStream->iState = CMceMediaStream::EInitialized;
  1239     changedStream->iState = CMceMediaStream::EInitialized;
  1175     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1240     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1176     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1241     EUNIT_ASSERT( iObserver->IsReseted() );
  1177     
  1242     
  1178     // EBuffering, stream is buffering
  1243     // EBuffering, stream is buffering
  1179     changedStream->iState = CMceMediaStream::EBuffering;
  1244     changedStream->iState = CMceMediaStream::EBuffering;
  1180     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1245     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1181     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1246     EUNIT_ASSERT( iObserver->IsReseted() );
  1182     
  1247     
  1183     // EIdle, stream is not receiving RTP
  1248     // EIdle, stream is not receiving RTP
  1184     changedStream->iState = CMceMediaStream::EIdle;
  1249     changedStream->iState = CMceMediaStream::EIdle;
  1185     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1250     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1186     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1251     EUNIT_ASSERT( iObserver->iStreamIdleCalled );
  1187     
  1252     
  1188     // EStreaming, stream is streaming
  1253     // EStreaming, stream is streaming
  1189     changedStream->iState = CMceMediaStream::EStreaming;
  1254     changedStream->iState = CMceMediaStream::EStreaming;
  1190     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1255     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1191     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1256     EUNIT_ASSERT( iObserver->iStreamStreamingCalled );
  1192                          TInt( CLcSessionObserverStub::EPlayerStateChanged ) )
  1257     iObserver->Reset();
  1193     iLcSessionObserver->Reset();
       
  1194     
  1258     
  1195     // EDisabled, stream is explicitly disabled
  1259     // EDisabled, stream is explicitly disabled
  1196     changedStream->iState = CMceMediaStream::EDisabled;
  1260     changedStream->iState = CMceMediaStream::EDisabled;
  1197     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1261     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1198     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1262     EUNIT_ASSERT( iObserver->IsReseted() );
  1199     
  1263     
  1200     // ENoResources, stream has no needed resources to stream
  1264     // ENoResources, stream has no needed resources to stream
  1201     changedStream->iState = CMceMediaStream::ENoResources;
  1265     changedStream->iState = CMceMediaStream::ENoResources;
  1202     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1266     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1203     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1267     EUNIT_ASSERT( iObserver->IsReseted() );
  1204     
  1268     
  1205     // ETranscodingRequired, stream requires non-realtime transcoding
  1269     // ETranscodingRequired, stream requires non-realtime transcoding
  1206     changedStream->iState = CMceMediaStream::ETranscodingRequired;
  1270     changedStream->iState = CMceMediaStream::ETranscodingRequired;
  1207     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1271     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1208     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1272     EUNIT_ASSERT( iObserver->IsReseted() );
  1209     
  1273     
  1210     // ETranscoding, stream is transcoding in non-realtime
  1274     // ETranscoding, stream is transcoding in non-realtime
  1211     changedStream->iState = CMceMediaStream::ETranscoding;
  1275     changedStream->iState = CMceMediaStream::ETranscoding;
  1212     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1276     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1213     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1277     EUNIT_ASSERT( iObserver->IsReseted() );
  1214     
  1278     
  1215     }
  1279     }
  1216 
  1280 
  1217 
  1281 
  1218 // -----------------------------------------------------------------------------
  1282 // -----------------------------------------------------------------------------
  1219 // All the possibilities are tested in order to make sure unit tests are changed
  1283 // All the possibilities are tested in order to make sure unit tests are changed
  1220 // when function is changed
  1284 // when function is changed
  1221 // -----------------------------------------------------------------------------
  1285 // -----------------------------------------------------------------------------
  1222 //  
  1286 //  
  1223 void UT_CMusEngMceSession::UT_StreamStateChangedWithSinkL()
  1287 void UT_CMusEngMceSession::UT_CMusEngMceSession_StreamStateChangedWithSinkL()
  1224     {
  1288     {
  1225     // Try without a session, nothing happens
  1289     // Try without a session, nothing happens
  1226     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
  1290     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
  1227     iLiveSession->CMusEngMceSession::StreamStateChanged( *audioStream );
  1291     iLiveSession->CMusEngMceSession::StreamStateChanged( *audioStream );
  1228     CleanupStack::PopAndDestroy( audioStream );
  1292     CleanupStack::PopAndDestroy( audioStream );
  1229     
  1293     
  1230     // Simulate sending invite
  1294     // Simulate sending invite
  1231     iLiveSession->EstablishLcSessionL();
  1295     iLiveSession->InviteL( KTestRecipientSipUri() );
  1232     
  1296     
  1233     // Try all the stream states
  1297     // Try all the stream states
  1234     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
  1298     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
  1235     
  1299     
  1236     // EUninitialized, stream is created, unexpected change, nothing happens
  1300     // EUninitialized, stream is created, unexpected change, nothing happens
  1237     changedStream->iState = CMceMediaStream::EUninitialized;
  1301     changedStream->iState = CMceMediaStream::EUninitialized;
  1238     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1302     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1239     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1303     EUNIT_ASSERT( iObserver->IsReseted() );
  1240     
  1304     
  1241     // EInitialized, stream is initialized
  1305     // EInitialized, stream is initialized
  1242     changedStream->iState = CMceMediaStream::EInitialized;
  1306     changedStream->iState = CMceMediaStream::EInitialized;
  1243     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1307     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1244     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1308     EUNIT_ASSERT( iObserver->IsReseted() );
  1245     
  1309     
  1246     // EBuffering, stream is buffering
  1310     // EBuffering, stream is buffering
  1247     changedStream->iState = CMceMediaStream::EBuffering;
  1311     changedStream->iState = CMceMediaStream::EBuffering;
  1248     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1312     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1249     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1313     EUNIT_ASSERT( iObserver->IsReseted() );
  1250     
  1314     
  1251     // EIdle, stream is not receiving RTP
  1315     // EIdle, stream is not receiving RTP
  1252     changedStream->iState = CMceMediaStream::EIdle;
  1316     changedStream->iState = CMceMediaStream::EIdle;
  1253     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1317     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1254     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1318     EUNIT_ASSERT( iObserver->iStreamIdleCalled );
  1255     
  1319     
  1256     // EStreaming, stream is streaming
  1320     // EStreaming, stream is streaming
  1257     changedStream->iState = CMceMediaStream::EStreaming;
  1321     changedStream->iState = CMceMediaStream::EStreaming;
  1258     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1322     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1259     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1323     EUNIT_ASSERT( iObserver->iStreamStreamingCalled );
  1260                          TInt( CLcSessionObserverStub::EPlayerStateChanged ) )
  1324     iObserver->Reset();
  1261     iLcSessionObserver->Reset();
       
  1262     
  1325     
  1263     // EDisabled, stream is explicitly disabled
  1326     // EDisabled, stream is explicitly disabled
  1264     changedStream->iState = CMceMediaStream::EDisabled;
  1327     changedStream->iState = CMceMediaStream::EDisabled;
  1265     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1328     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1266     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1329     EUNIT_ASSERT( iObserver->IsReseted() );
  1267     
  1330     
  1268     // ENoResources, stream has no needed resources to stream
  1331     // ENoResources, stream has no needed resources to stream
  1269     changedStream->iState = CMceMediaStream::ENoResources;
  1332     changedStream->iState = CMceMediaStream::ENoResources;
  1270     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1333     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1271     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1334     EUNIT_ASSERT( iObserver->IsReseted() );
  1272     
  1335     
  1273     // ETranscodingRequired, stream requires non-realtime transcoding
  1336     // ETranscodingRequired, stream requires non-realtime transcoding
  1274     changedStream->iState = CMceMediaStream::ETranscodingRequired;
  1337     changedStream->iState = CMceMediaStream::ETranscodingRequired;
  1275     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1338     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1276     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1339     EUNIT_ASSERT( iObserver->IsReseted() );
  1277     
  1340     
  1278     // ETranscoding, stream is transcoding in non-realtime
  1341     // ETranscoding, stream is transcoding in non-realtime
  1279     changedStream->iState = CMceMediaStream::ETranscoding;
  1342     changedStream->iState = CMceMediaStream::ETranscoding;
  1280     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1343     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
  1281     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1344     EUNIT_ASSERT( iObserver->IsReseted() );
  1282     
  1345     
  1283     }        
  1346     }        
  1284 
  1347 
  1285 
  1348 
  1286 // -----------------------------------------------------------------------------
  1349 // -----------------------------------------------------------------------------
  1287 //
  1350 //
  1288 // -----------------------------------------------------------------------------
  1351 // -----------------------------------------------------------------------------
  1289 //    
  1352 //    
  1290 void UT_CMusEngMceSession::UT_SessionStateChangedL()
  1353 void UT_CMusEngMceSession::UT_CMusEngMceSession_SessionStateChangedL()
  1291     {
  1354     {
  1292     // Simulate sending invite
  1355     // Simulate sending invite
  1293     iLiveSession->EstablishLcSessionL();   
  1356     iLiveSession->InviteL( KTestRecipientSipUri() );   
  1294 
  1357 
  1295     // No container, so expect to be handled as internal error
  1358     // No container, so expect to be handled as internal error
  1296     iLiveSession->SessionStateChanged( *iLiveSession->iSession, NULL );
  1359     iLiveSession->SessionStateChanged( *iLiveSession->iSession, NULL );
  1297     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1360     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
  1298                          TInt( CLcSessionObserverStub::ESessionFailed ) )
  1361     iObserver->Reset();    
  1299     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1300     iLcSessionObserver->Reset();    
       
  1301     
  1362     
  1302     // Try to tell session about some other session's state transition
  1363     // Try to tell session about some other session's state transition
  1303     
  1364     
  1304     TMceTransactionDataContainer container;
  1365     TMceTransactionDataContainer container;
  1305  
  1366  
  1306     iLiveSession->SessionStateChanged( *iSomeOtherSession->iSession, &container );
  1367     iLiveSession->SessionStateChanged( *iSomeOtherSession->iSession, &container );
  1307     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );    
  1368     EUNIT_ASSERT( iObserver->IsReseted() );    
  1308       
  1369       
  1309     // Try all the normal cases:
  1370     // Try all the normal cases:
  1310     
  1371     
  1311     // EIdle
  1372     // EIdle
  1312     iLiveSession->iSession->iState = CMceSession::EIdle;
  1373     iLiveSession->iSession->iState = CMceSession::EIdle;
  1314     // Set up any text to simulate reasonphrase
  1375     // Set up any text to simulate reasonphrase
  1315     HBufC8* anyReasonPhrase = KTestOriginator().AllocL();
  1376     HBufC8* anyReasonPhrase = KTestOriginator().AllocL();
  1316     container.SetReasonPhrase( anyReasonPhrase );
  1377     container.SetReasonPhrase( anyReasonPhrase );
  1317     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1378     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1318                                        &container );
  1379                                        &container );
  1319     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1380     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
  1320                          TInt( CLcSessionObserverStub::ESessionFailed ) )
  1381     iObserver->Reset();
  1321     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1322     iLcSessionObserver->Reset();
       
  1323     container.Clear();
  1382     container.Clear();
  1324     
  1383     
  1325     // EOffering
  1384     // EOffering
  1326     iLiveSession->iSession->iState = CMceSession::EOffering;
  1385     iLiveSession->iSession->iState = CMceSession::EOffering;
  1327     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1386     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1328     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1387     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1329                                        &container );
  1388                                        &container );
  1330     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1389     EUNIT_ASSERT( iObserver->IsReseted() );
  1331     
  1390     
  1332     // EIncoming
  1391     // EIncoming
  1333     iLiveSession->iSession->iState = CMceSession::EIncoming;
  1392     iLiveSession->iSession->iState = CMceSession::EIncoming;
  1334     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1393     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1335     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1394     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1336                                        &container );
  1395                                        &container );
  1337     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1396     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
  1338                          TInt( CLcSessionObserverStub::ESessionFailed ) )
  1397     iObserver->Reset();
  1339     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1340     iLcSessionObserver->Reset();
       
  1341     
  1398     
  1342     // EReserving
  1399     // EReserving
  1343     iLiveSession->iSession->iState = CMceSession::EReserving;
  1400     iLiveSession->iSession->iState = CMceSession::EReserving;
  1344     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1401     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1345     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1402     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1346                                        &container );
  1403                                        &container );
  1347     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1404     EUNIT_ASSERT( iObserver->IsReseted() );
  1348     
  1405     
  1349     // EAnswering
  1406     // EAnswering
  1350     iLiveSession->iSession->iState = CMceSession::EAnswering;
  1407     iLiveSession->iSession->iState = CMceSession::EAnswering;
  1351     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1408     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1352     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1409     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1353                                        &container );
  1410                                        &container );
  1354     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1411     EUNIT_ASSERT( iObserver->IsReseted() );
  1355     
  1412     
  1356     // EProceeding
  1413     // EProceeding
  1357     iLiveSession->iSession->iState = CMceSession::EProceeding;
  1414     iLiveSession->iSession->iState = CMceSession::EProceeding;
  1358     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1415     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1359     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1416     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1360                                        &container );
  1417                                        &container );
  1361     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1418     EUNIT_ASSERT( iObserver->IsReseted() );
  1362     
  1419     
  1363     // EEstablished
  1420     // EEstablished
  1364     iLiveSession->iSession->iState = CMceSession::EEstablished;
  1421     iLiveSession->iSession->iState = CMceSession::EEstablished;
  1365     container.SetStatusCode( KSipStatusCode200OK );
  1422     container.SetStatusCode( KSipStatusCode200OK );
  1366     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1423     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1367                                        &container );
  1424                                        &container );
  1368     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1425     EUNIT_ASSERT( iObserver->iSessionEstablishedCalled );
  1369                          TInt( CLcSessionObserverStub::ESessionStateChanged ) )
  1426     iObserver->Reset();
  1370     iLcSessionObserver->Reset();
       
  1371     
  1427     
  1372     // EEstablished again (meaning expiration of session timer 
  1428     // EEstablished again (meaning expiration of session timer 
  1373     // and refresment of session )
  1429     // and refresment of session )
  1374     iLiveSession->iSession->iState = CMceSession::EEstablished;
  1430     iLiveSession->iSession->iState = CMceSession::EEstablished;
  1375     container.SetStatusCode( KSipStatusCode200OK );
  1431     container.SetStatusCode( KSipStatusCode200OK );
  1376     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1432     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1377                                        &container );
  1433                                        &container );
  1378     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1434     EUNIT_ASSERT( iObserver->IsReseted() );
  1379     
  1435     
  1380     // ECancelling
  1436     // ECancelling
  1381     iLiveSession->iSession->iState = CMceSession::ECancelling;
  1437     iLiveSession->iSession->iState = CMceSession::ECancelling;
  1382     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1438     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1383     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1439     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1384                                        &container );
  1440                                        &container );
  1385     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1441     EUNIT_ASSERT( iObserver->IsReseted() );
  1386     iLcSessionObserver->Reset();
  1442     iObserver->Reset();
  1387     
  1443     
  1388     // ETerminating
  1444     // ETerminating
  1389     iLiveSession->iSession->iState = CMceSession::ETerminating;
  1445     iLiveSession->iSession->iState = CMceSession::ETerminating;
  1390     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1446     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1391     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1447     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1392                                        &container );
  1448                                        &container );
  1393     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1449     EUNIT_ASSERT( iObserver->IsReseted() );
  1394     iLcSessionObserver->Reset();
  1450     iObserver->Reset();
  1395     
  1451     
  1396     // ETerminated
  1452     // ETerminated
  1397     iLiveSession->iSession->iState = CMceSession::ETerminated;
  1453     iLiveSession->iSession->iState = CMceSession::ETerminated;
  1398     container.SetStatusCode( KSipStatusCode200OK );
  1454     container.SetStatusCode( KSipStatusCode200OK );
  1399     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1455     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
  1400                                        &container );
  1456                                        &container );
  1401     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1457     EUNIT_ASSERT( iObserver->iSessionTerminatedCalled );
  1402                          TInt( CLcSessionObserverStub::ESessionStateChanged ) )
  1458     iObserver->Reset();
  1403     iLcSessionObserver->Reset();
       
  1404     
  1459     
  1405     // Default case
  1460     // Default case
  1406     iLiveSession->iSession->iState = static_cast<CMceSession::TState>( 10 );
  1461     iLiveSession->iSession->iState = static_cast<CMceSession::TState>( 10 );
  1407     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1462     container.SetStatusCode( KSipStatusCodeNoCodeSet );
  1408     iLiveSession->SessionStateChanged( *iLiveSession->iSession, &container );
  1463     iLiveSession->SessionStateChanged( *iLiveSession->iSession, &container );
  1409     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
  1464     EUNIT_ASSERT( iObserver->IsReseted() );
  1410 
  1465 
  1411     }
  1466     }
       
  1467     
  1412 
  1468 
  1413 // -----------------------------------------------------------------------------
  1469 // -----------------------------------------------------------------------------
  1414 //
  1470 //
  1415 // -----------------------------------------------------------------------------
  1471 // -----------------------------------------------------------------------------
  1416 //     
  1472 //     
  1417 void UT_CMusEngMceSession::UT_HandleSessionStateChanged_EncoderKeyStoringL()
  1473 void UT_CMusEngMceSession::UT_CMusEngMceSession_SessionConnectionStateChangedL()
  1418     {
       
  1419     // Make repository empty, config keys must be written
       
  1420     CRepository::SetStubAvcConfigKeysL( KNullDesC8() );
       
  1421     
       
  1422     // Invite    
       
  1423     iLiveSession->EstablishLcSessionL();
       
  1424     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
  1425     
       
  1426     // Force failure on CenRep
       
  1427     CRepository::iForceFailWithCode = KErrNoMemory;
       
  1428     
       
  1429     // Simulate session state transition notification
       
  1430     iLiveSession->HandleSessionStateChanged( 
       
  1431         *iLiveSession->iSession, 200, KNullDesC8() );
       
  1432     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1433                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1434     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrNoMemory )    
       
  1435     
       
  1436     // Normal case, something will be written to CenRep    
       
  1437     iClipSession->EstablishLcSessionL();
       
  1438     iClipSession->iSession->iState = CMceSession::EEstablished;
       
  1439     iClipSession->HandleSessionStateChanged( 
       
  1440                             *iClipSession->iSession, 200, KNullDesC8() );  
       
  1441     HBufC8* info = MultimediaSharingSettings::EncoderConfigInfoLC();
       
  1442     EUNIT_ASSERT_NOT_EQUALS( *info, KMusAvcBitrateLevel_1b_ConfigKey() )
       
  1443     CleanupStack::PopAndDestroy( info );
       
  1444     }
       
  1445 
       
  1446 // -----------------------------------------------------------------------------
       
  1447 //
       
  1448 // -----------------------------------------------------------------------------
       
  1449 //     
       
  1450 void UT_CMusEngMceSession::UT_SessionConnectionStateChangedL()
       
  1451     {
  1474     {
  1452     
  1475     
  1453     // Try to tell session about another session's connection state change
  1476     // Try to tell session about another session's connection state change
  1454     
  1477     
  1455     iLiveSession->SessionConnectionStateChanged( *iSomeOtherSession->iSession, 
  1478     iLiveSession->SessionConnectionStateChanged( *iSomeOtherSession->iSession, 
  1456                                                  ETrue );
  1479                                                  ETrue );
  1457     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // No session yet, nothing happened
  1480     EUNIT_ASSERT( iObserver->IsReseted() ); // No session yet, nothing happened
  1458     
  1481     
  1459     // Simulate sending invite
  1482     // Simulate sending invite
  1460     iLiveSession->EstablishLcSessionL();
  1483     iLiveSession->InviteL( KTestRecipientSipUri() );
  1461     
  1484     
  1462     // Now try again to notify session about session connection state change
  1485     // Now try again to notify session about session connection state change
  1463     // of an another session
  1486     // of an another session
  1464     iLiveSession->SessionConnectionStateChanged( *iSomeOtherSession->iSession, 
  1487     iLiveSession->SessionConnectionStateChanged( *iSomeOtherSession->iSession, 
  1465                                                  ETrue );
  1488                                                  ETrue );
  1466     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // Wrong session, nothing happened
  1489     EUNIT_ASSERT( iObserver->IsReseted() ); // Wrong session, nothing happened
  1467     
  1490     
  1468     // Try tell session connection state is active
  1491     // Try tell session connection state is active
  1469     iLiveSession->SessionConnectionStateChanged( *iLiveSession->iSession, 
  1492     iLiveSession->SessionConnectionStateChanged( *iLiveSession->iSession, 
  1470                                                  ETrue );
  1493                                                  ETrue );
  1471     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // Session active, nothing happened
  1494     EUNIT_ASSERT( iObserver->IsReseted() ); // Session active, nothing happened
  1472     
  1495     
  1473     // Try tell session connection state is inactive
  1496     // Try tell session connection state is inactive
  1474     iLiveSession->SessionConnectionStateChanged( *iLiveSession->iSession, 
  1497     iLiveSession->SessionConnectionStateChanged( *iLiveSession->iSession, 
  1475                                                  EFalse );
  1498                                                  EFalse );
  1476     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1499     EUNIT_ASSERT( iObserver->iSessionConnectionLostCalled );
  1477                          TInt( CLcSessionObserverStub::ESessionFailed ) )
  1500     iObserver->Reset();
  1478     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError,
  1501     
  1479                          TInt( MLcSession::EConnectionLost ) )
       
  1480     iLcSessionObserver->Reset();  
       
  1481     }
  1502     }
  1482     
  1503     
  1483 
  1504 
  1484 // -----------------------------------------------------------------------------
  1505 // -----------------------------------------------------------------------------
  1485 //
  1506 //
  1486 // -----------------------------------------------------------------------------
  1507 // -----------------------------------------------------------------------------
  1487 // 
  1508 // 
  1488 void UT_CMusEngMceSession::UT_FailedL()
  1509 void UT_CMusEngMceSession::UT_CMusEngMceSession_FailedL()
  1489     {
  1510     {
  1490     // Try to tell session about failure of another session
  1511     // Try to tell session about failure of another session
  1491 
  1512 
  1492     iLiveSession->Failed( *iSomeOtherSession->iSession, 0 );
  1513     iLiveSession->Failed( *iSomeOtherSession->iSession, 0 );
  1493     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // No session yet, nothing happened
  1514     EUNIT_ASSERT( iObserver->IsReseted() ); // No session yet, nothing happened
  1494     
  1515     
  1495     // Simulate sending invite
  1516     // Simulate sending invite
  1496     iLiveSession->EstablishLcSessionL();
  1517     iLiveSession->InviteL( KTestRecipientSipUri() );
  1497     
  1518     
  1498     // Now try again to notify session about failure of an another session
  1519     // Now try again to notify session about failure of an another session
  1499     iLiveSession->Failed( *iSomeOtherSession->iSession, 0 );
  1520     iLiveSession->Failed( *iSomeOtherSession->iSession, 0 );
  1500     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // Wrong session, nothing happened
  1521     EUNIT_ASSERT( iObserver->IsReseted() ); // Wrong session, nothing happened
  1501     
  1522     
  1502     // Tell session that it has failed
  1523     // Tell session that it has failed
  1503     iLiveSession->Failed( *iLiveSession->iSession, KErrNotFound );
  1524     iLiveSession->Failed( *iLiveSession->iSession, 0 );
  1504     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1525     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
  1505                          TInt( CLcSessionObserverStub::ESessionFailed ) )
  1526     iObserver->Reset();
  1506     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrNotFound )
  1527     
  1507     iLcSessionObserver->Reset();
       
  1508     }
  1528     }
  1509     
  1529     
  1510 
  1530 
  1511 // -----------------------------------------------------------------------------
  1531 // -----------------------------------------------------------------------------
  1512 //
  1532 //
  1513 // -----------------------------------------------------------------------------
  1533 // -----------------------------------------------------------------------------
  1514 //     
  1534 //     
  1515 void UT_CMusEngMceSession::UT_UpdateFailedL()
  1535 void UT_CMusEngMceSession::UT_CMusEngMceSession_UpdateFailedL()
  1516     {
  1536     {
  1517     // Try to tell session about update failure of another session
  1537     // Try to tell session about update failure of another session
  1518     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, NULL );
  1538     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, NULL );
  1519     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1539     EUNIT_ASSERT( iObserver->iSessionFailedCalled ); // No container, internal error
  1520                          TInt( CLcSessionObserverStub::ESessionFailed ) )
  1540     iObserver->Reset();
  1521     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1522     iLcSessionObserver->Reset();
       
  1523     
  1541     
  1524     // Try again with container
  1542     // Try again with container
  1525     TMceTransactionDataContainer container;
  1543     TMceTransactionDataContainer container;
  1526     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, &container );
  1544     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, &container );
  1527     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // No session yet, nothing happened
  1545     EUNIT_ASSERT( iObserver->IsReseted() ); // No session yet, nothing happened
  1528     
  1546     
  1529     // Invite and try again.
  1547     // Invite and try again.
  1530     iLiveSession->EstablishLcSessionL();
  1548     iLiveSession->InviteL( KTestRecipientSipUri() );
  1531     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, &container );
  1549     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, &container );
  1532     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // Wrong session, nothing happened¨
  1550     EUNIT_ASSERT( iObserver->IsReseted() ); // Wrong session, nothing happened¨
  1533     
  1551     
  1534     // Try with right session
  1552     // Try with right session
  1535     iLiveSession->UpdateFailed( *iLiveSession->iSession, &container );
  1553     iLiveSession->UpdateFailed( *iLiveSession->iSession, &container );
  1536     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1554     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
  1537                          TInt( CLcSessionObserverStub::ESessionFailed ) )
  1555     iObserver->Reset();
  1538     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1539     iLcSessionObserver->Reset();
       
  1540     }
  1556     }
  1541     
  1557     
  1542 
  1558 
  1543 // -----------------------------------------------------------------------------
  1559 // -----------------------------------------------------------------------------
  1544 //
  1560 //
  1545 // -----------------------------------------------------------------------------
  1561 // -----------------------------------------------------------------------------
  1546 // 
  1562 // 
  1547 void UT_CMusEngMceSession::UT_SRReceivedL()
  1563 void UT_CMusEngMceSession::UT_CMusEngMceSession_SRReceivedL()
  1548     {
  1564     {
  1549     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
  1565     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
  1550     
  1566     
  1551     // No session yet, nothing happens
  1567     // No session yet, nothing happens
  1552     iLiveSession->SRReceived( *iSomeOtherSession->iSession,
  1568     iLiveSession->SRReceived( *iSomeOtherSession->iSession,
  1585 
  1601 
  1586 // -----------------------------------------------------------------------------
  1602 // -----------------------------------------------------------------------------
  1587 //
  1603 //
  1588 // -----------------------------------------------------------------------------
  1604 // -----------------------------------------------------------------------------
  1589 //     
  1605 //     
  1590 void UT_CMusEngMceSession::UT_RRReceivedL()
  1606 void UT_CMusEngMceSession::UT_CMusEngMceSession_RRReceivedL()
  1591     {
  1607     {
  1592     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
  1608     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
  1593     
  1609     
  1594     // No session yet, nothing happens
  1610     // No session yet, nothing happens
  1595     iLiveSession->RRReceived( *iSomeOtherSession->iSession,
  1611     iLiveSession->RRReceived( *iSomeOtherSession->iSession,
  1622                               *(iLiveSession->iSession->Streams()[0]) );
  1638                               *(iLiveSession->iSession->Streams()[0]) );
  1623 
  1639 
  1624     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );    
  1640     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );    
  1625     }
  1641     }
  1626     
  1642     
       
  1643 
       
  1644 // -----------------------------------------------------------------------------
       
  1645 //
       
  1646 // -----------------------------------------------------------------------------
       
  1647 //      
       
  1648 void UT_CMusEngMceSession::UT_CMusEngMceSession_InactivityTimeoutL()
       
  1649     {    
       
  1650     //   Construct an audio stream for this test
       
  1651     
       
  1652     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
       
  1653     
       
  1654     CMceRtpSource* rtpSource = CMceRtpSource::NewLC();
       
  1655     audioStream->SetSourceL( rtpSource );
       
  1656     CleanupStack::Pop( rtpSource );
       
  1657     
       
  1658     iReceiveSession->InactivityTimeout( *audioStream, *rtpSource );
       
  1659     
       
  1660     EUNIT_ASSERT( iObserver->IsReseted() )
       
  1661     
       
  1662     CleanupStack::PopAndDestroy( audioStream );
       
  1663     
       
  1664     // And now real inactivity timeout
       
  1665     
       
  1666     iReceiveSession->InactivityTimeout( 
       
  1667                 *iReceiveSession->iSession->Streams()[0],
       
  1668                 *static_cast<CMceRtpSource*>
       
  1669                         (iReceiveSession->iSession->Streams()[0]->Source()) );
       
  1670     
       
  1671     EUNIT_ASSERT( iObserver->iStreamIdleCalled )
       
  1672     
       
  1673     iObserver->Reset();
       
  1674     }
       
  1675     
  1627     
  1676     
  1628 // -----------------------------------------------------------------------------
  1677 // -----------------------------------------------------------------------------
  1629 //
  1678 //
  1630 // -----------------------------------------------------------------------------
  1679 // -----------------------------------------------------------------------------
  1631 //       
  1680 //       
  1632 void UT_CMusEngMceSession::UT_SsrcAddedL()
  1681 void UT_CMusEngMceSession::UT_CMusEngMceSession_SsrcAddedL()
  1633     {
  1682     {
  1634     // As CMusEngMceSession::SsrcAdded is expected to do nothing, just call
  1683     // As CMusEngMceSession::SsrcAdded is expected to do nothing, just call
  1635     // it to make sure it does not weaken the test coverage
  1684     // it to make sure it does not weaken the test coverage
  1636     
  1685     
  1637     CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>( 
  1686     CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>( 
  1646 
  1695 
  1647 // -----------------------------------------------------------------------------
  1696 // -----------------------------------------------------------------------------
  1648 //
  1697 //
  1649 // -----------------------------------------------------------------------------
  1698 // -----------------------------------------------------------------------------
  1650 //  
  1699 //  
  1651 void UT_CMusEngMceSession::UT_SsrcRemovedL()
  1700 void UT_CMusEngMceSession::UT_CMusEngMceSession_SsrcRemovedL()
  1652     {
  1701     {
  1653     // As CMusEngMceSession::SsrcRemoved is expected to do nothing, just call
  1702     // As CMusEngMceSession::SsrcRemoved is expected to do nothing, just call
  1654     // it to make sure it does not weaken the test coverage
  1703     // it to make sure it does not weaken the test coverage
  1655     
  1704     
  1656     CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>( 
  1705     CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>( 
  1665 
  1714 
  1666 // -----------------------------------------------------------------------------
  1715 // -----------------------------------------------------------------------------
  1667 //
  1716 //
  1668 // -----------------------------------------------------------------------------
  1717 // -----------------------------------------------------------------------------
  1669 //  
  1718 //  
  1670 void UT_CMusEngMceSession::UT_UpdateTimerEventL()
  1719 void UT_CMusEngMceSession::UT_CMusEngMceSession_UpdateTimerEventL()
  1671     {
  1720     {
  1672     iLcSessionObserver->Reset();
       
  1673     iLiveSession->UpdateTimerEvent();
  1721     iLiveSession->UpdateTimerEvent();
  1674     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1722     EUNIT_ASSERT( iObserver->iSessionTimeChangedCalled )
  1675                          TInt( CLcSessionObserverStub::EUnknown ) )
       
  1676     EUNIT_ASSERT( iLiveSession->iUpdateTimer->IsActive() )
  1723     EUNIT_ASSERT( iLiveSession->iUpdateTimer->IsActive() )
  1677     iLiveSession->iUpdateTimer->Cancel();
  1724     iLiveSession->iUpdateTimer->Cancel();
  1678     iLcSessionObserver->Reset();
  1725     iObserver->Reset();
  1679     
  1726     
  1680     iLiveSession->iSecondsFromLastRtcpReport = 25; // >KMusEngRtcpInactivityThreshold
  1727     iLiveSession->iSecondsFromLastRtcpReport = 25; // >KMusEngRtcpInactivityThreshold
  1681     iLiveSession->UpdateTimerEvent();
  1728     iLiveSession->UpdateTimerEvent();
  1682     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
  1729     EUNIT_ASSERT( iObserver->iSessionTimeChangedCalled )
  1683                          TInt( CLcSessionObserverStub::ESessionFailed ) )
  1730     EUNIT_ASSERT( iObserver->iInactivityTimeoutCalled );
  1684     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError,
       
  1685                          TInt( MLcSession::EMediaInactivityTimeout ) )
       
  1686     EUNIT_ASSERT( iLiveSession->iUpdateTimer->IsActive() )
  1731     EUNIT_ASSERT( iLiveSession->iUpdateTimer->IsActive() )
  1687     iLiveSession->iUpdateTimer->Cancel();
  1732     iLiveSession->iUpdateTimer->Cancel();
  1688     iLcSessionObserver->Reset(); 
  1733     iObserver->Reset();
  1689     }   
  1734     }   
  1690 
  1735 
  1691 
  1736 
  1692 // -----------------------------------------------------------------------------
  1737 // -----------------------------------------------------------------------------
  1693 //
  1738 //
  1694 // -----------------------------------------------------------------------------
  1739 // -----------------------------------------------------------------------------
  1695 //
  1740 //
  1696 void UT_CMusEngMceSession::UT_IsRoamingBetweenAPsAllowedL()
  1741 void UT_CMusEngMceSession::UT_CMusEngMceSession_IsRoamingBetweenAPsAllowedL()
  1697     {
  1742     {
  1698     // No session
  1743     // No session
  1699     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
  1744     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
  1700 
  1745 
  1701     // Session idle
  1746     // Session idle
  1702     iLiveSession->EstablishLcSessionL();
  1747     _LIT( KRecipientSipUri, "sip:user@some.where" );
       
  1748     iLiveSession->InviteL( KRecipientSipUri );
  1703     iLiveSession->iSession->iState = CMceSession::EIdle;
  1749     iLiveSession->iSession->iState = CMceSession::EIdle;
  1704     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
  1750     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
  1705     
  1751     
  1706     // Session established
  1752     // Session established
  1707     iLiveSession->iSession->iState = CMceSession::EEstablished;
  1753     iLiveSession->iSession->iState = CMceSession::EEstablished;
  1714 
  1760 
  1715 // -----------------------------------------------------------------------------
  1761 // -----------------------------------------------------------------------------
  1716 //
  1762 //
  1717 // -----------------------------------------------------------------------------
  1763 // -----------------------------------------------------------------------------
  1718 //
  1764 //
  1719 void UT_CMusEngMceSession::UT_SaveContactL()
  1765 void UT_CMusEngMceSession::UT_CMusEngMceSession_VolumeChangedL()
  1720     {     
  1766     {
  1721     _LIT8( KTestSaveContactAddr, "sip:abc@10.10.10.10");
  1767     // Try without session, nothing happens
  1722     
  1768     EUNIT_ASSERT( iObserver->iVolume == 0 );
  1723     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
  1769     iLiveSession->VolumeChanged( 1, EFalse );
  1724                                         NMusSessionApi::KTelNumber,
  1770     EUNIT_ASSERT( !VerifySpeakersVolume(*iLiveSession, 1) )
  1725                                         _L("12341234") ) );
  1771     EUNIT_ASSERT( iObserver->iVolume == 0 );
  1726     
  1772 
  1727     // Operator variant
  1773     // Establish session
  1728     iLiveSession->iOperatorVariant = ETrue;
  1774     ESTABLISH_OUT_SESSION( iClipSession )
  1729     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
  1775     
  1730             iLiveSession->SaveContactL( KTestSaveContactAddr ), KErrNotSupported )
  1776     // Try without observer
  1731     
  1777     iClipSession->VolumeChanged( 2, EFalse );
  1732     // No address to save
  1778     EUNIT_ASSERT( VerifySpeakersVolume(*iClipSession, 2) )
  1733     iLiveSession->iOperatorVariant = EFalse;
  1779     EUNIT_ASSERT( iObserver->iVolume == 0 );
  1734     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
  1780     
  1735                iLiveSession->SaveContactL( KNullDesC8 ), KErrArgument )
  1781     
  1736 
  1782     // Try with observer set
  1737     // Contact id KErrNotSupported (multiple matching contacts)
  1783     iClipSession->SetVolumeChangeObserver( iObserver );
  1738     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
  1784     iClipSession->VolumeChanged( 3, EFalse );
  1739                                      NMusSessionApi::KContactId,
  1785     EUNIT_ASSERT( VerifySpeakersVolume(*iClipSession, 3) )
  1740                                      KErrNotSupported ) );
  1786     EUNIT_ASSERT( iObserver->iVolume == 3 );
  1741     
  1787     
  1742     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
  1788     }
  1743                 iLiveSession->SaveContactL( KTestSaveContactAddr ), KErrNotFound )
  1789 
  1744     
  1790 // HELPERS
  1745     // SIP field exists already
  1791 TBool UT_CMusEngMceSession::VerifySpeakersVolume(CMusEngMceSession& aSession, TInt aVolume)
  1746     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
  1792     {
  1747                                         NMusSessionApi::KContactId,
  1793     TBool result = EFalse;
  1748                                         2 ) );
  1794     
  1749 
  1795     CMceSpeakerSink* speaker = NULL;    
  1750     ContactEngineStubHelper::SetSIPFieldFound( ETrue );
  1796     CMceSession* session = aSession.iSession;
  1751     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
  1797     
  1752                    iLiveSession->SaveContactL( KTestSaveContactAddr ), KErrAlreadyExists )
  1798     if ( session ) 
  1753     
       
  1754     // No correct field in fields info
       
  1755     ContactEngineStubHelper::Reset();
       
  1756     ContactEngineStubHelper::SetSIPFieldInfoFound( EFalse );
       
  1757     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
       
  1758                        iLiveSession->SaveContactL( KTestSaveContactAddr ), KErrNotFound )
       
  1759     
       
  1760     // Success
       
  1761     ContactEngineStubHelper::Reset();
       
  1762     iLiveSession->SaveContactL( KTestSaveContactAddr );
       
  1763     EUNIT_ASSERT( ContactEngineStubHelper::GetCalledFunction() == EContactEngineStubSetText );
       
  1764     
       
  1765     }
       
  1766 
       
  1767 // -----------------------------------------------------------------------------
       
  1768 //
       
  1769 // -----------------------------------------------------------------------------
       
  1770 //
       
  1771 void UT_CMusEngMceSession::UT_RectL()
       
  1772     {
       
  1773     iLiveSession->SetRectL( TRect( 0, 0, 100, 100 ) );    
       
  1774     TRect rect = iLiveSession->Rect();
       
  1775     
       
  1776     // Initial values
       
  1777     EUNIT_ASSERT( rect.iTl.iX == 0 );
       
  1778     EUNIT_ASSERT( rect.iTl.iY == 0 );
       
  1779     EUNIT_ASSERT( rect.iBr.iX == 100 );
       
  1780     EUNIT_ASSERT( rect.iBr.iY == 100 );
       
  1781     
       
  1782     iLiveSession->iRect.iTl.iX = 100;
       
  1783     iLiveSession->iRect.iTl.iY = 200;
       
  1784     iLiveSession->iRect.iBr.iX = 300;
       
  1785     iLiveSession->iRect.iBr.iY = 400;
       
  1786     
       
  1787     rect = iLiveSession->Rect();
       
  1788     
       
  1789     EUNIT_ASSERT( rect.iTl.iX == 100 );
       
  1790     EUNIT_ASSERT( rect.iTl.iY == 200 );
       
  1791     EUNIT_ASSERT( rect.iBr.iX == 300 );
       
  1792     EUNIT_ASSERT( rect.iBr.iY == 400 );  
       
  1793     }
       
  1794 
       
  1795 
       
  1796 // -----------------------------------------------------------------------------
       
  1797 //
       
  1798 // -----------------------------------------------------------------------------
       
  1799 //
       
  1800 void UT_CMusEngMceSession::UT_SetRectLL()
       
  1801     {
       
  1802     TRect rect;
       
  1803 
       
  1804     rect.iTl.iX = 100;
       
  1805     rect.iTl.iY = 200;
       
  1806     rect.iBr.iX = 300;
       
  1807     rect.iBr.iY = 400;
       
  1808 
       
  1809     iLiveSession->SetRectL( rect );
       
  1810     
       
  1811     EUNIT_ASSERT( iLiveSession->iRect.iTl.iX == 100 );
       
  1812     EUNIT_ASSERT( iLiveSession->iRect.iTl.iY == 200 );
       
  1813     EUNIT_ASSERT( iLiveSession->iRect.iBr.iX == 300 );
       
  1814     EUNIT_ASSERT( iLiveSession->iRect.iBr.iY == 400 );
       
  1815 
       
  1816     ESTABLISH_OUT_SESSION( iLiveSession );
       
  1817     
       
  1818     CMceDisplaySink* display = 
       
  1819                 MusEngMceUtils::GetDisplayL( *( iLiveSession->iSession ) );
       
  1820     TRect displayRect = display->DisplayRectL();
       
  1821     
       
  1822     EUNIT_ASSERT( displayRect.iTl.iX == 100 );
       
  1823     EUNIT_ASSERT( displayRect.iTl.iY == 200 );
       
  1824     EUNIT_ASSERT( displayRect.iBr.iX == 300 );
       
  1825     EUNIT_ASSERT( displayRect.iBr.iY == 400 );
       
  1826     }
       
  1827 
       
  1828 // -----------------------------------------------------------------------------
       
  1829 //
       
  1830 // -----------------------------------------------------------------------------
       
  1831 //
       
  1832 void UT_CMusEngMceSession::UT_SecondaryRectL()
       
  1833     {
       
  1834     iLiveSession->SetSecondaryRectL( TRect( 0, 0, 100, 100 ) );    
       
  1835     TRect rect = iLiveSession->SecondaryRect();
       
  1836     
       
  1837     // Initial values
       
  1838     EUNIT_ASSERT( rect.iTl.iX == 0 );
       
  1839     EUNIT_ASSERT( rect.iTl.iY == 0 );
       
  1840     EUNIT_ASSERT( rect.iBr.iX == 100 );
       
  1841     EUNIT_ASSERT( rect.iBr.iY == 100 );
       
  1842     
       
  1843     iLiveSession->iRect.iTl.iX = 100;
       
  1844     iLiveSession->iRect.iTl.iY = 200;
       
  1845     iLiveSession->iRect.iBr.iX = 300;
       
  1846     iLiveSession->iRect.iBr.iY = 400;
       
  1847     
       
  1848     rect = iLiveSession->SecondaryRect();
       
  1849     
       
  1850     EUNIT_ASSERT( rect.iTl.iX == 100 );
       
  1851     EUNIT_ASSERT( rect.iTl.iY == 200 );
       
  1852     EUNIT_ASSERT( rect.iBr.iX == 300 );
       
  1853     EUNIT_ASSERT( rect.iBr.iY == 400 );  
       
  1854     }
       
  1855 
       
  1856 
       
  1857 // -----------------------------------------------------------------------------
       
  1858 //
       
  1859 // -----------------------------------------------------------------------------
       
  1860 //
       
  1861 void UT_CMusEngMceSession::UT_SetSecondaryRectLL()
       
  1862     {
       
  1863     TRect rect;
       
  1864 
       
  1865     rect.iTl.iX = 100;
       
  1866     rect.iTl.iY = 200;
       
  1867     rect.iBr.iX = 300;
       
  1868     rect.iBr.iY = 400;
       
  1869 
       
  1870     iLiveSession->SetSecondaryRectL( rect );
       
  1871     
       
  1872     EUNIT_ASSERT( iLiveSession->iRect.iTl.iX == 100 );
       
  1873     EUNIT_ASSERT( iLiveSession->iRect.iTl.iY == 200 );
       
  1874     EUNIT_ASSERT( iLiveSession->iRect.iBr.iX == 300 );
       
  1875     EUNIT_ASSERT( iLiveSession->iRect.iBr.iY == 400 );
       
  1876 
       
  1877     ESTABLISH_OUT_SESSION( iLiveSession );
       
  1878     
       
  1879     CMceDisplaySink* display = 
       
  1880                 MusEngMceUtils::GetDisplayL( *( iLiveSession->iSession ) );
       
  1881     TRect displayRect = display->DisplayRectL();
       
  1882     
       
  1883     EUNIT_ASSERT( displayRect.iTl.iX == 100 );
       
  1884     EUNIT_ASSERT( displayRect.iTl.iY == 200 );
       
  1885     EUNIT_ASSERT( displayRect.iBr.iX == 300 );
       
  1886     EUNIT_ASSERT( displayRect.iBr.iY == 400 );
       
  1887     }
       
  1888 
       
  1889 // -----------------------------------------------------------------------------
       
  1890 //
       
  1891 // -----------------------------------------------------------------------------
       
  1892 //
       
  1893 void UT_CMusEngMceSession::UT_EnableDisplayLL()
       
  1894     {
       
  1895     TRAPD( error, iLiveSession->EnableDisplayL( ETrue ) );
       
  1896     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
  1897     EUNIT_ASSERT( error == KErrNotReady );
       
  1898     
       
  1899     ESTABLISH_OUT_SESSION( iLiveSession );
       
  1900     
       
  1901     CMceDisplaySink* display = 
       
  1902                     MusEngMceUtils::GetDisplayL( *(iLiveSession->iSession) );
       
  1903     
       
  1904     // Disable
       
  1905     iLiveSession->EnableDisplayL( EFalse );
       
  1906     
       
  1907     EUNIT_ASSERT( !display->iIsEnabled );
       
  1908     
       
  1909     // Try to disable again, request should be ignored
       
  1910     
       
  1911     iLiveSession->EnableDisplayL( EFalse );
       
  1912     
       
  1913     EUNIT_ASSERT( !display->iIsEnabled );
       
  1914 
       
  1915     // Enable
       
  1916     
       
  1917     iLiveSession->EnableDisplayL( ETrue );
       
  1918     
       
  1919     EUNIT_ASSERT( display->iIsEnabled );
       
  1920     
       
  1921     // Try to enable again, request should be ignored
       
  1922     
       
  1923     iLiveSession->EnableDisplayL( ETrue );
       
  1924     
       
  1925     EUNIT_ASSERT( display->iIsEnabled );
       
  1926     
       
  1927     EUNIT_ASSERT( iLiveSession->IsDisplayEnabled() )
       
  1928     EUNIT_ASSERT( iLiveSession->IsDisplayActive() )
       
  1929     }
       
  1930 
       
  1931 // -----------------------------------------------------------------------------
       
  1932 //
       
  1933 // -----------------------------------------------------------------------------
       
  1934 //
       
  1935 void UT_CMusEngMceSession::UT_CMusEngMceSession_SetOrientationLL()
       
  1936     {
       
  1937     // Try without session, fails
       
  1938     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->SetOrientationL( 
       
  1939                                                 CMusEngMceSession::EPortrait ), 
       
  1940                                  KErrNotReady )
       
  1941 
       
  1942     // Establish a session
       
  1943     ESTABLISH_OUT_SESSION( iLiveSession )
       
  1944     
       
  1945     CMceDisplaySink* display = 
       
  1946                     MusEngMceUtils::GetDisplayL( *iLiveSession->iSession );
       
  1947     
       
  1948     // Check the initial state
       
  1949     display->iRotation = CMceDisplaySink::ENone;
       
  1950     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
  1951                          CMusEngMceSession::EPortrait )      
       
  1952                          
       
  1953     // Successfully change orientation
       
  1954     
       
  1955     iLiveSession->SetOrientationL( CMusEngMceSession::ELandscape );
       
  1956     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
  1957                          CMusEngMceSession::ELandscape )
       
  1958     
       
  1959     iLiveSession->SetOrientationL( CMusEngMceSession::EPortrait );
       
  1960     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
  1961                          CMusEngMceSession::EPortrait )
       
  1962     }
       
  1963 
       
  1964 
       
  1965 // -----------------------------------------------------------------------------
       
  1966 //
       
  1967 // -----------------------------------------------------------------------------
       
  1968 //
       
  1969 void UT_CMusEngMceSession::UT_SetEncodingDeviceLL()
       
  1970     {
       
  1971     CMceAvcCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() );
       
  1972     
       
  1973     // Generic error in CenRep, leave expected
       
  1974     CRepository::iForceFailWithCode = KErrNotReady;
       
  1975     EUNIT_ASSERT_LEAVE( iLiveSession->SetEncodingDeviceL( *codec ) )
       
  1976     EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, TUid::Uid( 0 ) )
       
  1977     
       
  1978     // No entry in CenRep, default value expected
       
  1979     CRepository::iForceFailWithCode = KErrNotFound;
       
  1980     const TUid KDefaultEncodingDevice( TUid::Uid( 0x20001C13 ) );
       
  1981     iLiveSession->SetEncodingDeviceL( *codec );
       
  1982     EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, 
       
  1983                          KDefaultEncodingDevice )
       
  1984     
       
  1985     // Entry in CenRep
       
  1986     const TInt KSomeEncodingDevice( 0x20001C15 );
       
  1987     CRepository::iStaticEncoderUid = KSomeEncodingDevice;
       
  1988     iLiveSession->SetEncodingDeviceL( *codec );
       
  1989     EUNIT_ASSERT_EQUALS( codec->iEncodingDecodingDevice, 
       
  1990                          TUid::Uid( KSomeEncodingDevice ) )
       
  1991                                              
       
  1992     CleanupStack::PopAndDestroy( codec );
       
  1993     }
       
  1994 
       
  1995 // -----------------------------------------------------------------------------
       
  1996 //
       
  1997 // -----------------------------------------------------------------------------
       
  1998 //
       
  1999 void UT_CMusEngMceSession::UT_SetCodecConfigKeyLL()
       
  2000     {
       
  2001     CMceAvcCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() );
       
  2002     codec->SetAllowedBitrates( KMceAvcBitrateLevel1b );
       
  2003 
       
  2004     // Generic error in CenRep, leave expected
       
  2005     CRepository::iForceFailWithCode = KErrNotReady;
       
  2006     EUNIT_ASSERT_LEAVE( iLiveSession->SetCodecConfigKeyL( *codec ) );
       
  2007     EUNIT_ASSERT( !codec->iConfigKey )
       
  2008     EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo )
       
  2009     CRepository::iForceFailWithCode = KErrNone;
       
  2010     
       
  2011     // No entry in CenRep, nothing happens
       
  2012     iLiveSession->SetCodecConfigKeyL( *codec );
       
  2013     EUNIT_ASSERT( !codec->iConfigKey )
       
  2014     EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo )
       
  2015     
       
  2016     // Empty entry in CenRep
       
  2017     CRepository::SetStubAvcConfigKeysL( KNullDesC8() );
       
  2018     iLiveSession->SetCodecConfigKeyL( *codec );
       
  2019     EUNIT_ASSERT( !codec->iConfigKey )
       
  2020     EUNIT_ASSERT( iLiveSession->iStoreEncoderConfigInfo )
       
  2021     iLiveSession->iStoreEncoderConfigInfo = EFalse; // emulate original situation
       
  2022     
       
  2023     // Entry in CenRep
       
  2024     CRepository::SetStubAvcConfigKeysL( KMusAvcBitrateLevel_1b_ConfigKey );
       
  2025     iLiveSession->SetCodecConfigKeyL( *codec );
       
  2026     EUNIT_ASSERT( codec->iConfigKey )
       
  2027     HBufC8* key = codec->ConfigKeyL();
       
  2028     CleanupStack::PushL( key );
       
  2029     EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1bTestText() )
       
  2030     CleanupStack::PopAndDestroy( key );
       
  2031     EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo )
       
  2032     
       
  2033     CleanupStack::PopAndDestroy( codec );
       
  2034     }
       
  2035 
       
  2036 // -----------------------------------------------------------------------------
       
  2037 //
       
  2038 // -----------------------------------------------------------------------------
       
  2039 //
       
  2040 void UT_CMusEngMceSession::UT_ReadCodecConfigKeyLL()
       
  2041     {
       
  2042     HBufC8* key( NULL );
       
  2043     
       
  2044     // Try with H263, leave expected
       
  2045     CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( KMceSDPNameH263() );  
       
  2046     EUNIT_ASSERT_LEAVE( key = iLiveSession->ReadCodecConfigKeyL( *codecH263 ) )
       
  2047     CleanupStack::PopAndDestroy( codecH263 );
       
  2048     
       
  2049     // Try without an entry in CenRep, leave expected
       
  2050     CMceVideoCodec* codec = CMceAvcCodec::NewLC( KMceSDPNameH264() );
       
  2051     codec->SetAllowedBitrates( 0 | KMceAvcBitrateLevel1 );
       
  2052     EUNIT_ASSERT_LEAVE( key = iLiveSession->ReadCodecConfigKeyL( *codec ) )
       
  2053 
       
  2054     // Create CenRep entry which does not include wanted bitrate, NULL value
       
  2055     // expected
       
  2056     CRepository::SetStubAvcConfigKeysL( KMusAvcBitrateLevel1bTestText() );
       
  2057     key = iLiveSession->ReadCodecConfigKeyL( *codec );
       
  2058     EUNIT_ASSERT( !key )
       
  2059     
       
  2060     // Create entry with all AVC keys and try with all the values
       
  2061     CRepository::SetStubAvcConfigKeysL( KMusAvcAllLevelsConcatenation() );                           
       
  2062     
       
  2063     // KMceAvcBitrateLevel1
       
  2064     key = iLiveSession->ReadCodecConfigKeyL( *codec );
       
  2065     EUNIT_ASSERT( key );
       
  2066     CleanupStack::PushL( key );
       
  2067     EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1TestText );
       
  2068     CleanupStack::PopAndDestroy( key );
       
  2069     
       
  2070     // KMceAvcBitrateLevel1b
       
  2071     codec->SetAllowedBitrates( KMceAvcBitrateLevel1b );
       
  2072     key = iLiveSession->ReadCodecConfigKeyL( *codec );
       
  2073     EUNIT_ASSERT( key );
       
  2074     CleanupStack::PushL( key );
       
  2075     EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1bTestText );
       
  2076     CleanupStack::PopAndDestroy( key );
       
  2077     
       
  2078     // KMceAvcBitrateLevel1_1
       
  2079     codec->SetAllowedBitrates( KMceAvcBitrateLevel1_1 );
       
  2080     key = iLiveSession->ReadCodecConfigKeyL( *codec );
       
  2081     EUNIT_ASSERT( key );
       
  2082     CleanupStack::PushL( key );
       
  2083     EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_1TestText );
       
  2084     CleanupStack::PopAndDestroy( key );
       
  2085     
       
  2086     // KMceAvcBitrateLevel1_2
       
  2087     codec->SetAllowedBitrates( KMceAvcBitrateLevel1_2 );
       
  2088     key = iLiveSession->ReadCodecConfigKeyL( *codec );
       
  2089     EUNIT_ASSERT( key );
       
  2090     CleanupStack::PushL( key );
       
  2091     EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_2TestText );
       
  2092     CleanupStack::PopAndDestroy( key );
       
  2093     
       
  2094     // KMceAvcBitrateLevel1_3
       
  2095     codec->SetAllowedBitrates( KMceAvcBitrateLevel1_3 );
       
  2096     key = iLiveSession->ReadCodecConfigKeyL( *codec );
       
  2097     EUNIT_ASSERT( key );
       
  2098     CleanupStack::PushL( key );
       
  2099     EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel1_3TestText );
       
  2100     CleanupStack::PopAndDestroy( key );
       
  2101     
       
  2102     // KMceAvcBitrateLevel2
       
  2103     codec->SetAllowedBitrates( KMceAvcBitrateLevel2 );
       
  2104     key = iLiveSession->ReadCodecConfigKeyL( *codec );
       
  2105     EUNIT_ASSERT( key );
       
  2106     CleanupStack::PushL( key );
       
  2107     EUNIT_ASSERT_EQUALS( *key, KMusAvcBitrateLevel2TestText );
       
  2108     CleanupStack::PopAndDestroy( key );
       
  2109    
       
  2110     CleanupStack::PopAndDestroy( codec );
       
  2111     }
       
  2112 
       
  2113 // -----------------------------------------------------------------------------
       
  2114 //
       
  2115 // -----------------------------------------------------------------------------
       
  2116 //
       
  2117 void UT_CMusEngMceSession::UT_StoreEncoderConfigInfoLL()
       
  2118     {
       
  2119     CRepository::iStaticWriteAvcKeysToStaticData = ETrue;
       
  2120     
       
  2121     // Try with clean CenRep
       
  2122     MultimediaSharingSettings::SetEncoderConfigInfoL( KNullDesC8() );   
       
  2123     
       
  2124     ESTABLISH_OUT_SESSION( iLiveSession ) // calls StoreEncoderConfigInfoL
       
  2125     // If StoreEncoderConfigInfoL leaves with KErrNoMemory,
       
  2126     // MMusEngSessionObserver::SessionFailed will be called.
       
  2127     if ( iLcSessionObserver->iCalledFunction == CLcSessionObserverStub::ESessionFailed )
       
  2128         {
  1799         {
  2129         User::Leave( KErrNoMemory );
  1800         for ( TInt i = 0; i < session->Streams().Count(); ++i )
       
  1801             {
       
  1802             for ( TInt j = 0; j < session->Streams()[i]->Sinks().Count(); ++j )
       
  1803                 {
       
  1804                 if ( session->Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
  1805                     {
       
  1806                     speaker = static_cast<CMceSpeakerSink*>(
       
  1807                                               session->Streams()[i]->Sinks()[j] );
       
  1808                     result = ( speaker->VolumeL() == aVolume );
       
  1809                     }
       
  1810                 }
       
  1811             } 
  2130         }
  1812         }
  2131 
  1813     return result;
  2132     HBufC8* keys = MultimediaSharingSettings::EncoderConfigInfoLC();    
  1814     }
  2133     EUNIT_ASSERT_EQUALS( *keys, KMusAvcBitrateLevel_1b_ConfigKey() )
  1815 
  2134     CleanupStack::PopAndDestroy( keys );
  1816 
  2135     
  1817 // -----------------------------------------------------------------------------
  2136     // Try without a clean CenRep 
  1818 //
  2137     MultimediaSharingSettings::SetEncoderConfigInfoL(
  1819 // -----------------------------------------------------------------------------
  2138                                         KMusAvcBitrateLevel_1_1_ConfigKey() );   
  1820 //
  2139     
  1821 void UT_CMusEngMceSession::SetMaxVolForSpeakersL(CMceSession& aSession, TInt aMaxVol)
  2140     delete iLiveSession;
  1822     {
  2141     iLiveSession = NULL;
  1823     for ( TInt i = 0; i < aSession.Streams().Count(); ++i )
  2142     iLiveSession = CMusEngLiveSession::NewL();
  1824             {
  2143     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
  1825             for ( TInt j = 0; j < aSession.Streams()[i]->Sinks().Count(); ++j )
  2144     iLiveSession->SetLcUiProvider( iLcUiProvider );
  1826                 {
  2145     
  1827                 if ( aSession.Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
  2146     ESTABLISH_OUT_SESSION( iLiveSession ) // calls StoreEncoderConfigInfoL
  1828                     {
  2147     // If StoreEncoderConfigInfoL leaves with KErrNoMemory,
  1829                     CMceSpeakerSink* speaker = static_cast<CMceSpeakerSink*>(
  2148     // MMusEngSessionObserver::SessionFailed will be called.
  1830                                                 aSession.Streams()[i]->Sinks()[j] );
  2149     if ( iLcSessionObserver->iCalledFunction == CLcSessionObserverStub::ESessionFailed )
  1831                     speaker->iMaxVolume = aMaxVol;
  2150         {
  1832                     }
  2151         User::Leave( KErrNoMemory );
  1833                 }
  2152         }
  1834             } 
  2153                      
  1835     }
  2154     keys = MultimediaSharingSettings::EncoderConfigInfoLC();
  1836  
  2155     EUNIT_ASSERT_EQUALS( *keys, 
       
  2156                          KMusAvcBitrateLevels_1_1_And_1b_ConfigKeys() )
       
  2157     CleanupStack::PopAndDestroy( keys );
       
  2158     }
       
  2159 
       
  2160 // -----------------------------------------------------------------------------
       
  2161 //
       
  2162 // -----------------------------------------------------------------------------
       
  2163 //
       
  2164 void UT_CMusEngMceSession::UT_StreamStreamingL()
       
  2165     {
       
  2166     // Wrong stream type, no callbacks to MLcSessionObserver
       
  2167     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
       
  2168     iLiveSession->StreamStreaming( *audioStream );
       
  2169     CleanupStack::PopAndDestroy( audioStream );
       
  2170     EUNIT_ASSERT( iLcSessionObserver->IsReseted() )
       
  2171     
       
  2172     // Wrong state, no callbacks to MLcSessionObserver
       
  2173     CMceVideoStream* videoStream = CMceVideoStream::NewLC();
       
  2174     videoStream->iState = CMceMediaStream::EIdle;
       
  2175     iLiveSession->StreamStreaming( *videoStream );
       
  2176     EUNIT_ASSERT( iLcSessionObserver->IsReseted() )
       
  2177     
       
  2178     // Receive session, RTP source and remote player present
       
  2179     iLcSessionObserver->Reset();
       
  2180     videoStream->iState = CMceMediaStream::EStreaming;
       
  2181     CMceRtpSource* rtpSource = CMceRtpSource::NewLC();
       
  2182     videoStream->SetSourceL( rtpSource );
       
  2183     CleanupStack::Pop( rtpSource );
       
  2184     iReceiveSession->StreamStreaming( *videoStream );
       
  2185     EUNIT_ASSERT_EQUALS( 
       
  2186         TInt( CLcSessionObserverStub::EPlayerStateChanged ),
       
  2187         iLcSessionObserver->iCalledFunction )
       
  2188     EUNIT_ASSERT_EQUALS( 
       
  2189         iReceiveSession->RemoteVideoPlayer(),
       
  2190         iLcSessionObserver->iCurrentPlayer )
       
  2191     
       
  2192     // Live session, RTP sink and local player present
       
  2193     iLcSessionObserver->Reset();
       
  2194     videoStream->SetSourceL( NULL );
       
  2195     CMceRtpSink* rtpSink = CMceRtpSink::NewLC();
       
  2196     videoStream->AddSinkL( rtpSink );
       
  2197     CleanupStack::Pop( rtpSink );
       
  2198     iLiveSession->StreamStreaming( *videoStream );
       
  2199     EUNIT_ASSERT_EQUALS( 
       
  2200         TInt( CLcSessionObserverStub::EPlayerStateChanged ),
       
  2201         iLcSessionObserver->iCalledFunction )
       
  2202     EUNIT_ASSERT_EQUALS( 
       
  2203         iLiveSession->LocalVideoPlayer(),
       
  2204         iLcSessionObserver->iCurrentPlayer )
       
  2205 
       
  2206     // Live session, RTP sink present, but no local player
       
  2207     iLcSessionObserver->Reset();
       
  2208     delete iLiveSession->iLiveVideoPlayer;
       
  2209     iLiveSession->iLiveVideoPlayer = NULL;
       
  2210     iLiveSession->StreamStreaming( *videoStream );
       
  2211     EUNIT_ASSERT( iLcSessionObserver->IsReseted() )
       
  2212         
       
  2213     CleanupStack::PopAndDestroy( videoStream );
       
  2214     }
       
  2215 
       
  2216 
       
  2217 // -----------------------------------------------------------------------------
       
  2218 //
       
  2219 // -----------------------------------------------------------------------------
       
  2220 //
       
  2221 void UT_CMusEngMceSession::UT_InformObserverAboutSessionStateChangeL()
       
  2222     {
       
  2223     // Observer does not exist
       
  2224     iLiveSession->SetLcSessionObserver( NULL );
       
  2225     iLiveSession->InformObserverAboutSessionStateChange();
       
  2226     EUNIT_ASSERT_EQUALS( 
       
  2227         CLcSessionObserverStub::EUnknown, 
       
  2228         iLcSessionObserver->iCalledFunction )
       
  2229     
       
  2230     // Observer exists
       
  2231     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
       
  2232     iLiveSession->InformObserverAboutSessionStateChange();
       
  2233     EUNIT_ASSERT_EQUALS( 
       
  2234         CLcSessionObserverStub::ESessionStateChanged, 
       
  2235         iLcSessionObserver->iCalledFunction )  
       
  2236     }
       
  2237 
       
  2238 // -----------------------------------------------------------------------------
       
  2239 //
       
  2240 // -----------------------------------------------------------------------------
       
  2241 //
       
  2242 void UT_CMusEngMceSession::UT_InformObserverAboutSessionUpdateL()
       
  2243     {
       
  2244     // Observer does not exist
       
  2245     iLiveSession->SetLcSessionObserver( NULL );
       
  2246     iLiveSession->InformObserverAboutSessionUpdate();
       
  2247     EUNIT_ASSERT_EQUALS( 
       
  2248         CLcSessionObserverStub::EUnknown, 
       
  2249         iLcSessionObserver->iCalledFunction )    
       
  2250        
       
  2251     // Observer exists
       
  2252     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
       
  2253     iLiveSession->InformObserverAboutSessionUpdate();
       
  2254     EUNIT_ASSERT_EQUALS( 
       
  2255         CLcSessionObserverStub::ESessionUpdated, 
       
  2256         iLcSessionObserver->iCalledFunction )
       
  2257     }
       
  2258 
       
  2259 // -----------------------------------------------------------------------------
       
  2260 //
       
  2261 // -----------------------------------------------------------------------------
       
  2262 //
       
  2263 void UT_CMusEngMceSession::UT_InformObserverAboutSessionFailureL()
       
  2264     {
       
  2265     // Observer does not exist
       
  2266     iLiveSession->SetLcSessionObserver( NULL );
       
  2267     iLiveSession->InformObserverAboutSessionFailure( KErrGeneral );
       
  2268     EUNIT_ASSERT_EQUALS( 
       
  2269         CLcSessionObserverStub::EUnknown, 
       
  2270         iLcSessionObserver->iCalledFunction )
       
  2271     EUNIT_ASSERT_EQUALS( KErrNone, iLcSessionObserver->iError )    
       
  2272     
       
  2273     // Observer exists
       
  2274     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
       
  2275     iLiveSession->InformObserverAboutSessionFailure( KErrGeneral );
       
  2276     EUNIT_ASSERT_EQUALS( 
       
  2277         CLcSessionObserverStub::ESessionFailed, 
       
  2278         iLcSessionObserver->iCalledFunction )
       
  2279     EUNIT_ASSERT_EQUALS( KErrGeneral, iLcSessionObserver->iError )
       
  2280     }
       
  2281 
       
  2282 // -----------------------------------------------------------------------------
       
  2283 //
       
  2284 // -----------------------------------------------------------------------------
       
  2285 //
       
  2286 void UT_CMusEngMceSession::UT_InformObserverAboutPlayerStateChangeL()
       
  2287     {
       
  2288     // Observer does not exist
       
  2289     iLiveSession->SetLcSessionObserver( NULL );
       
  2290     iLiveSession->InformObserverAboutPlayerStateChange( NULL );
       
  2291     EUNIT_ASSERT_EQUALS( 
       
  2292         CLcSessionObserverStub::EUnknown, 
       
  2293         iLcSessionObserver->iCalledFunction )    
       
  2294     
       
  2295     // Observer exists, but the player is NULL
       
  2296     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
       
  2297     iLiveSession->InformObserverAboutPlayerStateChange( NULL );
       
  2298     EUNIT_ASSERT_EQUALS( 
       
  2299         CLcSessionObserverStub::EUnknown, 
       
  2300         iLcSessionObserver->iCalledFunction )    
       
  2301     
       
  2302     // Both observer and player exist
       
  2303     iLiveSession->InformObserverAboutPlayerStateChange( 
       
  2304         iLiveSession->LocalVideoPlayer() );
       
  2305     EUNIT_ASSERT_EQUALS( 
       
  2306         CLcSessionObserverStub::EPlayerStateChanged, 
       
  2307         iLcSessionObserver->iCalledFunction )
       
  2308     }
       
  2309 
       
  2310 // -----------------------------------------------------------------------------
       
  2311 //
       
  2312 // -----------------------------------------------------------------------------
       
  2313 //
       
  2314 void UT_CMusEngMceSession::UT_InformObserverAboutPlayerUpdateL()
       
  2315     {
       
  2316     // Observer does not exist
       
  2317     iLiveSession->SetLcSessionObserver( NULL );
       
  2318     iLiveSession->InformObserverAboutPlayerUpdate( NULL );
       
  2319     EUNIT_ASSERT_EQUALS( 
       
  2320         CLcSessionObserverStub::EUnknown, 
       
  2321         iLcSessionObserver->iCalledFunction )    
       
  2322     
       
  2323     // Observer exists, but the player is NULL
       
  2324     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
       
  2325     iLiveSession->InformObserverAboutPlayerUpdate( NULL );
       
  2326     EUNIT_ASSERT_EQUALS( 
       
  2327         CLcSessionObserverStub::EUnknown, 
       
  2328         iLcSessionObserver->iCalledFunction )    
       
  2329     
       
  2330     // Both observer and player exist
       
  2331     iLiveSession->InformObserverAboutPlayerUpdate( 
       
  2332         iLiveSession->LocalVideoPlayer() );
       
  2333     EUNIT_ASSERT_EQUALS( 
       
  2334         CLcSessionObserverStub::EPlayerUpdated, 
       
  2335         iLcSessionObserver->iCalledFunction )
       
  2336     }
       
  2337 
       
  2338 // -----------------------------------------------------------------------------
       
  2339 //
       
  2340 // -----------------------------------------------------------------------------
       
  2341 //
       
  2342 void UT_CMusEngMceSession::UT_InformObserverAboutPlayerFailureL()
       
  2343     {
       
  2344     // Observer does not exist
       
  2345     iLiveSession->SetLcSessionObserver( NULL );
       
  2346     iLiveSession->InformObserverAboutPlayerFailure( NULL, KErrGeneral );
       
  2347     EUNIT_ASSERT_EQUALS( 
       
  2348         CLcSessionObserverStub::EUnknown, 
       
  2349         iLcSessionObserver->iCalledFunction )
       
  2350     EUNIT_ASSERT_EQUALS( KErrNone, iLcSessionObserver->iError )
       
  2351     
       
  2352     // Observer exists, but the player is NULL
       
  2353     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
       
  2354     iLiveSession->InformObserverAboutPlayerFailure( NULL, KErrGeneral );
       
  2355     EUNIT_ASSERT_EQUALS( 
       
  2356         CLcSessionObserverStub::EUnknown, 
       
  2357         iLcSessionObserver->iCalledFunction )
       
  2358     EUNIT_ASSERT_EQUALS( KErrNone, iLcSessionObserver->iError )
       
  2359     
       
  2360     // Both observer and player exist
       
  2361     iLiveSession->InformObserverAboutPlayerFailure( 
       
  2362         iLiveSession->LocalVideoPlayer(), KErrGeneral );
       
  2363     EUNIT_ASSERT_EQUALS( 
       
  2364         CLcSessionObserverStub::EPlayerFailed, 
       
  2365         iLcSessionObserver->iCalledFunction )
       
  2366     EUNIT_ASSERT_EQUALS( KErrGeneral, iLcSessionObserver->iError )
       
  2367     }
       
  2368 
       
  2369 // -----------------------------------------------------------------------------
       
  2370 //
       
  2371 // -----------------------------------------------------------------------------
       
  2372 //
       
  2373 void UT_CMusEngMceSession::UT_LcUiProviderL()
       
  2374     {
       
  2375     // Provider does not exist 
       
  2376     iLiveSession->SetLcUiProvider( NULL );
       
  2377     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->LcUiProviderL(), KErrNotReady )
       
  2378     
       
  2379     // Provider exists
       
  2380     iLiveSession->SetLcUiProvider( iLcUiProvider  );
       
  2381     EUNIT_ASSERT( &iLiveSession->LcUiProviderL() == iLcUiProvider )
       
  2382     }
       
  2383 
       
  2384 // -----------------------------------------------------------------------------
       
  2385 //
       
  2386 // -----------------------------------------------------------------------------
       
  2387 //
       
  2388 void UT_CMusEngMceSession::UI_IsBackgroundStartupL()
       
  2389     {
       
  2390     // fast mode is not defined
       
  2391     EUNIT_ASSERT( !iLiveSession->IsBackgroundStartup() )
       
  2392     
       
  2393     // fast mode is Off
       
  2394     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
  2395                                         NMusSessionApi::KFastMode,
       
  2396                                         1 ) );
       
  2397 
       
  2398     EUNIT_ASSERT( !iLiveSession->IsBackgroundStartup() )
       
  2399 
       
  2400     // fast mode is On
       
  2401     // Bg value would be set to true at session contruct phase if property
       
  2402     // is set to EFastModeOn at that time.
       
  2403     iLiveSession->iBackground = ETrue;
       
  2404     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
  2405                                         NMusSessionApi::KFastMode,
       
  2406                                         0 ) );
       
  2407 
       
  2408     EUNIT_ASSERT( iLiveSession->IsBackgroundStartup() )    
       
  2409     
       
  2410     // Ensure after session recreation fast mode is off 
       
  2411     delete iLiveSession;
       
  2412     iLiveSession = NULL;
       
  2413     iLiveSession = CMusEngLiveSession::NewL();
       
  2414     EUNIT_ASSERT( !iLiveSession->IsBackgroundStartup() ) 
       
  2415     }
       
  2416 
       
  2417 // -----------------------------------------------------------------------------
       
  2418 //
       
  2419 // -----------------------------------------------------------------------------
       
  2420 //
       
  2421 void UT_CMusEngMceSession::UT_InformUiProviderAboutReceivingStartL()
       
  2422     {
       
  2423     // Observer does not exist
       
  2424     iLiveSession->SetLcUiProvider( NULL );
       
  2425     iLiveSession->InformUiProviderAboutReceivingStart();
       
  2426     EUNIT_ASSERT_EQUALS( TInt( CLcUiProviderStub::EUnknown ), 
       
  2427                          iLcUiProvider->iCalledFunction )
       
  2428     
       
  2429     // Observer exists, but we are on foreground (fast mode is off)
       
  2430     iLiveSession->SetLcUiProvider( iLcUiProvider );
       
  2431     iLiveSession->InformUiProviderAboutReceivingStart();
       
  2432     EUNIT_ASSERT_EQUALS( TInt( CLcUiProviderStub::EUnknown ), 
       
  2433                          iLcUiProvider->iCalledFunction )
       
  2434     
       
  2435     // Observer exists, we are on background
       
  2436     iLiveSession->iBackground = ETrue;
       
  2437     EUNIT_ASSERT( !iLcUiProvider->iForeground )
       
  2438     iLiveSession->InformUiProviderAboutReceivingStart();
       
  2439     EUNIT_ASSERT_EQUALS( TInt( CLcUiProviderStub::EHandleForegroundStatus ),
       
  2440                          iLcUiProvider->iCalledFunction )
       
  2441     EUNIT_ASSERT( iLcUiProvider->iForeground ) 
       
  2442     }
       
  2443 
       
  2444 // -----------------------------------------------------------------------------
       
  2445 //
       
  2446 // -----------------------------------------------------------------------------
       
  2447 //
       
  2448 void UT_CMusEngMceSession::UT_SetForegroundStatusL()
       
  2449     {
       
  2450     iLiveSession->iBackground = ETrue;
       
  2451     EUNIT_ASSERT( iLiveSession->SetForegroundStatus( ETrue ) == KErrNone );
       
  2452     EUNIT_ASSERT( !iLiveSession->iBackground );
       
  2453     EUNIT_ASSERT( iLiveSession->SetForegroundStatus( EFalse ) == KErrNone );
       
  2454     EUNIT_ASSERT( !iLiveSession->iBackground ); // Still bg
       
  2455     }
       
  2456 
       
  2457 
       
  2458 // -----------------------------------------------------------------------------
       
  2459 //
       
  2460 // -----------------------------------------------------------------------------
       
  2461 //
       
  2462 void UT_CMusEngMceSession::UT_UpdateLcSessionLL()
       
  2463     {
       
  2464     // No MCE session
       
  2465     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->UpdateLcSessionL(), KErrNotReady )
       
  2466         
       
  2467     ESTABLISH_OUT_SESSION( iLiveSession );
       
  2468     
       
  2469     iLiveSession->UpdateLcSessionL();
       
  2470     
       
  2471     }
       
  2472 
       
  2473 //  TEST TABLE
  1837 //  TEST TABLE
  2474 
  1838 
  2475 EUNIT_BEGIN_TEST_TABLE(
  1839 EUNIT_BEGIN_TEST_TABLE(
  2476     UT_CMusEngMceSession,
  1840     UT_CMusEngMceSession,
  2477     "UT_CMusEngMceSesssion",
  1841     "UT_CMusEngMceSesssion",
  2478     "UNIT" )
  1842     "UNIT" )
  2479 
  1843 
  2480 EUNIT_TEST(
  1844 EUNIT_TEST(
  2481     "LcSessionState - test ",
  1845     "TerminateL - test ",
  2482     "CMusEngMceSession",
  1846     "CMusEngMceSession",
  2483     "LcSessionState",
  1847     "TerminateL",
  2484     "FUNCTIONALITY",
  1848     "FUNCTIONALITY",
  2485     SetupL, UT_LcSessionStateL, Teardown)
  1849     SetupL, UT_CMusEngMceSession_TerminateLL, Teardown)
       
  1850 
       
  1851 EUNIT_TEST(
       
  1852     "GetSessionTime - test ",
       
  1853     "CMusEngMceSession",
       
  1854     "GetSessionTime",
       
  1855     "FUNCTIONALITY",
       
  1856     SetupL, UT_CMusEngMceSession_GetSessionTimeL, Teardown)
       
  1857 
       
  1858 EUNIT_TEST(
       
  1859     "ConnectionActive - test ",
       
  1860     "CMusEngMceSession",
       
  1861     "ConnectionActive",
       
  1862     "FUNCTIONALITY",
       
  1863     SetupL, UT_CMusEngMceSession_ConnectionActiveL, Teardown) 
       
  1864 
       
  1865 EUNIT_TEST(
       
  1866     "ContainsAudioL - test ",
       
  1867     "CMusEngMceSession",
       
  1868     "ContainsAudioL",
       
  1869     "FUNCTIONALITY",
       
  1870     SetupL, UT_CMusEngMceSession_ContainsAudioLL, Teardown) 
       
  1871 
       
  1872 EUNIT_TEST(
       
  1873     "IsMutedL - test ",
       
  1874     "CMusEngMceSession",
       
  1875     "IsMutedL",
       
  1876     "FUNCTIONALITY",
       
  1877     SetupL, UT_CMusEngMceSession_IsMutedLL, Teardown) 
       
  1878 
       
  1879 EUNIT_TEST(
       
  1880     "OrientationL - test ",
       
  1881     "CMusEngMceSession",
       
  1882     "OrientationL",
       
  1883     "FUNCTIONALITY",
       
  1884     SetupL, UT_CMusEngMceSession_OrientationLL, Teardown) 
       
  1885 
       
  1886 EUNIT_TEST(
       
  1887     "SetOrientationL - test ",
       
  1888     "CMusEngMceSession",
       
  1889     "SetOrientationL",
       
  1890     "FUNCTIONALITY",
       
  1891     SetupL, UT_CMusEngMceSession_SetOrientationLL, Teardown) 
       
  1892     
       
  1893 EUNIT_TEST(
       
  1894     "VolumeUpL - test ",
       
  1895     "CMusEngMceSession",
       
  1896     "VolumeUpL",
       
  1897     "FUNCTIONALITY",
       
  1898     SetupL, UT_CMusEngMceSession_VolumeUpLL, Teardown) 
       
  1899 
       
  1900 EUNIT_TEST(
       
  1901     "VolumeDownL - test ",
       
  1902     "CMusEngMceSession",
       
  1903     "VolumeDownL",
       
  1904     "FUNCTIONALITY",
       
  1905     SetupL, UT_CMusEngMceSession_VolumeDownLL, Teardown) 
       
  1906 
       
  1907 EUNIT_TEST(
       
  1908     "SetVolumeL - test ",
       
  1909     "CMusEngMceSession",
       
  1910     "SetVolumeL",
       
  1911     "FUNCTIONALITY",
       
  1912     SetupL, UT_CMusEngMceSession_SetVolumeLL, Teardown)
       
  1913     
       
  1914 EUNIT_TEST(
       
  1915     "EnableDisplay - test ",
       
  1916     "CMusEngMceSession",
       
  1917     "EnableDisplay",
       
  1918     "FUNCTIONALITY",
       
  1919     SetupL, UT_CMusEngMceSession_EnableDisplayL, Teardown)   
       
  1920 
       
  1921 EUNIT_TEST(
       
  1922     "MuteL - test ",
       
  1923     "CMusEngMceSession",
       
  1924     "MuteL",
       
  1925     "FUNCTIONALITY",
       
  1926     SetupL, UT_CMusEngMceSession_MuteLL, Teardown)   
       
  1927 
       
  1928 EUNIT_TEST(
       
  1929     "UnmuteL - test ",
       
  1930     "CMusEngMceSession",
       
  1931     "UnmuteL",
       
  1932     "FUNCTIONALITY",
       
  1933     SetupL, UT_CMusEngMceSession_UnmuteLL, Teardown)   
       
  1934 
       
  1935 EUNIT_TEST(
       
  1936     "HandleTermination - test ",
       
  1937     "CMusEngMceSession",
       
  1938     "HandleTermination",
       
  1939     "FUNCTIONALITY",
       
  1940     SetupL, UT_CMusEngMceSession_HandleTerminationL, Teardown)   
       
  1941 
       
  1942 EUNIT_TEST(
       
  1943     "AdjustVideoCodecL - test ",
       
  1944     "CMusEngMceSession",
       
  1945     "AdjustVideoCodecL",
       
  1946     "FUNCTIONALITY",
       
  1947     SetupL, UT_CMusEngMceSession_AdjustVideoCodecLL, Teardown) 
       
  1948 
       
  1949 EUNIT_TEST(
       
  1950     "AdjustAudioCodecL - test ",
       
  1951     "CMusEngMceSession",
       
  1952     "AdjustAudioCodecL",
       
  1953     "FUNCTIONALITY",
       
  1954     SetupL, UT_CMusEngMceSession_AdjustAudioCodecLL, Teardown) 
       
  1955     
       
  1956 EUNIT_TEST(
       
  1957     "RectChangedL - test ",
       
  1958     "CMusEngMceSession",
       
  1959     "RectChangedL",
       
  1960     "FUNCTIONALITY",
       
  1961     SetupL, UT_CMusEngMceSession_RectChangedLL, Teardown) 
       
  1962 
       
  1963 EUNIT_TEST(
       
  1964     "SetSessionSdpLinesL - test ",
       
  1965     "CMusEngMceSession",
       
  1966     "SetSessionSdpLinesL",
       
  1967     "FUNCTIONALITY",
       
  1968     SetupL, UT_CMusEngMceSession_SetSessionSdpLinesLL, Teardown) 
       
  1969 
       
  1970 EUNIT_TEST(
       
  1971     "AdjustStreamsAndCodecsL - test ",
       
  1972     "CMusEngMceSession",
       
  1973     "AdjustStreamsAndCodecsL",
       
  1974     "FUNCTIONALITY",
       
  1975     SetupL, UT_CMusEngMceSession_AdjustStreamsAndCodecsLL, Teardown)
       
  1976 
       
  1977 EUNIT_TEST(
       
  1978     "IncomingSession - test ",
       
  1979     "CMusEngMceSession",
       
  1980     "IncomingSession",
       
  1981     "FUNCTIONALITY",
       
  1982     SetupL, UT_CMusEngMceSession_IncomingSessionL, Teardown)          
       
  1983 
       
  1984 EUNIT_TEST(
       
  1985     "IncomingUpdate - test ",
       
  1986     "CMusEngMceSession",
       
  1987     "IncomingUpdate",
       
  1988     "FUNCTIONALITY",
       
  1989     SetupL, UT_CMusEngMceSession_IncomingUpdateL, Teardown)      
       
  1990 
       
  1991 EUNIT_TEST(
       
  1992     "StreamStateChangedL( source ) - test ",
       
  1993     "CMusEngMceSession",
       
  1994     "StreamStateChangedL( source )",
       
  1995     "FUNCTIONALITY",
       
  1996     SetupL, UT_CMusEngMceSession_StreamStateChangedWithSourceL, Teardown)          
       
  1997 
       
  1998 EUNIT_TEST(
       
  1999     "SessionStateChanged - test ",
       
  2000     "CMusEngMceSession",
       
  2001     "SessionStateChanged",
       
  2002     "FUNCTIONALITY",
       
  2003     SetupL, UT_CMusEngMceSession_SessionStateChangedL, Teardown) 
       
  2004     
       
  2005 EUNIT_TEST(
       
  2006     "SessionConnectionStateChanged - test ",
       
  2007     "CMusEngMceSession",
       
  2008     "SessionConnectionStateChanged",
       
  2009     "FUNCTIONALITY",
       
  2010     SetupL, UT_CMusEngMceSession_SessionConnectionStateChangedL, Teardown) 
       
  2011 
       
  2012 EUNIT_TEST(
       
  2013     "Failed - test ",
       
  2014     "CMusEngMceSession",
       
  2015     "Failed",
       
  2016     "FUNCTIONALITY",
       
  2017     SetupL, UT_CMusEngMceSession_FailedL, Teardown)     
       
  2018 
       
  2019 EUNIT_TEST(
       
  2020     "UpdateFailed - test ",
       
  2021     "CMusEngMceSession",
       
  2022     "UpdateFailed",
       
  2023     "FUNCTIONALITY",
       
  2024     SetupL, UT_CMusEngMceSession_UpdateFailedL, Teardown) 
       
  2025 
       
  2026 EUNIT_TEST(
       
  2027     "StreamStateChanged - test ",
       
  2028     "CMusEngMceSession",
       
  2029     "StreamStateChanged",
       
  2030     "FUNCTIONALITY",
       
  2031     SetupL, UT_CMusEngMceSession_StreamStateChangedL, Teardown)             
       
  2032 
       
  2033 EUNIT_TEST(
       
  2034     "StreamStateChangedL (sink ) - test ",
       
  2035     "CMusEngMceSession",
       
  2036     "StreamStateChangedL( sink )",
       
  2037     "FUNCTIONALITY",
       
  2038     SetupL, UT_CMusEngMceSession_StreamStateChangedWithSinkL, Teardown) 
       
  2039 
       
  2040 EUNIT_TEST(
       
  2041     "SRReceived - test ",
       
  2042     "CMusEngMceSession",
       
  2043     "SRReceived",
       
  2044     "FUNCTIONALITY",
       
  2045     SetupL, UT_CMusEngMceSession_SRReceivedL, Teardown)     
       
  2046 
       
  2047 EUNIT_TEST(
       
  2048     "RRReceived - test ",
       
  2049     "CMusEngMceSession",
       
  2050     "RRReceived",
       
  2051     "FUNCTIONALITY",
       
  2052     SetupL, UT_CMusEngMceSession_RRReceivedL, Teardown) 
       
  2053 
       
  2054 EUNIT_TEST(
       
  2055     "InactivityTimeout - test ",
       
  2056     "CMusEngMceSession",
       
  2057     "InactivityTimeout",
       
  2058     "FUNCTIONALITY",
       
  2059     SetupL, UT_CMusEngMceSession_InactivityTimeoutL, Teardown)     
       
  2060 
       
  2061 EUNIT_TEST(
       
  2062     "SsrcAdded - test ",
       
  2063     "CMusEngMceSession",
       
  2064     "SsrcAdded",
       
  2065     "FUNCTIONALITY",
       
  2066     SetupL, UT_CMusEngMceSession_SsrcAddedL, Teardown) 
       
  2067 
       
  2068 EUNIT_TEST(
       
  2069     "SsrcRemoved - test ",
       
  2070     "CMusEngMceSession",
       
  2071     "SsrcRemoved",
       
  2072     "FUNCTIONALITY",
       
  2073     SetupL, UT_CMusEngMceSession_SsrcRemovedL, Teardown)         
       
  2074 EUNIT_TEST(
       
  2075     "IsDisplayEnabledL - test ",
       
  2076     "CMusEngMceSession",
       
  2077     "IsDisplayEnabledL",
       
  2078     "FUNCTIONALITY",
       
  2079     SetupL, UT_CMusEngMceSession_IsDisplayEnabledLL, Teardown)  	
       
  2080 
       
  2081 EUNIT_TEST(
       
  2082     "UpdateTimerEvent - test ",
       
  2083     "CMusEngMceSession",
       
  2084     "UpdateTimerEvent",
       
  2085     "FUNCTIONALITY",
       
  2086     SetupL, UT_CMusEngMceSession_UpdateTimerEventL, Teardown)              
       
  2087 
       
  2088 EUNIT_TEST(
       
  2089     "IsRoamingBetweenAPsAllowed - test ",
       
  2090     "CMusEngMceSession",
       
  2091     "IsRoamingBetweenAPsAllowed",
       
  2092     "FUNCTIONALITY",
       
  2093     SetupL, UT_CMusEngMceSession_IsRoamingBetweenAPsAllowedL, Teardown)
  2486         
  2094         
  2487 EUNIT_TEST(
  2095 EUNIT_TEST(
  2488     "RemoteVideoPlayer - test ",
  2096     "VolumeChanged - test ",
  2489     "CMusEngMceSession",
  2097     "CMusEngMceSession",
  2490     "RemoteVideoPlayer",
  2098     "VolumeChanged",
  2491     "FUNCTIONALITY",
  2099     "FUNCTIONALITY",
  2492     SetupL, UT_RemoteVideoPlayerL, Teardown)
  2100     SetupL, UT_CMusEngMceSession_VolumeChangedL, Teardown)
  2493         
  2101     
  2494 EUNIT_TEST(
  2102 
  2495     "LocalVideoPlayer - test ",
       
  2496     "CMusEngMceSession",
       
  2497     "LocalVideoPlayer",
       
  2498     "FUNCTIONALITY",
       
  2499     SetupL, UT_LocalVideoPlayerL, Teardown) 
       
  2500         
       
  2501 EUNIT_TEST(
       
  2502     "LocalDisplayNameL - test ",
       
  2503     "CMusEngMceSession",
       
  2504     "LocalDisplayNameL",
       
  2505     "FUNCTIONALITY",
       
  2506     SetupL, UT_LocalDisplayNameL, Teardown)
       
  2507 
       
  2508 EUNIT_TEST(
       
  2509     "RemoteDisplayName - test ",
       
  2510     "CMusEngMceSession",
       
  2511     "RemoteDisplayName",
       
  2512     "FUNCTIONALITY",
       
  2513     SetupL, UT_RemoteDisplayNameL, Teardown)
       
  2514     
       
  2515 EUNIT_TEST(
       
  2516     "RemoteDetails - test ",
       
  2517     "CMusEngMceSession",
       
  2518     "RemoteDetails",
       
  2519     "FUNCTIONALITY",
       
  2520     SetupL, UT_RemoteDetailsL, Teardown)
       
  2521 
       
  2522 EUNIT_TEST(
       
  2523     "SetParameter - test ",
       
  2524     "CMusEngMceSession",
       
  2525     "SetParameter",
       
  2526     "FUNCTIONALITY",
       
  2527     SetupL, UT_SetParameterL, Teardown)
       
  2528         
       
  2529 EUNIT_TEST(
       
  2530     "ParameterValue - test ",
       
  2531     "CMusEngMceSession",
       
  2532     "ParameterValue",
       
  2533     "FUNCTIONALITY",
       
  2534     SetupL, UT_ParameterValueL, Teardown)    
       
  2535         
       
  2536 EUNIT_TEST(
       
  2537     "IsLcAudioMutedL - test ",
       
  2538     "CMusEngMceSession",
       
  2539     "IsLcAudioMutedL",
       
  2540     "FUNCTIONALITY",
       
  2541     SetupL, UT_IsLcAudioMutedL, Teardown)
       
  2542         
       
  2543 EUNIT_TEST(
       
  2544     "MuteLcAudioL - test ",
       
  2545     "CMusEngMceSession",
       
  2546     "MuteLcAudioL",
       
  2547     "FUNCTIONALITY",
       
  2548     SetupL, UT_MuteLcAudioL, Teardown)    
       
  2549 
       
  2550 EUNIT_TEST(
       
  2551     "MuteLcMicL - test ",
       
  2552     "CMusEngMceSession",
       
  2553     "MuteLcMicL",
       
  2554     "FUNCTIONALITY",
       
  2555     SetupL, UT_MuteLcMicL, Teardown)
       
  2556         
       
  2557 EUNIT_TEST(
       
  2558     "EnableLcLoudspeakerL - test ",
       
  2559     "CMusEngMceSession",
       
  2560     "EnableLcLoudspeakerL",
       
  2561     "FUNCTIONALITY",
       
  2562     SetupL, UT_EnableLcLoudspeakerL, Teardown)
       
  2563         
       
  2564 EUNIT_TEST(
       
  2565     "SetLcVolumeL - test ",
       
  2566     "CMusEngMceSession",
       
  2567     "SetLcVolumeL",
       
  2568     "FUNCTIONALITY",
       
  2569     SetupL, UT_SetLcVolumeL, Teardown)
       
  2570 
       
  2571 EUNIT_TEST(
       
  2572     "GetSessionTime - test ",
       
  2573     "CMusEngMceSession",
       
  2574     "GetSessionTime",
       
  2575     "FUNCTIONALITY",
       
  2576     SetupL, UT_GetSessionTimeL, Teardown)   
       
  2577 
       
  2578 EUNIT_TEST(
       
  2579     "HandleTermination - test ",
       
  2580     "CMusEngMceSession",
       
  2581     "HandleTermination",
       
  2582     "FUNCTIONALITY",
       
  2583     SetupL, UT_HandleTerminationL, Teardown)   
       
  2584 
       
  2585 EUNIT_TEST(
       
  2586     "AdjustVideoCodecL - test ",
       
  2587     "CMusEngMceSession",
       
  2588     "AdjustVideoCodecL",
       
  2589     "FUNCTIONALITY",
       
  2590     SetupL, UT_AdjustVideoCodecL, Teardown) 
       
  2591 
       
  2592 EUNIT_TEST(
       
  2593     "AdjustAudioCodecL - test ",
       
  2594     "CMusEngMceSession",
       
  2595     "AdjustAudioCodecL",
       
  2596     "FUNCTIONALITY",
       
  2597     SetupL, UT_AdjustAudioCodecL, Teardown) 
       
  2598     
       
  2599 EUNIT_TEST(
       
  2600     "RectChangedL - test ",
       
  2601     "CMusEngMceSession",
       
  2602     "RectChangedL",
       
  2603     "FUNCTIONALITY",
       
  2604     SetupL, UT_RectChangedL, Teardown) 
       
  2605 
       
  2606 EUNIT_TEST(
       
  2607     "SetSessionSdpLinesL - test ",
       
  2608     "CMusEngMceSession",
       
  2609     "SetSessionSdpLinesL",
       
  2610     "FUNCTIONALITY",
       
  2611     SetupL, UT_SetSessionSdpLinesL, Teardown) 
       
  2612 
       
  2613 EUNIT_TEST(
       
  2614     "SetSessionSdpLinesL - operator variant test ",
       
  2615     "CMusEngMceSession",
       
  2616     "SetSessionSdpLinesL",
       
  2617     "FUNCTIONALITY",
       
  2618     SetupL, UT_SetSessionSdpLines_OperatorL, Teardown)
       
  2619     
       
  2620 EUNIT_TEST(
       
  2621     "SetMediaSdpLinesL - test ",
       
  2622     "CMusEngMceSession",
       
  2623     "SetMediaSdpLinesL",
       
  2624     "FUNCTIONALITY",
       
  2625     SetupL, UT_SetMediaSdpLinesL, Teardown) 
       
  2626 
       
  2627 EUNIT_TEST(
       
  2628     "SetMediaSdpLinesL - operator variant test ",
       
  2629     "CMusEngMceSession",
       
  2630     "SetMediaSdpLinesL",
       
  2631     "FUNCTIONALITY",
       
  2632     SetupL, UT_SetMediaSdpLines_OperatorL, Teardown) 
       
  2633     
       
  2634 EUNIT_TEST(
       
  2635     "AdjustStreamsAndCodecsL - test ",
       
  2636     "CMusEngMceSession",
       
  2637     "AdjustStreamsAndCodecsL",
       
  2638     "FUNCTIONALITY",
       
  2639     SetupL, UT_AdjustStreamsAndCodecsL, Teardown)
       
  2640 
       
  2641 EUNIT_TEST(
       
  2642     "IncomingSession - test ",
       
  2643     "CMusEngMceSession",
       
  2644     "IncomingSession",
       
  2645     "FUNCTIONALITY",
       
  2646     SetupL, UT_IncomingSessionL, Teardown)          
       
  2647 
       
  2648 EUNIT_TEST(
       
  2649     "IncomingUpdate - test ",
       
  2650     "CMusEngMceSession",
       
  2651     "IncomingUpdate",
       
  2652     "FUNCTIONALITY",
       
  2653     SetupL, UT_IncomingUpdateL, Teardown)      
       
  2654 
       
  2655 EUNIT_TEST(
       
  2656     "StreamStateChangedL( source ) - test ",
       
  2657     "CMusEngMceSession",
       
  2658     "StreamStateChangedL( source )",
       
  2659     "FUNCTIONALITY",
       
  2660     SetupL, UT_StreamStateChangedWithSourceL, Teardown)          
       
  2661 
       
  2662 EUNIT_TEST(
       
  2663     "SessionStateChanged - test ",
       
  2664     "CMusEngMceSession",
       
  2665     "SessionStateChanged",
       
  2666     "FUNCTIONALITY",
       
  2667     SetupL, UT_SessionStateChangedL, Teardown)
       
  2668     
       
  2669 EUNIT_TEST(
       
  2670     "HandleSessionStateChanged - encoder key storing ",
       
  2671     "CMusEngMceSession",
       
  2672     "HandleSessionStateChanged",
       
  2673     "FUNCTIONALITY",
       
  2674     SetupL, UT_HandleSessionStateChanged_EncoderKeyStoringL, Teardown)
       
  2675     
       
  2676 EUNIT_TEST(
       
  2677     "SessionConnectionStateChanged - test ",
       
  2678     "CMusEngMceSession",
       
  2679     "SessionConnectionStateChanged",
       
  2680     "FUNCTIONALITY",
       
  2681     SetupL, UT_SessionConnectionStateChangedL, Teardown) 
       
  2682 
       
  2683 EUNIT_TEST(
       
  2684     "Failed - test ",
       
  2685     "CMusEngMceSession",
       
  2686     "Failed",
       
  2687     "FUNCTIONALITY",
       
  2688     SetupL, UT_FailedL, Teardown)     
       
  2689 
       
  2690 EUNIT_TEST(
       
  2691     "UpdateFailed - test ",
       
  2692     "CMusEngMceSession",
       
  2693     "UpdateFailed",
       
  2694     "FUNCTIONALITY",
       
  2695     SetupL, UT_UpdateFailedL, Teardown) 
       
  2696 
       
  2697 EUNIT_TEST(
       
  2698     "StreamStateChanged - test ",
       
  2699     "CMusEngMceSession",
       
  2700     "StreamStateChanged",
       
  2701     "FUNCTIONALITY",
       
  2702     SetupL, UT_StreamStateChangedL, Teardown)             
       
  2703 
       
  2704 EUNIT_TEST(
       
  2705     "StreamStateChangedL (sink ) - test ",
       
  2706     "CMusEngMceSession",
       
  2707     "StreamStateChangedL( sink )",
       
  2708     "FUNCTIONALITY",
       
  2709     SetupL, UT_StreamStateChangedWithSinkL, Teardown) 
       
  2710 
       
  2711 EUNIT_TEST(
       
  2712     "SRReceived - test ",
       
  2713     "CMusEngMceSession",
       
  2714     "SRReceived",
       
  2715     "FUNCTIONALITY",
       
  2716     SetupL, UT_SRReceivedL, Teardown)     
       
  2717 
       
  2718 EUNIT_TEST(
       
  2719     "RRReceived - test ",
       
  2720     "CMusEngMceSession",
       
  2721     "RRReceived",
       
  2722     "FUNCTIONALITY",
       
  2723     SetupL, UT_RRReceivedL, Teardown) 
       
  2724 
       
  2725 EUNIT_TEST(
       
  2726     "SsrcAdded - test ",
       
  2727     "CMusEngMceSession",
       
  2728     "SsrcAdded",
       
  2729     "FUNCTIONALITY",
       
  2730     SetupL, UT_SsrcAddedL, Teardown) 
       
  2731 
       
  2732 EUNIT_TEST(
       
  2733     "SsrcRemoved - test ",
       
  2734     "CMusEngMceSession",
       
  2735     "SsrcRemoved",
       
  2736     "FUNCTIONALITY",
       
  2737     SetupL, UT_SsrcRemovedL, Teardown)         
       
  2738 
       
  2739 EUNIT_TEST(
       
  2740     "UpdateTimerEvent - test ",
       
  2741     "CMusEngMceSession",
       
  2742     "UpdateTimerEvent",
       
  2743     "FUNCTIONALITY",
       
  2744     SetupL, UT_UpdateTimerEventL, Teardown)              
       
  2745 
       
  2746 EUNIT_TEST(
       
  2747     "IsRoamingBetweenAPsAllowed - test ",
       
  2748     "CMusEngMceSession",
       
  2749     "IsRoamingBetweenAPsAllowed",
       
  2750     "FUNCTIONALITY",
       
  2751     SetupL, UT_IsRoamingBetweenAPsAllowedL, Teardown)
       
  2752 
       
  2753 EUNIT_TEST(
       
  2754     "SaveContactL - test ",
       
  2755     "CMusEngMceSession",
       
  2756     "SaveContactL",
       
  2757     "FUNCTIONALITY",
       
  2758     SetupL, UT_SaveContactL, Teardown)    
       
  2759 
       
  2760 EUNIT_TEST(
       
  2761     "Rect - test ",
       
  2762     "CMusEngMceSession",
       
  2763     "Rect",
       
  2764     "FUNCTIONALITY",
       
  2765     SetupL, UT_RectL, Teardown)
       
  2766 
       
  2767 EUNIT_TEST(
       
  2768     "SetRectL - test ",
       
  2769     "CMusEngMceSession",
       
  2770     "SetRectL",
       
  2771     "FUNCTIONALITY",
       
  2772     SetupL, UT_SetRectLL, Teardown)
       
  2773 
       
  2774 EUNIT_TEST(
       
  2775     "SecondaryRect - test ",
       
  2776     "CMusEngMceSession",
       
  2777     "SecondaryRect",
       
  2778     "FUNCTIONALITY",
       
  2779     SetupL, UT_SecondaryRectL, Teardown)
       
  2780 
       
  2781 EUNIT_TEST(
       
  2782     "SetSecondaryRectL - test ",
       
  2783     "CMusEngMceSession",
       
  2784     "SetSecondaryRectL",
       
  2785     "FUNCTIONALITY",
       
  2786     SetupL, UT_SetSecondaryRectLL, Teardown)
       
  2787 
       
  2788 EUNIT_TEST(
       
  2789     "EnableDisplayL - test ",
       
  2790     "CMusEngMceSession",
       
  2791     "EnableDisplayL",
       
  2792     "FUNCTIONALITY",
       
  2793     SetupL, UT_EnableDisplayLL, Teardown)
       
  2794     
       
  2795 EUNIT_TEST(
       
  2796     "SetOrientationL - test ",
       
  2797     "CMusEngMceSession",
       
  2798     "SetOrientationL",
       
  2799     "FUNCTIONALITY",
       
  2800     SetupL, UT_CMusEngMceSession_SetOrientationLL, Teardown) 
       
  2801 
       
  2802 EUNIT_TEST(
       
  2803     "SetEncodingDeviceL - test ",
       
  2804     "CMusEngMceSession",
       
  2805     "SetEncodingDeviceL",
       
  2806     "FUNCTIONALITY",
       
  2807     SetupL, UT_SetEncodingDeviceLL, Teardown)   
       
  2808 
       
  2809 EUNIT_TEST(
       
  2810     "SetCodecConfigKeyL - test ",
       
  2811     "CMusEngMceSession",
       
  2812     "SetCodecConfigKeyL",
       
  2813     "FUNCTIONALITY",
       
  2814     SetupL, UT_SetCodecConfigKeyLL, Teardown)    
       
  2815 
       
  2816 EUNIT_TEST(
       
  2817     "ReadCodecConfigKeyL - test ",
       
  2818     "CMusEngMceSession",
       
  2819     "ReadCodecConfigKeyL",
       
  2820     "FUNCTIONALITY",
       
  2821     SetupL, UT_ReadCodecConfigKeyLL, Teardown)        
       
  2822 
       
  2823 EUNIT_TEST(
       
  2824     "StoreEncoderConfigInfoL - test ",
       
  2825     "CMusEngMceSession",
       
  2826     "StoreEncoderConfigInfoL",
       
  2827     "FUNCTIONALITY",
       
  2828     SetupL, UT_StoreEncoderConfigInfoLL, Teardown)   
       
  2829 
       
  2830 EUNIT_TEST(
       
  2831     "StreamStreaming - test ",
       
  2832     "CMusEngMceSession",
       
  2833     "StreamStreaming",
       
  2834     "FUNCTIONALITY",
       
  2835     SetupL, UT_StreamStreamingL, Teardown)   
       
  2836    
       
  2837 EUNIT_TEST(
       
  2838     "InformObserverAboutSessionStateChange - test ",
       
  2839     "CMusEngMceSession",
       
  2840     "InformObserverAboutSessionStateChange",
       
  2841     "FUNCTIONALITY",
       
  2842     SetupL, UT_InformObserverAboutSessionStateChangeL, Teardown)
       
  2843 
       
  2844 EUNIT_TEST(
       
  2845     "InformObserverAboutSessionUpdate - test ",
       
  2846     "CMusEngMceSession",
       
  2847     "InformObserverAboutSessionUpdate",
       
  2848     "FUNCTIONALITY",
       
  2849     SetupL, UT_InformObserverAboutSessionUpdateL, Teardown)
       
  2850 
       
  2851 EUNIT_TEST(
       
  2852     "InformObserverAboutSessionFailure - test ",
       
  2853     "CMusEngMceSession",
       
  2854     "InformObserverAboutSessionFailure",
       
  2855     "FUNCTIONALITY",
       
  2856     SetupL, UT_InformObserverAboutSessionFailureL, Teardown)
       
  2857 
       
  2858 EUNIT_TEST(
       
  2859     "InformObserverAboutPlayerStateChange - test ",
       
  2860     "CMusEngMceSession",
       
  2861     "InformObserverAboutPlayerStateChange",
       
  2862     "FUNCTIONALITY",
       
  2863     SetupL, UT_InformObserverAboutPlayerStateChangeL, Teardown)
       
  2864 
       
  2865 EUNIT_TEST(
       
  2866     "InformObserverAboutPlayerUpdate - test ",
       
  2867     "CMusEngMceSession",
       
  2868     "InformObserverAboutPlayerUpdate",
       
  2869     "FUNCTIONALITY",
       
  2870     SetupL, UT_InformObserverAboutPlayerUpdateL, Teardown)
       
  2871 
       
  2872 EUNIT_TEST(
       
  2873     "InformObserverAboutPlayerFailure - test ",
       
  2874     "CMusEngMceSession",
       
  2875     "InformObserverAboutPlayerFailure",
       
  2876     "FUNCTIONALITY",
       
  2877     SetupL, UT_InformObserverAboutPlayerFailureL, Teardown)
       
  2878     
       
  2879 EUNIT_TEST(
       
  2880     "LcUiProviderL - test ",
       
  2881     "CMusEngMceSession",
       
  2882     "LcUiProviderL",
       
  2883     "FUNCTIONALITY",
       
  2884     SetupL, UT_LcUiProviderL, Teardown)
       
  2885 
       
  2886 EUNIT_TEST(
       
  2887     "IsBackgroundStartup - test ",
       
  2888     "CMusEngMceSession",
       
  2889     "IsBackgroundStartup",
       
  2890     "FUNCTIONALITY",
       
  2891     SetupL, UI_IsBackgroundStartupL, Teardown)
       
  2892 
       
  2893 EUNIT_TEST(
       
  2894     "InformUiProviderAboutReceivingStart - test ",
       
  2895     "CMusEngMceSession",
       
  2896     "InformUiProviderAboutReceivingStart",
       
  2897     "FUNCTIONALITY",
       
  2898     SetupL, UT_InformUiProviderAboutReceivingStartL, Teardown)
       
  2899 
       
  2900 EUNIT_TEST(
       
  2901     "SetForegroundStatus - test ",
       
  2902     "CMusEngMceSession",
       
  2903     "SetForegroundStatus",
       
  2904     "FUNCTIONALITY",
       
  2905     SetupL, UT_SetForegroundStatusL, Teardown)
       
  2906     
       
  2907 EUNIT_TEST(
       
  2908     "UpdateLcSessionL - test ",
       
  2909     "CMusEngMceSession",
       
  2910     "UpdateL",
       
  2911     "FUNCTIONALITY",
       
  2912     SetupL, UT_UpdateLcSessionLL, Teardown)
       
  2913 
       
  2914     
       
  2915 EUNIT_END_TEST_TABLE
  2103 EUNIT_END_TEST_TABLE
  2916 
  2104 
  2917 //  END OF FILE
  2105 //  END OF FILE
  2918 
       
  2919