mmsharing/mmshavailability/tsrc/ut_availability/src/UT_CMusAvaCapability.cpp
branchRCL_3
changeset 32 73a1feb507fb
parent 0 f0cf47e981f9
child 33 bc78a40cd63c
equal deleted inserted replaced
31:33a5d2bbf6fc 32:73a1feb507fb
    20 #include "UT_CMusAvaCapability.h"
    20 #include "UT_CMusAvaCapability.h"
    21 
    21 
    22 //  EXTERNAL INCLUDES
    22 //  EXTERNAL INCLUDES
    23 #include <digia/eunit/eunitmacros.h>
    23 #include <digia/eunit/eunitmacros.h>
    24 #include <sdpmediafield.h>
    24 #include <sdpmediafield.h>
       
    25 #include <sdpattributefield.h>
    25 
    26 
    26 
    27 
    27 //  INTERNAL INCLUDES
    28 //  INTERNAL INCLUDES
    28 #include "sipprofile.h"
    29 #include "sipprofile.h"
    29 #include "sipconnection.h"
    30 #include "sipconnection.h"
   108     iExchange = iOptionHandler->iCapabilityExchange;
   109     iExchange = iOptionHandler->iCapabilityExchange;
   109     
   110     
   110     iCapability = iOptionHandler->iSwisCapability;
   111     iCapability = iOptionHandler->iSwisCapability;
   111     
   112     
   112     CSipSseTestTls::OpenL();
   113     CSipSseTestTls::OpenL();
   113     
   114     iStorage = CSipSseTestTls::Storage();
       
   115     iStorage->Set( MusSettingsKeys::KFastStartupMode, 
       
   116          MusSettingsKeys::EFastModeOff );
   114     }
   117     }
   115 
   118 
   116 void UT_CMusAvaCapability::Teardown(  )
   119 void UT_CMusAvaCapability::Teardown(  )
   117     {
   120     {
   118     delete iOptionHandler;
   121     delete iOptionHandler;
   119     delete iAvailabilityObserver;
   122     delete iAvailabilityObserver;
   120     delete iConcreteSettings;
   123     delete iConcreteSettings;
   121     CSipSseTestTls::Close();
   124     if ( iStorage )
   122     
   125         {
       
   126         iStorage->Clear();
       
   127         CSipSseTestTls::Close();
       
   128         iStorage = NULL;
       
   129         }
       
   130 
   123     delete iSIPConnection;
   131     delete iSIPConnection;
   124     delete iProfile;
   132     delete iProfile;
   125     delete iSIP;
   133     delete iSIP;
   126 
   134 
   127     }
   135     }
   171                                              KCapabilitySwisFeature,
   179                                              KCapabilitySwisFeature,
   172                                              KCapabilityTestAcceptHeader,
   180                                              KCapabilityTestAcceptHeader,
   173                                              KCapabilityTestTerminalID_B );
   181                                              KCapabilityTestTerminalID_B );
   174     CleanupStack::PushL( options );                                         
   182     CleanupStack::PushL( options );                                         
   175 
   183 
   176     // Test  : AVC enabled => H263 & H264
   184     CSdpDocument* sdpContent = 
   177     TInt32 KMusDisableAVC = 0x0ffffff1; // some value other than disable magic value
   185             CMusAvaCapability::ResponseContentLC( *options );
   178     MultimediaSharingSettings::SetPropertyValueL(MusSettingsKeys::KEncodingDevice,
   186 
   179                                                          KMusDisableAVC );
       
   180     CSdpDocument* sdpContent = CMusAvaCapability::ResponseContentLC( *options );
       
   181     RPointerArray<CSIPHeaderBase> responseHeaders;
   187     RPointerArray<CSIPHeaderBase> responseHeaders;
   182     CSIPHeaderBase::PushLC( &responseHeaders );
   188     CSIPHeaderBase::PushLC( &responseHeaders );
   183 
   189 
   184     iCapability->PopulateResponseL( *options, responseHeaders, *sdpContent );
   190     iCapability->PopulateResponseL( *options, responseHeaders, *sdpContent );
   185 
   191 
   186     EUNIT_ASSERT( responseHeaders.Count() == 1 );
   192     EUNIT_ASSERT( responseHeaders.Count() == 1 );
   187     EUNIT_ASSERT( sdpContent->AttributeFields().Count() == 2 );
   193     EUNIT_ASSERT( sdpContent->AttributeFields().Count() == 2 );
   188     EUNIT_ASSERT( sdpContent->MediaFields().Count() == 1 );
   194     EUNIT_ASSERT( sdpContent->MediaFields().Count() == 1 );
   189     EUNIT_ASSERT( sdpContent->MediaFields()[0]->FormatAttributeFields().Count() == 2 );
   195     EUNIT_ASSERT( sdpContent->MediaFields()[0]->FormatAttributeFields().Count() == 2 );
   190     CleanupStack::PopAndDestroy( &responseHeaders );
   196 
   191     CleanupStack::PopAndDestroy( sdpContent );
       
   192     
       
   193     // Test : AVC disabled => H263
       
   194     KMusDisableAVC = 0x0fffffff; // disable magic value
       
   195     MultimediaSharingSettings::SetPropertyValueL(MusSettingsKeys::KEncodingDevice,
       
   196                                                      KMusDisableAVC );
       
   197     sdpContent = CMusAvaCapability::ResponseContentLC( *options );
       
   198     CSIPHeaderBase::PushLC( &responseHeaders );
       
   199     iCapability->PopulateResponseL( *options, responseHeaders, *sdpContent );
       
   200     EUNIT_ASSERT( responseHeaders.Count() == 1 );
       
   201     EUNIT_ASSERT( sdpContent->AttributeFields().Count() == 2 );
       
   202     EUNIT_ASSERT( sdpContent->MediaFields().Count() == 1 );
       
   203     EUNIT_ASSERT( sdpContent->MediaFields()[0]->FormatAttributeFields().Count() == 1 );
       
   204     CleanupStack::PopAndDestroy( &responseHeaders );
   197     CleanupStack::PopAndDestroy( &responseHeaders );
   205     CleanupStack::PopAndDestroy( sdpContent );
   198     CleanupStack::PopAndDestroy( sdpContent );
   206     CleanupStack::PopAndDestroy( options );
   199     CleanupStack::PopAndDestroy( options );
   207 
   200 
   208     }
   201     }
   214     iOpVariantSetting = MultimediaSharingSettings::OperatorVariantSettingL();
   207     iOpVariantSetting = MultimediaSharingSettings::OperatorVariantSettingL();
   215     iCapabQueryObserver = new ( ELeave ) CMusAvaCapabilityQueryObserverImp();
   208     iCapabQueryObserver = new ( ELeave ) CMusAvaCapabilityQueryObserverImp();
   216     iExchange = CMusAvaCapabilityExchange::NewL( KTestTerminalId, *iCapabQueryObserver );
   209     iExchange = CMusAvaCapabilityExchange::NewL( KTestTerminalId, *iCapabQueryObserver );
   217     iCapability = CMusAvaCapability::NewL( *iExchange );
   210     iCapability = CMusAvaCapability::NewL( *iExchange );
   218     CSipSseTestTls::OpenL();
   211     CSipSseTestTls::OpenL();
       
   212     iStorage = CSipSseTestTls::Storage();
       
   213     iStorage->Set( MusSettingsKeys::KFastStartupMode, 
       
   214          MusSettingsKeys::EFastModeOff );
   219     }
   215     }
   220 
   216 
   221 void UT_CMusAvaCapability::Teardown1(  )
   217 void UT_CMusAvaCapability::Teardown1(  )
   222     {
   218     {
   223     CSipSseTestTls::Close();
   219     if ( iStorage )
       
   220         {
       
   221         iStorage->Clear();
       
   222         CSipSseTestTls::Close();
       
   223         iStorage = NULL;
       
   224         }
   224     delete iCapability;
   225     delete iCapability;
   225     delete iExchange;
   226     delete iExchange;
   226     delete iCapabQueryObserver;     
   227     delete iCapabQueryObserver;     
   227     }   
   228     }   
   228     
   229     
   342     CleanupStack::PopAndDestroy( sdpContent );
   343     CleanupStack::PopAndDestroy( sdpContent );
   343     CleanupStack::PopAndDestroy( options );
   344     CleanupStack::PopAndDestroy( options );
   344     }
   345     }
   345 
   346 
   346 
   347 
       
   348 void UT_CMusAvaCapability::UT_CMusAvaCapability_ResolveFastModeLL()
       
   349     {
       
   350     // Fast mode feature is disabled in cenrep, fast mode is present in SDP
       
   351     CSdpDocument* sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPFastMode );
       
   352     MusSettingsKeys::TFastMode mode = iCapability->ResolveFastModeL( *sdpContent );
       
   353     EUNIT_ASSERT( mode == MusSettingsKeys::EFastModeOff );
       
   354     CleanupStack::PopAndDestroy( sdpContent );
       
   355     
       
   356     // Fast mode feature is enabled in cenrep, fast mode is present in SDP
       
   357     iStorage->Set( MusSettingsKeys::KFastStartupMode, MusSettingsKeys::EFastModeOn );
       
   358     sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDPFastMode );
       
   359     mode = iCapability->ResolveFastModeL( *sdpContent );
       
   360     EUNIT_ASSERT( mode == MusSettingsKeys::EFastModeOn );
       
   361     CleanupStack::PopAndDestroy( sdpContent );
       
   362 
       
   363     // Fast mode feature is enabled in cenrep, fast mode isn't present in SDP
       
   364     sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP );
       
   365     mode = iCapability->ResolveFastModeL( *sdpContent );
       
   366     EUNIT_ASSERT( mode == MusSettingsKeys::EFastModeOff );
       
   367     CleanupStack::PopAndDestroy( sdpContent );
       
   368     }
       
   369 
       
   370 void UT_CMusAvaCapability::UT_CMusAvaCapability_AddFastModeLL()
       
   371     {
       
   372     // Fast mode feature is disabled in cenrep
       
   373     CSdpDocument* sdpContent = CSdpDocument::DecodeLC( KCapabilityTestSDP );
       
   374     EUNIT_ASSERT( sdpContent->AttributeFields().Count() == 2 );
       
   375     iCapability->AddFastModeL( *sdpContent );
       
   376     EUNIT_ASSERT( sdpContent->AttributeFields().Count() == 2 );
       
   377     
       
   378     // Fast mode feature is enabled in cenrep, a=keywds:fastmode added
       
   379     iStorage->Set( MusSettingsKeys::KFastStartupMode, MusSettingsKeys::EFastModeOn );
       
   380     iCapability->AddFastModeL( *sdpContent );
       
   381     EUNIT_ASSERT( sdpContent->AttributeFields().Count() == 3 );
       
   382     const CSdpAttributeField* field = sdpContent->AttributeFields()[2];
       
   383     RStringF keywds = MusAvaCapabilityContext::SDPStringL( 
       
   384             SdpCodecStringConstants::EAttributeKeywds );
       
   385     EUNIT_ASSERT( field->Attribute() == keywds );
       
   386     EUNIT_ASSERT( field->Value().Compare( KCapabilitySDPAttributeFastMode ) == 0 );
       
   387     CleanupStack::PopAndDestroy( sdpContent );
       
   388     }
       
   389 
       
   390 
   347 //  TEST TABLE
   391 //  TEST TABLE
   348 
   392 
   349 EUNIT_BEGIN_TEST_TABLE(
   393 EUNIT_BEGIN_TEST_TABLE(
   350     UT_CMusAvaCapability,
   394     UT_CMusAvaCapability,
   351     "CMusAvaCapability",
   395     "CMusAvaCapability",
   390     "PopulateResponseL Operator Specific - test ",
   434     "PopulateResponseL Operator Specific - test ",
   391     "CMusAvaCapability",
   435     "CMusAvaCapability",
   392     "PopulateResponseL",
   436     "PopulateResponseL",
   393     "FUNCTIONALITY",
   437     "FUNCTIONALITY",
   394     Setup1L, UT_CMusAvaCapability_PopulateResponseL_OpSpecificL, Teardown1 )         
   438     Setup1L, UT_CMusAvaCapability_PopulateResponseL_OpSpecificL, Teardown1 )         
   395     
   439    
       
   440 EUNIT_TEST(
       
   441     "ResolveFastModeL - test ",
       
   442     "CMusAvaCapability",
       
   443     "ResolveFastModeL",
       
   444     "FUNCTIONALITY",
       
   445     SetupL, UT_CMusAvaCapability_ResolveFastModeLL, Teardown)
       
   446     
       
   447 EUNIT_TEST(
       
   448     "AddFastModeL - test ",
       
   449     "CMusAvaCapability",
       
   450     "AddFastModeL",
       
   451     "FUNCTIONALITY",
       
   452     SetupL, UT_CMusAvaCapability_AddFastModeLL, Teardown)
   396 
   453 
   397 EUNIT_END_TEST_TABLE
   454 EUNIT_END_TEST_TABLE
   398 
   455 
   399 //  END OF FILE
   456 //  END OF FILE