mmsharing/mmshengine/tsrc/ut_engine/src/ut_musengmceutils.cpp
branchRCL_3
changeset 22 73a1feb507fb
parent 0 f0cf47e981f9
child 23 bc78a40cd63c
--- a/mmsharing/mmshengine/tsrc/ut_engine/src/ut_musengmceutils.cpp	Thu Aug 19 09:51:39 2010 +0300
+++ b/mmsharing/mmshengine/tsrc/ut_engine/src/ut_musengmceutils.cpp	Tue Aug 31 15:12:07 2010 +0300
@@ -97,16 +97,6 @@
     CEUnitTestSuiteClass::ConstructL();
     }
 
-    
-// -----------------------------------------------------------------------------
-// From MMusSipProfileUser
-// -----------------------------------------------------------------------------
-//
-TBool UT_MusEngMceUtils::IsRoamingBetweenAPsAllowed()
-    {
-    return ETrue; // Dummy implementation
-    }
-
 
 // -----------------------------------------------------------------------------
 //
@@ -115,7 +105,9 @@
 void UT_MusEngMceUtils::SetupL()
     {
     iManager = CMceManager::NewL( TUid::Null(), NULL );
-    iProfileHandler = CMusSipProfileHandler::NewL( *this );
+    iObserver = new( ELeave ) CMusEngObserverStub;
+    iObserver->iRoamingBetweenAPsAllowed = ETrue;
+    iProfileHandler = CMusSipProfileHandler::NewL( *iObserver );
     
     iProfileHandler->CreateProfileL( KSipProfileId );
     iEmptySession = CMceOutSession::NewL( *iManager, 
@@ -162,8 +154,10 @@
     // Video part
     CMceVideoStream* videoIn  = CMceVideoStream::NewLC();
     
-    videoIn->AddSinkL( CMceDisplaySink::NewLC( *iManager ) );
+    CMceDisplaySink* receivingDisplay = CMceDisplaySink::NewLC( *iManager );
+    videoIn->AddSinkL( receivingDisplay );
     CleanupStack::Pop();
+    iReceivingDisplay = receivingDisplay;
     
     videoIn->SetSourceL( CMceRtpSource::NewLC() );
     CleanupStack::Pop();
@@ -172,6 +166,56 @@
     CleanupStack::Pop( videoIn );
     }
 
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void UT_MusEngMceUtils::Setup2L()
+    {
+    iManager = CMceManager::NewL( TUid::Null(), NULL );
+    iObserver = new( ELeave ) CMusEngObserverStub;
+    iObserver->iRoamingBetweenAPsAllowed = ETrue;
+    iProfileHandler = CMusSipProfileHandler::NewL( *iObserver );
+    
+    iProfileHandler->CreateProfileL( KSipProfileId );
+    iEmptySession = CMceOutSession::NewL( *iManager, 
+                                          *iProfileHandler->Profile(),
+                                          KTestRecipientSipUri8() );
+    
+    // Contruct an outgoing video sesssion                                 
+    iVideoOutSession = CMceOutSession::NewL( *iManager,
+                                             *iProfileHandler->Profile(),
+                                             KTestRecipientSipUri8() );
+    
+    
+    CMceVideoStream* videoOut = CMceVideoStream::NewLC();
+    
+    videoOut->AddSinkL( CMceRtpSink::NewLC() );
+    CleanupStack::Pop();
+    
+    videoOut->AddSinkL( CMceDisplaySink::NewLC( *iManager ) );
+    CleanupStack::Pop();
+    
+    videoOut->SetSourceL( CMceCameraSource::NewLC( *iManager ) );
+    CleanupStack::Pop();
+    
+    // Video part
+    CMceVideoStream* videoIn  = CMceVideoStream::NewLC();
+    
+    CMceDisplaySink* receivingDisplay = CMceDisplaySink::NewLC( *iManager );
+    videoIn->AddSinkL( receivingDisplay );
+    CleanupStack::Pop();
+    iReceivingDisplay = receivingDisplay;
+    
+    videoIn->SetSourceL( CMceRtpSource::NewLC() );
+    CleanupStack::Pop();
+    
+    videoOut->BindL( videoIn );
+    CleanupStack::Pop( videoIn );
+    
+    iVideoOutSession->AddStreamL( videoOut );
+    CleanupStack::Pop( videoOut );
+    }
 
 // -----------------------------------------------------------------------------
 //
@@ -182,8 +226,11 @@
     delete iEmptySession;
     delete iVideoOutSession;
     delete iVideoInSession;
+    iVideoInSession = NULL;
     delete iProfileHandler;
+    delete iObserver;
     delete iManager;
+    iReceivingDisplay = NULL; // Not owned
     }
 
 
@@ -196,7 +243,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_IsVideoInStreamL()
+void UT_MusEngMceUtils::UT_IsVideoInStreamL()
     {
     // Stream 0 is audio stream
     EUNIT_ASSERT( !MusEngMceUtils::IsVideoInStream( 
@@ -221,7 +268,31 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_IsAudioInStreamL()
+void UT_MusEngMceUtils::UT_IsVideoOutStreamL()
+    {
+    // Stream 0 is audio stream
+    EUNIT_ASSERT( !MusEngMceUtils::IsVideoOutStream( 
+                                        *iVideoInSession->Streams()[0] ) )
+    
+    // No sink
+    CMceVideoStream* videoStream = CMceVideoStream::NewLC();
+    EUNIT_ASSERT( !MusEngMceUtils::IsVideoOutStream( *videoStream ) )
+    CleanupStack::PopAndDestroy( videoStream );
+    
+    // display sink
+    EUNIT_ASSERT( !MusEngMceUtils::IsVideoOutStream( 
+                                        *iVideoInSession->Streams()[1] ) )
+                                        
+    // Video outstream
+    EUNIT_ASSERT( MusEngMceUtils::IsVideoOutStream( 
+                                        *iVideoOutSession->Streams()[0] ) )
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void UT_MusEngMceUtils::UT_IsAudioInStreamL()
     {
     // Stream 0 is video stream
     EUNIT_ASSERT( !MusEngMceUtils::IsAudioInStream( 
@@ -248,7 +319,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetVideoOutStreamLL()
+void UT_MusEngMceUtils::UT_GetVideoOutStreamLL()
     {
     // No streams, must fail
     EUNIT_ASSERT_SPECIFIC_LEAVE(
@@ -273,15 +344,30 @@
                 MusEngMceUtils::GetVideoOutStreamL( *iVideoInSession ),
                 KErrNotFound )
     
-    // One outgoing video stream, succeeds
+    // One incoming video stream with bound outstream, must find bound stream
+    CMceVideoStream* boundVideoOut = CMceVideoStream::NewLC();
+    boundVideoOut->AddSinkL( CMceRtpSink::NewLC() );
+    CleanupStack::Pop();
+    boundVideoOut->SetSourceL( CMceCameraSource::NewLC( *iManager ) );
+    CleanupStack::Pop();
+    reinterpret_cast<CMceVideoStream*>( 
+            iVideoInSession->Streams()[ 1 ] )->BindL( boundVideoOut );
+    CleanupStack::Pop( boundVideoOut );
     CMceVideoStream* videoStream = MusEngMceUtils::GetVideoOutStreamL( 
-                                                        *iVideoOutSession );
+                                                    *iVideoInSession );
+    EUNIT_ASSERT( videoStream )
+    EUNIT_ASSERT( videoStream->Type() == KMceVideo )
+    EUNIT_ASSERT( videoStream->Sinks().Count() == 1 ) // Rtp
+    EUNIT_ASSERT( videoStream->Sinks()[0]->Type() == KMceRTPSink )
+
+    // One outgoing video stream, succeeds
+    videoStream = MusEngMceUtils::GetVideoOutStreamL( *iVideoOutSession );
     EUNIT_ASSERT( videoStream )
     EUNIT_ASSERT( videoStream->Type() == KMceVideo )
     EUNIT_ASSERT( videoStream->Sinks().Count() == 2 ) // Rtp, Display
     EUNIT_ASSERT( videoStream->Sinks()[0]->Type() == KMceRTPSink )
     EUNIT_ASSERT( videoStream->Sinks()[1]->Type() == KMceDisplaySink )
-    
+        
     // Add another stream
     CMceVideoStream* videoOut = CMceVideoStream::NewLC();
     
@@ -306,7 +392,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetVideoInStreamLL()
+void UT_MusEngMceUtils::UT_GetVideoInStreamLL()
     {
     // No streams, must fail
     EUNIT_ASSERT_SPECIFIC_LEAVE( 
@@ -362,7 +448,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetRecordingStreamL()
+void UT_MusEngMceUtils::UT_GetRecordingStreamL()
     {
     CMceVideoStream* recordingStream = 
                         MusEngMceUtils::GetRecordingStream( *iVideoInSession );
@@ -392,7 +478,7 @@
 // From stream
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetMediaSinkL()
+void UT_MusEngMceUtils::UT_GetMediaSinkFromStreamL()
     {    
     CMceMediaSink* sink = MusEngMceUtils::GetMediaSink( 
                                             *(iVideoInSession->Streams()[0]), 
@@ -412,7 +498,7 @@
 // From stream
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetMediaSinkLL()
+void UT_MusEngMceUtils::UT_GetMediaSinkLFromStreamL()
     {                                                      
     CMceMediaSink* sink = NULL;
     EUNIT_ASSERT_SPECIFIC_LEAVE(
@@ -430,7 +516,7 @@
 // From session
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetMediaSink2L()
+void UT_MusEngMceUtils::UT_GetMediaSinkFromSessionL()
     {
     CMceMediaSink* sink = MusEngMceUtils::GetMediaSink( *iEmptySession, 
                                                         KMceRTPSink );
@@ -447,7 +533,7 @@
 // From session
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetMediaSinkL2L()
+void UT_MusEngMceUtils::UT_GetMediaSinkLFromSessionL()
     {
     CMceMediaSink* sink = NULL;
     EUNIT_ASSERT_SPECIFIC_LEAVE( MusEngMceUtils::GetMediaSinkL( *iEmptySession, 
@@ -463,7 +549,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetCameraLL()
+void UT_MusEngMceUtils::UT_GetCameraLL()
     {
     // empty session fails
     EUNIT_ASSERT_SPECIFIC_LEAVE( MusEngMceUtils::GetCameraL( *iEmptySession ),
@@ -497,7 +583,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetFileSourceLL()
+void UT_MusEngMceUtils::UT_GetFileSourceLL()
     {
     // empty session fails
     EUNIT_ASSERT_SPECIFIC_LEAVE( 
@@ -538,7 +624,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetDisplayL()
+void UT_MusEngMceUtils::UT_GetDisplayL()
     {
     CMceDisplaySink* display = MusEngMceUtils::GetDisplay( *iEmptySession );
     
@@ -555,7 +641,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_GetDisplayLL()
+void UT_MusEngMceUtils::UT_GetDisplayLL()
     {
     CMceDisplaySink* display = NULL;
     
@@ -573,7 +659,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_AddDisplayLL()
+void UT_MusEngMceUtils::UT_AddDisplayLL()
     {
    
     TRect rect( 110, 111, 112, 113 );
@@ -617,6 +703,14 @@
     EUNIT_ASSERT_EQUALS( display->DisplayRectL(), newRect );
     
     CleanupStack::PopAndDestroy( videoStream );
+    
+    // Add disabled display
+    CMceVideoStream* videoStream2 = CMceVideoStream::NewLC();
+    MusEngMceUtils::AddDisplayL( *videoStream2, *iManager, rect, ETrue );
+    EUNIT_ASSERT_EQUALS( videoStream2->Sinks().Count(), 1 )
+    EUNIT_ASSERT_EQUALS( videoStream2->Sinks()[0]->Type(), KMceDisplaySink )
+    EUNIT_ASSERT( !videoStream2->Sinks()[0]->IsEnabled() );
+    CleanupStack::PopAndDestroy( videoStream2 );
     }
 
 
@@ -624,7 +718,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_AddSpeakerLL()
+void UT_MusEngMceUtils::UT_AddSpeakerLL()
     {
     // Check that speaker cannot be added to video stream
     
@@ -666,7 +760,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void UT_MusEngMceUtils::UT_MusEngMceUtils_DisableStreamLL()
+void UT_MusEngMceUtils::UT_DisableStreamLL()
     {
     CMceAudioStream* audioStream = CMceAudioStream::NewLC();
 
@@ -707,8 +801,72 @@
     CleanupStack::PopAndDestroy( audioStream );
     }
 
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void UT_MusEngMceUtils::UT_GetReceivingDisplayL()
+    {
+    CMceDisplaySink* display = MusEngMceUtils::GetReceivingDisplay( *iEmptySession );
+    
+    EUNIT_ASSERT( !display )
+    
+    display = MusEngMceUtils::GetReceivingDisplay( *iVideoOutSession );
+    
+    EUNIT_ASSERT( display )
+    EUNIT_ASSERT( display->Type() == KMceDisplaySink )
+    EUNIT_ASSERT( display == iReceivingDisplay )
+    }  
 
 
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void UT_MusEngMceUtils::UT_GetReceivingDisplayLL()
+    {
+    CMceDisplaySink* display = NULL;
+    
+    EUNIT_ASSERT_SPECIFIC_LEAVE( MusEngMceUtils::GetReceivingDisplayL( *iEmptySession ),
+                                 KErrNotFound )
+    
+    display = MusEngMceUtils::GetReceivingDisplayL( *iVideoOutSession );
+    
+    EUNIT_ASSERT( display )
+    EUNIT_ASSERT( display->Type() == KMceDisplaySink )
+    EUNIT_ASSERT( display == iReceivingDisplay )
+    }  
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void UT_MusEngMceUtils::UT_GetVfDisplayL()
+    {
+    CMceDisplaySink* display = MusEngMceUtils::GetVfDisplay( *iEmptySession );
+    
+    EUNIT_ASSERT( !display )
+    
+    display = MusEngMceUtils::GetVfDisplay( *iVideoOutSession );
+    
+    EUNIT_ASSERT( display )
+    EUNIT_ASSERT( display->Type() == KMceDisplaySink )
+    EUNIT_ASSERT( display != iReceivingDisplay )
+    } 
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void UT_MusEngMceUtils::UT_EnableInactivityTimerL()
+    {
+    // Instream not found, nothing is done
+    EUNIT_ASSERT_EQUALS( MusEngMceUtils::EnableInactivityTimer( *iEmptySession, 1000 ), KErrNotFound );
+
+    // In stream found
+    EUNIT_ASSERT_EQUALS( MusEngMceUtils::EnableInactivityTimer( *iVideoOutSession, 1000 ), KErrNone );
+    } 
+
 //  TEST TABLE
 
 EUNIT_BEGIN_TEST_TABLE(
@@ -721,113 +879,147 @@
     "MusEngMceUtils",
     "IsVideoInStream",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_IsVideoInStreamL, Teardown)
+    SetupL, UT_IsVideoInStreamL, Teardown)
 
 EUNIT_TEST(
+    "IsVideoOutStream - test ",
+    "MusEngMceUtils",
+    "IsVideoOutStream",
+    "FUNCTIONALITY",
+    SetupL, UT_IsVideoOutStreamL, Teardown)
+    
+EUNIT_TEST(
     "IsAudioInStream - test ",
     "MusEngMceUtils",
     "IsAudioInStream",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_IsAudioInStreamL, Teardown)
+    SetupL, UT_IsAudioInStreamL, Teardown)
 
 EUNIT_TEST(
     "GetVideoOutStreamL - test ",
     "MusEngMceUtils",
     "GetVideoOutStreamL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetVideoOutStreamLL, Teardown)
+    SetupL, UT_GetVideoOutStreamLL, Teardown)
 
 EUNIT_TEST(
     "GetVideoInStreamL - test ",
     "MusEngMceUtils",
     "GetVideoInStreamL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetVideoInStreamLL, Teardown)
+    SetupL, UT_GetVideoInStreamLL, Teardown)
 
 EUNIT_TEST(
     "GetRecordingStream - test ",
     "MusEngMceUtils",
     "GetRecordingStream",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetRecordingStreamL, Teardown)
+    SetupL, UT_GetRecordingStreamL, Teardown)
 
 EUNIT_TEST(
     "GetMediaSink - test ",
     "MusEngMceUtils",
     "GetMediaSink",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetMediaSinkL, Teardown)
+    SetupL, UT_GetMediaSinkFromStreamL, Teardown)
 
 EUNIT_TEST(
     "GetMediaSinkL - test ",
     "MusEngMceUtils",
     "GetMediaSinkL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetMediaSinkLL, Teardown)
+    SetupL, UT_GetMediaSinkLFromStreamL, Teardown)
 
 EUNIT_TEST(
     "GetMediaSink2 - test ",
     "MusEngMceUtils",
     "GetMediaSink2",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetMediaSink2L, Teardown)
+    SetupL, UT_GetMediaSinkFromSessionL, Teardown)
 
 EUNIT_TEST(
     "GetMediaSinkL2 - test ",
     "MusEngMceUtils",
     "GetMediaSinkL2",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetMediaSinkL2L, Teardown)
+    SetupL, UT_GetMediaSinkLFromSessionL, Teardown)
 
 EUNIT_TEST(
     "GetCameraL - test ",
     "MusEngMceUtils",
     "GetCameraL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetCameraLL, Teardown)
+    SetupL, UT_GetCameraLL, Teardown)
 
 EUNIT_TEST(
     "GetFileSourceL - test ",
     "MusEngMceUtils",
     "GetFileSourceL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetFileSourceLL, Teardown)
+    SetupL, UT_GetFileSourceLL, Teardown)
 
 EUNIT_TEST(
     "GetDisplay - test ",
     "MusEngMceUtils",
     "GetDisplay",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetDisplayL, Teardown)
+    SetupL, UT_GetDisplayL, Teardown)
 
 EUNIT_TEST(
     "GetDisplayL - test ",
     "MusEngMceUtils",
     "GetDisplayL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_GetDisplayLL, Teardown)
+    SetupL, UT_GetDisplayLL, Teardown)
 
 EUNIT_TEST(
     "AddDisplayL - test ",
     "MusEngMceUtils",
     "AddDisplayL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_AddDisplayLL, Teardown)
+    SetupL, UT_AddDisplayLL, Teardown)
 
 EUNIT_TEST(
     "AddSpeakerL - test ",
     "MusEngMceUtils",
     "AddSpeakerL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_AddSpeakerLL, Teardown)    
+    SetupL, UT_AddSpeakerLL, Teardown)    
 
 EUNIT_TEST(
     "DisableStreamL - test ",
     "MusEngMceUtils",
     "DisableStreamL",
     "FUNCTIONALITY",
-    SetupL, UT_MusEngMceUtils_DisableStreamLL, Teardown)        
+    SetupL, UT_DisableStreamLL, Teardown)        
+
+EUNIT_TEST(
+    "GetReceivingDisplay - test ",
+    "MusEngMceUtils",
+    "GetReceivingDisplay",
+    "FUNCTIONALITY",
+    Setup2L, UT_GetReceivingDisplayL, Teardown)
 
+EUNIT_TEST(
+    "GetReceivingDisplayL - test ",
+    "MusEngMceUtils",
+    "GetReceivingDisplayL",
+    "FUNCTIONALITY",
+    Setup2L, UT_GetReceivingDisplayLL, Teardown)
+    
+EUNIT_TEST(
+    "GetVfDisplay - test ",
+    "MusEngMceUtils",
+    "GetVfDisplay",
+    "FUNCTIONALITY",
+    Setup2L, UT_GetVfDisplayL, Teardown)
+
+EUNIT_TEST(
+    "EnableInactivityTimer - test ",
+    "MusEngMceUtils",
+    "EnableInactivityTimer",
+    "FUNCTIONALITY",
+    Setup2L, UT_EnableInactivityTimerL, Teardown)
     
 EUNIT_END_TEST_TABLE