multimediacommsengine/mmcesrv/mmceserver/tsrc/ut_server/src/UT_CMCEStateConfirming.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004 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 
       
    20 
       
    21 //  CLASS HEADER
       
    22 #include "ut_cmcestateconfirming.h"
       
    23 
       
    24 //  EXTERNAL INCLUDES
       
    25 #include <digia/eunit/eunitmacros.h>
       
    26 
       
    27 
       
    28 //  INTERNAL INCLUDES
       
    29 #include "MCETestHelper.h"
       
    30 
       
    31 #include "mcesipsession.h"
       
    32 #include "mcesipstatemachine.h"
       
    33 #include "mceservercore.h"
       
    34 #include "mcecssession.h"
       
    35 #include "mcecssessionimplementation.h"
       
    36 #include "mcesipconnection.h"
       
    37 #include "mcecomsession.h"
       
    38 #include "mcestateconfirming.h"
       
    39 #include "mceevent.h"
       
    40 #include "mceserial.h"
       
    41 #include "mcemediamanager.h"
       
    42 
       
    43 
       
    44 
       
    45 // CONSTRUCTION
       
    46 UT_CMceStateConfirming* UT_CMceStateConfirming::NewL()
       
    47     {
       
    48     UT_CMceStateConfirming* self = UT_CMceStateConfirming::NewLC(); 
       
    49     CleanupStack::Pop();
       
    50 
       
    51     return self;
       
    52     }
       
    53 
       
    54 UT_CMceStateConfirming* UT_CMceStateConfirming::NewLC()
       
    55     {
       
    56     UT_CMceStateConfirming* self = new( ELeave ) UT_CMceStateConfirming();
       
    57     CleanupStack::PushL( self );
       
    58 
       
    59 	self->ConstructL(); 
       
    60 
       
    61     return self;
       
    62     }
       
    63 
       
    64 // Destructor (virtual by CBase)
       
    65 UT_CMceStateConfirming::~UT_CMceStateConfirming()
       
    66     {
       
    67     }
       
    68  
       
    69  
       
    70 // Default constructor
       
    71 UT_CMceStateConfirming::UT_CMceStateConfirming()
       
    72     {
       
    73     }
       
    74 
       
    75 // Second phase construct
       
    76 void UT_CMceStateConfirming::ConstructL()
       
    77     {
       
    78     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    79     // It generates the test case table.
       
    80     CEUnitTestSuiteClass::ConstructL();
       
    81     }
       
    82 
       
    83 //  METHODS
       
    84 
       
    85 
       
    86 
       
    87 void UT_CMceStateConfirming::SetupL(  )
       
    88     {
       
    89     CMCETls::OpenL();
       
    90     SdpCodecStringPool::OpenL();
       
    91     
       
    92     iIds.iProfileID = 1;
       
    93     iIds.iManagerType = KMceCSSIPSession;
       
    94     iIds.iDialogType = KMceDlgTypeInvite;
       
    95     iServerCore = CMceServerCore::NewL();
       
    96     
       
    97     iStorage = CMCETls::Storage();
       
    98     
       
    99 	CDesC8ArrayFlat* params = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity );
       
   100 	CleanupStack::PushL( params );
       
   101 	params->AppendL( _L8("User <user2@host>") );
       
   102 	params->AppendL( _L8("User <user@host>") );
       
   103     
       
   104     CMceMsgTextArray* msgParams = new (ELeave) CMceMsgTextArray( *params );
       
   105     CleanupStack::PushL( msgParams );
       
   106     iStorage->StoreL( iIds, *msgParams );
       
   107     CleanupStack::PopAndDestroy( msgParams );
       
   108     CleanupStack::PopAndDestroy( params );
       
   109     
       
   110     iSession = CMceCsSession::NewL(*iServerCore);
       
   111     iSession->CreateSubSessionL(iIds, RMessage2());
       
   112     iSipSession =  static_cast<CMceSipSession*>((iSession->Implementation().SubSessions())[0]);
       
   113     
       
   114     CMceComSession* clientSession = CMceComSession::NewL( CMceComSession::EOutSession );
       
   115     CleanupStack::PushL( clientSession );
       
   116     iSipSession->SetBodyL( clientSession );
       
   117     CleanupStack::Pop( clientSession );
       
   118     
       
   119     CSIPClientTransaction* invite = 
       
   120         MCETestHelper::ClientTransactionLC( SipStrConsts::EInvite );
       
   121 	iSipSession->SetPendingTransactionL( invite );
       
   122 	CleanupStack::Pop( invite );
       
   123     
       
   124     MCE_SET_STATES( iSipSession /*session*/, 
       
   125                     CMceSession::EOffering /*clientState*/, 
       
   126                     KMceStateConfirming /*serverState*/ );
       
   127     iState = static_cast<CMceStateConfirming*>(&iSipSession->CurrentState());
       
   128     }
       
   129 
       
   130 void UT_CMceStateConfirming::Teardown()
       
   131     {
       
   132     CMCETls::Close();
       
   133 	delete iSession;
       
   134     delete iServerCore;
       
   135 
       
   136     SdpCodecStringPool::Close();
       
   137     
       
   138     }
       
   139 
       
   140 
       
   141 void UT_CMceStateConfirming::UT_CMceStateConfirming_AcceptLL()
       
   142     {
       
   143     TMceIds ids;
       
   144     CMceMsgBase* msg = NULL;
       
   145 
       
   146     CSIPClientTransaction* clitransaction = 
       
   147         MCETestHelper::ClientTransactionLC( SipStrConsts::EUpdate, KMceSipOK, SipStrConsts::EPhraseRinging, EFalse );
       
   148 	iSipSession->SetPendingTransactionL( clitransaction );
       
   149     CleanupStack::Pop( clitransaction );
       
   150     
       
   151     iSipSession->iResponse = clitransaction;
       
   152     
       
   153     TMceStateTransitionEvent event1( *iSipSession, EMceResponse );
       
   154     EUNIT_ASSERT ( iState->AcceptL( event1 ) );
       
   155 
       
   156     TMceStateTransitionEvent event2( *iSipSession, EMceProvisionalResponse );
       
   157     EUNIT_ASSERT ( iState->AcceptL( event2 ) );
       
   158     
       
   159     TMceStateTransitionEvent event3( *iSipSession, EMceErrorResponse );
       
   160     EUNIT_ASSERT ( iState->AcceptL( event3 ) );
       
   161 
       
   162     TMceStateTransitionEvent event4( *iSipSession, EMceRedirectionResponse );
       
   163     EUNIT_ASSERT ( iState->AcceptL( event4 ) );
       
   164     
       
   165     TMceStateTransitionEvent event5( *iSipSession, EMceItcCancel, ids, *msg );
       
   166     EUNIT_ASSERT ( iState->AcceptL( event5 ) );
       
   167     
       
   168     TMceStateTransitionEvent event6( *iSipSession, EMceMediaUpdated );
       
   169     EUNIT_ASSERT ( iState->AcceptL( event6 ) );
       
   170     
       
   171     TMceStateTransitionEvent event7( *iSipSession, EMceInvite );
       
   172     MCE_EUNIT_ASSERT_SPECIFIC_LEAVE( iState->AcceptL( event7 ), KErrTotalLossOfPrecision );
       
   173     }
       
   174 
       
   175 void UT_CMceStateConfirming::UT_CMceStateConfirming_EntryLL()
       
   176     {
       
   177     TMceIds ids;
       
   178     CMceMsgBase* msg = NULL;
       
   179 
       
   180     MCE_RESET_STUBS();
       
   181     // EMceResponse
       
   182     // 2xx to INVITE, no SDP
       
   183     TInt inviteInd = iSipSession->iPendingTransactions.Find( iSipSession->InviteTransaction() );
       
   184     MCETestHelper::ResponseL( iSipSession, 
       
   185                               KMceSipOK, 
       
   186                               SipStrConsts::EPhraseOk, 
       
   187                               inviteInd,
       
   188                               EFalse );
       
   189     MCE_RESET_STUBS();
       
   190     MCE_SET_STATES( iSipSession /*session*/, 
       
   191                     CMceSession::EOffering /*clientState*/, 
       
   192                     KMceStateClientReserving /*serverState*/ );
       
   193     
       
   194     TMceStateTransitionEvent event1( *iSipSession, EMceResponse );
       
   195     iState->EntryL( event1 );
       
   196     
       
   197     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   198                       CMCETls::ENone /*mmsdpaction*/, 
       
   199                       SipStrConsts::EAck /*sentMethod*/, 
       
   200                       KErrNotFound /*sentResponse*/);
       
   201     
       
   202     MCE_RESET_STUBS();
       
   203     
       
   204     // 2xx to INVITE, SDP, no PRACK nor UPDATE pending -> leave
       
   205     iSipSession->iReceivedSdpCount = 0;
       
   206     iSipSession->iSentSdpCount = 1;    
       
   207     CSIPClientTransaction* invite = 
       
   208         MCETestHelper::ClientTransactionLC( SipStrConsts::EInvite, KMceSipOK, 
       
   209         SipStrConsts::EPhraseOk, ETrue );
       
   210     iSipSession->SetResponse( *invite );
       
   211     CleanupStack::Pop( invite );
       
   212     MCE_SET_STATES( iSipSession /*session*/, 
       
   213                     CMceSession::EOffering /*clientState*/, 
       
   214                     KMceStateClientReserving /*serverState*/ );
       
   215     
       
   216     TMceStateTransitionEvent event1_2( *iSipSession, EMceResponse );
       
   217     TRAPD( err, iState->EntryL( event1_2 ) );
       
   218     EUNIT_ASSERT( err );
       
   219     if ( err != KErrNoMemory )
       
   220         {
       
   221         MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   222                       CMCETls::ENone /*mmsdpaction*/, 
       
   223                       SipStrConsts::EAck /*sentMethod*/, 
       
   224                       KErrNotFound /*sentResponse*/);    
       
   225         }
       
   226     else
       
   227     	{
       
   228     	User::Leave( KErrNoMemory );
       
   229     	}
       
   230     MCE_RESET_STUBS();
       
   231     
       
   232     // empty prack pending, 2xx to INVITE received, no need to negotiate
       
   233     iStorage->iMediaManagerNeedToNegotiate = EFalse;
       
   234     iSipSession->iReceivedSdpCount = 0;
       
   235     iSipSession->iSentSdpCount = 1;    
       
   236     TInt pendingCount = iSipSession->PendingTransactions().Count();
       
   237     CSIPClientTransaction* prack = 
       
   238         CSIPClientTransaction::NewL( SIPStrings::StringF( SipStrConsts::EPrack ) );
       
   239     CleanupStack::PushL( prack );
       
   240     iSipSession->SetPendingTransactionL( prack );
       
   241     CleanupStack::Pop( prack );
       
   242     EUNIT_ASSERT( iSipSession->PendingTransactions().Count() == pendingCount + 1 );
       
   243     MCE_SET_STATES( iSipSession /*session*/, 
       
   244                     CMceSession::EOffering /*clientState*/, 
       
   245                     KMceStateClientReserving /*serverState*/ );
       
   246     
       
   247     TMceStateTransitionEvent event1_3( *iSipSession, EMceResponse );
       
   248     iState->EntryL( event1_3 );
       
   249     EUNIT_ASSERT( iSipSession->PendingTransactions().Count() == pendingCount );
       
   250     MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
       
   251                       CMCETls::EDecode /*mmsdpaction*/, 
       
   252                       SipStrConsts::EAck /*sentMethod*/, 
       
   253                       KErrNotFound /*sentResponse*/);
       
   254     MCE_ASSERT_EVENT( event1_3 /*event*/, 
       
   255                       EMceMediaUpdated /*code*/, 
       
   256                       KErrNone /*status*/ );                      
       
   257     
       
   258     MCE_RESET_STUBS();
       
   259 
       
   260     // update pending, 2xx to INVITE received, need to negotiate
       
   261     iStorage->iMediaManagerNeedToNegotiate = ETrue;
       
   262     iSipSession->iReceivedSdpCount = 0;
       
   263     iSipSession->iSentSdpCount = 1;    
       
   264     pendingCount = iSipSession->PendingTransactions().Count();
       
   265     CSIPClientTransaction* update = 
       
   266         CSIPClientTransaction::NewL( SIPStrings::StringF( SipStrConsts::EUpdate ) );
       
   267     CleanupStack::PushL( update );
       
   268     iSipSession->SetPendingTransactionL( update );
       
   269     CleanupStack::Pop( update );
       
   270     EUNIT_ASSERT( iSipSession->PendingTransactions().Count() == pendingCount + 1 );
       
   271     MCE_SET_STATES( iSipSession /*session*/, 
       
   272                     CMceSession::EOffering /*clientState*/, 
       
   273                     KMceStateClientReserving /*serverState*/ );
       
   274     
       
   275     TMceStateTransitionEvent event1_4( *iSipSession, EMceResponse );
       
   276     iState->EntryL( event1_4 );
       
   277     EUNIT_ASSERT( iSipSession->PendingTransactions().Count() == pendingCount + 1 );
       
   278     MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
       
   279                       CMCETls::EEncode /*mmsdpaction*/, 
       
   280                       SipStrConsts::EInvite /*sentMethod*/, 
       
   281                       KErrNotFound /*sentResponse*/);
       
   282     MCE_ASSERT_EVENT( event1_4 /*event*/, 
       
   283                       EMceMediaUpdated /*code*/, 
       
   284                       KErrNone /*status*/ );                      
       
   285     
       
   286     MCE_RESET_STUBS();
       
   287     
       
   288     // update pending, 2xx to INVITE received, update async
       
   289     iStorage->iMediaManagerUpdateStatus = KMceAsync;
       
   290     pendingCount = iSipSession->PendingTransactions().Count();
       
   291     update = CSIPClientTransaction::NewL( SIPStrings::StringF( SipStrConsts::EUpdate ) );
       
   292     CleanupStack::PushL( update );
       
   293     iSipSession->SetPendingTransactionL( update );
       
   294     CleanupStack::Pop( update );
       
   295     EUNIT_ASSERT( iSipSession->PendingTransactions().Count() == pendingCount + 1 );
       
   296     MCE_SET_STATES( iSipSession /*session*/, 
       
   297                     CMceSession::EOffering /*clientState*/, 
       
   298                     KMceStateClientReserving /*serverState*/ );
       
   299     
       
   300     TMceStateTransitionEvent event1_5( *iSipSession, EMceResponse );
       
   301     iState->EntryL( event1_5 );
       
   302     EUNIT_ASSERT( iSipSession->PendingTransactions().Count() == pendingCount );
       
   303     MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
       
   304                       CMCETls::EDecode /*mmsdpaction*/, 
       
   305                       SipStrConsts::EAck /*sentMethod*/, 
       
   306                       KErrNotFound /*sentResponse*/);
       
   307     MCE_ASSERT_EVENT( event1_5 /*event*/, 
       
   308                       EMceResponse /*code*/, 
       
   309                       KErrNone /*status*/ );                      
       
   310     
       
   311     MCE_RESET_STUBS();
       
   312     
       
   313     // update pending, 2xx to INVITE received, update async
       
   314     iStorage->iMediaManagerUpdateStatus = KErrGeneral;
       
   315     pendingCount = iSipSession->PendingTransactions().Count();
       
   316     update = CSIPClientTransaction::NewL( SIPStrings::StringF( SipStrConsts::EUpdate ) );
       
   317     CleanupStack::PushL( update );
       
   318     iSipSession->SetPendingTransactionL( update );
       
   319     CleanupStack::Pop( update );
       
   320     EUNIT_ASSERT( iSipSession->PendingTransactions().Count() == pendingCount + 1 );
       
   321     MCE_SET_STATES( iSipSession /*session*/, 
       
   322                     CMceSession::EOffering /*clientState*/, 
       
   323                     KMceStateClientReserving /*serverState*/ );
       
   324     
       
   325     
       
   326     TMceStateTransitionEvent event1_6( *iSipSession, EMceResponse );
       
   327     TRAPD( err2, iState->EntryL( event1_6 ) );
       
   328     EUNIT_ASSERT( err2 );
       
   329     if ( err2 != KErrNoMemory )
       
   330         {
       
   331         EUNIT_ASSERT( iSipSession->PendingTransactions().Count() == pendingCount );
       
   332         MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
       
   333                           CMCETls::EDecode /*mmsdpaction*/, 
       
   334                           SipStrConsts::EAck /*sentMethod*/, 
       
   335                           KErrNotFound /*sentResponse*/);
       
   336         }
       
   337 	else
       
   338     	{
       
   339     	User::Leave( KErrNoMemory );
       
   340     	}
       
   341     MCE_RESET_STUBS();
       
   342 
       
   343     // 2xx to PRACK with no SDP, update ready, need to negotiate
       
   344     prack = MCETestHelper::ClientTransactionLC( SipStrConsts::EPrack );
       
   345 	iSipSession->SetPendingTransactionL( prack );
       
   346     CleanupStack::Pop( prack );
       
   347     TInt prackInd = iSipSession->iPendingTransactions.Find( prack );
       
   348     MCETestHelper::ResponseL( iSipSession,
       
   349                               KMceSipOK,
       
   350                               SipStrConsts::EPhraseOk,
       
   351                               prackInd,
       
   352                               EFalse,
       
   353                               EFalse,
       
   354                               1,
       
   355                               EFalse );
       
   356     MCE_RESET_STUBS();                       
       
   357     
       
   358     TMceStateTransitionEvent event2( *iSipSession, EMceResponse );
       
   359     iState->EntryL( event2 );
       
   360     
       
   361     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   362                       CMCETls::ENone /*mmsdpaction*/, 
       
   363                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   364                       KErrNotFound /*sentResponse*/);
       
   365     MCE_ASSERT_EVENT( event2 /*event*/, 
       
   366                       EMceMediaUpdated /*code*/, 
       
   367                       KErrNone /*status*/ );                      
       
   368     MCE_RESET_STUBS();
       
   369     
       
   370     // 2xx to UPDATE with SDP, update ready, no need to negotiate
       
   371     update = CSIPClientTransaction::NewL( SIPStrings::StringF( SipStrConsts::EUpdate ) );
       
   372     CleanupStack::PushL( update );
       
   373     iSipSession->SetPendingTransactionL( update );
       
   374     CleanupStack::Pop( update );
       
   375     TInt updateInd = iSipSession->iPendingTransactions.Count() - 1;
       
   376     MCETestHelper::ResponseL( iSipSession,
       
   377                               KMceSipOK,
       
   378                               SipStrConsts::EPhraseOk,
       
   379                               updateInd,
       
   380                               ETrue );
       
   381     MCE_RESET_STUBS();
       
   382     iStorage->iMediaManagerNeedToNegotiate = EFalse;         
       
   383     iSipSession->iReceivedSdpCount = 0;
       
   384     iSipSession->iSentSdpCount = 1;
       
   385     
       
   386     TMceStateTransitionEvent event3( *iSipSession, EMceResponse );
       
   387     iState->EntryL( event3 );
       
   388     
       
   389     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   390                       CMCETls::ENone /*mmsdpaction*/, 
       
   391                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   392                       KErrNotFound /*sentResponse*/);
       
   393     MCE_ASSERT_EVENT( event3 /*event*/, 
       
   394                       EMceMediaUpdated /*code*/, 
       
   395                       KErrNone /*status*/ );                      
       
   396     MCE_RESET_STUBS();
       
   397                               
       
   398     // 2xx to UPDATE with SDP, update not ready.
       
   399     iStorage->iMediaManagerUpdateStatus = KMceAsync;
       
   400     
       
   401     TMceStateTransitionEvent event4( *iSipSession, EMceResponse );
       
   402     iState->EntryL( event4 );
       
   403     
       
   404     MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
       
   405                       CMCETls::EDecode /*mmsdpaction*/, 
       
   406                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   407                       KErrNotFound /*sentResponse*/);
       
   408     MCE_ASSERT_EVENT( event4 /*event*/, 
       
   409                       EMceResponse /*code*/, 
       
   410                       KMceAsync /*status*/ );                      
       
   411     MCE_RESET_STUBS();
       
   412     
       
   413     // 2xx to UPDATE, media manager update fails
       
   414     iStorage->iMediaManagerUpdateStatus = KErrGeneral;
       
   415     
       
   416     TMceStateTransitionEvent event5( *iSipSession, EMceResponse );
       
   417     EUNIT_ASSERT_LEAVE( iState->EntryL( event5 ) );
       
   418     
       
   419     MCE_ASSERT_STUBS( CMCETls::EUpdate /*mmaction*/, 
       
   420                       CMCETls::EDecode /*mmsdpaction*/, 
       
   421                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   422                       KErrNotFound /*sentResponse*/);
       
   423     MCE_ASSERT_EVENT( event5 /*event*/, 
       
   424                       EMceResponse /*code*/, 
       
   425                       KErrNone /*status*/ );                      
       
   426     MCE_RESET_STUBS();
       
   427     
       
   428     // 2xx to BYE
       
   429     CSIPClientTransaction* bye = 
       
   430         MCETestHelper::ClientTransactionLC( SipStrConsts::EBye );
       
   431 	iSipSession->SetPendingTransactionL( bye );
       
   432     CleanupStack::Pop( bye );
       
   433     TInt byeInd = iSipSession->iPendingTransactions.Find( bye );
       
   434     MCETestHelper::ResponseL( iSipSession,
       
   435                               KMceSipOK,
       
   436                               SipStrConsts::EPhraseOk,
       
   437                               byeInd );
       
   438     MCE_RESET_STUBS();                       
       
   439     
       
   440     TMceStateTransitionEvent event6( *iSipSession, EMceResponse );
       
   441     MCE_EUNIT_ASSERT_SPECIFIC_LEAVE( iState->EntryL( event6 ), KErrTotalLossOfPrecision );
       
   442     
       
   443     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   444                       CMCETls::ENone /*mmsdpaction*/, 
       
   445                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   446                       KErrNotFound /*sentResponse*/);
       
   447     MCE_ASSERT_EVENT( event6 /*event*/, 
       
   448                       EMceResponse /*code*/, 
       
   449                       KErrNone /*status*/ );     
       
   450     
       
   451     MCE_RESET_STUBS();
       
   452                       
       
   453     // Enable & disable    
       
   454     
       
   455     MCE_ASSERT_ENDPOINT_ENABLE_AND_DISABLE();     
       
   456            
       
   457     }
       
   458 
       
   459 void UT_CMceStateConfirming::UT_CMceStateConfirming_EntryL2L()
       
   460     {
       
   461     // EMceProvisionalResponse
       
   462     TInt inviteInd = iSipSession->iPendingTransactions.Find( iSipSession->InviteTransaction() );
       
   463     MCETestHelper::ResponseL( iSipSession,
       
   464                               KMceSipRinging,
       
   465                               SipStrConsts::EPhraseRinging,
       
   466                               inviteInd );
       
   467     MCE_RESET_STUBS();
       
   468     
       
   469     TMceStateTransitionEvent event1( *iSipSession, EMceProvisionalResponse );
       
   470     iState->EntryL( event1 );
       
   471     
       
   472     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   473                       CMCETls::ENone /*mmsdpaction*/, 
       
   474                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   475                       KErrNotFound /*sentResponse*/);
       
   476     MCE_ASSERT_EVENT( event1 /*event*/, 
       
   477                       EMceProvisionalResponse /*code*/, 
       
   478                       KErrNone /*status*/ );                      
       
   479     }
       
   480 
       
   481 void UT_CMceStateConfirming::UT_CMceStateConfirming_EntryL3L()
       
   482     {
       
   483     // EMceErrorResponse
       
   484     // Error response to first INVITE
       
   485     TInt inviteInd = iSipSession->iPendingTransactions.Find( iSipSession->InviteTransaction() );
       
   486     MCETestHelper::ResponseL( iSipSession,
       
   487                               KMceSipBadRequest,
       
   488                               SipStrConsts::EPhraseBadRequest,
       
   489                               inviteInd );
       
   490     MCE_RESET_STUBS();
       
   491                                   
       
   492     TMceStateTransitionEvent event1( *iSipSession, EMceErrorResponse );
       
   493     iState->EntryL( event1 );
       
   494     
       
   495     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   496                       CMCETls::ENone /*mmsdpaction*/, 
       
   497                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   498                       KErrNotFound /*sentResponse*/);
       
   499     MCE_ASSERT_EVENT( event1 /*event*/, 
       
   500                       EMceErrorResponse /*code*/, 
       
   501                       KErrNone /*status*/ );
       
   502     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   503                        CMceSession::ETerminated /*clientState*/, 
       
   504                        KMceStateTerminated /*serverState*/ );
       
   505     MCE_SET_STATES( iSipSession /*session*/, 
       
   506                     CMceSession::EOffering /*clientState*/, 
       
   507                     KMceStateConfirming /*serverState*/ );
       
   508     MCE_RESET_STUBS();
       
   509     
       
   510     // Error response to re-INVITE
       
   511     iSipSession->SetSubState( CMceSipSession::EUpdating );
       
   512     TMceStateTransitionEvent event2( *iSipSession, EMceErrorResponse );
       
   513     iState->EntryL( event2 );
       
   514     
       
   515     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   516                       CMCETls::ENone /*mmsdpaction*/, 
       
   517                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   518                       KErrNotFound /*sentResponse*/);
       
   519     MCE_ASSERT_EVENT( event2 /*event*/, 
       
   520                       EMceErrorResponse /*code*/, 
       
   521                       KErrNone /*status*/ );
       
   522     iSipSession->SetSubState( CMceSipSession::EOffering );                      
       
   523     }
       
   524 
       
   525 void UT_CMceStateConfirming::UT_CMceStateConfirming_EntryL4L()
       
   526     {    
       
   527     // Error response to PRACK
       
   528     CSIPClientTransaction* prack = 
       
   529         MCETestHelper::ClientTransactionLC( SipStrConsts::EPrack );
       
   530 	iSipSession->SetPendingTransactionL( prack );
       
   531     CleanupStack::Pop( prack );
       
   532     TInt prackInd = iSipSession->iPendingTransactions.Find( prack );
       
   533     MCETestHelper::ResponseL( iSipSession,
       
   534                               KMceSipBadRequest,
       
   535                               SipStrConsts::EPhraseBadRequest,
       
   536                               prackInd );
       
   537     CSIPClientTransaction* invite = iSipSession->InviteTransaction();
       
   538     invite->iState = CSIPTransactionBase::EProceeding;
       
   539     MCE_RESET_STUBS();                       
       
   540     
       
   541     TMceStateTransitionEvent event1( *iSipSession, EMceErrorResponse );
       
   542     iState->EntryL( event1 );
       
   543     
       
   544     MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
       
   545                       CMCETls::ENone /*mmsdpaction*/, 
       
   546                       SipStrConsts::ECancel /*sentMethod*/, 
       
   547                       KErrNotFound /*sentResponse*/);
       
   548     MCE_ASSERT_EVENT( event1 /*event*/, 
       
   549                       EMceErrorResponse /*code*/, 
       
   550                       KErrNone /*status*/ );                      
       
   551     MCE_RESET_STUBS();
       
   552     
       
   553     // Redirection response to UPDATE
       
   554     CSIPClientTransaction* update = 
       
   555         MCETestHelper::ClientTransactionLC( SipStrConsts::EUpdate );
       
   556 	iSipSession->SetPendingTransactionL( update );
       
   557     CleanupStack::Pop( update );
       
   558     TInt updateInd = iSipSession->iPendingTransactions.Find( update );
       
   559     MCETestHelper::ResponseL( iSipSession,
       
   560                               KMceSipMultipleChoices,
       
   561                               SipStrConsts::EPhraseBadRequest,
       
   562                               updateInd );
       
   563     MCE_RESET_STUBS();                       
       
   564     
       
   565     TMceStateTransitionEvent event2( *iSipSession, EMceRedirectionResponse );
       
   566     iState->EntryL( event2 );
       
   567     
       
   568     MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
       
   569                       CMCETls::ENone /*mmsdpaction*/, 
       
   570                       SipStrConsts::ECancel /*sentMethod*/, 
       
   571                       KErrNotFound /*sentResponse*/);
       
   572     MCE_ASSERT_EVENT( event2 /*event*/, 
       
   573                       EMceRedirectionResponse /*code*/, 
       
   574                       KErrNone /*status*/ );                      
       
   575     MCE_RESET_STUBS();
       
   576     
       
   577     // Error response to BYE
       
   578     CSIPClientTransaction* bye = 
       
   579         MCETestHelper::ClientTransactionLC( SipStrConsts::EBye );
       
   580 	iSipSession->SetPendingTransactionL( bye );
       
   581     CleanupStack::Pop( bye );
       
   582     TInt byeInd = iSipSession->iPendingTransactions.Find( bye );
       
   583     MCETestHelper::ResponseL( iSipSession,
       
   584                               KMceSipBadRequest,
       
   585                               SipStrConsts::EPhraseBadRequest,
       
   586                               byeInd );
       
   587     MCE_RESET_STUBS();                       
       
   588     
       
   589     TMceStateTransitionEvent event3( *iSipSession, EMceErrorResponse );
       
   590     MCE_EUNIT_ASSERT_SPECIFIC_LEAVE( iState->EntryL( event3 ), KErrTotalLossOfPrecision );
       
   591     
       
   592     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   593                       CMCETls::ENone /*mmsdpaction*/, 
       
   594                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   595                       KErrNotFound /*sentResponse*/);
       
   596     MCE_ASSERT_EVENT( event3 /*event*/, 
       
   597                       EMceErrorResponse /*code*/, 
       
   598                       KErrNone /*status*/ );                      
       
   599     }
       
   600 
       
   601 void UT_CMceStateConfirming::UT_CMceStateConfirming_EntryL5L()
       
   602     {
       
   603     // EMceItcCancel
       
   604     TMceIds ids;
       
   605     CMceMsgBase* msg = NULL;
       
   606     
       
   607     //subState == CMceSipSession::EOffering
       
   608     iSipSession->SetSubState( CMceSipSession::EOffering );
       
   609     iSipSession->InviteTransaction()->iState = CSIPTransactionBase::EProceeding;
       
   610     TMceStateTransitionEvent event1( *iSipSession, EMceItcCancel, ids, *msg );
       
   611     iState->EntryL( event1 );
       
   612     
       
   613     MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
       
   614                       CMCETls::ENone /*mmsdpaction*/, 
       
   615                       SipStrConsts::ECancel /*sentMethod*/, 
       
   616                       KErrNotFound /*sentResponse*/);
       
   617     
       
   618     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   619                        CMceSession::EOffering /*clientState*/, 
       
   620                        KMceStateConfirming /*serverState*/ );
       
   621     MCE_ASSERT_EVENT( event1 /*event*/, 
       
   622                       EMceItcCancel /*code*/, 
       
   623                       KErrNone /*status*/ );                                             
       
   624     MCE_RESET_STUBS();
       
   625     
       
   626     //subState == CMceSipSession::EUpdating
       
   627     iSipSession->iNewBodyCandidate = iSipSession->Body()->CloneL();
       
   628     
       
   629     iSipSession->SetSubState( CMceSipSession::EUpdating );
       
   630     TMceStateTransitionEvent event2( *iSipSession, EMceItcCancel, ids, *msg );
       
   631     iState->EntryL( event2 );
       
   632     
       
   633     MCE_ASSERT_STUBS( CMCETls::ECloseSession /*mmaction*/, 
       
   634                       CMCETls::ENone /*mmsdpaction*/, 
       
   635                       SipStrConsts::ECancel /*sentMethod*/, 
       
   636                       KErrNotFound /*sentResponse*/);
       
   637     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   638                        CMceSession::EOffering /*clientState*/, 
       
   639                        KMceStateConfirming /*serverState*/ );
       
   640     MCE_ASSERT_EVENT( event2 /*event*/, 
       
   641                       EMceItcCancel /*code*/, 
       
   642                       KErrNone /*status*/ );                      
       
   643                            
       
   644     iSipSession->SetSubState( CMceSipSession::EOffering );
       
   645     MCE_RESET_STUBS();
       
   646     
       
   647     // default
       
   648     TMceStateTransitionEvent event3( *iSipSession, EMceInvite );
       
   649     iState->EntryL( event3 );
       
   650     
       
   651     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   652                       CMCETls::ENone /*mmsdpaction*/, 
       
   653                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   654                       KErrNotFound /*sentResponse*/);
       
   655     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   656                        CMceSession::EOffering /*clientState*/, 
       
   657                        KMceStateConfirming /*serverState*/ );
       
   658     MCE_ASSERT_EVENT( event3 /*event*/, 
       
   659                       EMceInvite /*code*/, 
       
   660                       KErrNone /*status*/ );
       
   661     }
       
   662 
       
   663 void UT_CMceStateConfirming::UT_CMceStateConfirming_EntryL6L()
       
   664     {
       
   665     // EMceMediaUpdated
       
   666     MCE_RESET_STUBS();
       
   667     // !session.Actions().NeedToNegotiate()
       
   668     iStorage->iMediaManagerNeedToNegotiate = EFalse;
       
   669     
       
   670     TMceStateTransitionEvent event1( *iSipSession, EMceMediaUpdated );
       
   671     iState->EntryL( event1 );
       
   672     
       
   673     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   674                       CMCETls::ENone /*mmsdpaction*/, 
       
   675                       SipStrConsts::EEmpty /*sentMethod*/, 
       
   676                       KErrNotFound /*sentResponse*/);
       
   677     MCE_ASSERT_EVENT( event1 /*event*/, 
       
   678                       EMceMediaUpdated /*code*/, 
       
   679                       KErrNone /*status*/ );                      
       
   680     
       
   681                           
       
   682     MCE_RESET_STUBS();
       
   683     
       
   684     // session.Actions().NeedToNegotiate() && 
       
   685     // session.Dialog()->Dialog().State() != CSIPDialog::EEarly 
       
   686     iStorage->iMediaManagerNeedToNegotiate = ETrue;
       
   687     TMceStateTransitionEvent event2( *iSipSession, EMceMediaUpdated );
       
   688     iState->EntryL( event2 );
       
   689     
       
   690     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   691                       CMCETls::EEncode /*mmsdpaction*/, 
       
   692                       SipStrConsts::EInvite /*sentMethod*/, 
       
   693                       KErrNotFound /*sentResponse*/);
       
   694     MCE_ASSERT_EVENT( event2 /*event*/, 
       
   695                       EMceMediaUpdated /*code*/, 
       
   696                       KErrNone /*status*/ );                      
       
   697     
       
   698     // session.Actions().NeedToNegotiate() && 
       
   699     // session.Dialog()->Dialog().State() == CSIPDialog::EEarly 
       
   700     iStorage->iMediaManagerNeedToNegotiate = ETrue;
       
   701     iSipSession->Dialog()->Dialog().iState = CSIPDialog::EEarly;
       
   702     TMceStateTransitionEvent event3( *iSipSession, EMceMediaUpdated );
       
   703     iState->EntryL( event3 );
       
   704     
       
   705     MCE_ASSERT_STUBS( CMCETls::ENone /*mmaction*/, 
       
   706                       CMCETls::EEncode /*mmsdpaction*/, 
       
   707                       SipStrConsts::EUpdate /*sentMethod*/, 
       
   708                       KErrNotFound /*sentResponse*/);
       
   709     MCE_ASSERT_EVENT( event3 /*event*/, 
       
   710                       EMceMediaUpdated /*code*/, 
       
   711                       KErrNone /*status*/ );
       
   712     }
       
   713     
       
   714 void UT_CMceStateConfirming::UT_CMceStateConfirming_ExitLL()
       
   715     {
       
   716     TMceIds ids;
       
   717     CMceMsgBase* msg = NULL;
       
   718 
       
   719     // EMceMediaUpdated
       
   720     // !update && !invite->StateL() == CSIPTransactionBase::ETerminated
       
   721     TMceStateTransitionEvent event1( *iSipSession, EMceMediaUpdated );
       
   722     iState->ExitL( event1 );
       
   723     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   724                        CMceSession::EOffering /*clientState*/, 
       
   725                        KMceStateOffering /*serverState*/ );
       
   726     MCE_SET_STATES( iSipSession /*session*/, 
       
   727                     CMceSession::EOffering /*clientState*/, 
       
   728                     KMceStateConfirming /*serverState*/ );
       
   729     
       
   730     // !update && invite->StateL() == CSIPTransactionBase::ETerminated
       
   731     CSIPClientTransaction* invite = iSipSession->InviteTransaction();
       
   732     invite->iState = CSIPTransactionBase::ETerminated;
       
   733     MCETestHelper::ResponseL( iSipSession,
       
   734                               KMceSipOK,
       
   735                               SipStrConsts::EPhraseOk,
       
   736                               iSipSession->iPendingTransactions.Find( invite ) );
       
   737     
       
   738     TMceStateTransitionEvent event2( *iSipSession, EMceMediaUpdated );
       
   739     iState->ExitL( event2 );
       
   740     
       
   741     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   742                        CMceSession::EEstablished /*clientState*/, 
       
   743                        KMceStateEstablished /*serverState*/ );
       
   744     MCE_SET_STATES( iSipSession /*session*/, 
       
   745                     CMceSession::EOffering /*clientState*/, 
       
   746                     KMceStateConfirming /*serverState*/ );
       
   747     
       
   748     // update
       
   749     CSIPClientTransaction* update = 
       
   750         MCETestHelper::ClientTransactionLC( SipStrConsts::EUpdate );
       
   751 	iSipSession->SetPendingTransactionL( update );
       
   752     CleanupStack::Pop( update );
       
   753     
       
   754     TMceStateTransitionEvent event3( *iSipSession, EMceMediaUpdated );
       
   755     iState->ExitL( event3 );
       
   756     
       
   757     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   758                        CMceSession::EOffering /*clientState*/, 
       
   759                        KMceStateConfirming /*serverState*/ );
       
   760     
       
   761     // EMceItcCancel
       
   762     TMceStateTransitionEvent event4( *iSipSession, EMceItcCancel, ids, *msg );
       
   763     iState->ExitL( event4 );
       
   764     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   765                        CMceSession::ECancelling /*clientState*/, 
       
   766                        KMceStateCanceled /*serverState*/ );
       
   767     MCE_SET_STATES( iSipSession /*session*/, 
       
   768                     CMceSession::EOffering /*clientState*/, 
       
   769                     KMceStateConfirming /*serverState*/ );
       
   770     
       
   771     // EMceErrorResponse
       
   772     TMceStateTransitionEvent event5( *iSipSession, EMceErrorResponse );
       
   773     iState->ExitL( event5 );
       
   774            
       
   775     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   776                        CMceSession::ECancelling /*clientState*/, 
       
   777                        KMceStateCanceled /* serverState*/ );
       
   778     MCE_SET_STATES( iSipSession /*session*/, 
       
   779                     CMceSession::EOffering /*clientState*/, 
       
   780                     KMceStateConfirming /*serverState*/ );
       
   781     
       
   782     // EMceRedirectionResponse
       
   783     TMceStateTransitionEvent event6( *iSipSession, EMceRedirectionResponse );
       
   784     iState->ExitL( event6 );
       
   785     
       
   786     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   787                        CMceSession::ECancelling /*clientState*/, 
       
   788                        KMceStateCanceled /*serverState*/ );
       
   789     MCE_SET_STATES( iSipSession /*session*/, 
       
   790                     CMceSession::EOffering /*clientState*/, 
       
   791                     KMceStateConfirming /*serverState*/ );
       
   792     
       
   793     // default
       
   794     TMceStateTransitionEvent event7( *iSipSession, EMceInvite );
       
   795     iState->ExitL( event7 );
       
   796     MCE_ASSERT_STATES( iSipSession /*session*/, 
       
   797                        CMceSession::EOffering /*clientState*/, 
       
   798                        KMceStateConfirming /*serverState*/ );
       
   799     MCE_SET_STATES( iSipSession /*session*/, 
       
   800                     CMceSession::EOffering /*clientState*/, 
       
   801                     KMceStateConfirming /*serverState*/ );
       
   802     
       
   803     }
       
   804     
       
   805     
       
   806         
       
   807 //  TEST TABLE
       
   808 
       
   809 EUNIT_BEGIN_TEST_TABLE( 
       
   810     UT_CMceStateConfirming,
       
   811     "UT_CMceStateConfirming",
       
   812     "UNIT" )
       
   813 
       
   814 EUNIT_TEST(
       
   815     "AcceptL - test ",
       
   816     "CMceStateConfirming",
       
   817     "AcceptL",
       
   818     "FUNCTIONALITY",
       
   819     SetupL, UT_CMceStateConfirming_AcceptLL, Teardown)
       
   820 
       
   821 EUNIT_TEST(
       
   822     "EntryL - test ",
       
   823     "CMceStateConfirming",
       
   824     "EntryL",
       
   825     "FUNCTIONALITY",
       
   826     SetupL, UT_CMceStateConfirming_EntryLL, Teardown)
       
   827 
       
   828 EUNIT_TEST(
       
   829     "EntryL - provisional - test ",
       
   830     "CMceStateConfirming",
       
   831     "EntryL",
       
   832     "FUNCTIONALITY",
       
   833     SetupL, UT_CMceStateConfirming_EntryL2L, Teardown)
       
   834 
       
   835 EUNIT_TEST(
       
   836     "EntryL - error to INVITE - test ",
       
   837     "CMceStateConfirming",
       
   838     "EntryL",
       
   839     "FUNCTIONALITY",
       
   840     SetupL, UT_CMceStateConfirming_EntryL3L, Teardown)
       
   841 
       
   842 EUNIT_TEST(
       
   843     "EntryL - error to PRACK/UPDATE - test ",
       
   844     "CMceStateConfirming",
       
   845     "EntryL",
       
   846     "FUNCTIONALITY",
       
   847     SetupL, UT_CMceStateConfirming_EntryL4L, Teardown)
       
   848 
       
   849 EUNIT_TEST(
       
   850     "EntryL - cancel - test ",
       
   851     "CMceStateConfirming",
       
   852     "EntryL",
       
   853     "FUNCTIONALITY",
       
   854     SetupL, UT_CMceStateConfirming_EntryL5L, Teardown)
       
   855 
       
   856 EUNIT_TEST(
       
   857     "EntryL - updated - test ",
       
   858     "CMceStateConfirming",
       
   859     "EntryL",
       
   860     "FUNCTIONALITY",
       
   861     SetupL, UT_CMceStateConfirming_EntryL6L, Teardown)
       
   862 
       
   863 
       
   864 EUNIT_TEST(
       
   865     "ExitL - test ",
       
   866     "CMceStateConfirming",
       
   867     "ExitL",
       
   868     "FUNCTIONALITY",
       
   869     SetupL, UT_CMceStateConfirming_ExitLL, Teardown)
       
   870 
       
   871 
       
   872 EUNIT_END_TEST_TABLE
       
   873 
       
   874 //  END OF FILE