mmsharing/mmshengine/tsrc/ut_engine/src/ut_musengmcesession.cpp
changeset 15 ccd8e69b5392
parent 2 b31261fd4e04
child 20 e8be2c2e049d
child 22 496ad160a278
equal deleted inserted replaced
2:b31261fd4e04 15:ccd8e69b5392
     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 
       
    32 //  SYSTEM INCLUDES
       
    33 
       
    34 #include <digia/eunit/eunitmacros.h>
       
    35 #include <mceinsession.h>
       
    36 #include <mcevideostream.h>
       
    37 #include <mcedisplaysink.h>
       
    38 #include <mcertpsource.h>
       
    39 #include <mcespeakersink.h>
       
    40 #include <mceaudiostream.h>
       
    41 #include <mcertpsink.h>
       
    42 #include <mcevideocodec.h>
       
    43 #include <mceaudiocodec.h>
       
    44 #include <audiopreference.h>
       
    45 #include <mceh263codec.h>
       
    46 #include <mceavccodec.h>
       
    47 
       
    48 
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 UT_CMusEngMceSession* UT_CMusEngMceSession::NewL()
       
    55     {
       
    56     UT_CMusEngMceSession* self = UT_CMusEngMceSession::NewLC();
       
    57     CleanupStack::Pop( self );
       
    58     return self;
       
    59     }
       
    60 
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 UT_CMusEngMceSession* UT_CMusEngMceSession::NewLC()
       
    67     {
       
    68     UT_CMusEngMceSession* self = new( ELeave ) UT_CMusEngMceSession();
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL();
       
    71     return self;
       
    72     }
       
    73 
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 UT_CMusEngMceSession::~UT_CMusEngMceSession()
       
    80     {
       
    81     // NOP
       
    82     }
       
    83 
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // Default constructor
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 UT_CMusEngMceSession::UT_CMusEngMceSession()
       
    90     {
       
    91     // NOP
       
    92     }
       
    93 
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // Second phase construct
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 void UT_CMusEngMceSession::ConstructL()
       
   100     {
       
   101     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
   102     // It generates the test case table.
       
   103     CEUnitTestSuiteClass::ConstructL();
       
   104     }
       
   105     
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void UT_CMusEngMceSession::SetupL(  )
       
   112     {
       
   113     iObserver = new( ELeave ) CMusEngObserverStub;
       
   114     iLiveSession = CMusEngLiveSession::NewL( KNullDesC,
       
   115                                              TRect(0,0, 100,100),
       
   116                                              *iObserver,
       
   117                                              *iObserver,
       
   118                                              *iObserver );
       
   119     
       
   120     iSomeOtherSession = CMusEngLiveSession::NewL( KNullDesC,
       
   121                                                   TRect(0,0, 100,100),
       
   122                                                   *iObserver,
       
   123                                                   *iObserver,
       
   124                                                   *iObserver );
       
   125     ESTABLISH_OUT_SESSION( iSomeOtherSession );
       
   126     
       
   127     iClipSession = CMusEngClipSession::NewL( TRect(0,0, 100,100),
       
   128                                              *iObserver,
       
   129                                              *iObserver,
       
   130                                              *iObserver );                                             
       
   131     iClipSession->SetClipL( KTestVideoFileName() );
       
   132 
       
   133     TBuf<50> videoCodec;
       
   134     videoCodec.Copy( KMceSDPNameH264() );
       
   135     iClipSession->SetSupportedVideoCodecListL(videoCodec);
       
   136     
       
   137     // Construct and establish an incoming session
       
   138     iReceiveSession = CMusEngReceiveSession::NewL( TRect(0,0, 100,100), 
       
   139                                                    *iObserver,
       
   140                                                    *iObserver );
       
   141     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
       
   142                                                     KTestOriginator() );
       
   143                                                     
       
   144     CMceVideoStream* videoStream = CMceVideoStream::NewLC();
       
   145     
       
   146     videoStream->SetSourceL( CMceRtpSource::NewLC() );
       
   147     CleanupStack::Pop();
       
   148     
       
   149     inSession->AddStreamL( videoStream );
       
   150     CleanupStack::Pop( videoStream );
       
   151                                                     
       
   152     iReceiveSession->iManager->iInSessionObserver->IncomingSession( 
       
   153                                                         inSession, 
       
   154                                                         &iContainer );
       
   155     iReceiveSession->iSession->iState = CMceSession::EProceeding;
       
   156     iReceiveSession->AcceptInvitationL( ETrue );
       
   157     
       
   158     iObserver->Reset();
       
   159     }
       
   160 
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void UT_CMusEngMceSession::Teardown(  )
       
   167     {
       
   168     delete iLiveSession;
       
   169     delete iClipSession;
       
   170     delete iReceiveSession;
       
   171     delete iObserver;
       
   172     delete iSomeOtherSession;
       
   173     
       
   174     }
       
   175 
       
   176 
       
   177 
       
   178 // TEST CASES
       
   179 
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void UT_CMusEngMceSession::UT_CMusEngMceSession_TerminateLL()
       
   186     {
       
   187     TRAPD( error, iLiveSession->TerminateL() );
       
   188     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   189     EUNIT_ASSERT( error == KErrNotReady );
       
   190     
       
   191     ESTABLISH_OUT_SESSION( iLiveSession );
       
   192     
       
   193     EUNIT_ASSERT( iLiveSession->iSession->iState == CMceSession::EEstablished );
       
   194     
       
   195     iLiveSession->TerminateL();
       
   196     
       
   197     EUNIT_ASSERT( iLiveSession->iSession->iState == CMceSession::ETerminating );
       
   198     
       
   199     }
       
   200 
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 // -----------------------------------------------------------------------------
       
   205 //  
       
   206 void UT_CMusEngMceSession::UT_CMusEngMceSession_GetSessionTimeL()
       
   207     {
       
   208     EUNIT_ASSERT( iLiveSession->GetSessionTime() < TTimeIntervalSeconds( 0 ) );
       
   209     
       
   210     // Invite
       
   211     iLiveSession->InviteL( KTestRecipientSipUri );
       
   212     
       
   213     EUNIT_ASSERT( iLiveSession->GetSessionTime() < TTimeIntervalSeconds( 0 ) );
       
   214     
       
   215     // Simulate establishment
       
   216     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
   217     iLiveSession->iStartTime.HomeTime();
       
   218     
       
   219     TTimeIntervalSeconds sessionTime = iLiveSession->GetSessionTime();
       
   220     EUNIT_ASSERT( sessionTime >= TTimeIntervalSeconds( 0 ) );
       
   221     }
       
   222     
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 void UT_CMusEngMceSession::UT_CMusEngMceSession_ConnectionActiveL()
       
   229     {
       
   230     EUNIT_ASSERT( !iLiveSession->ConnectionActive() );
       
   231     
       
   232     ESTABLISH_OUT_SESSION( iLiveSession );
       
   233     
       
   234     EUNIT_ASSERT( iLiveSession->ConnectionActive() );
       
   235     }
       
   236 
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 void UT_CMusEngMceSession::UT_CMusEngMceSession_ContainsAudioLL()
       
   243     {
       
   244     // Try without session, fails
       
   245     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->ContainsAudioL(), KErrNotReady )
       
   246     
       
   247     // Establish session without audio
       
   248     ESTABLISH_OUT_SESSION( iLiveSession )
       
   249     
       
   250     EUNIT_ASSERT( !iLiveSession->ContainsAudioL() )
       
   251     
       
   252     // Establish session with audio
       
   253     ESTABLISH_OUT_SESSION( iClipSession )
       
   254     
       
   255     EUNIT_ASSERT( iClipSession->ContainsAudioL() )
       
   256     }
       
   257 
       
   258 
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 void UT_CMusEngMceSession::UT_CMusEngMceSession_IsMutedLL()
       
   264     {
       
   265     // Try without session, fails
       
   266     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->IsMutedL(), KErrNotReady )
       
   267     
       
   268     // Establish session without audio
       
   269     ESTABLISH_OUT_SESSION( iLiveSession )
       
   270     
       
   271     EUNIT_ASSERT( iLiveSession->IsMutedL() )
       
   272     
       
   273     // Establish session with audio
       
   274     ESTABLISH_OUT_SESSION( iClipSession )
       
   275     
       
   276     EUNIT_ASSERT( !iClipSession->IsMutedL() )  // Not muted although disabled
       
   277     
       
   278     iClipSession->EnableDisplayL( ETrue ); // Enabled also speaker
       
   279     
       
   280     EUNIT_ASSERT( !iClipSession->IsMutedL() )  // Enabled and not muted
       
   281 
       
   282     iClipSession->MuteL();
       
   283     
       
   284     EUNIT_ASSERT( iClipSession->IsMutedL() ) // Explicitly muted
       
   285     
       
   286     iClipSession->UnmuteL();
       
   287     
       
   288     EUNIT_ASSERT( !iClipSession->IsMutedL() ) // Explicitly unmuted
       
   289     }
       
   290 
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 void UT_CMusEngMceSession::UT_CMusEngMceSession_OrientationLL()
       
   297     {
       
   298     // Try without session, fails
       
   299     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->OrientationL(), KErrNotReady )
       
   300     
       
   301     // Establish a session and try all the MCE rotation values
       
   302     ESTABLISH_OUT_SESSION( iLiveSession )
       
   303     
       
   304     CMceDisplaySink* display = 
       
   305                     MusEngMceUtils::GetDisplayL( *iLiveSession->iSession );
       
   306 
       
   307     display->iRotation = CMceDisplaySink::ENone;
       
   308     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   309                          CMusEngMceSession::EPortrait )
       
   310     
       
   311     display->iRotation = CMceDisplaySink::EClockwise90Degree;
       
   312     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   313                          CMusEngMceSession::ELandscape )
       
   314     
       
   315     display->iRotation = CMceDisplaySink::EClockwise180Degree;
       
   316     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   317                          CMusEngMceSession::ELandscape )
       
   318     
       
   319     display->iRotation = CMceDisplaySink::EClockwise270Degree;
       
   320     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   321                          CMusEngMceSession::ELandscape )
       
   322             
       
   323     }
       
   324     
       
   325 
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 // -----------------------------------------------------------------------------
       
   329 //
       
   330 void UT_CMusEngMceSession::UT_CMusEngMceSession_SetOrientationLL()
       
   331     {
       
   332     // Try without session, fails
       
   333     EUNIT_ASSERT_SPECIFIC_LEAVE( iLiveSession->SetOrientationL( 
       
   334                                                 CMusEngMceSession::EPortrait ), 
       
   335                                  KErrNotReady )
       
   336 
       
   337     // Establish a session
       
   338     ESTABLISH_OUT_SESSION( iLiveSession )
       
   339     
       
   340     CMceDisplaySink* display = 
       
   341                     MusEngMceUtils::GetDisplayL( *iLiveSession->iSession );
       
   342     
       
   343     // Check the initial state
       
   344     display->iRotation = CMceDisplaySink::ENone;
       
   345     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   346                          CMusEngMceSession::EPortrait )      
       
   347                          
       
   348     // Successfully change orientation
       
   349     
       
   350     iLiveSession->SetOrientationL( CMusEngMceSession::ELandscape );
       
   351     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   352                          CMusEngMceSession::ELandscape )
       
   353     
       
   354     iLiveSession->SetOrientationL( CMusEngMceSession::EPortrait );
       
   355     EUNIT_ASSERT_EQUALS( iLiveSession->OrientationL(), 
       
   356                          CMusEngMceSession::EPortrait )                     
       
   357                          
       
   358     }
       
   359         
       
   360 
       
   361 // -----------------------------------------------------------------------------
       
   362 //
       
   363 // -----------------------------------------------------------------------------
       
   364 //
       
   365 void UT_CMusEngMceSession::UT_CMusEngMceSession_VolumeUpLL()
       
   366     {    
       
   367     // Try without session, fails
       
   368     TRAPD( error, iLiveSession->VolumeUpL() );
       
   369     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   370     EUNIT_ASSERT( error == KErrNotReady );
       
   371     
       
   372     // Test only usage of CMceSpeaker, phone part is tested in base class
       
   373     
       
   374     // Check that nothing crashes without any speakers    
       
   375     iReceiveSession->VolumeUpL();
       
   376     
       
   377     // Establish session
       
   378     ESTABLISH_OUT_SESSION( iClipSession )
       
   379     
       
   380     TInt initialVolume = iClipSession->VolumeL();
       
   381     
       
   382     iClipSession->VolumeUpL();
       
   383 
       
   384     // Check that all speaker volumes are adjusted and store one speaker pointer
       
   385     
       
   386     CMceSpeakerSink* speaker = NULL;
       
   387     
       
   388     CMceSession* session = iClipSession->iSession;
       
   389     
       
   390     for ( TInt i = 0; i < session->Streams().Count(); ++i )
       
   391         {
       
   392         for ( TInt j = 0; j < session->Streams()[i]->Sinks().Count(); ++j )
       
   393             {
       
   394             if ( session->Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
   395                 {
       
   396                 speaker = static_cast<CMceSpeakerSink*>(
       
   397                                             session->Streams()[i]->Sinks()[j] );
       
   398                 EUNIT_ASSERT( speaker->VolumeL() == initialVolume + 1 );
       
   399                 }
       
   400             }
       
   401         } 
       
   402 
       
   403     while ( iClipSession->VolumeL() < speaker->MaxVolumeL() )
       
   404         {
       
   405         iClipSession->VolumeUpL();
       
   406         }
       
   407 
       
   408     iClipSession->VolumeUpL(); // Does not do anything to volume
       
   409     
       
   410     EUNIT_ASSERT( iClipSession->VolumeL() == speaker->MaxVolumeL() );
       
   411     
       
   412     }
       
   413 
       
   414 
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 void UT_CMusEngMceSession::UT_CMusEngMceSession_VolumeDownLL()
       
   420     {
       
   421         // Try without session, fails
       
   422     TRAPD( error, iLiveSession->VolumeDownL() );
       
   423     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   424     EUNIT_ASSERT( error == KErrNotReady );
       
   425     
       
   426     // Test only usage of CMceSpeaker, phone part is tested in base class
       
   427     
       
   428     // Check that nothing crashes without any speakers    
       
   429     iReceiveSession->VolumeUpL();
       
   430     
       
   431     // Establish session
       
   432     ESTABLISH_OUT_SESSION( iClipSession )
       
   433     
       
   434     TInt initialVolume = iClipSession->VolumeL();
       
   435     
       
   436     iClipSession->VolumeDownL();
       
   437 
       
   438     // Check that all speaker volumes are adjusted and store one speaker pointer
       
   439     
       
   440     CMceSpeakerSink* speaker = NULL;
       
   441     
       
   442     CMceSession* session = iClipSession->iSession;
       
   443     
       
   444     for ( TInt i = 0; i < session->Streams().Count(); ++i )
       
   445         {
       
   446         for ( TInt j = 0; j < session->Streams()[i]->Sinks().Count(); ++j )
       
   447             {
       
   448             if ( session->Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
   449                 {
       
   450                 speaker = static_cast<CMceSpeakerSink*>(
       
   451                                             session->Streams()[i]->Sinks()[j] );
       
   452                 EUNIT_ASSERT( speaker->VolumeL() == initialVolume - 1 );
       
   453                 }
       
   454             }
       
   455         } 
       
   456 
       
   457     while ( iClipSession->VolumeL() > 0 )
       
   458         {
       
   459         iClipSession->VolumeDownL();
       
   460         }
       
   461 
       
   462     iClipSession->VolumeDownL(); // Does not do anything to volume
       
   463     
       
   464     EUNIT_ASSERT_EQUALS( iClipSession->VolumeL(), 0 );
       
   465         
       
   466     }
       
   467 
       
   468 
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 // -----------------------------------------------------------------------------
       
   472 //
       
   473 void UT_CMusEngMceSession::UT_CMusEngMceSession_SetVolumeLL()
       
   474     {    
       
   475     // Try without session, fails
       
   476     TInt newVolume = KTelephonyVolumeDefaultValue + 1;
       
   477     
       
   478     TRAPD( error, iLiveSession->SetVolumeL( newVolume ) );
       
   479     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   480     EUNIT_ASSERT( error == KErrNotReady );
       
   481     
       
   482     // Test only usage of CMceSpeaker, phone part is tested in base class
       
   483     
       
   484     // Check that nothing crashes without any speakers    
       
   485     iReceiveSession->SetVolumeL( newVolume );
       
   486     
       
   487     // Establish session
       
   488     ESTABLISH_OUT_SESSION( iClipSession )
       
   489     
       
   490     TInt initialVolume = iClipSession->VolumeL();
       
   491     
       
   492     iClipSession->SetVolumeL( newVolume );
       
   493 
       
   494     // Check that all speaker volumes are adjusted and store one speaker pointer
       
   495     
       
   496     CMceSpeakerSink* speaker = NULL;
       
   497     
       
   498     CMceSession* session = iClipSession->iSession;
       
   499     
       
   500     for ( TInt i = 0; i < session->Streams().Count(); ++i )
       
   501         {
       
   502         for ( TInt j = 0; j < session->Streams()[i]->Sinks().Count(); ++j )
       
   503             {
       
   504             if ( session->Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
   505                 {
       
   506                 speaker = static_cast<CMceSpeakerSink*>(
       
   507                                             session->Streams()[i]->Sinks()[j] );
       
   508                 EUNIT_ASSERT( speaker->VolumeL() == newVolume );
       
   509                 }
       
   510             }
       
   511         } 
       
   512 
       
   513     newVolume = speaker->MaxVolumeL() + 1;
       
   514     iClipSession->SetVolumeL( newVolume );
       
   515     EUNIT_ASSERT( iClipSession->VolumeL() == speaker->MaxVolumeL() );
       
   516     
       
   517     newVolume = -1;
       
   518     iClipSession->SetVolumeL( newVolume );
       
   519     EUNIT_ASSERT( iClipSession->VolumeL() == 0 );
       
   520     
       
   521     // Test situation where MCE max volume is bigger than MUS max vol
       
   522     SetMaxVolForSpeakersL(*session, KMusEngMaxVolume * 10);
       
   523     newVolume = 5;
       
   524     iClipSession->SetVolumeL( newVolume );
       
   525     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   526     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 10 );
       
   527     newVolume = 1;
       
   528     iClipSession->SetVolumeL( newVolume );
       
   529     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   530     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 10 );
       
   531     newVolume = KMusEngMaxVolume;
       
   532     iClipSession->SetVolumeL( newVolume );
       
   533     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   534     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 10 );
       
   535     
       
   536     SetMaxVolForSpeakersL(*session, KMusEngMaxVolume * 1000);
       
   537     newVolume = 7;
       
   538     iClipSession->SetVolumeL( newVolume );
       
   539     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   540     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 1000 );
       
   541     newVolume = 1;
       
   542     iClipSession->SetVolumeL( newVolume );
       
   543     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   544     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 1000 );
       
   545     newVolume = KMusEngMaxVolume;
       
   546     iClipSession->SetVolumeL( newVolume );
       
   547     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   548     EUNIT_ASSERT( speaker->VolumeL() == newVolume * 1000 );
       
   549     
       
   550     
       
   551     // Test situation where MCE max volume is smaller than MUS max vol
       
   552     SetMaxVolForSpeakersL(*session, KMusEngMaxVolume / 2);
       
   553     newVolume = 3;
       
   554     iClipSession->SetVolumeL( newVolume );
       
   555     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   556     EUNIT_ASSERT( speaker->VolumeL() == newVolume / 2 );
       
   557     newVolume = 1;
       
   558     iClipSession->SetVolumeL( newVolume );
       
   559     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   560     EUNIT_ASSERT( speaker->VolumeL() == 1 );
       
   561     newVolume = KMusEngMaxVolume;
       
   562     iClipSession->SetVolumeL( newVolume );
       
   563     EUNIT_ASSERT( iClipSession->VolumeL() == newVolume );
       
   564     EUNIT_ASSERT( speaker->VolumeL() == newVolume / 2 );
       
   565     }
       
   566 
       
   567 // -----------------------------------------------------------------------------
       
   568 //
       
   569 // -----------------------------------------------------------------------------
       
   570 //
       
   571 void UT_CMusEngMceSession::UT_CMusEngMceSession_EnableDisplayL()
       
   572     {
       
   573     TRAPD( error, iLiveSession->EnableDisplayL( ETrue ) );
       
   574     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   575     EUNIT_ASSERT( error == KErrNotReady );
       
   576     
       
   577     ESTABLISH_OUT_SESSION( iLiveSession );
       
   578     
       
   579     CMceDisplaySink* display = 
       
   580                     MusEngMceUtils::GetDisplayL( *(iLiveSession->iSession) );
       
   581     
       
   582     // Disable
       
   583     iLiveSession->EnableDisplayL( EFalse );
       
   584     
       
   585     EUNIT_ASSERT( !display->iIsEnabled );
       
   586     
       
   587     // Try to disable again, request should be ignored
       
   588     
       
   589     iLiveSession->EnableDisplayL( EFalse );
       
   590     
       
   591     EUNIT_ASSERT( !display->iIsEnabled );
       
   592 
       
   593     // Enable
       
   594     
       
   595     iLiveSession->EnableDisplayL( ETrue );
       
   596     
       
   597     EUNIT_ASSERT( display->iIsEnabled );
       
   598     
       
   599     // Try to enable again, request should be ignored
       
   600     
       
   601     iLiveSession->EnableDisplayL( ETrue );
       
   602     
       
   603     EUNIT_ASSERT( display->iIsEnabled );
       
   604     }
       
   605 
       
   606 
       
   607 // -----------------------------------------------------------------------------
       
   608 //
       
   609 // -----------------------------------------------------------------------------
       
   610 //
       
   611 void UT_CMusEngMceSession::UT_CMusEngMceSession_MuteLL()
       
   612     {
       
   613     TRAPD( error, iClipSession->MuteL() );
       
   614     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   615     EUNIT_ASSERT( error == KErrNotReady );
       
   616     
       
   617     ESTABLISH_OUT_SESSION_AND_START_STREAMING( iClipSession );
       
   618     
       
   619     const RPointerArray<CMceMediaStream> streams = 
       
   620                                             iClipSession->iSession->Streams();
       
   621     
       
   622     iClipSession->MuteL();
       
   623     
       
   624     // Check that all audio speaker sinks are disabled and only those                                        
       
   625     for ( TInt i = 0; i < streams.Count(); ++i )
       
   626         {
       
   627         for ( TInt j = 0; j < streams[i]->Sinks().Count(); ++j )
       
   628             {
       
   629             CMceMediaSink* sink = streams[i]->Sinks()[j];
       
   630             if ( sink->Type() == KMceSpeakerSink  &&
       
   631                  streams[i]->Type() == KMceAudio )
       
   632                 {
       
   633                 EUNIT_ASSERT( sink->IsEnabled() == EFalse )
       
   634                 }    
       
   635             else
       
   636                 {
       
   637                 EUNIT_ASSERT( sink->IsEnabled() == ETrue )
       
   638                 } 
       
   639             }        
       
   640         }
       
   641     
       
   642     EUNIT_ASSERT( iClipSession->iExplicitlyMuted ) 
       
   643     
       
   644     // Try to mute again, request should be ignored without actions or leaving
       
   645 
       
   646     iClipSession->MuteL();
       
   647 
       
   648     }
       
   649     
       
   650 
       
   651 // -----------------------------------------------------------------------------
       
   652 // Relies on previous test
       
   653 // -----------------------------------------------------------------------------
       
   654 //
       
   655 void UT_CMusEngMceSession::UT_CMusEngMceSession_UnmuteLL()
       
   656     {
       
   657     TRAPD( error, iClipSession->UnmuteL() );
       
   658     MUS_TEST_FORWARD_ALLOC_FAILURE( error );
       
   659     EUNIT_ASSERT( error == KErrNotReady );
       
   660     
       
   661     ESTABLISH_OUT_SESSION( iClipSession );
       
   662     
       
   663     const RPointerArray<CMceMediaStream> streams = 
       
   664                                             iClipSession->iSession->Streams();
       
   665     
       
   666     iClipSession->MuteL();
       
   667     
       
   668     iClipSession->UnmuteL();
       
   669     
       
   670     // Check that all audio speaker sinks are enabled
       
   671                                             
       
   672     for ( TInt i = 0; i < streams.Count(); ++i )
       
   673         {
       
   674         for ( TInt j = 0; j < streams[i]->Sinks().Count(); ++j )
       
   675             {
       
   676             if ( streams[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
   677                 {
       
   678                 EUNIT_ASSERT( streams[i]->Sinks()[j]->IsEnabled() == ETrue )
       
   679                 }
       
   680             }        
       
   681         }
       
   682     
       
   683     EUNIT_ASSERT( !iClipSession->iExplicitlyMuted ) 
       
   684     
       
   685     // Try to unmute again, request should be ignored without actions or leaving
       
   686 
       
   687     iClipSession->UnmuteL();
       
   688     }
       
   689     
       
   690 
       
   691 // -----------------------------------------------------------------------------
       
   692 //
       
   693 // -----------------------------------------------------------------------------
       
   694 //
       
   695 void UT_CMusEngMceSession::UT_CMusEngMceSession_HandleTerminationL()
       
   696     { 
       
   697     // Try different values
       
   698     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCodeNoCodeSet,
       
   699                                                         KNullDesC8() );
       
   700     EUNIT_ASSERT( iObserver->iSessionTerminatedCalled );
       
   701     iObserver->Reset();
       
   702 
       
   703     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCode200OK,
       
   704                                                         KNullDesC8() );
       
   705     EUNIT_ASSERT( iObserver->iSessionTerminatedCalled );
       
   706     iObserver->Reset();
       
   707 
       
   708     iLiveSession->CMusEngMceSession::HandleTermination( KSipStatusCodeUnknown,
       
   709                                                         KNullDesC8() );
       
   710     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
       
   711     iObserver->Reset();
       
   712     
       
   713     }
       
   714 
       
   715 
       
   716 // -----------------------------------------------------------------------------
       
   717 //
       
   718 // -----------------------------------------------------------------------------
       
   719 //
       
   720 void UT_CMusEngMceSession::UT_CMusEngMceSession_AdjustVideoCodecLL()
       
   721     {
       
   722     // CMusEngMceSession::AdjustVideoCodecL does nothing, so NULL test is enough
       
   723     CMceVideoCodec* codec = 
       
   724                 iLiveSession->iManager->SupportedVideoCodecs()[0]->CloneL();
       
   725     CleanupStack::PushL( codec );
       
   726     iLiveSession->CMusEngMceSession::AdjustVideoCodecL( *codec );
       
   727     CleanupStack::PopAndDestroy( codec );
       
   728     }
       
   729 
       
   730 
       
   731 // -----------------------------------------------------------------------------
       
   732 //
       
   733 // -----------------------------------------------------------------------------
       
   734 //
       
   735 void UT_CMusEngMceSession::UT_CMusEngMceSession_AdjustAudioCodecLL()
       
   736     {
       
   737     CMceAudioCodec* codec = 
       
   738                 iLiveSession->iManager->SupportedAudioCodecs()[0]->CloneL();
       
   739     CleanupStack::PushL( codec );
       
   740     iLiveSession->CMusEngMceSession::AdjustAudioCodecL( *codec );
       
   741     
       
   742     EUNIT_ASSERT( codec->iMMFPriority == KAudioPrioritySwisPlayback )
       
   743     EUNIT_ASSERT( codec->iMMFPriorityPreference == KAudioPrefSwisPlayback )
       
   744     
       
   745     CleanupStack::PopAndDestroy( codec );
       
   746     }
       
   747         
       
   748         
       
   749 // -----------------------------------------------------------------------------
       
   750 //
       
   751 // -----------------------------------------------------------------------------
       
   752 //
       
   753 void UT_CMusEngMceSession::UT_CMusEngMceSession_RectChangedLL()
       
   754     {
       
   755     
       
   756     // Does nothing before session establishment
       
   757     
       
   758     iLiveSession->RectChangedL();
       
   759     
       
   760     ESTABLISH_OUT_SESSION( iLiveSession );
       
   761 
       
   762     // Next leads to a call to RectChangedL()
       
   763     iLiveSession->SetRectL( TRect( 100, 200, 300, 400 ) ); 
       
   764     
       
   765     // Display size has been updated
       
   766     
       
   767     CMceDisplaySink* display = 
       
   768                 MusEngMceUtils::GetDisplayL( *( iLiveSession->iSession ) );
       
   769     
       
   770     EUNIT_ASSERT( display->DisplayRectL() == iLiveSession->Rect() );
       
   771     
       
   772     // Terminate session and try again, rect must not be changed
       
   773     
       
   774     iLiveSession->iSession->iState = CMceSession::ETerminated;
       
   775     
       
   776     TRect newRect( 200, 300, 400, 500 );
       
   777     
       
   778     iLiveSession->SetRectL( newRect ); 
       
   779     
       
   780     EUNIT_ASSERT( display->DisplayRectL() != newRect )
       
   781     
       
   782     
       
   783     }
       
   784 
       
   785 
       
   786 // -----------------------------------------------------------------------------
       
   787 //
       
   788 // -----------------------------------------------------------------------------
       
   789 //
       
   790 void UT_CMusEngMceSession::UT_CMusEngMceSession_SetSessionSdpLinesLL()
       
   791     {
       
   792     // set operator variant off
       
   793     MultimediaSharingSettings::SetOperatorVariantSettingL(
       
   794                      MusSettingsKeys::EStandard );
       
   795                      
       
   796     // There is no sdp lines in session, right one is added
       
   797 
       
   798     CMceInSession* inSession = CMceInSession::NewL( *iReceiveSession->iManager,
       
   799                                                     KTestOriginator );
       
   800     CleanupStack::PushL( inSession );
       
   801     
       
   802     iReceiveSession->SetSessionSdpLinesL( *inSession );
       
   803     
       
   804     MDesC8Array* sdpLines = inSession->SessionSDPLinesL();
       
   805     CleanupDeletePushL( sdpLines );
       
   806     
       
   807     EUNIT_ASSERT( sdpLines );
       
   808     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
       
   809     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
       
   810     
       
   811     CleanupStack::PopAndDestroy(); // sdplines
       
   812 
       
   813     // There is one line ready, replace it with right one
       
   814     CDesC8Array* newSdpLines = new ( ELeave ) CDesC8ArrayFlat( 3 );
       
   815     CleanupStack::PushL( newSdpLines );
       
   816     newSdpLines->AppendL( KTestRecipientRandomText8() );
       
   817     inSession->SetSessionSDPLinesL( newSdpLines );
       
   818     CleanupStack::Pop( newSdpLines );
       
   819     
       
   820     iReceiveSession->SetSessionSdpLinesL( *inSession );
       
   821     
       
   822     sdpLines = inSession->SessionSDPLinesL();
       
   823     CleanupDeletePushL( sdpLines );
       
   824       
       
   825     EUNIT_ASSERT( sdpLines );
       
   826     EUNIT_ASSERT( sdpLines->MdcaCount() == 1 );
       
   827     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() );
       
   828     
       
   829     CleanupStack::PopAndDestroy(); // sdplines
       
   830     
       
   831 
       
   832     CleanupStack::PopAndDestroy( inSession );
       
   833 
       
   834     // for operator variant testing
       
   835     // set operator variant
       
   836     iReceiveSession->iOperatorVariant = ETrue;
       
   837 
       
   838     // There is no sdp lines in session, right ones are added to session and media level
       
   839     inSession = CMceInSession::NewL( *iReceiveSession->iManager,
       
   840                                                     KTestOriginator );
       
   841     CleanupStack::PushL( inSession );
       
   842     
       
   843     iReceiveSession->SetSessionSdpLinesL( *inSession );
       
   844     
       
   845     sdpLines = inSession->SessionSDPLinesL();
       
   846     CleanupDeletePushL( sdpLines );
       
   847     
       
   848     EUNIT_ASSERT( sdpLines );
       
   849     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
       
   850     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineApplication() );
       
   851     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineType() );
       
   852     
       
   853     CleanupStack::PopAndDestroy(); // sdplines
       
   854     
       
   855     MDesC8Array* mediaSdpLines = 
       
   856         iReceiveSession->iSession->Streams()[ 0 ]->MediaAttributeLinesL();
       
   857     CleanupDeletePushL( mediaSdpLines );
       
   858     TBool bandwidthFoundFromMediaLevel = EFalse;
       
   859     for ( TInt i = 0; mediaSdpLines && i < mediaSdpLines->MdcaCount(); i++ )
       
   860         {
       
   861         if ( mediaSdpLines->MdcaPoint( i ).Compare( 
       
   862                 KMusEngSessionSdpLineBandwidthField() ) == 0 )
       
   863             {
       
   864             bandwidthFoundFromMediaLevel = ETrue;
       
   865             }
       
   866         }
       
   867     EUNIT_ASSERT( bandwidthFoundFromMediaLevel );
       
   868     CleanupStack::PopAndDestroy( mediaSdpLines );
       
   869 
       
   870     // There is one line ready, replace it with right ones
       
   871     newSdpLines = new ( ELeave ) CDesC8ArrayFlat( 3 );
       
   872     CleanupStack::PushL( newSdpLines );
       
   873     newSdpLines->AppendL( KTestRecipientRandomText8() );
       
   874     inSession->SetSessionSDPLinesL( newSdpLines );
       
   875     CleanupStack::Pop( newSdpLines );
       
   876     
       
   877     iReceiveSession->SetSessionSdpLinesL( *inSession );
       
   878     
       
   879     sdpLines = inSession->SessionSDPLinesL();
       
   880     CleanupDeletePushL( sdpLines );
       
   881       
       
   882     EUNIT_ASSERT( sdpLines );
       
   883     EUNIT_ASSERT( sdpLines->MdcaCount() == 2 );
       
   884     EUNIT_ASSERT( sdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineApplication() );
       
   885     EUNIT_ASSERT( sdpLines->MdcaPoint( 1 ) == KMusEngSessionSdpLineType() );
       
   886     
       
   887     CleanupStack::PopAndDestroy(); // sdplines
       
   888     
       
   889 
       
   890     CleanupStack::PopAndDestroy( inSession );
       
   891 
       
   892 
       
   893     // set operator variant off
       
   894     MultimediaSharingSettings::SetOperatorVariantSettingL(
       
   895                      MusSettingsKeys::EStandard );
       
   896     }
       
   897 
       
   898 
       
   899 // -----------------------------------------------------------------------------
       
   900 //
       
   901 // -----------------------------------------------------------------------------
       
   902 //
       
   903 void UT_CMusEngMceSession::UT_CMusEngMceSession_AdjustStreamsAndCodecsLL()
       
   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     // Test for Configuration based codec removal. Magic uid not set.    
       
  1010     CMceVideoCodec* codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() );    
       
  1011     videoStream->AddCodecL( codecAvc );
       
  1012     CleanupStack::Pop( codecAvc );         
       
  1013     iClipSession->AdjustStreamsAndCodecsL();   
       
  1014     TBool avcCodecFound(EFalse);
       
  1015     for ( TInt i = 0; i < videoStream->Codecs().Count(); i++ )
       
  1016       {      
       
  1017       if( !videoStream->Codecs()[ i ]->SdpName().CompareF( KMceSDPNameH264 ) )
       
  1018         {
       
  1019         avcCodecFound = ETrue;
       
  1020         }      
       
  1021       }
       
  1022     // AVC should present
       
  1023     EUNIT_ASSERT(avcCodecFound);
       
  1024     
       
  1025     // Test for Configuration based codec removal. Magic uid set.
       
  1026     // Store the real value and revert back later , so that other tests will not be affected.
       
  1027     TUid uid = MultimediaSharingSettings::EncodingDeviceL();    
       
  1028     TInt32 KMusDisableAVC = 0x0fffffff;
       
  1029     MultimediaSharingSettings::SetPropertyValueL( MusSettingsKeys::KEncodingDevice,KMusDisableAVC);
       
  1030     codecAvc = CMceAvcCodec::NewLC( KMceSDPNameH264() );    
       
  1031     videoStream->AddCodecL( codecAvc );
       
  1032     CleanupStack::Pop( codecAvc );  
       
  1033     codecH2632000 = CMceH263Codec::NewLC( KMceSDPNameH2632000() );
       
  1034     videoStream->AddCodecL( codecH2632000 );
       
  1035     CleanupStack::Pop( codecH2632000 );
       
  1036     iClipSession->AdjustStreamsAndCodecsL();    
       
  1037     for ( TInt i = 0; i < videoStream->Codecs().Count(); i++ )
       
  1038        {
       
  1039        // H264 ( AVC ) codec should be removed
       
  1040        EUNIT_ASSERT( 
       
  1041                    videoStream->Codecs()[ i ]->SdpName().CompareF( KMceSDPNameH264 ) );
       
  1042        }
       
  1043     
       
  1044     
       
  1045     MultimediaSharingSettings::SetPropertyValueL( MusSettingsKeys::KEncodingDevice,uid.iUid);
       
  1046     
       
  1047     
       
  1048     }
       
  1049 
       
  1050 
       
  1051 // -----------------------------------------------------------------------------
       
  1052 //
       
  1053 // -----------------------------------------------------------------------------
       
  1054 //  
       
  1055 void UT_CMusEngMceSession::UT_CMusEngMceSession_IncomingSessionL()
       
  1056     {
       
  1057     // New session should get rejected and deleted in any case, first failure
       
  1058     CMceInSession* inSession = CMceInSession::NewL( 
       
  1059                                       *iLiveSession->iManager, KNullDesC8 );
       
  1060     CleanupStack::PushL( inSession );
       
  1061     iLiveSession->IncomingSession( inSession, NULL );
       
  1062     CleanupStack::Pop( inSession );
       
  1063     
       
  1064     // And then succesfull case, this would leak memory if session was not
       
  1065     // deleted
       
  1066     inSession = CMceInSession::NewL( *iLiveSession->iManager, KNullDesC8 );
       
  1067     CleanupStack::PushL( inSession );
       
  1068     iLiveSession->IncomingSession( inSession, NULL );
       
  1069     CleanupStack::Pop( inSession );
       
  1070     }
       
  1071 
       
  1072 
       
  1073 // -----------------------------------------------------------------------------
       
  1074 //
       
  1075 // -----------------------------------------------------------------------------
       
  1076 //  
       
  1077 void UT_CMusEngMceSession::UT_CMusEngMceSession_IncomingUpdateL()
       
  1078     {
       
  1079     CMceInSession* inSession = CMceInSession::NewL( 
       
  1080                                       *iLiveSession->iManager, KNullDesC8 );
       
  1081     
       
  1082     // Try to update before having a session, session gets rejected and deleted
       
  1083     CleanupStack::PushL( inSession );
       
  1084     iLiveSession->IncomingUpdate( *inSession, inSession, NULL );
       
  1085     CleanupStack::Pop( inSession );
       
  1086     
       
  1087     
       
  1088     // Try to update with unknown session, session gets rejected and deleted
       
  1089     ESTABLISH_OUT_SESSION( iLiveSession )
       
  1090     
       
  1091     inSession = CMceInSession::NewL( 
       
  1092                                       *iLiveSession->iManager, KNullDesC8 );
       
  1093     CleanupStack::PushL( inSession );
       
  1094     iLiveSession->IncomingUpdate( *inSession, inSession, NULL );
       
  1095     CleanupStack::Pop( inSession );
       
  1096     
       
  1097     // Normal case, old session gets deleted. New session gets rejected.
       
  1098     
       
  1099     inSession = CMceInSession::NewL( 
       
  1100                                       *iLiveSession->iManager, KNullDesC8 );
       
  1101     CleanupStack::PushL( inSession );
       
  1102     iLiveSession->IncomingUpdate( *iLiveSession->iSession, inSession, NULL );
       
  1103     CleanupStack::Pop( inSession );
       
  1104     
       
  1105     EUNIT_ASSERT( iLiveSession->iSession == inSession )
       
  1106     EUNIT_ASSERT( iLiveSession->iSession->iState == CMceSession::ETerminated )
       
  1107     
       
  1108     }
       
  1109         
       
  1110 
       
  1111 // -----------------------------------------------------------------------------
       
  1112 //
       
  1113 // -----------------------------------------------------------------------------
       
  1114 //  
       
  1115 void UT_CMusEngMceSession::UT_CMusEngMceSession_StreamStateChangedL()
       
  1116     {
       
  1117     // Try without a session, nothing happens
       
  1118     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
       
  1119     iLiveSession->CMusEngMceSession::StreamStateChanged( *audioStream );
       
  1120     CleanupStack::PopAndDestroy( audioStream );
       
  1121     
       
  1122     // Simulate sending invite
       
  1123     iLiveSession->InviteL( KTestRecipientSipUri() );
       
  1124     
       
  1125     // No observer set, so expect nothing to be done, cannot be asserted
       
  1126     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
       
  1127 
       
  1128     // Try all the stream states
       
  1129     
       
  1130     // EUninitialized, stream is created, unexpected change, nothing happens
       
  1131     changedStream->iState = CMceMediaStream::EUninitialized;
       
  1132     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1133     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1134     
       
  1135     // EInitialized, stream is initialized
       
  1136     changedStream->iState = CMceMediaStream::EInitialized;
       
  1137     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1138     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1139     
       
  1140     // EBuffering, stream is buffering
       
  1141     changedStream->iState = CMceMediaStream::EBuffering;
       
  1142     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1143     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1144     
       
  1145     // EIdle, stream is not receiving RTP
       
  1146     changedStream->iState = CMceMediaStream::EIdle;
       
  1147     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1148     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1149     
       
  1150     // EStreaming, stream is streaming
       
  1151     changedStream->iState = CMceMediaStream::EStreaming;
       
  1152     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1153     EUNIT_ASSERT( iObserver->iStreamStreamingCalled );
       
  1154     iObserver->Reset();
       
  1155     
       
  1156     // EStreaming, stream is streaming, other than video out- or instream
       
  1157     changedStream->iState = CMceMediaStream::EStreaming;
       
  1158     iLiveSession->CMusEngMceSession::StreamStateChanged( 
       
  1159                                 *iLiveSession->iSession->Streams()[1] );
       
  1160     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1161     iObserver->Reset();
       
  1162     
       
  1163     // EDisabled, stream is explicitly disabled
       
  1164     changedStream->iState = CMceMediaStream::EDisabled;
       
  1165     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1166     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1167     
       
  1168     // ENoResources, stream has no needed resources to stream
       
  1169     changedStream->iState = CMceMediaStream::ENoResources;
       
  1170     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1171     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1172     
       
  1173     // ETranscodingRequired, stream requires non-realtime transcoding
       
  1174     changedStream->iState = CMceMediaStream::ETranscodingRequired;
       
  1175     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1176     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1177     
       
  1178     // ETranscoding, stream is transcoding in non-realtime
       
  1179     changedStream->iState = CMceMediaStream::ETranscoding;
       
  1180     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1181     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1182     
       
  1183     }
       
  1184     
       
  1185 
       
  1186 // -----------------------------------------------------------------------------
       
  1187 // All the possibilities are tested in order to make sure unit tests are changed
       
  1188 // when function is changed
       
  1189 // -----------------------------------------------------------------------------
       
  1190 //  
       
  1191 void UT_CMusEngMceSession::UT_CMusEngMceSession_StreamStateChangedWithSourceL()
       
  1192     {
       
  1193     // Try without a session, nothing happens
       
  1194     iLiveSession->CMusEngMceSession::StreamStateChanged( 
       
  1195                                         *CMceAudioStream::NewLC(),
       
  1196                                         *CMceRtpSource::NewLC() );
       
  1197                                         
       
  1198     CleanupStack::PopAndDestroy(); // rtp                                    
       
  1199     CleanupStack::PopAndDestroy(); // audiostream
       
  1200     
       
  1201     // Simulate sending invite
       
  1202     iLiveSession->InviteL( KTestRecipientSipUri() );
       
  1203     
       
  1204     // Try all the stream states
       
  1205     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
       
  1206     
       
  1207     // EUninitialized, stream is created, unexpected change, nothing happens
       
  1208     changedStream->iState = CMceMediaStream::EUninitialized;
       
  1209     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1210     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1211     
       
  1212     // EInitialized, stream is initialized
       
  1213     changedStream->iState = CMceMediaStream::EInitialized;
       
  1214     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1215     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1216     
       
  1217     // EBuffering, stream is buffering
       
  1218     changedStream->iState = CMceMediaStream::EBuffering;
       
  1219     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1220     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1221     
       
  1222     // EIdle, stream is not receiving RTP
       
  1223     changedStream->iState = CMceMediaStream::EIdle;
       
  1224     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1225     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1226     
       
  1227     // EStreaming, stream is streaming
       
  1228     changedStream->iState = CMceMediaStream::EStreaming;
       
  1229     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1230     EUNIT_ASSERT( iObserver->iStreamStreamingCalled );
       
  1231     iObserver->Reset();
       
  1232     
       
  1233     // EDisabled, stream is explicitly disabled
       
  1234     changedStream->iState = CMceMediaStream::EDisabled;
       
  1235     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1236     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1237     
       
  1238     // ENoResources, stream has no needed resources to stream
       
  1239     changedStream->iState = CMceMediaStream::ENoResources;
       
  1240     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1241     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1242     
       
  1243     // ETranscodingRequired, stream requires non-realtime transcoding
       
  1244     changedStream->iState = CMceMediaStream::ETranscodingRequired;
       
  1245     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1246     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1247     
       
  1248     // ETranscoding, stream is transcoding in non-realtime
       
  1249     changedStream->iState = CMceMediaStream::ETranscoding;
       
  1250     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1251     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1252     
       
  1253     }
       
  1254 
       
  1255 
       
  1256 // -----------------------------------------------------------------------------
       
  1257 // All the possibilities are tested in order to make sure unit tests are changed
       
  1258 // when function is changed
       
  1259 // -----------------------------------------------------------------------------
       
  1260 //  
       
  1261 void UT_CMusEngMceSession::UT_CMusEngMceSession_StreamStateChangedWithSinkL()
       
  1262     {
       
  1263     // Try without a session, nothing happens
       
  1264     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
       
  1265     iLiveSession->CMusEngMceSession::StreamStateChanged( *audioStream );
       
  1266     CleanupStack::PopAndDestroy( audioStream );
       
  1267     
       
  1268     // Simulate sending invite
       
  1269     iLiveSession->InviteL( KTestRecipientSipUri() );
       
  1270     
       
  1271     // Try all the stream states
       
  1272     CMceMediaStream* changedStream = iLiveSession->iSession->Streams()[0];
       
  1273     
       
  1274     // EUninitialized, stream is created, unexpected change, nothing happens
       
  1275     changedStream->iState = CMceMediaStream::EUninitialized;
       
  1276     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1277     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1278     
       
  1279     // EInitialized, stream is initialized
       
  1280     changedStream->iState = CMceMediaStream::EInitialized;
       
  1281     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1282     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1283     
       
  1284     // EBuffering, stream is buffering
       
  1285     changedStream->iState = CMceMediaStream::EBuffering;
       
  1286     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1287     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1288     
       
  1289     // EIdle, stream is not receiving RTP
       
  1290     changedStream->iState = CMceMediaStream::EIdle;
       
  1291     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1292     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1293     
       
  1294     // EStreaming, stream is streaming
       
  1295     changedStream->iState = CMceMediaStream::EStreaming;
       
  1296     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1297     EUNIT_ASSERT( iObserver->iStreamStreamingCalled );
       
  1298     iObserver->Reset();
       
  1299     
       
  1300     // EDisabled, stream is explicitly disabled
       
  1301     changedStream->iState = CMceMediaStream::EDisabled;
       
  1302     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1303     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1304     
       
  1305     // ENoResources, stream has no needed resources to stream
       
  1306     changedStream->iState = CMceMediaStream::ENoResources;
       
  1307     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1308     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1309     
       
  1310     // ETranscodingRequired, stream requires non-realtime transcoding
       
  1311     changedStream->iState = CMceMediaStream::ETranscodingRequired;
       
  1312     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1313     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1314     
       
  1315     // ETranscoding, stream is transcoding in non-realtime
       
  1316     changedStream->iState = CMceMediaStream::ETranscoding;
       
  1317     iLiveSession->CMusEngMceSession::StreamStateChanged( *changedStream );
       
  1318     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1319     
       
  1320     }        
       
  1321 
       
  1322 
       
  1323 // -----------------------------------------------------------------------------
       
  1324 //
       
  1325 // -----------------------------------------------------------------------------
       
  1326 //    
       
  1327 void UT_CMusEngMceSession::UT_CMusEngMceSession_SessionStateChangedL()
       
  1328     {
       
  1329     // Simulate sending invite
       
  1330     iLiveSession->InviteL( KTestRecipientSipUri() );   
       
  1331 
       
  1332     // No container, so expect to be handled as internal error
       
  1333     iLiveSession->SessionStateChanged( *iLiveSession->iSession, NULL );
       
  1334     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
       
  1335     iObserver->Reset();    
       
  1336     
       
  1337     // Try to tell session about some other session's state transition
       
  1338     
       
  1339     TMceTransactionDataContainer container;
       
  1340  
       
  1341     iLiveSession->SessionStateChanged( *iSomeOtherSession->iSession, &container );
       
  1342     EUNIT_ASSERT( iObserver->IsReseted() );    
       
  1343       
       
  1344     // Try all the normal cases:
       
  1345     
       
  1346     // EIdle
       
  1347     iLiveSession->iSession->iState = CMceSession::EIdle;
       
  1348     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1349     // Set up any text to simulate reasonphrase
       
  1350     HBufC8* anyReasonPhrase = KTestOriginator().AllocL();
       
  1351     container.SetReasonPhrase( anyReasonPhrase );
       
  1352     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1353                                        &container );
       
  1354     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
       
  1355     iObserver->Reset();
       
  1356     container.Clear();
       
  1357     
       
  1358     // EOffering
       
  1359     iLiveSession->iSession->iState = CMceSession::EOffering;
       
  1360     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1361     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1362                                        &container );
       
  1363     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1364     
       
  1365     // EIncoming
       
  1366     iLiveSession->iSession->iState = CMceSession::EIncoming;
       
  1367     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1368     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1369                                        &container );
       
  1370     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
       
  1371     iObserver->Reset();
       
  1372     
       
  1373     // EReserving
       
  1374     iLiveSession->iSession->iState = CMceSession::EReserving;
       
  1375     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1376     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1377                                        &container );
       
  1378     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1379     
       
  1380     // EAnswering
       
  1381     iLiveSession->iSession->iState = CMceSession::EAnswering;
       
  1382     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1383     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1384                                        &container );
       
  1385     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1386     
       
  1387     // EProceeding
       
  1388     iLiveSession->iSession->iState = CMceSession::EProceeding;
       
  1389     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1390     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1391                                        &container );
       
  1392     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1393     
       
  1394     // EEstablished
       
  1395     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
  1396     container.SetStatusCode( KSipStatusCode200OK );
       
  1397     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1398                                        &container );
       
  1399     EUNIT_ASSERT( iObserver->iSessionEstablishedCalled );
       
  1400     iObserver->Reset();
       
  1401     
       
  1402     // EEstablished again (meaning expiration of session timer 
       
  1403     // and refresment of session )
       
  1404     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
  1405     container.SetStatusCode( KSipStatusCode200OK );
       
  1406     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1407                                        &container );
       
  1408     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1409     
       
  1410     // ECancelling
       
  1411     iLiveSession->iSession->iState = CMceSession::ECancelling;
       
  1412     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1413     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1414                                        &container );
       
  1415     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1416     iObserver->Reset();
       
  1417     
       
  1418     // ETerminating
       
  1419     iLiveSession->iSession->iState = CMceSession::ETerminating;
       
  1420     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1421     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1422                                        &container );
       
  1423     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1424     iObserver->Reset();
       
  1425     
       
  1426     // ETerminated
       
  1427     iLiveSession->iSession->iState = CMceSession::ETerminated;
       
  1428     container.SetStatusCode( KSipStatusCode200OK );
       
  1429     iLiveSession->SessionStateChanged( *iLiveSession->iSession, 
       
  1430                                        &container );
       
  1431     EUNIT_ASSERT( iObserver->iSessionTerminatedCalled );
       
  1432     iObserver->Reset();
       
  1433     
       
  1434     // Default case
       
  1435     iLiveSession->iSession->iState = static_cast<CMceSession::TState>( 10 );
       
  1436     container.SetStatusCode( KSipStatusCodeNoCodeSet );
       
  1437     iLiveSession->SessionStateChanged( *iLiveSession->iSession, &container );
       
  1438     EUNIT_ASSERT( iObserver->IsReseted() );
       
  1439 
       
  1440     }
       
  1441     
       
  1442 
       
  1443 // -----------------------------------------------------------------------------
       
  1444 //
       
  1445 // -----------------------------------------------------------------------------
       
  1446 //     
       
  1447 void UT_CMusEngMceSession::UT_CMusEngMceSession_SessionConnectionStateChangedL()
       
  1448     {
       
  1449     
       
  1450     // Try to tell session about another session's connection state change
       
  1451     
       
  1452     iLiveSession->SessionConnectionStateChanged( *iSomeOtherSession->iSession, 
       
  1453                                                  ETrue );
       
  1454     EUNIT_ASSERT( iObserver->IsReseted() ); // No session yet, nothing happened
       
  1455     
       
  1456     // Simulate sending invite
       
  1457     iLiveSession->InviteL( KTestRecipientSipUri() );
       
  1458     
       
  1459     // Now try again to notify session about session connection state change
       
  1460     // of an another session
       
  1461     iLiveSession->SessionConnectionStateChanged( *iSomeOtherSession->iSession, 
       
  1462                                                  ETrue );
       
  1463     EUNIT_ASSERT( iObserver->IsReseted() ); // Wrong session, nothing happened
       
  1464     
       
  1465     // Try tell session connection state is active
       
  1466     iLiveSession->SessionConnectionStateChanged( *iLiveSession->iSession, 
       
  1467                                                  ETrue );
       
  1468     EUNIT_ASSERT( iObserver->IsReseted() ); // Session active, nothing happened
       
  1469     
       
  1470     // Try tell session connection state is inactive
       
  1471     iLiveSession->SessionConnectionStateChanged( *iLiveSession->iSession, 
       
  1472                                                  EFalse );
       
  1473     EUNIT_ASSERT( iObserver->iSessionConnectionLostCalled );
       
  1474     iObserver->Reset();
       
  1475     
       
  1476     }
       
  1477     
       
  1478 
       
  1479 // -----------------------------------------------------------------------------
       
  1480 //
       
  1481 // -----------------------------------------------------------------------------
       
  1482 // 
       
  1483 void UT_CMusEngMceSession::UT_CMusEngMceSession_FailedL()
       
  1484     {
       
  1485     // Try to tell session about failure of another session
       
  1486 
       
  1487     iLiveSession->Failed( *iSomeOtherSession->iSession, 0 );
       
  1488     EUNIT_ASSERT( iObserver->IsReseted() ); // No session yet, nothing happened
       
  1489     
       
  1490     // Simulate sending invite
       
  1491     iLiveSession->InviteL( KTestRecipientSipUri() );
       
  1492     
       
  1493     // Now try again to notify session about failure of an another session
       
  1494     iLiveSession->Failed( *iSomeOtherSession->iSession, 0 );
       
  1495     EUNIT_ASSERT( iObserver->IsReseted() ); // Wrong session, nothing happened
       
  1496     
       
  1497     // Tell session that it has failed
       
  1498     iLiveSession->Failed( *iLiveSession->iSession, 0 );
       
  1499     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
       
  1500     iObserver->Reset();
       
  1501     
       
  1502     }
       
  1503     
       
  1504 
       
  1505 // -----------------------------------------------------------------------------
       
  1506 //
       
  1507 // -----------------------------------------------------------------------------
       
  1508 //     
       
  1509 void UT_CMusEngMceSession::UT_CMusEngMceSession_UpdateFailedL()
       
  1510     {
       
  1511     // Try to tell session about update failure of another session
       
  1512     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, NULL );
       
  1513     EUNIT_ASSERT( iObserver->iSessionFailedCalled ); // No container, internal error
       
  1514     iObserver->Reset();
       
  1515     
       
  1516     // Try again with container
       
  1517     TMceTransactionDataContainer container;
       
  1518     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, &container );
       
  1519     EUNIT_ASSERT( iObserver->IsReseted() ); // No session yet, nothing happened
       
  1520     
       
  1521     // Invite and try again.
       
  1522     iLiveSession->InviteL( KTestRecipientSipUri() );
       
  1523     iLiveSession->UpdateFailed( *iSomeOtherSession->iSession, &container );
       
  1524     EUNIT_ASSERT( iObserver->IsReseted() ); // Wrong session, nothing happened¨
       
  1525     
       
  1526     // Try with right session
       
  1527     iLiveSession->UpdateFailed( *iLiveSession->iSession, &container );
       
  1528     EUNIT_ASSERT( iObserver->iSessionFailedCalled );
       
  1529     iObserver->Reset();
       
  1530     }
       
  1531     
       
  1532 
       
  1533 // -----------------------------------------------------------------------------
       
  1534 //
       
  1535 // -----------------------------------------------------------------------------
       
  1536 // 
       
  1537 void UT_CMusEngMceSession::UT_CMusEngMceSession_SRReceivedL()
       
  1538     {
       
  1539     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1540     
       
  1541     // No session yet, nothing happens
       
  1542     iLiveSession->SRReceived( *iSomeOtherSession->iSession,
       
  1543                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1544     
       
  1545     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1546     
       
  1547     ESTABLISH_OUT_SESSION( iLiveSession );
       
  1548     
       
  1549     // Simulate bigger value
       
  1550     iLiveSession->iSecondsFromLastRtcpReport = 10;
       
  1551     
       
  1552     // We have session, but informing concearn wrong session, timer is 
       
  1553     // not nullified
       
  1554     iLiveSession->SRReceived( *iSomeOtherSession->iSession,
       
  1555                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1556     
       
  1557     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 10 );
       
  1558     
       
  1559     // Right session but wrong stream, timer should not be nullified
       
  1560     iLiveSession->SRReceived( *iLiveSession->iSession,
       
  1561                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1562     
       
  1563     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 10 );
       
  1564     
       
  1565     // Right stream and established session, timer should be nullified
       
  1566     
       
  1567     
       
  1568     iLiveSession->SRReceived( *iLiveSession->iSession,
       
  1569                               *(iLiveSession->iSession->Streams()[0]) );
       
  1570 
       
  1571     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1572     
       
  1573     }
       
  1574     
       
  1575 
       
  1576 // -----------------------------------------------------------------------------
       
  1577 //
       
  1578 // -----------------------------------------------------------------------------
       
  1579 //     
       
  1580 void UT_CMusEngMceSession::UT_CMusEngMceSession_RRReceivedL()
       
  1581     {
       
  1582     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1583     
       
  1584     // No session yet, nothing happens
       
  1585     iLiveSession->RRReceived( *iSomeOtherSession->iSession,
       
  1586                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1587     
       
  1588     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );
       
  1589     
       
  1590     ESTABLISH_OUT_SESSION( iLiveSession );
       
  1591     
       
  1592     // Simulate bigger value
       
  1593     iLiveSession->iSecondsFromLastRtcpReport = 10;
       
  1594     
       
  1595     // We have session, but informing concearn wrong session, timer is 
       
  1596     // not nullified
       
  1597     iLiveSession->RRReceived( *iSomeOtherSession->iSession,
       
  1598                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1599     
       
  1600     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 10 );
       
  1601     
       
  1602     // Right session but wrong stream, timer should not be nullified
       
  1603     iLiveSession->RRReceived( *iLiveSession->iSession,
       
  1604                               *(iSomeOtherSession->iSession->Streams()[0]) );
       
  1605     
       
  1606     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 10 );
       
  1607     
       
  1608     // Right stream and established session, timer should be nullified
       
  1609     
       
  1610     
       
  1611     iLiveSession->RRReceived( *iLiveSession->iSession,
       
  1612                               *(iLiveSession->iSession->Streams()[0]) );
       
  1613 
       
  1614     EUNIT_ASSERT( iLiveSession->iSecondsFromLastRtcpReport == 0 );    
       
  1615     }
       
  1616     
       
  1617 
       
  1618 // -----------------------------------------------------------------------------
       
  1619 //
       
  1620 // -----------------------------------------------------------------------------
       
  1621 //      
       
  1622 void UT_CMusEngMceSession::UT_CMusEngMceSession_InactivityTimeoutL()
       
  1623     {    
       
  1624     //   Construct an audio stream for this test
       
  1625     
       
  1626     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
       
  1627     
       
  1628     CMceRtpSource* rtpSource = CMceRtpSource::NewLC();
       
  1629     audioStream->SetSourceL( rtpSource );
       
  1630     CleanupStack::Pop( rtpSource );
       
  1631     
       
  1632     iReceiveSession->InactivityTimeout( *audioStream, *rtpSource );
       
  1633     
       
  1634     EUNIT_ASSERT( iObserver->IsReseted() )
       
  1635     
       
  1636     CleanupStack::PopAndDestroy( audioStream );
       
  1637     
       
  1638     // And now real inactivity timeout
       
  1639     
       
  1640     iReceiveSession->InactivityTimeout( 
       
  1641                 *iReceiveSession->iSession->Streams()[0],
       
  1642                 *static_cast<CMceRtpSource*>
       
  1643                         (iReceiveSession->iSession->Streams()[0]->Source()) );
       
  1644     
       
  1645     EUNIT_ASSERT( iObserver->iStreamIdleCalled )
       
  1646     
       
  1647     iObserver->Reset();
       
  1648     }
       
  1649     
       
  1650     
       
  1651 // -----------------------------------------------------------------------------
       
  1652 //
       
  1653 // -----------------------------------------------------------------------------
       
  1654 //       
       
  1655 void UT_CMusEngMceSession::UT_CMusEngMceSession_SsrcAddedL()
       
  1656     {
       
  1657     // As CMusEngMceSession::SsrcAdded is expected to do nothing, just call
       
  1658     // it to make sure it does not weaken the test coverage
       
  1659     
       
  1660     CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>( 
       
  1661                             iReceiveSession->iSession->Streams()[0]->Source() );   
       
  1662     iReceiveSession->SsrcAdded( 
       
  1663                         *iReceiveSession->iSession->Streams()[0],
       
  1664                         *rtpSource,
       
  1665                         0 );
       
  1666     
       
  1667     }
       
  1668 
       
  1669 
       
  1670 // -----------------------------------------------------------------------------
       
  1671 //
       
  1672 // -----------------------------------------------------------------------------
       
  1673 //  
       
  1674 void UT_CMusEngMceSession::UT_CMusEngMceSession_SsrcRemovedL()
       
  1675     {
       
  1676     // As CMusEngMceSession::SsrcRemoved is expected to do nothing, just call
       
  1677     // it to make sure it does not weaken the test coverage
       
  1678     
       
  1679     CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>( 
       
  1680                             iReceiveSession->iSession->Streams()[0]->Source() );   
       
  1681 
       
  1682     iReceiveSession->SsrcRemoved( 
       
  1683                         *iReceiveSession->iSession->Streams()[0],
       
  1684                         *rtpSource,
       
  1685                         0 );
       
  1686     }
       
  1687 
       
  1688 
       
  1689 // -----------------------------------------------------------------------------
       
  1690 //
       
  1691 // -----------------------------------------------------------------------------
       
  1692 //  
       
  1693 void UT_CMusEngMceSession::UT_CMusEngMceSession_UpdateTimerEventL()
       
  1694     {
       
  1695     iLiveSession->UpdateTimerEvent();
       
  1696     EUNIT_ASSERT( iObserver->iSessionTimeChangedCalled )
       
  1697     EUNIT_ASSERT( iLiveSession->iUpdateTimer->IsActive() )
       
  1698     iLiveSession->iUpdateTimer->Cancel();
       
  1699     iObserver->Reset();
       
  1700     
       
  1701     iLiveSession->iSecondsFromLastRtcpReport = 25; // >KMusEngRtcpInactivityThreshold
       
  1702     iLiveSession->UpdateTimerEvent();
       
  1703     EUNIT_ASSERT( iObserver->iSessionTimeChangedCalled )
       
  1704     EUNIT_ASSERT( iObserver->iInactivityTimeoutCalled );
       
  1705     EUNIT_ASSERT( iLiveSession->iUpdateTimer->IsActive() )
       
  1706     iLiveSession->iUpdateTimer->Cancel();
       
  1707     iObserver->Reset();
       
  1708     }   
       
  1709 
       
  1710 
       
  1711 // -----------------------------------------------------------------------------
       
  1712 //
       
  1713 // -----------------------------------------------------------------------------
       
  1714 //
       
  1715 void UT_CMusEngMceSession::UT_CMusEngMceSession_IsRoamingBetweenAPsAllowedL()
       
  1716     {
       
  1717     // No session
       
  1718     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
       
  1719 
       
  1720     // Session idle
       
  1721     _LIT( KRecipientSipUri, "sip:user@some.where" );
       
  1722     iLiveSession->InviteL( KRecipientSipUri );
       
  1723     iLiveSession->iSession->iState = CMceSession::EIdle;
       
  1724     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
       
  1725     
       
  1726     // Session established
       
  1727     iLiveSession->iSession->iState = CMceSession::EEstablished;
       
  1728     EUNIT_ASSERT( !iLiveSession->IsRoamingBetweenAPsAllowed() )
       
  1729     
       
  1730     // Session terminated
       
  1731     iLiveSession->iSession->iState = CMceSession::ETerminated;
       
  1732     EUNIT_ASSERT( iLiveSession->IsRoamingBetweenAPsAllowed() )
       
  1733     }
       
  1734 
       
  1735 // HELPERS
       
  1736 
       
  1737 // -----------------------------------------------------------------------------
       
  1738 //
       
  1739 // -----------------------------------------------------------------------------
       
  1740 //
       
  1741 void UT_CMusEngMceSession::SetMaxVolForSpeakersL(CMceSession& aSession, TInt aMaxVol)
       
  1742     {
       
  1743     for ( TInt i = 0; i < aSession.Streams().Count(); ++i )
       
  1744             {
       
  1745             for ( TInt j = 0; j < aSession.Streams()[i]->Sinks().Count(); ++j )
       
  1746                 {
       
  1747                 if ( aSession.Streams()[i]->Sinks()[j]->Type() == KMceSpeakerSink )
       
  1748                     {
       
  1749                     CMceSpeakerSink* speaker = static_cast<CMceSpeakerSink*>(
       
  1750                                                 aSession.Streams()[i]->Sinks()[j] );
       
  1751                     speaker->iMaxVolume = aMaxVol;
       
  1752                     }
       
  1753                 }
       
  1754             } 
       
  1755     }
       
  1756  
       
  1757 //  TEST TABLE
       
  1758 
       
  1759 EUNIT_BEGIN_TEST_TABLE(
       
  1760     UT_CMusEngMceSession,
       
  1761     "UT_CMusEngMceSesssion",
       
  1762     "UNIT" )
       
  1763 
       
  1764 EUNIT_TEST(
       
  1765     "TerminateL - test ",
       
  1766     "CMusEngMceSession",
       
  1767     "TerminateL",
       
  1768     "FUNCTIONALITY",
       
  1769     SetupL, UT_CMusEngMceSession_TerminateLL, Teardown)
       
  1770 
       
  1771 EUNIT_TEST(
       
  1772     "GetSessionTime - test ",
       
  1773     "CMusEngMceSession",
       
  1774     "GetSessionTime",
       
  1775     "FUNCTIONALITY",
       
  1776     SetupL, UT_CMusEngMceSession_GetSessionTimeL, Teardown)
       
  1777 
       
  1778 EUNIT_TEST(
       
  1779     "ConnectionActive - test ",
       
  1780     "CMusEngMceSession",
       
  1781     "ConnectionActive",
       
  1782     "FUNCTIONALITY",
       
  1783     SetupL, UT_CMusEngMceSession_ConnectionActiveL, Teardown) 
       
  1784 
       
  1785 EUNIT_TEST(
       
  1786     "ContainsAudioL - test ",
       
  1787     "CMusEngMceSession",
       
  1788     "ContainsAudioL",
       
  1789     "FUNCTIONALITY",
       
  1790     SetupL, UT_CMusEngMceSession_ContainsAudioLL, Teardown) 
       
  1791 
       
  1792 EUNIT_TEST(
       
  1793     "IsMutedL - test ",
       
  1794     "CMusEngMceSession",
       
  1795     "IsMutedL",
       
  1796     "FUNCTIONALITY",
       
  1797     SetupL, UT_CMusEngMceSession_IsMutedLL, Teardown) 
       
  1798 
       
  1799 EUNIT_TEST(
       
  1800     "OrientationL - test ",
       
  1801     "CMusEngMceSession",
       
  1802     "OrientationL",
       
  1803     "FUNCTIONALITY",
       
  1804     SetupL, UT_CMusEngMceSession_OrientationLL, Teardown) 
       
  1805 
       
  1806 EUNIT_TEST(
       
  1807     "SetOrientationL - test ",
       
  1808     "CMusEngMceSession",
       
  1809     "SetOrientationL",
       
  1810     "FUNCTIONALITY",
       
  1811     SetupL, UT_CMusEngMceSession_SetOrientationLL, Teardown) 
       
  1812     
       
  1813 EUNIT_TEST(
       
  1814     "VolumeUpL - test ",
       
  1815     "CMusEngMceSession",
       
  1816     "VolumeUpL",
       
  1817     "FUNCTIONALITY",
       
  1818     SetupL, UT_CMusEngMceSession_VolumeUpLL, Teardown) 
       
  1819 
       
  1820 EUNIT_TEST(
       
  1821     "VolumeDownL - test ",
       
  1822     "CMusEngMceSession",
       
  1823     "VolumeDownL",
       
  1824     "FUNCTIONALITY",
       
  1825     SetupL, UT_CMusEngMceSession_VolumeDownLL, Teardown) 
       
  1826 
       
  1827 EUNIT_TEST(
       
  1828     "SetVolumeL - test ",
       
  1829     "CMusEngMceSession",
       
  1830     "SetVolumeL",
       
  1831     "FUNCTIONALITY",
       
  1832     SetupL, UT_CMusEngMceSession_SetVolumeLL, Teardown)
       
  1833     
       
  1834 EUNIT_TEST(
       
  1835     "EnableDisplay - test ",
       
  1836     "CMusEngMceSession",
       
  1837     "EnableDisplay",
       
  1838     "FUNCTIONALITY",
       
  1839     SetupL, UT_CMusEngMceSession_EnableDisplayL, Teardown)   
       
  1840 
       
  1841 EUNIT_TEST(
       
  1842     "MuteL - test ",
       
  1843     "CMusEngMceSession",
       
  1844     "MuteL",
       
  1845     "FUNCTIONALITY",
       
  1846     SetupL, UT_CMusEngMceSession_MuteLL, Teardown)   
       
  1847 
       
  1848 EUNIT_TEST(
       
  1849     "UnmuteL - test ",
       
  1850     "CMusEngMceSession",
       
  1851     "UnmuteL",
       
  1852     "FUNCTIONALITY",
       
  1853     SetupL, UT_CMusEngMceSession_UnmuteLL, Teardown)   
       
  1854 
       
  1855 EUNIT_TEST(
       
  1856     "HandleTermination - test ",
       
  1857     "CMusEngMceSession",
       
  1858     "HandleTermination",
       
  1859     "FUNCTIONALITY",
       
  1860     SetupL, UT_CMusEngMceSession_HandleTerminationL, Teardown)   
       
  1861 
       
  1862 EUNIT_TEST(
       
  1863     "AdjustVideoCodecL - test ",
       
  1864     "CMusEngMceSession",
       
  1865     "AdjustVideoCodecL",
       
  1866     "FUNCTIONALITY",
       
  1867     SetupL, UT_CMusEngMceSession_AdjustVideoCodecLL, Teardown) 
       
  1868 
       
  1869 EUNIT_TEST(
       
  1870     "AdjustAudioCodecL - test ",
       
  1871     "CMusEngMceSession",
       
  1872     "AdjustAudioCodecL",
       
  1873     "FUNCTIONALITY",
       
  1874     SetupL, UT_CMusEngMceSession_AdjustAudioCodecLL, Teardown) 
       
  1875     
       
  1876 EUNIT_TEST(
       
  1877     "RectChangedL - test ",
       
  1878     "CMusEngMceSession",
       
  1879     "RectChangedL",
       
  1880     "FUNCTIONALITY",
       
  1881     SetupL, UT_CMusEngMceSession_RectChangedLL, Teardown) 
       
  1882 
       
  1883 EUNIT_TEST(
       
  1884     "SetSessionSdpLinesL - test ",
       
  1885     "CMusEngMceSession",
       
  1886     "SetSessionSdpLinesL",
       
  1887     "FUNCTIONALITY",
       
  1888     SetupL, UT_CMusEngMceSession_SetSessionSdpLinesLL, Teardown) 
       
  1889 
       
  1890 EUNIT_TEST(
       
  1891     "AdjustStreamsAndCodecsL - test ",
       
  1892     "CMusEngMceSession",
       
  1893     "AdjustStreamsAndCodecsL",
       
  1894     "FUNCTIONALITY",
       
  1895     SetupL, UT_CMusEngMceSession_AdjustStreamsAndCodecsLL, Teardown)
       
  1896 
       
  1897 EUNIT_TEST(
       
  1898     "IncomingSession - test ",
       
  1899     "CMusEngMceSession",
       
  1900     "IncomingSession",
       
  1901     "FUNCTIONALITY",
       
  1902     SetupL, UT_CMusEngMceSession_IncomingSessionL, Teardown)          
       
  1903 
       
  1904 EUNIT_TEST(
       
  1905     "IncomingUpdate - test ",
       
  1906     "CMusEngMceSession",
       
  1907     "IncomingUpdate",
       
  1908     "FUNCTIONALITY",
       
  1909     SetupL, UT_CMusEngMceSession_IncomingUpdateL, Teardown)      
       
  1910 
       
  1911 EUNIT_TEST(
       
  1912     "StreamStateChangedL( source ) - test ",
       
  1913     "CMusEngMceSession",
       
  1914     "StreamStateChangedL( source )",
       
  1915     "FUNCTIONALITY",
       
  1916     SetupL, UT_CMusEngMceSession_StreamStateChangedWithSourceL, Teardown)          
       
  1917 
       
  1918 EUNIT_TEST(
       
  1919     "SessionStateChanged - test ",
       
  1920     "CMusEngMceSession",
       
  1921     "SessionStateChanged",
       
  1922     "FUNCTIONALITY",
       
  1923     SetupL, UT_CMusEngMceSession_SessionStateChangedL, Teardown) 
       
  1924     
       
  1925 EUNIT_TEST(
       
  1926     "SessionConnectionStateChanged - test ",
       
  1927     "CMusEngMceSession",
       
  1928     "SessionConnectionStateChanged",
       
  1929     "FUNCTIONALITY",
       
  1930     SetupL, UT_CMusEngMceSession_SessionConnectionStateChangedL, Teardown) 
       
  1931 
       
  1932 EUNIT_TEST(
       
  1933     "Failed - test ",
       
  1934     "CMusEngMceSession",
       
  1935     "Failed",
       
  1936     "FUNCTIONALITY",
       
  1937     SetupL, UT_CMusEngMceSession_FailedL, Teardown)     
       
  1938 
       
  1939 EUNIT_TEST(
       
  1940     "UpdateFailed - test ",
       
  1941     "CMusEngMceSession",
       
  1942     "UpdateFailed",
       
  1943     "FUNCTIONALITY",
       
  1944     SetupL, UT_CMusEngMceSession_UpdateFailedL, Teardown) 
       
  1945 
       
  1946 EUNIT_TEST(
       
  1947     "StreamStateChanged - test ",
       
  1948     "CMusEngMceSession",
       
  1949     "StreamStateChanged",
       
  1950     "FUNCTIONALITY",
       
  1951     SetupL, UT_CMusEngMceSession_StreamStateChangedL, Teardown)             
       
  1952 
       
  1953 EUNIT_TEST(
       
  1954     "StreamStateChangedL (sink ) - test ",
       
  1955     "CMusEngMceSession",
       
  1956     "StreamStateChangedL( sink )",
       
  1957     "FUNCTIONALITY",
       
  1958     SetupL, UT_CMusEngMceSession_StreamStateChangedWithSinkL, Teardown) 
       
  1959 
       
  1960 EUNIT_TEST(
       
  1961     "SRReceived - test ",
       
  1962     "CMusEngMceSession",
       
  1963     "SRReceived",
       
  1964     "FUNCTIONALITY",
       
  1965     SetupL, UT_CMusEngMceSession_SRReceivedL, Teardown)     
       
  1966 
       
  1967 EUNIT_TEST(
       
  1968     "RRReceived - test ",
       
  1969     "CMusEngMceSession",
       
  1970     "RRReceived",
       
  1971     "FUNCTIONALITY",
       
  1972     SetupL, UT_CMusEngMceSession_RRReceivedL, Teardown) 
       
  1973 
       
  1974 EUNIT_TEST(
       
  1975     "InactivityTimeout - test ",
       
  1976     "CMusEngMceSession",
       
  1977     "InactivityTimeout",
       
  1978     "FUNCTIONALITY",
       
  1979     SetupL, UT_CMusEngMceSession_InactivityTimeoutL, Teardown)     
       
  1980 
       
  1981 EUNIT_TEST(
       
  1982     "SsrcAdded - test ",
       
  1983     "CMusEngMceSession",
       
  1984     "SsrcAdded",
       
  1985     "FUNCTIONALITY",
       
  1986     SetupL, UT_CMusEngMceSession_SsrcAddedL, Teardown) 
       
  1987 
       
  1988 EUNIT_TEST(
       
  1989     "SsrcRemoved - test ",
       
  1990     "CMusEngMceSession",
       
  1991     "SsrcRemoved",
       
  1992     "FUNCTIONALITY",
       
  1993     SetupL, UT_CMusEngMceSession_SsrcRemovedL, Teardown)         
       
  1994 
       
  1995 EUNIT_TEST(
       
  1996     "UpdateTimerEvent - test ",
       
  1997     "CMusEngMceSession",
       
  1998     "UpdateTimerEvent",
       
  1999     "FUNCTIONALITY",
       
  2000     SetupL, UT_CMusEngMceSession_UpdateTimerEventL, Teardown)              
       
  2001 
       
  2002 EUNIT_TEST(
       
  2003     "IsRoamingBetweenAPsAllowed - test ",
       
  2004     "CMusEngMceSession",
       
  2005     "IsRoamingBetweenAPsAllowed",
       
  2006     "FUNCTIONALITY",
       
  2007     SetupL, UT_CMusEngMceSession_IsRoamingBetweenAPsAllowedL, Teardown)
       
  2008         
       
  2009 EUNIT_END_TEST_TABLE
       
  2010 
       
  2011 //  END OF FILE