multimediacommscontroller/mmccsubcontroller/tsrc/ut_subcontroller/Src/UT_CMccRtpManager.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_CMccRtpManager.h"
       
    23 
       
    24 //  EXTERNAL INCLUDES
       
    25 #include <digia/eunit/eunitmacros.h>
       
    26 
       
    27 
       
    28 //  INTERNAL INCLUDES
       
    29 #include "Mccrtpmanager.h"
       
    30 #include "Mcctesteventhandler.h"
       
    31 #include "mccresourcepool_stub.h"
       
    32 #include "mccunittestmacros.h"
       
    33 
       
    34 // CONSTRUCTION
       
    35 UT_CMccRtpManager* UT_CMccRtpManager::NewL()
       
    36     {
       
    37     UT_CMccRtpManager* self = UT_CMccRtpManager::NewLC();
       
    38     CleanupStack::Pop();
       
    39 
       
    40     return self;
       
    41     }
       
    42 
       
    43 UT_CMccRtpManager* UT_CMccRtpManager::NewLC()
       
    44     {
       
    45     UT_CMccRtpManager* self = new( ELeave ) UT_CMccRtpManager();
       
    46     CleanupStack::PushL( self );
       
    47 
       
    48     self->ConstructL();
       
    49 
       
    50     return self;
       
    51     }
       
    52 
       
    53 // Destructor (virtual by CBase)
       
    54 UT_CMccRtpManager::~UT_CMccRtpManager()
       
    55     {
       
    56     }
       
    57 
       
    58 // Default constructor
       
    59 UT_CMccRtpManager::UT_CMccRtpManager() :
       
    60     iRtpMan( NULL )
       
    61     {
       
    62     }
       
    63 
       
    64 // Second phase construct
       
    65 void UT_CMccRtpManager::ConstructL()
       
    66     {
       
    67     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    68     // It generates the test case table.
       
    69     CEUnitTestSuiteClass::ConstructL();
       
    70     }
       
    71 
       
    72 //  METHODS
       
    73 
       
    74 
       
    75 
       
    76 void UT_CMccRtpManager::SetupL(  )
       
    77     {
       
    78     iHandler = CMccTestEventHandler::NewL();
       
    79     iResources = CMccResourcePoolStub::NewL();
       
    80     iRtpMan = CMccRtpManager::NewL( *iHandler, *iResources, iMccSessionId );
       
    81     iHandler->iLastEvent = TMccEvent();
       
    82     }
       
    83 
       
    84 void UT_CMccRtpManager::Teardown(  )
       
    85     {
       
    86     if ( iRtpMan )
       
    87         {
       
    88         delete iRtpMan;
       
    89         }
       
    90     if ( iHandler )
       
    91         {
       
    92         delete iHandler;
       
    93         }
       
    94     delete iResources;
       
    95     }
       
    96 
       
    97 void UT_CMccRtpManager::UT_CMccRtpManager_RemoveStreamFromArray()
       
    98     {
       
    99     TRtpId rtpid(3);
       
   100     iRtpMan->RemoveStreamFromArray( rtpid );
       
   101     TInt err = iRtpMan->iStreamArray.Append( rtpid );
       
   102     EUNIT_ASSERT( !err || err == KErrNoMemory );
       
   103     iRtpMan->RemoveStreamFromArray( rtpid );
       
   104     }
       
   105     
       
   106 void UT_CMccRtpManager::UT_CMccRtpManager_IsOpen()
       
   107     {
       
   108     EUNIT_ASSERT( !iRtpMan->IsOpen() );
       
   109     }
       
   110  
       
   111  
       
   112 void UT_CMccRtpManager::UT_CMccRtpManager_CheckStreamExists()
       
   113     {
       
   114 
       
   115     TRtpId rtpid(3);
       
   116     EUNIT_ASSERT( !iRtpMan->CheckStreamExists( rtpid ) );
       
   117     TInt err = iRtpMan->iStreamArray.Append( rtpid );
       
   118     EUNIT_ASSERT( !err || err == KErrNoMemory );
       
   119     EUNIT_ASSERT( err == KErrNoMemory || iRtpMan->CheckStreamExists( rtpid ) );
       
   120 
       
   121     }
       
   122  
       
   123 
       
   124 void UT_CMccRtpManager::UT_CMccRtpManager_CreateSessionLL(  )
       
   125     {
       
   126     TUint port( 5000 );
       
   127     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->CreateSessionL( port, EFalse, EFalse ) );
       
   128     
       
   129     // KErrAlreadyExists
       
   130     EUNIT_ASSERT_LEAVE( iRtpMan->CreateSessionL( port, EFalse, EFalse ) );
       
   131     }
       
   132 
       
   133 void UT_CMccRtpManager::UT_CMccRtpManager_CloseSessionL(  )
       
   134     {
       
   135     iRtpMan->CloseSession();
       
   136     
       
   137     TUint port( 5000 );
       
   138     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->CreateSessionL( port, EFalse, EFalse ) );
       
   139 
       
   140     iRtpMan->CloseSession();
       
   141     }
       
   142 
       
   143 void UT_CMccRtpManager::UT_CMccRtpManager_GetRtpReferenceLL(  )
       
   144     {
       
   145     CRtpAPI* rtp( NULL );
       
   146     EUNIT_ASSERT_LEAVE( rtp = iRtpMan->GetRtpReferenceL() );
       
   147     }
       
   148 
       
   149 void UT_CMccRtpManager::UT_CMccRtpManager_SetRemoteAddressL(  )
       
   150     {
       
   151     TInetAddr addr;
       
   152     EUNIT_ASSERT_EQUALS( iRtpMan->SetRemoteAddress( addr ), KErrNotFound );
       
   153 
       
   154     TUint port( 5000 );
       
   155     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->CreateSessionL( port, EFalse, EFalse ) );
       
   156 
       
   157     addr.SetPort( port );
       
   158     EUNIT_ASSERT_EQUALS( iRtpMan->SetRemoteAddress( addr ), KErrNone );
       
   159     EUNIT_ASSERT( iRtpMan->iRemoteAddress.Address() == addr.Address() )
       
   160     EUNIT_ASSERT( iRtpMan->iRemoteAddress.Port() == addr.Port() )
       
   161     
       
   162     // Port not changed
       
   163     EUNIT_ASSERT_EQUALS( iRtpMan->SetRemoteAddress( addr ), KErrNone );
       
   164     
       
   165     // Port changed
       
   166     TUint port2( 5002 );
       
   167     addr.SetPort( port2 );
       
   168     EUNIT_ASSERT_EQUALS( iRtpMan->SetRemoteAddress( addr ), KErrNone );
       
   169     EUNIT_ASSERT( iRtpMan->iRemoteAddress.Address() == addr.Address() )
       
   170     EUNIT_ASSERT( iRtpMan->iRemoteAddress.Port() == addr.Port() )
       
   171     }
       
   172     
       
   173     
       
   174 void UT_CMccRtpManager::UT_CMccRtpManager_SetRemoteRtcpAddrL(  )
       
   175     {
       
   176     TInetAddr addr;
       
   177     EUNIT_ASSERT_EQUALS( iRtpMan->SetRemoteRtcpAddr( addr ), KErrNotFound );
       
   178 
       
   179     TUint port( 5000 );
       
   180     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->CreateSessionL( port, EFalse, EFalse ) );
       
   181 
       
   182     addr.SetPort( port );
       
   183     EUNIT_ASSERT_EQUALS( iRtpMan->SetRemoteRtcpAddr( addr ), KErrNone );
       
   184     EUNIT_ASSERT( iRtpMan->iRemoteRtcpAddr.Address() == addr.Address() )
       
   185     EUNIT_ASSERT( iRtpMan->iRemoteRtcpAddr.Port() == addr.Port() )
       
   186     
       
   187     // Port not changed
       
   188     EUNIT_ASSERT_EQUALS( iRtpMan->SetRemoteRtcpAddr( addr ), KErrNone );
       
   189     
       
   190     // Port changed
       
   191     TUint port2( 5002 );
       
   192     addr.SetPort( port2 );
       
   193     EUNIT_ASSERT_EQUALS( iRtpMan->SetRemoteRtcpAddr( addr ), KErrNone );
       
   194     EUNIT_ASSERT( iRtpMan->iRemoteRtcpAddr.Address() == addr.Address() )
       
   195     EUNIT_ASSERT( iRtpMan->iRemoteRtcpAddr.Port() == addr.Port() )
       
   196     }    
       
   197 
       
   198 void UT_CMccRtpManager::UT_CMccRtpManager_SetIpTOSL(  )
       
   199     {
       
   200     iRtpMan->SetIpTOS( 0 );
       
   201     }
       
   202 
       
   203 void UT_CMccRtpManager::UT_CMccRtpManager_StartSessionLL(  )
       
   204     {
       
   205     EUNIT_ASSERT_LEAVE( iRtpMan->StartSessionL() );
       
   206     
       
   207     TUint port( 5000 );
       
   208     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->CreateSessionL( port, EFalse, EFalse ) );
       
   209 
       
   210     // StartSessionL contains a special fix for TEST_EUNIT 
       
   211     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->StartSessionL() );
       
   212     }
       
   213 
       
   214 void UT_CMccRtpManager::UT_CMccRtpManager_InitializeLL(  )
       
   215     {
       
   216     TRequestStatus status;
       
   217     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->InitializeL( status, 5 ) );
       
   218     User::WaitForAnyRequest();
       
   219     }
       
   220 
       
   221 void UT_CMccRtpManager::UT_CMccRtpManager_SessionIdL(  )
       
   222     {
       
   223     TRtpId id = iRtpMan->SessionId();
       
   224     }
       
   225 
       
   226 void UT_CMccRtpManager::UT_CMccRtpManager_CreateTransmitStreamLL(  )
       
   227     {
       
   228     //EUNIT_ASSERT( ETrue );
       
   229     }
       
   230 
       
   231 void UT_CMccRtpManager::UT_CMccRtpManager_CreateReceiveStreamLL(  )
       
   232     {
       
   233     //EUNIT_ASSERT( ETrue );
       
   234     }
       
   235 
       
   236 void UT_CMccRtpManager::UT_CMccRtpManager_RefreshDownlinkLL(  )
       
   237     {
       
   238     //EUNIT_ASSERT( ETrue );
       
   239     }
       
   240 
       
   241 void UT_CMccRtpManager::UT_CMccRtpManager_SetRTCPSendL(  )
       
   242     {
       
   243     EUNIT_ASSERT_EQUALS( iRtpMan->SetRTCPSendReceive( ETrue ), KErrNotFound );
       
   244     
       
   245     TUint port( 5000 );
       
   246     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->CreateSessionL( port, EFalse, EFalse ) );
       
   247     
       
   248     EUNIT_ASSERT_EQUALS( iRtpMan->SetRTCPSendReceive( ETrue ), KErrNone );
       
   249     }
       
   250 
       
   251 void UT_CMccRtpManager::UT_CMccRtpManager_ErrorNotifyL(  )
       
   252     {
       
   253     iRtpMan->ErrorNotify( KErrNone );
       
   254     EUNIT_ASSERT_EQUALS( iHandler->iLastEvent.iEventType, KMccEventNone );
       
   255     
       
   256     iRtpMan->ErrorNotify( KErrGeneral );
       
   257     EUNIT_ASSERT_EQUALS( iHandler->iLastEvent.iEventType, KMccEventNone );
       
   258     
       
   259     // test handling of ICMP host unreachable error
       
   260     iRtpMan->ErrorNotify( KErrHostUnreach );
       
   261     EUNIT_ASSERT_EQUALS( iHandler->iLastEvent.iEventType, KMccStreamError );
       
   262     EUNIT_ASSERT_EQUALS( iHandler->iLastEvent.iEventCategory, KMccEventCategoryRtp );
       
   263     EUNIT_ASSERT_EQUALS( iHandler->iLastEvent.iErrorCode, KErrHostUnreach );
       
   264     
       
   265     // test handling of ICMP port unreachable error
       
   266     iRtpMan->ErrorNotify( KErrCouldNotConnect );
       
   267     EUNIT_ASSERT_EQUALS( iHandler->iLastEvent.iEventType, KMccStreamError );
       
   268     EUNIT_ASSERT_EQUALS( iHandler->iLastEvent.iEventCategory, KMccEventCategoryRtp );
       
   269     EUNIT_ASSERT_EQUALS( iHandler->iLastEvent.iErrorCode, KErrHostUnreach );
       
   270     }
       
   271 
       
   272 void UT_CMccRtpManager::UT_CMccRtpManager_GetLocalIpAddressesL()
       
   273     {
       
   274     TMccCreateLink createlink;
       
   275     
       
   276     iRtpMan->iRtpSessionId = KNullId;
       
   277     MCC_EUNIT_ASSERT_SPECIFIC_LEAVE( iRtpMan->GetLocalIpAddressesL( createlink ), KErrNotReady );
       
   278     
       
   279     iRtpMan->iRtpSessionId = 5;
       
   280     delete iRtpMan->iRtpApi;
       
   281     iRtpMan->iRtpApi = NULL;
       
   282     MCC_EUNIT_ASSERT_SPECIFIC_LEAVE( iRtpMan->GetLocalIpAddressesL( createlink ), KErrNotReady );
       
   283     
       
   284     iRtpMan->iRtpApi = CRtpAPI::NewL( *iRtpMan );
       
   285     
       
   286     MCC_EUNIT_ASSERT_SPECIFIC_LEAVE( iRtpMan->GetLocalIpAddressesL( createlink ), KErrGeneral );
       
   287     }
       
   288 
       
   289 void UT_CMccRtpManager::UT_CMccRtpManager_SetCNameL()
       
   290     {
       
   291     MCC_EUNIT_ASSERT_NO_LEAVE( iRtpMan->SetCNameL( _L8("Name") ) );  
       
   292     }
       
   293     
       
   294 void UT_CMccRtpManager::UT_CMccRtpManager_QoSParamEvent()
       
   295     {
       
   296     TInt error = 0; 
       
   297     iRtpMan->QoSParamEvent(error, 0);  
       
   298     }
       
   299 
       
   300 void UT_CMccRtpManager::UT_CMccRtpManager_QoSConnEvent()
       
   301     {
       
   302     TInt error = 0; 
       
   303     iRtpMan->QoSConnEvent(error, 0);  
       
   304     }
       
   305     
       
   306 
       
   307 
       
   308 //  TEST TABLE
       
   309 
       
   310 EUNIT_BEGIN_TEST_TABLE(
       
   311     UT_CMccRtpManager,
       
   312     "CMccRtpManager",
       
   313     "UNIT" )
       
   314 
       
   315 EUNIT_TEST(
       
   316     "RemoveStreamFromArray - test ",
       
   317     "CMccRtpManager",
       
   318     "RemoveStreamFromArray",
       
   319     "FUNCTIONALITY",
       
   320     SetupL, UT_CMccRtpManager_RemoveStreamFromArray, Teardown)
       
   321 
       
   322 EUNIT_TEST(
       
   323     "IsOpen - test ",
       
   324     "CMccRtpManager",
       
   325     "IsOpen",
       
   326     "FUNCTIONALITY",
       
   327     SetupL, UT_CMccRtpManager_IsOpen, Teardown)
       
   328     
       
   329 EUNIT_TEST(
       
   330     "CheckStreamExists - test ",
       
   331     "CMccRtpManager",
       
   332     "CheckStreamExists",
       
   333     "FUNCTIONALITY",
       
   334     SetupL, UT_CMccRtpManager_CheckStreamExists, Teardown)
       
   335   
       
   336 EUNIT_TEST(
       
   337     "CreateSessionL - test ",
       
   338     "CMccRtpManager",
       
   339     "CreateSessionL",
       
   340     "FUNCTIONALITY",
       
   341     SetupL, UT_CMccRtpManager_CreateSessionLL, Teardown)
       
   342 
       
   343 EUNIT_TEST(
       
   344     "CloseSession - test ",
       
   345     "CMccRtpManager",
       
   346     "CloseSession",
       
   347     "FUNCTIONALITY",
       
   348     SetupL, UT_CMccRtpManager_CloseSessionL, Teardown)
       
   349 
       
   350 EUNIT_TEST(
       
   351     "GetRtpReferenceL - test ",
       
   352     "CMccRtpManager",
       
   353     "GetRtpReferenceL",
       
   354     "FUNCTIONALITY",
       
   355     SetupL, UT_CMccRtpManager_GetRtpReferenceLL, Teardown)
       
   356 
       
   357 EUNIT_TEST(
       
   358     "SetRemoteAddress - test ",
       
   359     "CMccRtpManager",
       
   360     "SetRemoteAddress",
       
   361     "FUNCTIONALITY",
       
   362     SetupL, UT_CMccRtpManager_SetRemoteAddressL, Teardown)
       
   363 
       
   364 EUNIT_TEST(
       
   365     "SetIpTOS - test ",
       
   366     "CMccRtpManager",
       
   367     "SetIpTOS",
       
   368     "FUNCTIONALITY",
       
   369     SetupL, UT_CMccRtpManager_SetIpTOSL, Teardown)
       
   370 
       
   371 EUNIT_TEST(
       
   372     "StartSessionL - test ",
       
   373     "CMccRtpManager",
       
   374     "StartSessionL",
       
   375     "FUNCTIONALITY",
       
   376     SetupL, UT_CMccRtpManager_StartSessionLL, Teardown)
       
   377 
       
   378 EUNIT_TEST(
       
   379     "InitializeL - test ",
       
   380     "CMccRtpManager",
       
   381     "InitializeL",
       
   382     "FUNCTIONALITY",
       
   383     SetupL, UT_CMccRtpManager_InitializeLL, Teardown)
       
   384 
       
   385 EUNIT_TEST(
       
   386     "SessionId - test ",
       
   387     "CMccRtpManager",
       
   388     "SessionId",
       
   389     "FUNCTIONALITY",
       
   390     SetupL, UT_CMccRtpManager_SessionIdL, Teardown)
       
   391 
       
   392 EUNIT_TEST(
       
   393     "CreateTransmitStreamL - test ",
       
   394     "CMccRtpManager",
       
   395     "CreateTransmitStreamL",
       
   396     "FUNCTIONALITY",
       
   397     SetupL, UT_CMccRtpManager_CreateTransmitStreamLL, Teardown)
       
   398 
       
   399 EUNIT_TEST(
       
   400     "CreateReceiveStreamL - test ",
       
   401     "CMccRtpManager",
       
   402     "CreateReceiveStreamL",
       
   403     "FUNCTIONALITY",
       
   404     SetupL, UT_CMccRtpManager_CreateReceiveStreamLL, Teardown)
       
   405 
       
   406 EUNIT_TEST(
       
   407     "RefreshDownlinkL - test ",
       
   408     "CMccRtpManager",
       
   409     "RefreshDownlinkL",
       
   410     "FUNCTIONALITY",
       
   411     SetupL, UT_CMccRtpManager_RefreshDownlinkLL, Teardown)
       
   412 
       
   413 EUNIT_TEST(
       
   414     "SetRTCPSend - test ",
       
   415     "CMccRtpManager",
       
   416     "SetRTCPSend",
       
   417     "FUNCTIONALITY",
       
   418     SetupL, UT_CMccRtpManager_SetRTCPSendL, Teardown)
       
   419 
       
   420 EUNIT_TEST(
       
   421     "ErrorNotify - test ",
       
   422     "CMccRtpManager",
       
   423     "ErrorNotify",
       
   424     "FUNCTIONALITY",
       
   425     SetupL, UT_CMccRtpManager_ErrorNotifyL, Teardown)
       
   426 
       
   427 EUNIT_TEST(
       
   428     "GetLocalIpAddressesL - test ",
       
   429     "CMccRtpManager",
       
   430     "GetLocalIpAddressesL",
       
   431     "FUNCTIONALITY",
       
   432     SetupL, UT_CMccRtpManager_GetLocalIpAddressesL, Teardown)
       
   433 
       
   434 EUNIT_TEST(
       
   435     "SetCNameL - test ",
       
   436     "CMccRtpManager",
       
   437     "SetCNameL",
       
   438     "FUNCTIONALITY",
       
   439     SetupL, UT_CMccRtpManager_SetCNameL, Teardown)
       
   440 
       
   441 EUNIT_TEST(
       
   442     "QoSParamEvent - test ",
       
   443     "CMccRtpManager",
       
   444     "QoSParamEvent",
       
   445     "FUNCTIONALITY",
       
   446     SetupL, UT_CMccRtpManager_QoSParamEvent, Teardown)
       
   447 
       
   448 EUNIT_TEST(
       
   449     "QoSConnEvent - test ",
       
   450     "CMccRtpManager",
       
   451     "QoSConnEvent",
       
   452     "FUNCTIONALITY",
       
   453     SetupL, UT_CMccRtpManager_QoSConnEvent, Teardown)
       
   454 
       
   455 
       
   456 
       
   457 
       
   458 
       
   459 EUNIT_END_TEST_TABLE
       
   460 
       
   461 //  END OF FILE