mmshplugins/mmshsipcrplugin/tsrc/ut_sipcrplugin/src/mussipcrplugintest.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
    13 *
    13 *
    14 * Description:  Main plugin class
    14 * Description:  Main plugin class
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 #include <sipstrings.h>
    19 #include "musunittesting.h"
    19 #include "musunittesting.h"
    20 #include "musmanagerstub.h"
    20 #include "musmanagerstub.h"
    21 #include "mussipcrplugin.h"
    21 #include "mussipcrplugin.h"
    22 #include "mussipcrplugintest.h"
    22 #include "mussipcrplugintest.h"
    23 #include "muslogger.h" 
    23 #include "muslogger.h" 
    24 #include "musmanager.h"
    24 #include "musmanager.h"
    25 #include "mussettings.h"
       
    26 
    25 
    27 #include <alwaysonlinemanagercommon.h>
    26 #include <alwaysonlinemanagercommon.h>
    28 #include <alwaysonlinemanagerclient.h>
    27 #include <alwaysonlinemanagerclient.h>
    29 #include <digia/eunit/eunitmacros.h>
    28 #include <digia/eunit/eunitmacros.h>
    30 #include <SipResolvedClient.h>    
    29 #include <SipResolvedClient.h>    
    31 #include <sipstrings.h>
       
    32 #include <sipstrconsts.h>
    30 #include <sipstrconsts.h>
    33 #include <SdpCodecStringPool.h>
    31 #include "FeatMgr.h"
    34 #include <sdpdocument.h>
    32 
    35 
    33 
    36 // Next row is to disable warning emerging from EUnit code.
    34 // Next row is to disable warning emerging from EUnit code.
    37 #pragma warn_illtokenpasting off
    35 #pragma warn_illtokenpasting off
    38 
       
    39 _LIT8( KSdpSendOnly, "v=0\r\n\
       
    40 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\
       
    41 s=-\r\n\
       
    42 c=IN IP4 10.0.0.6\r\n\
       
    43 t=0 0\r\n\
       
    44 m=video 49152 RTP/AVP 98\r\n\
       
    45 a=sendonly\r\n\
       
    46 a=rtpmap:98 H264/90000\r\n" );
       
    47 
       
    48 _LIT8( KSdpSendRecv, "v=0\r\n\
       
    49 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\
       
    50 s=-\r\n\
       
    51 c=IN IP4 10.0.0.6\r\n\
       
    52 t=0 0\r\n\
       
    53 m=video 49152 RTP/AVP 98\r\n\
       
    54 a=sendrecv\r\n\
       
    55 a=rtpmap:98 H264/90000\r\n" );
       
    56 
       
    57 _LIT8( KSdpNoMedia, "v=0\r\n\
       
    58 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\
       
    59 s=-\r\n\
       
    60 c=IN IP4 10.0.0.6\r\n\
       
    61 t=0 0\r\n" );
       
    62 
       
    63 _LIT8( KSdpNoVideo, "v=0\r\n\
       
    64 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\
       
    65 s=-\r\n\
       
    66 c=IN IP4 10.0.0.6\r\n\
       
    67 t=0 0\r\n\
       
    68 m=audio 5000 RTP/AVP 106 8 0\r\n\
       
    69 a=sendrecv\r\n\
       
    70 a=rtpmap:106 AMR/8000\r\n" );
       
    71 
       
    72 _LIT8( KSdpVideoNoAttributes, "v=0\r\n\
       
    73 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\
       
    74 s=-\r\n\
       
    75 c=IN IP4 10.0.0.6\r\n\
       
    76 t=0 0\r\n\
       
    77 m=video 49152 RTP/AVP 98\r\n" );
       
    78 
       
    79 _LIT8( KSdpRecvOnly, "v=0\r\n\
       
    80 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\
       
    81 s=-\r\n\
       
    82 c=IN IP4 10.0.0.6\r\n\
       
    83 t=0 0\r\n\
       
    84 m=video 49152 RTP/AVP 98\r\n\
       
    85 a=recvonly\r\n\
       
    86 a=rtpmap:98 H264/90000\r\n" );
       
    87 
    36 
    88 
    37 
    89 // --------------------------------------------------------------------------
    38 // --------------------------------------------------------------------------
    90 // C++ constructor.
    39 // C++ constructor.
    91 // --------------------------------------------------------------------------
    40 // --------------------------------------------------------------------------
   138 // --------------------------------------------------------------------------
    87 // --------------------------------------------------------------------------
   139 //     
    88 //     
   140 void CMusSipCrPluginTest::SetupL(  )
    89 void CMusSipCrPluginTest::SetupL(  )
   141     {
    90     {
   142     iPlugin = CMusSipCrPlugin::NewL();
    91     iPlugin = CMusSipCrPlugin::NewL();
       
    92     }
       
    93 
       
    94 
       
    95 // --------------------------------------------------------------------------
       
    96 // 
       
    97 // --------------------------------------------------------------------------
       
    98 // 
       
    99 void CMusSipCrPluginTest::Teardown(  )
       
   100     {
       
   101     delete iPlugin;
       
   102     }
       
   103 
       
   104 
       
   105 
       
   106 // ------------------------- Test functions begin ---------------------------
       
   107 
       
   108 
       
   109 // --------------------------------------------------------------------------
       
   110 // 
       
   111 // --------------------------------------------------------------------------
       
   112 // 
       
   113 void CMusSipCrPluginTest::UT_ChannelL()
       
   114     {
   143     SIPStrings::OpenL();
   115     SIPStrings::OpenL();
   144     }
   116     
   145 
       
   146 
       
   147 // --------------------------------------------------------------------------
       
   148 // 
       
   149 // --------------------------------------------------------------------------
       
   150 // 
       
   151 void CMusSipCrPluginTest::Teardown(  )
       
   152     {
       
   153     SIPStrings::Close();
       
   154     delete iPlugin;
       
   155     }
       
   156 
       
   157 
       
   158 
       
   159 // ------------------------- Test functions begin ---------------------------
       
   160 
       
   161 // --------------------------------------------------------------------------
       
   162 // 
       
   163 // --------------------------------------------------------------------------
       
   164 // 
       
   165 void CMusSipCrPluginTest::UT_ConstructL()
       
   166     {
       
   167     // 1. String pool was opend by us
       
   168     EUNIT_ASSERT( iPlugin->iCloseStringPool );
       
   169         
       
   170     // 2. String pool was already opened by someone else, KErrAlreadyExists
       
   171     delete iPlugin;
       
   172     iPlugin = NULL;
       
   173     SdpCodecStringPool::OpenL();
       
   174     TRAPD( err, iPlugin = CMusSipCrPlugin::NewL() );
       
   175     if ( err != KErrNone )
       
   176         {
       
   177         SdpCodecStringPool::Close();
       
   178         User::Leave(err);
       
   179         }
       
   180     EUNIT_ASSERT( !iPlugin->iCloseStringPool );
       
   181     SdpCodecStringPool::Close();    
       
   182     }
       
   183 
       
   184 
       
   185 // --------------------------------------------------------------------------
       
   186 // 
       
   187 // --------------------------------------------------------------------------
       
   188 // 
       
   189 void CMusSipCrPluginTest::UT_ChannelL()
       
   190     {
       
   191     RPointerArray<CSIPHeaderBase> array;
   117     RPointerArray<CSIPHeaderBase> array;
   192     
   118     
   193     TUid response;
   119     TUid response;
   194     
   120     
   195     // Options
   121     // Options
   200                        KNullDesC8(),
   126                        KNullDesC8(),
   201                        NULL );
   127                        NULL );
   202 
   128 
   203     EUNIT_ASSERT( response.iUid == CMusManager::ESipOptions )
   129     EUNIT_ASSERT( response.iUid == CMusManager::ESipOptions )
   204 
   130 
   205     // Everything is OK, 2-way video not supported
   131     // Everything is OK
   206     CMusManager::SetAvailability( 
   132     CMusManager::SetAvailability( 
   207                  ( MultimediaSharing::TMusAvailabilityStatus ) KErrNone );
   133                  ( MultimediaSharing::TMusAvailabilityStatus ) KErrNone );
   208     
   134     
   209     response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ),
   135     response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ),
   210                        KNullDesC8(),
   136                        KNullDesC8(),
   234                        array,
   160                        array,
   235                        KNullDesC8(),
   161                        KNullDesC8(),
   236                        NULL );
   162                        NULL );
   237     
   163     
   238     EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired )
   164     EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired )
   239        
   165     //Feature Manager testing
   240     // 2-way video is supported and sendrecv not present in SDP    
   166     FeatureManager::MultimediaSharingNotSupported();
   241     MultimediaSharingSettings::iVideoDirection = MusSettingsKeys::ETwoWayVideo;    
   167     response = iPlugin->ChannelL( 
       
   168     		           SIPStrings::StringF( SipStrConsts::EOptions ),
       
   169                        KNullDesC8(),
       
   170                        array,
       
   171                        KNullDesC8(),
       
   172                        NULL );
       
   173 
       
   174     EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired )
       
   175     // Everything is OK
   242     CMusManager::SetAvailability( 
   176     CMusManager::SetAvailability( 
   243                  ( MultimediaSharing::TMusAvailabilityStatus ) KErrNone );
   177                  ( MultimediaSharing::TMusAvailabilityStatus ) KErrNone );
   244 
   178     
   245     response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ),
   179     response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ),
   246                        KNullDesC8(),
   180                        KNullDesC8(),
   247                        array,
   181                        array,
   248                        KSdpSendOnly(),
   182                        KNullDesC8(),
   249                        NULL );
   183                        NULL );
   250 
   184     
   251     EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteDesired )
   185     EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired )
   252     
   186     
   253     // 2-way video is supported and sendrecv is present in SDP    
   187     // Server is shut down                     
   254     response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ),
   188     CMusManager::SetAvailability( MultimediaSharing::EErrServerShutDown );
   255                        KNullDesC8(),
   189     
   256                        array,
   190     response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ),
   257                        KSdpSendRecv(),
   191                        KNullDesC8(),
   258                        NULL );
   192                        array,
   259         
   193                        KNullDesC8(),
   260     EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteDesired2WayVideo )
   194                        NULL );
       
   195 
       
   196     EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired )
       
   197 
       
   198     // Mus is not supported
       
   199     CMusManager::SetAvailability(
       
   200             ( MultimediaSharing::TMusAvailabilityStatus ) KErrNotSupported );
       
   201     
       
   202     response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ),
       
   203                        KNullDesC8(),
       
   204                        array,
       
   205                        KNullDesC8(),
       
   206                        NULL );
       
   207     
       
   208     EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired )
       
   209     FeatureManager::MultimediaSharingSupported();  
       
   210     SIPStrings::Close();                       
       
   211                         
   261     }
   212     }
   262 
   213 
   263 
   214 
   264 // --------------------------------------------------------------------------
   215 // --------------------------------------------------------------------------
   265 // 
   216 // 
   316     
   267     
   317     ImplementationGroupProxy( tableCount );
   268     ImplementationGroupProxy( tableCount );
   318     }
   269     }
   319 
   270 
   320 
   271 
   321 // --------------------------------------------------------------------------
       
   322 // 
       
   323 // --------------------------------------------------------------------------
       
   324 // 
       
   325 void CMusSipCrPluginTest::UT_CheckForSendRecvAttributeL()
       
   326     {
       
   327     CSdpDocument* sdpDocument;
       
   328     TBool sendRecv;
       
   329     
       
   330     // 1. SDP doesn't have a single media field
       
   331     sdpDocument = CSdpDocument::DecodeLC( KSdpNoMedia() );
       
   332     sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() );
       
   333     CleanupStack::PopAndDestroy( sdpDocument );
       
   334     EUNIT_ASSERT( !sendRecv );
       
   335     
       
   336     // 2. SDP has audio field, but no video
       
   337     sdpDocument = CSdpDocument::DecodeLC( KSdpNoVideo() );
       
   338     sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() );
       
   339     CleanupStack::PopAndDestroy( sdpDocument );
       
   340     EUNIT_ASSERT( !sendRecv );
       
   341     
       
   342     // 3. SDP has video field without any attributes
       
   343     sdpDocument = CSdpDocument::DecodeLC( KSdpVideoNoAttributes() );
       
   344     sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() );
       
   345     CleanupStack::PopAndDestroy( sdpDocument );
       
   346     EUNIT_ASSERT( sendRecv );
       
   347         
       
   348     // 4. SDP has video with "sendrecv" attribute
       
   349     sdpDocument = CSdpDocument::DecodeLC( KSdpSendRecv() );
       
   350     sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() );
       
   351     CleanupStack::PopAndDestroy( sdpDocument );
       
   352     EUNIT_ASSERT( sendRecv );    
       
   353     
       
   354     // 5. SDP has video with "recvonly" attribute
       
   355     sdpDocument = CSdpDocument::DecodeLC( KSdpRecvOnly() );
       
   356     sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() );
       
   357     CleanupStack::PopAndDestroy( sdpDocument );
       
   358     EUNIT_ASSERT( !sendRecv );
       
   359     }
       
   360 
   272 
   361 
   273 
   362 //  TEST TABLE
   274 //  TEST TABLE
   363 
   275 
   364 EUNIT_BEGIN_TEST_TABLE(
   276 EUNIT_BEGIN_TEST_TABLE(
   365     CMusSipCrPluginTest,
   277     CMusSipCrPluginTest,
   366     "CMusSipCrPluginTest",
   278     "CMusSipCrPluginTest",
   367     "CMusSipCrPluginTest" )
   279     "CMusSipCrPluginTest" )
   368    
       
   369 EUNIT_TEST(
       
   370     "ConstructL - test",
       
   371     "CMusSipCrPluginTest",
       
   372     "UT_ConstructL",
       
   373     "FUNCTIONALITY",
       
   374     SetupL, UT_ConstructL, Teardown)
       
   375 
   280 
   376 EUNIT_TEST(
   281 EUNIT_TEST(
   377     "CMusSipCrPluginTest",
   282     "CMusSipCrPluginTest",
   378     "CMusSipCrPluginTest",
   283     "CMusSipCrPluginTest",
   379     "ConnectL",
   284     "ConnectL",
   399     "CMusSipCrPluginTest",
   304     "CMusSipCrPluginTest",
   400     "ImplementationGroupProxyTest",
   305     "ImplementationGroupProxyTest",
   401     "FUNCTIONALITY",
   306     "FUNCTIONALITY",
   402     SetupL, UT_ImplementationGroupProxy, Teardown)
   307     SetupL, UT_ImplementationGroupProxy, Teardown)
   403     
   308     
   404 EUNIT_TEST(
       
   405     "CheckForSendRecvAttribute - stest",
       
   406     "CMusSipCrPluginTest",
       
   407     "UT_CheckForSendRecvAttribute",
       
   408     "FUNCTIONALITY",
       
   409     SetupL, UT_CheckForSendRecvAttributeL, Teardown)
       
   410     
       
   411 EUNIT_END_TEST_TABLE
   309 EUNIT_END_TEST_TABLE
   412 
   310