mmsharing/mmshengine/tsrc/ut_engine/src/ut_musengmcesession.cpp
changeset 22 496ad160a278
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INTERNAL INCLUDES
       
    20 #include "ut_musengmcesession.h"
       
    21 #include "musengstubs.h"
       
    22 #include "musengtestdefs.h"
       
    23 
       
    24 #include "mussettings.h"
       
    25 #include "musenglivesession.h"
       
    26 #include "musengclipsession.h"
       
    27 #include "musengreceivesession.h"
       
    28 #include "musengsessiondurationtimer.h"
       
    29 #include "musengtelephoneutils.h"
       
    30 #include "musengmceutils.h"
       
    31 #include "mussessionproperties.h"
       
    32 #include "contactenginestub.h"
       
    33 #include "musenglivevideoplayer.h"
       
    34 
       
    35 //  SYSTEM INCLUDES
       
    36 #include <lcsourcefilecontrol.h>
       
    37 #include <digia/eunit/eunitmacros.h>
       
    38 #include <mceinsession.h>
       
    39 #include <mcevideostream.h>
       
    40 #include <mcedisplaysink.h>
       
    41 #include <mcertpsource.h>
       
    42 #include <mcespeakersink.h>
       
    43 #include <mceaudiostream.h>
       
    44 #include <mcertpsink.h>
       
    45 #include <mcevideocodec.h>
       
    46 #include <mceaudiocodec.h>
       
    47 #include <audiopreference.h>
       
    48 #include <mceavccodec.h>
       
    49 #include <mceh263codec.h>
       
    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 
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 UT_CMusEngMceSession* UT_CMusEngMceSession::NewL()
       
    86     {
       
    87     UT_CMusEngMceSession* self = UT_CMusEngMceSession::NewLC();
       
    88     CleanupStack::Pop( self );
       
    89     return self;
       
    90     }
       
    91 
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 UT_CMusEngMceSession* UT_CMusEngMceSession::NewLC()
       
    98     {
       
    99     UT_CMusEngMceSession* self = new( ELeave ) UT_CMusEngMceSession();
       
   100     CleanupStack::PushL( self );
       
   101     self->ConstructL();
       
   102     return self;
       
   103     }
       
   104 
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 UT_CMusEngMceSession::~UT_CMusEngMceSession()
       
   111     {
       
   112     // NOP
       
   113     }
       
   114 
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // Default constructor
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 UT_CMusEngMceSession::UT_CMusEngMceSession()
       
   121     {
       
   122     // NOP
       
   123     }
       
   124 
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // Second phase construct
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 void UT_CMusEngMceSession::ConstructL()
       
   131     {
       
   132     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
   133     // It generates the test case table.
       
   134     CEUnitTestSuiteClass::ConstructL();
       
   135     }
       
   136     
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void UT_CMusEngMceSession::SetupL(  )
       
   143     {
       
   144     iLcSessionObserver = new( ELeave )CLcSessionObserverStub;
       
   145     iLcUiProvider = new( ELeave )CLcUiProviderStub;
       
   146 
       
   147     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
   148                                         NMusSessionApi::KRemoteSipAddress,
       
   149                                         KTestRecipientSipUri ) );    
       
   150     
       
   151     iLiveSession = CMusEngLiveSession::NewL();
       
   152     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
       
   153     iLiveSession->SetLcUiProvider( iLcUiProvider );    
       
   154     
       
   155     iSomeOtherSession = CMusEngLiveSession::NewL();
       
   156     iSomeOtherSession->SetLcSessionObserver( iLcSessionObserver );
       
   157     iSomeOtherSession->SetLcUiProvider( iLcUiProvider );
       
   158     
       
   159     ESTABLISH_OUT_SESSION( iSomeOtherSession );
       
   160    
       
   161     iClipSession = CMusEngClipSession::NewL();
       
   162     iClipSession->SetLcSessionObserver( iLcSessionObserver );
       
   163     iClipSession->SetLcUiProvider( iLcUiProvider );
       
   164     MLcSourceFileControl* sourceFileControl =
       
   165         iClipSession->LocalVideoPlayer()->LcSourceFileControl();
       
   166     sourceFileControl->SetLcFileNameL( KTestAvcVideoFileName() );
       
   167 
       
   168     delete iClipSession->iVideoCodecList;
       
   169     iClipSession->iVideoCodecList = NULL;
       
   170     iClipSession->iVideoCodecList = KMceSDPNameH264().AllocL();
       
   171     
       
   172     // Construct and establish an incoming session
       
   173     iReceiveSession = CMusEngReceiveSession::NewL();
       
   174     iReceiveSession->SetLcSessionObserver( iLcSessionObserver ); 
       
   175     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
       
   176                                                     KTestOriginator() );
       
   177                                                     
       
   178     CMceVideoStream* videoStream = CMceVideoStream::NewLC();
       
   179     
       
   180     videoStream->SetSourceL( CMceRtpSource::NewLC() );
       
   181     CleanupStack::Pop();
       
   182     
       
   183     inSession->AddStreamL( videoStream );
       
   184     CleanupStack::Pop( videoStream );
       
   185                                                     
       
   186     iReceiveSession->iManager->iInSessionObserver->IncomingSession( 
       
   187                                                         inSession, 
       
   188                                                         &iContainer );
       
   189     iReceiveSession->iSession->iState = CMceSession::EProceeding;
       
   190     iReceiveSession->EstablishLcSessionL();
       
   191    
       
   192     iLcSessionObserver->Reset();
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 void UT_CMusEngMceSession::Teardown(  )
       
   200     {
       
   201     delete iLiveSession;
       
   202     delete iClipSession;
       
   203     delete iReceiveSession;
       
   204     delete iLcSessionObserver;
       
   205     delete iLcUiProvider;
       
   206     delete iSomeOtherSession;
       
   207     PropertyHelper::Close();
       
   208     // Delete static data from CenRep stub
       
   209     CRepository::iStaticWriteAvcKeysToStaticData = EFalse;
       
   210     CRepository::DeleteStubAvcConfigKeys();
       
   211     CRepository::ResetStubGlobal();
       
   212     CRepository::iForceFailWithCode = KErrNone;
       
   213     }
       
   214 
       
   215 
       
   216 
       
   217 // TEST CASES
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 void UT_CMusEngMceSession::UT_LcSessionStateL()
       
   224     {
       
   225     // No MCE session -> MLcSession::EUninitialized
       
   226     EUNIT_ASSERT_EQUALS( MLcSession::EUninitialized, 
       
   227                          iLiveSession->LcSessionState() )
       
   228                          
       
   229     // MLcSession::EOpen
       
   230     ESTABLISH_OUT_SESSION( iLiveSession )
       
   231     EUNIT_ASSERT_EQUALS( TInt( CMceSession::EEstablished ),
       
   232                          TInt( iLiveSession->iSession->iState ) )  
       
   233     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EOpen ), 
       
   234                          TInt( iLiveSession->LcSessionState() ) )
       
   235 
       
   236     // MLcSession::EInitialized
       
   237     iLiveSession->iSession->iState = CMceSession::EIdle;
       
   238     EUNIT_ASSERT_EQUALS( TInt( MLcSession::EInitialized ), 
       
   239                          TInt( iLiveSession->LcSessionState() ) )
       
   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 
       
   470 // -----------------------------------------------------------------------------
       
   471 //
       
   472 // -----------------------------------------------------------------------------
       
   473 //  
       
   474 void UT_CMusEngMceSession::UT_GetSessionTimeL()
       
   475     {
       
   476     EUNIT_ASSERT( iLiveSession->GetSessionTime() < TTimeIntervalSeconds( 0 ) );
       
   477     
       
   478     // Invite
       
   479     iLiveSession->EstablishLcSessionL();
       
   480     
       
   481     EUNIT_ASSERT( iLiveSession->GetSessionTime() < TTimeIntervalSeconds( 0 ) );
       
   482     
       
   483     // Simulate establishment
       
   484     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
   485     iLiveSession->iStartTime.HomeTime();
       
   486     
       
   487     TTimeIntervalSeconds sessionTime = iLiveSession->GetSessionTime();
       
   488     EUNIT_ASSERT( sessionTime >= TTimeIntervalSeconds( 0 ) );
       
   489     }
       
   490 
       
   491 // -----------------------------------------------------------------------------
       
   492 //
       
   493 // -----------------------------------------------------------------------------
       
   494 //
       
   495 void UT_CMusEngMceSession::UT_HandleTerminationL()
       
   496     { 
       
   497     // Try different values
       
   498     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCodeNoCodeSet,
       
   499                                                         KNullDesC8() );
       
   500     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
   501                          TInt( CLcSessionObserverStub::ESessionStateChanged ) )
       
   502     iLcSessionObserver->Reset();
       
   503 
       
   504     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCode200OK,
       
   505                                                         KNullDesC8() );
       
   506     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
   507                          TInt( CLcSessionObserverStub::ESessionStateChanged ) )
       
   508     iLcSessionObserver->Reset();
       
   509 
       
   510     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCodeUnknown,
       
   511                                                         KNullDesC8() );
       
   512     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
   513                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
   514     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
   515     iLcSessionObserver->Reset();
       
   516     }
       
   517 
       
   518 // -----------------------------------------------------------------------------
       
   519 //
       
   520 // -----------------------------------------------------------------------------
       
   521 //
       
   522 void UT_CMusEngMceSession::UT_AdjustVideoCodecL()
       
   523     {
       
   524     CRepository::SetStubAvcConfigKeysL( KNullDesC8() );
       
   525         
       
   526     CMceVideoCodec* codecH263 = CMceH263Codec::NewLC( KMceSDPNameH263() );
       
   527     CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() );
       
   528     CMceVideoCodec* codecAvcFromFile = CMceAvcCodec::NewLC( KMceSDPNameH264() );
       
   529     
       
   530     iLiveSession->CMusEngMceSession::AdjustVideoCodecL( *codecH263,
       
   531                                                         KMceCameraSource );
       
   532     EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo )
       
   533 
       
   534     iLiveSession->CMusEngMceSession::AdjustVideoCodecL( *codecAvcFromFile,
       
   535                                                         KMceFileSource);  
       
   536     EUNIT_ASSERT( !iLiveSession->iStoreEncoderConfigInfo )
       
   537     
       
   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     {
       
   553     CMceAudioCodec* codec = 
       
   554                 iLiveSession->iManager->SupportedAudioCodecs()[0]->CloneL();
       
   555     CleanupStack::PushL( codec );
       
   556     iLiveSession->CMusEngMceSession::AdjustAudioCodecL( *codec );
       
   557     
       
   558     EUNIT_ASSERT( codec->iMMFPriority == KAudioPrioritySwisPlayback )
       
   559     EUNIT_ASSERT( codec->iMMFPriorityPreference == KAudioPrefSwisPlayback )
       
   560     
       
   561     CleanupStack::PopAndDestroy( codec );
       
   562     }   
       
   563         
       
   564 // -----------------------------------------------------------------------------
       
   565 //
       
   566 // -----------------------------------------------------------------------------
       
   567 //
       
   568 void UT_CMusEngMceSession::UT_RectChangedL()
       
   569     {
       
   570     // Does nothing before session establishment
       
   571     
       
   572     iLiveSession->RectChangedL();
       
   573     
       
   574     ESTABLISH_OUT_SESSION( iLiveSession );
       
   575 
       
   576     // Next leads to a call to RectChangedL()
       
   577     iLiveSession->SetRectL( TRect( 100, 200, 300, 400 ) ); 
       
   578     
       
   579     // Display size has been updated
       
   580     
       
   581     CMceDisplaySink* display = 
       
   582         MusEngMceUtils::GetDisplayL( *( iLiveSession->iSession ) );
       
   583     
       
   584     EUNIT_ASSERT( display->DisplayRectL() == iLiveSession->Rect() )
       
   585     
       
   586     // Terminate session and try again, rect must not be changed
       
   587     
       
   588     iLiveSession->iSession->iState = CMceSession::ETerminated;
       
   589     
       
   590     TRect newRect( 200, 300, 400, 500 );
       
   591     
       
   592     iLiveSession->SetRectL( newRect ); 
       
   593     
       
   594     EUNIT_ASSERT( display->DisplayRectL() != newRect )
       
   595     }
       
   596 
       
   597 // -----------------------------------------------------------------------------
       
   598 //
       
   599 // -----------------------------------------------------------------------------
       
   600 //
       
   601 void UT_CMusEngMceSession::UT_SetSessionSdpLinesL()
       
   602     {
       
   603     // set operator variant off
       
   604     iReceiveSession->iOperatorVariant = EFalse;
       
   605     CRepository::SetStubGlobal( MusSettingsKeys::KVideoBandwidth,
       
   606                                 128 );
       
   607                      
       
   608     // 1. There is b=AS line at session level
       
   609     // => Xapplication, b=AS and b=TIAS set to session level  
       
   610     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
       
   611                                                     KTestOriginator );
       
   612     CleanupStack::PushL( inSession );    
       
   613     EUNIT_ASSERT( !inSession->iSessionSDPLines );
       
   614     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
       
   615     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineBandwidthField() );
       
   616         
       
   617     iReceiveSession->SetSessionSdpLinesL( *inSession, ETrue );
       
   618     
       
   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 );
       
   656     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
       
   657     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
       
   658     
       
   659     // 4. No KVideoBandwidth entry in CenRep => TIAS usage should be disabled
       
   660     // There is AS and TIAS at session level => AS is taken at session level
       
   661     CRepository::iForceFailWithCode = KErrNotFound;
       
   662     delete inSession->iSessionSDPLines;
       
   663     inSession->iSessionSDPLines = NULL;
       
   664     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
       
   665     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineTiasLine() );
       
   666     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineBandwidthField() );
       
   667         
       
   668     iReceiveSession->SetSessionSdpLinesL( *inSession, ETrue );
       
   669     
       
   670     sdpLines = inSession->iSessionSDPLines;    
       
   671     EUNIT_ASSERT( sdpLines );
       
   672     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
       
   673     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
       
   674     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineBandwidthField() );
       
   675     
       
   676     CleanupStack::PopAndDestroy( inSession );
       
   677     }
       
   678 
       
   679 // -----------------------------------------------------------------------------
       
   680 //
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 void UT_CMusEngMceSession::UT_SetSessionSdpLines_OperatorL()
       
   684     {
       
   685     // set operator variant
       
   686     iReceiveSession->iOperatorVariant = ETrue;
       
   687 
       
   688     // 1. There is b=TIAS sdp line in session => only application and  
       
   689     // type lines are set, no bandwidth related attributes
       
   690     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
       
   691                                      KTestOriginator );
       
   692     CleanupStack::PushL( inSession );        
       
   693     
       
   694     EUNIT_ASSERT( !inSession->iSessionSDPLines );
       
   695     inSession->iSessionSDPLines = new ( ELeave ) CDesC8ArrayFlat( 1 );
       
   696     inSession->iSessionSDPLines->AppendL( KMusEngSessionSdpLineTiasLine() );
       
   697         
       
   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 );
       
   733     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
       
   734     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineApplication() );
       
   735     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineType() );
       
   736         
       
   737     CleanupStack::PopAndDestroy( inSession );   
       
   738     }
       
   739 
       
   740 // -----------------------------------------------------------------------------
       
   741 //
       
   742 // -----------------------------------------------------------------------------
       
   743 //
       
   744 void UT_CMusEngMceSession::UT_SetMediaSdpLinesL()
       
   745     {
       
   746     // set operator variant off
       
   747     iReceiveSession->iOperatorVariant = EFalse;
       
   748     CRepository::SetStubGlobal( MusSettingsKeys::KVideoBandwidth,
       
   749                                 128 );
       
   750 
       
   751     // 1. There is no b=AS, b=TIAS sdp lines at session level
       
   752     // => b=AS and b=TIAS are taken at media level
       
   753     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
       
   754                                                     KTestOriginator );
       
   755     CleanupStack::PushL( inSession );
       
   756     
       
   757     CMceVideoStream* videoStream = CMceVideoStream::NewLC();        
       
   758     videoStream->SetSourceL( CMceRtpSource::NewLC() );
       
   759     CleanupStack::Pop(); //rtpSource        
       
   760     videoStream->AddSinkL( CMceDisplaySink::NewLC( *iReceiveSession->iManager ) );
       
   761     CleanupStack::Pop(); //displaySink
       
   762         
       
   763     inSession->AddStreamL( videoStream );
       
   764     CleanupStack::Pop( videoStream );
       
   765 
       
   766     iReceiveSession->SetMediaSdpLinesL( *videoStream, ETrue );
       
   767     
       
   768     MDesC8Array* sdpLines = inSession->Streams()[ 0 ]->iMediaSDPLines;
       
   769     EUNIT_ASSERT( sdpLines );
       
   770     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
       
   771     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ).Find( 
       
   772             KMusEngSessionSdpLineBandwidthLine() ) == 0 );
       
   773     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ).Find( 
       
   774             KMusEngSessionSdpLineTiasLine() ) == 0 );
       
   775     
       
   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 
       
   821     CleanupStack::PopAndDestroy( inSession );
       
   822     }
       
   823 
       
   824 // -----------------------------------------------------------------------------
       
   825 //
       
   826 // -----------------------------------------------------------------------------
       
   827 //
       
   828 void UT_CMusEngMceSession::UT_SetMediaSdpLines_OperatorL()
       
   829     {
       
   830     // set operator variant
       
   831     iReceiveSession->iOperatorVariant = ETrue;
       
   832 
       
   833     // 1. There is no b=AS sdp line at session level
       
   834     // => b=AS is taken at media level
       
   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     {
       
   905     // Check that function cannot be called before creating the session
       
   906     TRAPD( error, iClipSession->AdjustStreamsAndCodecsL() );
       
   907     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   908     EUNIT_ASSERT( error == KErrNotReady );
       
   909     
       
   910     // Establishing a clip session leads to call to AdjustStreamsAndCodecsL
       
   911     ESTABLISH_OUT_SESSION( iClipSession )
       
   912    
       
   913     const RPointerArray<CMceMediaStream>& streams = 
       
   914                                             iClipSession->iSession->Streams();
       
   915     
       
   916     TBool videoCodecFound = EFalse;
       
   917     TBool audioCodecFound = EFalse;
       
   918     
       
   919     // Test that AdjustVideoCodecL and AdjustAudioCodecL have been called
       
   920     CMceVideoStream* videoStream = NULL;
       
   921     for ( TInt i = 0; i < streams.Count(); ++i )
       
   922         {
       
   923         if ( streams[i]->Type() == KMceAudio )
       
   924             {
       
   925             CMceAudioStream* audioStream = 
       
   926                             static_cast<CMceAudioStream*>( streams[i] );
       
   927             
       
   928             const RPointerArray<CMceAudioCodec>& codecs = audioStream->Codecs();
       
   929             
       
   930             for ( TInt i = 0; i < codecs.Count(); ++i )
       
   931                 {
       
   932                 audioCodecFound = ETrue;
       
   933 
       
   934                 EUNIT_ASSERT( codecs[i]->MMFPriority() == 
       
   935                               KAudioPrioritySwisPlayback )
       
   936                 EUNIT_ASSERT( codecs[i]->MMFPriorityPreference() == 
       
   937                               KAudioPrefSwisPlayback )
       
   938                 }
       
   939             }
       
   940         else
       
   941             {
       
   942             videoStream = static_cast<CMceVideoStream*>( streams[i] );
       
   943             
       
   944             const RPointerArray<CMceVideoCodec>& codecs = videoStream->Codecs();
       
   945             
       
   946             for ( TInt i = 0; i < codecs.Count(); ++i )
       
   947                 {
       
   948                 videoCodecFound = ETrue;
       
   949 
       
   950                 EUNIT_ASSERT( codecs[i]->iPayloadType == 96 ||
       
   951                               codecs[i]->iPayloadType == 98 )
       
   952                 }
       
   953             }
       
   954     
       
   955         }
       
   956         
       
   957     EUNIT_ASSERT( audioCodecFound ) // At least one audiocodec found
       
   958     EUNIT_ASSERT( videoCodecFound ) // At least one videocodec found
       
   959     
       
   960     // Test removing of H.263 multiples (mode 2000 preferred)
       
   961     EUNIT_ASSERT( videoStream != NULL )
       
   962     for ( TInt i = videoStream->Codecs().Count() - 1; i >= 0; i-- )
       
   963         {
       
   964         videoStream->RemoveCodecL( 
       
   965             *const_cast<CMceVideoCodec*>( videoStream->Codecs()[ i ] ) );
       
   966         }
       
   967     CMceH263Codec* codecH2632000 = CMceH263Codec::NewLC( KMceSDPNameH2632000() );
       
   968     videoStream->AddCodecL( codecH2632000 );
       
   969     CleanupStack::Pop( codecH2632000 );
       
   970     
       
   971     CMceH263Codec* codecH2631998 = CMceH263Codec::NewLC( KMceSDPNameH2631998() );
       
   972     videoStream->AddCodecL( codecH2631998 );
       
   973     CleanupStack::Pop( codecH2631998 );
       
   974     
       
   975     iClipSession->AdjustStreamsAndCodecsL();
       
   976     
       
   977     // 1998 version should have been removed
       
   978     for ( TInt i = 0; i < videoStream->Codecs().Count(); i++ )
       
   979         {
       
   980         EUNIT_ASSERT( 
       
   981             !videoStream->Codecs()[ i ]->SdpName().CompareF( KMceSDPNameH2632000() ) );
       
   982         }
       
   983         
       
   984     // Test removing of multiples with different bitrates
       
   985     for ( TInt i = videoStream->Codecs().Count() - 1; i >= 0; i-- )
       
   986         {
       
   987         videoStream->RemoveCodecL( 
       
   988             *const_cast<CMceVideoCodec*>( videoStream->Codecs()[ i ] ) );
       
   989         }
       
   990     codecH2632000 = CMceH263Codec::NewLC( KMceSDPNameH2632000() );
       
   991     codecH2632000->SetMaxBitrateL( 64000 );
       
   992     videoStream->AddCodecL( codecH2632000 );
       
   993     CleanupStack::Pop( codecH2632000 );
       
   994     
       
   995     codecH2632000 = CMceH263Codec::NewLC( KMceSDPNameH2632000() );
       
   996     codecH2632000->SetMaxBitrateL( 128000 );
       
   997     videoStream->AddCodecL( codecH2632000 );
       
   998     CleanupStack::Pop( codecH2632000 );
       
   999     
       
  1000     iClipSession->AdjustStreamsAndCodecsL();
       
  1001     
       
  1002      // Lower bitrate version should have been removed
       
  1003     for ( TInt i = 0; i < videoStream->Codecs().Count(); i++ )
       
  1004         {
       
  1005         EUNIT_ASSERT( 
       
  1006             videoStream->Codecs()[ i ]->MaxBitRate() == 128000 );
       
  1007         }
       
  1008     }
       
  1009 
       
  1010 
       
  1011 // -----------------------------------------------------------------------------
       
  1012 //
       
  1013 // -----------------------------------------------------------------------------
       
  1014 //  
       
  1015 void UT_CMusEngMceSession::UT_IncomingSessionL()
       
  1016     {
       
  1017     // New session should get rejected and deleted in any case, first failure
       
  1018     CMceInSession* inSession = CMceInSession::NewL( 
       
  1019                                       *iLiveSession->iManager, KNullDesC8 );
       
  1020     CleanupStack::PushL( inSession );
       
  1021     iLiveSession->IncomingSession( inSession, NULL );
       
  1022     CleanupStack::Pop( inSession );
       
  1023     
       
  1024     // And then succesfull case, this would leak memory if session was not
       
  1025     // deleted
       
  1026     inSession = CMceInSession::NewL( *iLiveSession->iManager, KNullDesC8 );
       
  1027     CleanupStack::PushL( inSession );
       
  1028     iLiveSession->IncomingSession( inSession, NULL );
       
  1029     CleanupStack::Pop( inSession );
       
  1030     }
       
  1031 
       
  1032 
       
  1033 // -----------------------------------------------------------------------------
       
  1034 //
       
  1035 // -----------------------------------------------------------------------------
       
  1036 //  
       
  1037 void UT_CMusEngMceSession::UT_IncomingUpdateL()
       
  1038     {
       
  1039     CMceInSession* inSession = CMceInSession::NewL( 
       
  1040                                       *iLiveSession->iManager, KNullDesC8 );
       
  1041     
       
  1042     // Try to update before having a session, session gets rejected and deleted
       
  1043     CleanupStack::PushL( inSession );
       
  1044     iLiveSession->IncomingUpdate( *inSession, inSession, NULL );
       
  1045     CleanupStack::Pop( inSession );
       
  1046     
       
  1047     
       
  1048     // Try to update with unknown session, session gets rejected and deleted
       
  1049     ESTABLISH_OUT_SESSION( iLiveSession )
       
  1050     
       
  1051     inSession = CMceInSession::NewL( 
       
  1052                                       *iLiveSession->iManager, KNullDesC8 );
       
  1053     CleanupStack::PushL( inSession );
       
  1054     iLiveSession->IncomingUpdate( *inSession, inSession, NULL );
       
  1055     CleanupStack::Pop( inSession );
       
  1056     
       
  1057     // Normal case, old session gets deleted. New session gets rejected.
       
  1058     
       
  1059     inSession = CMceInSession::NewL( 
       
  1060                                       *iLiveSession->iManager, KNullDesC8 );
       
  1061     CleanupStack::PushL( inSession );
       
  1062     iLiveSession->IncomingUpdate( *iLiveSession->iSession, inSession, NULL );
       
  1063     CleanupStack::Pop( inSession );
       
  1064     
       
  1065     EUNIT_ASSERT( iLiveSession->iSession == inSession )
       
  1066     EUNIT_ASSERT( iLiveSession->iSession->iState == CMceSession::ETerminated )
       
  1067     
       
  1068     }
       
  1069         
       
  1070 
       
  1071 // -----------------------------------------------------------------------------
       
  1072 //
       
  1073 // -----------------------------------------------------------------------------
       
  1074 //  
       
  1075 void UT_CMusEngMceSession::UT_StreamStateChangedL()
       
  1076     {
       
  1077     // Try without a session, nothing happens
       
  1078     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
       
  1079     iLiveSession->CMusEngMceSession::StreamStateChanged( *audioStream );
       
  1080     CleanupStack::PopAndDestroy( audioStream );
       
  1081     
       
  1082     // Simulate sending invite
       
  1083     iLiveSession->EstablishLcSessionL();
       
  1084     
       
  1085     // No observer set, so expect nothing to be done, cannot be asserted
       
  1086     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
       
  1087 
       
  1088     // Try all the stream states
       
  1089     
       
  1090     // EUninitialized, stream is created, unexpected change, nothing happens
       
  1091     changedStream->iState = CMceMediaStream::EUninitialized;
       
  1092     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1093     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1094     
       
  1095     // EInitialized, stream is initialized
       
  1096     changedStream->iState = CMceMediaStream::EInitialized;
       
  1097     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1098     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1099     
       
  1100     // EBuffering, stream is buffering
       
  1101     changedStream->iState = CMceMediaStream::EBuffering;
       
  1102     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1103     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1104     
       
  1105     // EIdle, stream is not receiving RTP
       
  1106     changedStream->iState = CMceMediaStream::EIdle;
       
  1107     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1108     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1109     
       
  1110     // EStreaming, stream is streaming
       
  1111     changedStream->iState = CMceMediaStream::EStreaming;
       
  1112     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1113     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1114                          TInt( CLcSessionObserverStub::EPlayerStateChanged ) )
       
  1115     iLcSessionObserver->Reset();
       
  1116     
       
  1117     // EStreaming, stream is streaming, other than video out- or instream
       
  1118     changedStream->iState = CMceMediaStream::EStreaming;
       
  1119     iLiveSession->CMusEngMceSession::StreamStateChanged( 
       
  1120                                 *iLiveSession->iSession->Streams()[1] );
       
  1121     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1122     iLcSessionObserver->Reset();
       
  1123     
       
  1124     // EDisabled, stream is explicitly disabled
       
  1125     changedStream->iState = CMceMediaStream::EDisabled;
       
  1126     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1127     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1128     
       
  1129     // ENoResources, stream has no needed resources to stream
       
  1130     changedStream->iState = CMceMediaStream::ENoResources;
       
  1131     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1132     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1133     
       
  1134     // ETranscodingRequired, stream requires non-realtime transcoding
       
  1135     changedStream->iState = CMceMediaStream::ETranscodingRequired;
       
  1136     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1137     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1138     
       
  1139     // ETranscoding, stream is transcoding in non-realtime
       
  1140     changedStream->iState = CMceMediaStream::ETranscoding;
       
  1141     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1142     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1143     
       
  1144     }
       
  1145     
       
  1146 
       
  1147 // -----------------------------------------------------------------------------
       
  1148 // All the possibilities are tested in order to make sure unit tests are changed
       
  1149 // when function is changed
       
  1150 // -----------------------------------------------------------------------------
       
  1151 //  
       
  1152 void UT_CMusEngMceSession::UT_StreamStateChangedWithSourceL()
       
  1153     {
       
  1154     // Try without a session, nothing happens
       
  1155     iLiveSession->CMusEngMceSession::StreamStateChanged( 
       
  1156                                         *CMceAudioStream::NewLC(),
       
  1157                                         *CMceRtpSource::NewLC() );
       
  1158                                         
       
  1159     CleanupStack::PopAndDestroy(); // rtp                                    
       
  1160     CleanupStack::PopAndDestroy(); // audiostream
       
  1161     
       
  1162     // Simulate sending invite
       
  1163     iLiveSession->EstablishLcSessionL();
       
  1164     
       
  1165     // Try all the stream states
       
  1166     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
       
  1167     
       
  1168     // EUninitialized, stream is created, unexpected change, nothing happens
       
  1169     changedStream->iState = CMceMediaStream::EUninitialized;
       
  1170     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1171     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1172     
       
  1173     // EInitialized, stream is initialized
       
  1174     changedStream->iState = CMceMediaStream::EInitialized;
       
  1175     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1176     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1177     
       
  1178     // EBuffering, stream is buffering
       
  1179     changedStream->iState = CMceMediaStream::EBuffering;
       
  1180     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1181     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1182     
       
  1183     // EIdle, stream is not receiving RTP
       
  1184     changedStream->iState = CMceMediaStream::EIdle;
       
  1185     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1186     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1187     
       
  1188     // EStreaming, stream is streaming
       
  1189     changedStream->iState = CMceMediaStream::EStreaming;
       
  1190     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1191     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1192                          TInt( CLcSessionObserverStub::EPlayerStateChanged ) )
       
  1193     iLcSessionObserver->Reset();
       
  1194     
       
  1195     // EDisabled, stream is explicitly disabled
       
  1196     changedStream->iState = CMceMediaStream::EDisabled;
       
  1197     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1198     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1199     
       
  1200     // ENoResources, stream has no needed resources to stream
       
  1201     changedStream->iState = CMceMediaStream::ENoResources;
       
  1202     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1203     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1204     
       
  1205     // ETranscodingRequired, stream requires non-realtime transcoding
       
  1206     changedStream->iState = CMceMediaStream::ETranscodingRequired;
       
  1207     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1208     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1209     
       
  1210     // ETranscoding, stream is transcoding in non-realtime
       
  1211     changedStream->iState = CMceMediaStream::ETranscoding;
       
  1212     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1213     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1214     
       
  1215     }
       
  1216 
       
  1217 
       
  1218 // -----------------------------------------------------------------------------
       
  1219 // All the possibilities are tested in order to make sure unit tests are changed
       
  1220 // when function is changed
       
  1221 // -----------------------------------------------------------------------------
       
  1222 //  
       
  1223 void UT_CMusEngMceSession::UT_StreamStateChangedWithSinkL()
       
  1224     {
       
  1225     // Try without a session, nothing happens
       
  1226     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
       
  1227     iLiveSession->CMusEngMceSession::StreamStateChanged( *audioStream );
       
  1228     CleanupStack::PopAndDestroy( audioStream );
       
  1229     
       
  1230     // Simulate sending invite
       
  1231     iLiveSession->EstablishLcSessionL();
       
  1232     
       
  1233     // Try all the stream states
       
  1234     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
       
  1235     
       
  1236     // EUninitialized, stream is created, unexpected change, nothing happens
       
  1237     changedStream->iState = CMceMediaStream::EUninitialized;
       
  1238     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1239     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1240     
       
  1241     // EInitialized, stream is initialized
       
  1242     changedStream->iState = CMceMediaStream::EInitialized;
       
  1243     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1244     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1245     
       
  1246     // EBuffering, stream is buffering
       
  1247     changedStream->iState = CMceMediaStream::EBuffering;
       
  1248     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1249     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1250     
       
  1251     // EIdle, stream is not receiving RTP
       
  1252     changedStream->iState = CMceMediaStream::EIdle;
       
  1253     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1254     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1255     
       
  1256     // EStreaming, stream is streaming
       
  1257     changedStream->iState = CMceMediaStream::EStreaming;
       
  1258     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1259     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1260                          TInt( CLcSessionObserverStub::EPlayerStateChanged ) )
       
  1261     iLcSessionObserver->Reset();
       
  1262     
       
  1263     // EDisabled, stream is explicitly disabled
       
  1264     changedStream->iState = CMceMediaStream::EDisabled;
       
  1265     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1266     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1267     
       
  1268     // ENoResources, stream has no needed resources to stream
       
  1269     changedStream->iState = CMceMediaStream::ENoResources;
       
  1270     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1271     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1272     
       
  1273     // ETranscodingRequired, stream requires non-realtime transcoding
       
  1274     changedStream->iState = CMceMediaStream::ETranscodingRequired;
       
  1275     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1276     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1277     
       
  1278     // ETranscoding, stream is transcoding in non-realtime
       
  1279     changedStream->iState = CMceMediaStream::ETranscoding;
       
  1280     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1281     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1282     
       
  1283     }        
       
  1284 
       
  1285 
       
  1286 // -----------------------------------------------------------------------------
       
  1287 //
       
  1288 // -----------------------------------------------------------------------------
       
  1289 //    
       
  1290 void UT_CMusEngMceSession::UT_SessionStateChangedL()
       
  1291     {
       
  1292     // Simulate sending invite
       
  1293     iLiveSession->EstablishLcSessionL();   
       
  1294 
       
  1295     // No container, so expect to be handled as internal error
       
  1296     iLiveSession->SessionStateChanged( *iLiveSession->iSession, NULL );
       
  1297     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1298                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1299     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1300     iLcSessionObserver->Reset();    
       
  1301     
       
  1302     // Try to tell session about some other session's state transition
       
  1303     
       
  1304     TMceTransactionDataContainer container;
       
  1305  
       
  1306     iLiveSession->SessionStateChanged( *iSomeOtherSession->iSession, &container );
       
  1307     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );    
       
  1308       
       
  1309     // Try all the normal cases:
       
  1310     
       
  1311     // EIdle
       
  1312     iLiveSession->iSession->iState = CMceSession::EIdle;
       
  1313     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1314     // Set up any text to simulate reasonphrase
       
  1315     HBufC8* anyReasonPhrase = KTestOriginator().AllocL();
       
  1316     container.SetReasonPhrase( anyReasonPhrase );
       
  1317     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1318                                        &container );
       
  1319     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1320                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1321     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1322     iLcSessionObserver->Reset();
       
  1323     container.Clear();
       
  1324     
       
  1325     // EOffering
       
  1326     iLiveSession->iSession->iState = CMceSession::EOffering;
       
  1327     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1328     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1329                                        &container );
       
  1330     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1331     
       
  1332     // EIncoming
       
  1333     iLiveSession->iSession->iState = CMceSession::EIncoming;
       
  1334     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1335     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1336                                        &container );
       
  1337     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1338                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1339     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1340     iLcSessionObserver->Reset();
       
  1341     
       
  1342     // EReserving
       
  1343     iLiveSession->iSession->iState = CMceSession::EReserving;
       
  1344     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1345     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1346                                        &container );
       
  1347     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1348     
       
  1349     // EAnswering
       
  1350     iLiveSession->iSession->iState = CMceSession::EAnswering;
       
  1351     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1352     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1353                                        &container );
       
  1354     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1355     
       
  1356     // EProceeding
       
  1357     iLiveSession->iSession->iState = CMceSession::EProceeding;
       
  1358     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1359     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1360                                        &container );
       
  1361     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1362     
       
  1363     // EEstablished
       
  1364     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
  1365     container.SetStatusCode( KSipStatusCode200OK );
       
  1366     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1367                                        &container );
       
  1368     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1369                          TInt( CLcSessionObserverStub::ESessionStateChanged ) )
       
  1370     iLcSessionObserver->Reset();
       
  1371     
       
  1372     // EEstablished again (meaning expiration of session timer 
       
  1373     // and refresment of session )
       
  1374     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
  1375     container.SetStatusCode( KSipStatusCode200OK );
       
  1376     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1377                                        &container );
       
  1378     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1379     
       
  1380     // ECancelling
       
  1381     iLiveSession->iSession->iState = CMceSession::ECancelling;
       
  1382     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1383     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1384                                        &container );
       
  1385     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1386     iLcSessionObserver->Reset();
       
  1387     
       
  1388     // ETerminating
       
  1389     iLiveSession->iSession->iState = CMceSession::ETerminating;
       
  1390     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1391     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1392                                        &container );
       
  1393     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1394     iLcSessionObserver->Reset();
       
  1395     
       
  1396     // ETerminated
       
  1397     iLiveSession->iSession->iState = CMceSession::ETerminated;
       
  1398     container.SetStatusCode( KSipStatusCode200OK );
       
  1399     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1400                                        &container );
       
  1401     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1402                          TInt( CLcSessionObserverStub::ESessionStateChanged ) )
       
  1403     iLcSessionObserver->Reset();
       
  1404     
       
  1405     // Default case
       
  1406     iLiveSession->iSession->iState = static_cast<CMceSession::TState>( 10 );
       
  1407     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1408     iLiveSession->SessionStateChanged( *iLiveSession->iSession, &container );
       
  1409     EUNIT_ASSERT( iLcSessionObserver->IsReseted() );
       
  1410 
       
  1411     }
       
  1412 
       
  1413 // -----------------------------------------------------------------------------
       
  1414 //
       
  1415 // -----------------------------------------------------------------------------
       
  1416 //     
       
  1417 void UT_CMusEngMceSession::UT_HandleSessionStateChanged_EncoderKeyStoringL()
       
  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     {
       
  1452     
       
  1453     // Try to tell session about another session's connection state change
       
  1454     
       
  1455     iLiveSession->SessionConnectionStateChanged( *iSomeOtherSession->iSession, 
       
  1456                                                  ETrue );
       
  1457     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // No session yet, nothing happened
       
  1458     
       
  1459     // Simulate sending invite
       
  1460     iLiveSession->EstablishLcSessionL();
       
  1461     
       
  1462     // Now try again to notify session about session connection state change
       
  1463     // of an another session
       
  1464     iLiveSession->SessionConnectionStateChanged( *iSomeOtherSession->iSession, 
       
  1465                                                  ETrue );
       
  1466     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // Wrong session, nothing happened
       
  1467     
       
  1468     // Try tell session connection state is active
       
  1469     iLiveSession->SessionConnectionStateChanged( *iLiveSession->iSession, 
       
  1470                                                  ETrue );
       
  1471     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // Session active, nothing happened
       
  1472     
       
  1473     // Try tell session connection state is inactive
       
  1474     iLiveSession->SessionConnectionStateChanged( *iLiveSession->iSession, 
       
  1475                                                  EFalse );
       
  1476     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1477                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1478     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError,
       
  1479                          TInt( MLcSession::EConnectionLost ) )
       
  1480     iLcSessionObserver->Reset();  
       
  1481     }
       
  1482     
       
  1483 
       
  1484 // -----------------------------------------------------------------------------
       
  1485 //
       
  1486 // -----------------------------------------------------------------------------
       
  1487 // 
       
  1488 void UT_CMusEngMceSession::UT_FailedL()
       
  1489     {
       
  1490     // Try to tell session about failure of another session
       
  1491 
       
  1492     iLiveSession->Failed( *iSomeOtherSession->iSession, 0 );
       
  1493     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // No session yet, nothing happened
       
  1494     
       
  1495     // Simulate sending invite
       
  1496     iLiveSession->EstablishLcSessionL();
       
  1497     
       
  1498     // Now try again to notify session about failure of an another session
       
  1499     iLiveSession->Failed( *iSomeOtherSession->iSession, 0 );
       
  1500     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // Wrong session, nothing happened
       
  1501     
       
  1502     // Tell session that it has failed
       
  1503     iLiveSession->Failed( *iLiveSession->iSession, KErrNotFound );
       
  1504     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1505                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1506     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrNotFound )
       
  1507     iLcSessionObserver->Reset();
       
  1508     }
       
  1509     
       
  1510 
       
  1511 // -----------------------------------------------------------------------------
       
  1512 //
       
  1513 // -----------------------------------------------------------------------------
       
  1514 //     
       
  1515 void UT_CMusEngMceSession::UT_UpdateFailedL()
       
  1516     {
       
  1517     // Try to tell session about update failure of another session
       
  1518     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, NULL );
       
  1519     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1520                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1521     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1522     iLcSessionObserver->Reset();
       
  1523     
       
  1524     // Try again with container
       
  1525     TMceTransactionDataContainer container;
       
  1526     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, &container );
       
  1527     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // No session yet, nothing happened
       
  1528     
       
  1529     // Invite and try again.
       
  1530     iLiveSession->EstablishLcSessionL();
       
  1531     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, &container );
       
  1532     EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); // Wrong session, nothing happened¨
       
  1533     
       
  1534     // Try with right session
       
  1535     iLiveSession->UpdateFailed( *iLiveSession->iSession, &container );
       
  1536     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1537                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1538     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError, KErrGeneral )
       
  1539     iLcSessionObserver->Reset();
       
  1540     }
       
  1541     
       
  1542 
       
  1543 // -----------------------------------------------------------------------------
       
  1544 //
       
  1545 // -----------------------------------------------------------------------------
       
  1546 // 
       
  1547 void UT_CMusEngMceSession::UT_SRReceivedL()
       
  1548     {
       
  1549     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1550     
       
  1551     // No session yet, nothing happens
       
  1552     iLiveSession->SRReceived( *iSomeOtherSession->iSession,
       
  1553                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1554     
       
  1555     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1556     
       
  1557     ESTABLISH_OUT_SESSION( iLiveSession );
       
  1558     
       
  1559     // Simulate bigger value
       
  1560     iLiveSession->iSecondsFromLastRtcpReport = 10;
       
  1561     
       
  1562     // We have session, but informing concearn wrong session, timer is 
       
  1563     // not nullified
       
  1564     iLiveSession->SRReceived( *iSomeOtherSession->iSession,
       
  1565                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1566     
       
  1567     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 10 );
       
  1568     
       
  1569     // Right session but wrong stream, timer should not be nullified
       
  1570     iLiveSession->SRReceived( *iLiveSession->iSession,
       
  1571                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1572     
       
  1573     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 10 );
       
  1574     
       
  1575     // Right stream and established session, timer should be nullified
       
  1576     
       
  1577     
       
  1578     iLiveSession->SRReceived( *iLiveSession->iSession,
       
  1579                               *(iLiveSession->iSession->Streams()[0]) );
       
  1580 
       
  1581     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1582     
       
  1583     }
       
  1584     
       
  1585 
       
  1586 // -----------------------------------------------------------------------------
       
  1587 //
       
  1588 // -----------------------------------------------------------------------------
       
  1589 //     
       
  1590 void UT_CMusEngMceSession::UT_RRReceivedL()
       
  1591     {
       
  1592     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1593     
       
  1594     // No session yet, nothing happens
       
  1595     iLiveSession->RRReceived( *iSomeOtherSession->iSession,
       
  1596                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1597     
       
  1598     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1599     
       
  1600     ESTABLISH_OUT_SESSION( iLiveSession );
       
  1601     
       
  1602     // Simulate bigger value
       
  1603     iLiveSession->iSecondsFromLastRtcpReport = 10;
       
  1604     
       
  1605     // We have session, but informing concearn wrong session, timer is 
       
  1606     // not nullified
       
  1607     iLiveSession->RRReceived( *iSomeOtherSession->iSession,
       
  1608                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1609     
       
  1610     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 10 );
       
  1611     
       
  1612     // Right session but wrong stream, timer should not be nullified
       
  1613     iLiveSession->RRReceived( *iLiveSession->iSession,
       
  1614                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1615     
       
  1616     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 10 );
       
  1617     
       
  1618     // Right stream and established session, timer should be nullified
       
  1619     
       
  1620     
       
  1621     iLiveSession->RRReceived( *iLiveSession->iSession,
       
  1622                               *(iLiveSession->iSession->Streams()[0]) );
       
  1623 
       
  1624     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );    
       
  1625     }
       
  1626     
       
  1627     
       
  1628 // -----------------------------------------------------------------------------
       
  1629 //
       
  1630 // -----------------------------------------------------------------------------
       
  1631 //       
       
  1632 void UT_CMusEngMceSession::UT_SsrcAddedL()
       
  1633     {
       
  1634     // As CMusEngMceSession::SsrcAdded is expected to do nothing, just call
       
  1635     // it to make sure it does not weaken the test coverage
       
  1636     
       
  1637     CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>( 
       
  1638                             iReceiveSession->iSession->Streams()[0]->Source() );   
       
  1639     iReceiveSession->SsrcAdded( 
       
  1640                         *iReceiveSession->iSession->Streams()[0],
       
  1641                         *rtpSource,
       
  1642                         0 );
       
  1643     
       
  1644     }
       
  1645 
       
  1646 
       
  1647 // -----------------------------------------------------------------------------
       
  1648 //
       
  1649 // -----------------------------------------------------------------------------
       
  1650 //  
       
  1651 void UT_CMusEngMceSession::UT_SsrcRemovedL()
       
  1652     {
       
  1653     // As CMusEngMceSession::SsrcRemoved is expected to do nothing, just call
       
  1654     // it to make sure it does not weaken the test coverage
       
  1655     
       
  1656     CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>( 
       
  1657                             iReceiveSession->iSession->Streams()[0]->Source() );   
       
  1658 
       
  1659     iReceiveSession->SsrcRemoved( 
       
  1660                         *iReceiveSession->iSession->Streams()[0],
       
  1661                         *rtpSource,
       
  1662                         0 );
       
  1663     }
       
  1664 
       
  1665 
       
  1666 // -----------------------------------------------------------------------------
       
  1667 //
       
  1668 // -----------------------------------------------------------------------------
       
  1669 //  
       
  1670 void UT_CMusEngMceSession::UT_UpdateTimerEventL()
       
  1671     {
       
  1672     iLcSessionObserver->Reset();
       
  1673     iLiveSession->UpdateTimerEvent();
       
  1674     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1675                          TInt( CLcSessionObserverStub::EUnknown ) )
       
  1676     EUNIT_ASSERT( iLiveSession->iUpdateTimer->IsActive() )
       
  1677     iLiveSession->iUpdateTimer->Cancel();
       
  1678     iLcSessionObserver->Reset();
       
  1679     
       
  1680     iLiveSession->iSecondsFromLastRtcpReport = 25; // >KMusEngRtcpInactivityThreshold
       
  1681     iLiveSession->UpdateTimerEvent();
       
  1682     EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ),
       
  1683                          TInt( CLcSessionObserverStub::ESessionFailed ) )
       
  1684     EUNIT_ASSERT_EQUALS( iLcSessionObserver->iError,
       
  1685                          TInt( MLcSession::EMediaInactivityTimeout ) )
       
  1686     EUNIT_ASSERT( iLiveSession->iUpdateTimer->IsActive() )
       
  1687     iLiveSession->iUpdateTimer->Cancel();
       
  1688     iLcSessionObserver->Reset(); 
       
  1689     }   
       
  1690 
       
  1691 
       
  1692 // -----------------------------------------------------------------------------
       
  1693 //
       
  1694 // -----------------------------------------------------------------------------
       
  1695 //
       
  1696 void UT_CMusEngMceSession::UT_IsRoamingBetweenAPsAllowedL()
       
  1697     {
       
  1698     // No session
       
  1699     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
       
  1700 
       
  1701     // Session idle
       
  1702     iLiveSession->EstablishLcSessionL();
       
  1703     iLiveSession->iSession->iState = CMceSession::EIdle;
       
  1704     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
       
  1705     
       
  1706     // Session established
       
  1707     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
  1708     EUNIT_ASSERT( !iLiveSession->IsRoamingBetweenAPsAllowed() )
       
  1709     
       
  1710     // Session terminated
       
  1711     iLiveSession->iSession->iState = CMceSession::ETerminated;
       
  1712     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
       
  1713     }
       
  1714 
       
  1715 // -----------------------------------------------------------------------------
       
  1716 //
       
  1717 // -----------------------------------------------------------------------------
       
  1718 //
       
  1719 void UT_CMusEngMceSession::UT_SaveContactL()
       
  1720     {     
       
  1721     _LIT8( KTestSaveContactAddr, "sip:abc@10.10.10.10");
       
  1722     
       
  1723     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
  1724                                         NMusSessionApi::KTelNumber,
       
  1725                                         _L("12341234") ) );
       
  1726     
       
  1727     // Operator variant
       
  1728     iLiveSession->iOperatorVariant = ETrue;
       
  1729     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
       
  1730             iLiveSession->SaveContactL( KTestSaveContactAddr ), KErrNotSupported )
       
  1731     
       
  1732     // No address to save
       
  1733     iLiveSession->iOperatorVariant = EFalse;
       
  1734     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
       
  1735                iLiveSession->SaveContactL( KNullDesC8 ), KErrArgument )
       
  1736 
       
  1737     // Contact id KErrNotSupported (multiple matching contacts)
       
  1738     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
  1739                                      NMusSessionApi::KContactId,
       
  1740                                      KErrNotSupported ) );
       
  1741     
       
  1742     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
       
  1743                 iLiveSession->SaveContactL( KTestSaveContactAddr ), KErrNotFound )
       
  1744     
       
  1745     // SIP field exists already
       
  1746     User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid,
       
  1747                                         NMusSessionApi::KContactId,
       
  1748                                         2 ) );
       
  1749 
       
  1750     ContactEngineStubHelper::SetSIPFieldFound( ETrue );
       
  1751     MUSENG_EUNIT_ASSERT_SPECIFIC_LEAVE( 
       
  1752                    iLiveSession->SaveContactL( KTestSaveContactAddr ), KErrAlreadyExists )
       
  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         {
       
  2129         User::Leave( KErrNoMemory );
       
  2130         }
       
  2131 
       
  2132     HBufC8* keys = MultimediaSharingSettings::EncoderConfigInfoLC();    
       
  2133     EUNIT_ASSERT_EQUALS( *keys, KMusAvcBitrateLevel_1b_ConfigKey() )
       
  2134     CleanupStack::PopAndDestroy( keys );
       
  2135     
       
  2136     // Try without a clean CenRep 
       
  2137     MultimediaSharingSettings::SetEncoderConfigInfoL(
       
  2138                                         KMusAvcBitrateLevel_1_1_ConfigKey() );   
       
  2139     
       
  2140     delete iLiveSession;
       
  2141     iLiveSession = NULL;
       
  2142     iLiveSession = CMusEngLiveSession::NewL();
       
  2143     iLiveSession->SetLcSessionObserver( iLcSessionObserver );
       
  2144     iLiveSession->SetLcUiProvider( iLcUiProvider );
       
  2145     
       
  2146     ESTABLISH_OUT_SESSION( iLiveSession ) // calls StoreEncoderConfigInfoL
       
  2147     // If StoreEncoderConfigInfoL leaves with KErrNoMemory,
       
  2148     // MMusEngSessionObserver::SessionFailed will be called.
       
  2149     if ( iLcSessionObserver->iCalledFunction == CLcSessionObserverStub::ESessionFailed )
       
  2150         {
       
  2151         User::Leave( KErrNoMemory );
       
  2152         }
       
  2153                      
       
  2154     keys = MultimediaSharingSettings::EncoderConfigInfoLC();
       
  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
       
  2474 
       
  2475 EUNIT_BEGIN_TEST_TABLE(
       
  2476     UT_CMusEngMceSession,
       
  2477     "UT_CMusEngMceSesssion",
       
  2478     "UNIT" )
       
  2479 
       
  2480 EUNIT_TEST(
       
  2481     "LcSessionState - test ",
       
  2482     "CMusEngMceSession",
       
  2483     "LcSessionState",
       
  2484     "FUNCTIONALITY",
       
  2485     SetupL, UT_LcSessionStateL, Teardown)
       
  2486         
       
  2487 EUNIT_TEST(
       
  2488     "RemoteVideoPlayer - test ",
       
  2489     "CMusEngMceSession",
       
  2490     "RemoteVideoPlayer",
       
  2491     "FUNCTIONALITY",
       
  2492     SetupL, UT_RemoteVideoPlayerL, Teardown)
       
  2493         
       
  2494 EUNIT_TEST(
       
  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
       
  2916 
       
  2917 //  END OF FILE
       
  2918 
       
  2919