276 // |
296 // |
277 void UT_CMusEngReceiveSession::UT_NewLL( ) |
297 void UT_CMusEngReceiveSession::UT_NewLL( ) |
278 { |
298 { |
279 EUNIT_ASSERT( iReceiveSession ); |
299 EUNIT_ASSERT( iReceiveSession ); |
280 EUNIT_ASSERT( !iReceiveSession->iSession ); |
300 EUNIT_ASSERT( !iReceiveSession->iSession ); |
281 } |
301 EUNIT_ASSERT( iReceiveSession->iMceManagerUid == TUid::Uid( KMusUiUid ) ); |
282 |
302 } |
283 |
303 |
284 // ----------------------------------------------------------------------------- |
304 // ----------------------------------------------------------------------------- |
285 // |
305 // |
286 // ----------------------------------------------------------------------------- |
306 // ----------------------------------------------------------------------------- |
287 // |
307 // |
288 void UT_CMusEngReceiveSession::UT_AcceptInvitationLL() |
308 void UT_CMusEngReceiveSession::UT_LcSessionStateL() |
289 { |
309 { |
|
310 // No MCE session -> Convert to MLcSession::EReceived |
|
311 EUNIT_ASSERT_EQUALS( TInt( MLcSession::EReceived ), |
|
312 TInt( iReceiveSession->LcSessionState() ) ) |
|
313 |
|
314 // Some other state -> State returned from the base class |
290 TMceTransactionDataContainer container; |
315 TMceTransactionDataContainer container; |
291 |
|
292 // There is no pending session to accept, must fail |
|
293 TRAPD( error, iReceiveSession->AcceptInvitationL( ETrue ) ); |
|
294 MUS_TEST_FORWARD_ALLOC_FAILURE( error ); |
|
295 EUNIT_ASSERT( error == KErrNotReady ); |
|
296 |
|
297 // There is pending session, but it is not yet reserved resources, |
|
298 // so accepting fails |
|
299 CMceInSession* inSession = ConstructInSessionLC( 1, 0 ); |
316 CMceInSession* inSession = ConstructInSessionLC( 1, 0 ); |
300 iReceiveSession->IncomingSession( inSession, &container ); |
317 iReceiveSession->IncomingSession( inSession, &container ); |
301 CleanupStack::Pop( inSession ); |
318 CleanupStack::Pop( inSession ); |
302 |
|
303 TRAP( error, iReceiveSession->AcceptInvitationL( ETrue ) ); |
|
304 MUS_TEST_FORWARD_ALLOC_FAILURE( error ); |
|
305 EUNIT_ASSERT( error == KErrNotReady ); |
|
306 |
|
307 // Simulate resource reservation and reject |
|
308 iReceiveSession->iSession->iState = CMceSession::EProceeding; |
319 iReceiveSession->iSession->iState = CMceSession::EProceeding; |
309 iReceiveSession->AcceptInvitationL( EFalse ); |
320 iReceiveSession->EstablishLcSessionL(); |
310 |
321 EUNIT_ASSERT_EQUALS( TInt( MLcSession::EOpening ), |
311 EUNIT_ASSERT( iReceiveSession->iSession->iState == |
322 TInt( iReceiveSession->LcSessionState() ) ) |
312 CMceSession::ETerminated ); |
323 } |
313 |
324 |
314 // Construct new session and reject it with operator variant |
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 void UT_CMusEngReceiveSession::UT_EstablishLcSessionL() |
|
330 { |
|
331 // No MCE session |
|
332 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
333 iReceiveSession->EstablishLcSessionL(), KErrNotReady ) |
|
334 |
|
335 // Construct a new session and accept it |
|
336 TMceTransactionDataContainer container; |
|
337 CMceInSession* inSession = ConstructInSessionLC( 1, 0 ); |
|
338 iReceiveSession->IncomingSession( inSession, &container ); |
|
339 CleanupStack::Pop( inSession ); |
|
340 iReceiveSession->iSession->iState = CMceSession::EProceeding; |
|
341 iReceiveSession->EstablishLcSessionL(); |
|
342 EUNIT_ASSERT( iReceiveSession->iSession ) |
|
343 EUNIT_ASSERT_EQUALS( inSession, iReceiveSession->iSession ); |
|
344 EUNIT_ASSERT_EQUALS( TInt( CMceSession::EAnswering ), |
|
345 TInt( iReceiveSession->iSession->iState ) ) |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 void UT_CMusEngReceiveSession::UT_TerminateLcSessionL() |
|
353 { |
|
354 // No MCE session |
|
355 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
356 iReceiveSession->TerminateLcSessionL(), KErrNotReady ) |
|
357 |
|
358 // Reject session, session state incoming, no operator variant |
|
359 TMceTransactionDataContainer container; |
|
360 CMceInSession* inSession = ConstructInSessionLC( 1, 0 ); |
|
361 iReceiveSession->IncomingSession( inSession, &container ); |
|
362 CleanupStack::Pop( inSession ); |
|
363 iReceiveSession->iSession->iState = CMceSession::EIncoming; |
|
364 iReceiveSession->iOperatorVariant = EFalse; |
|
365 iReceiveSession->TerminateLcSessionL(); |
|
366 EUNIT_ASSERT_EQUALS( TInt( CMceSession::ETerminated ), |
|
367 TInt( iReceiveSession->iSession->iState ) ) |
|
368 |
|
369 // Reject session, session state proceeding, no operator variant |
315 inSession = ConstructInSessionLC( 1, 0 ); |
370 inSession = ConstructInSessionLC( 1, 0 ); |
316 iReceiveSession->IncomingSession( inSession, &container ); |
371 iReceiveSession->IncomingSession( inSession, &container ); |
317 CleanupStack::Pop( inSession ); |
372 CleanupStack::Pop( inSession ); |
318 iReceiveSession->iSession->iState = CMceSession::EProceeding; |
373 iReceiveSession->iSession->iState = CMceSession::EProceeding; |
319 iReceiveSession->iOperatorVariant = ETrue; |
374 iReceiveSession->iOperatorVariant = EFalse; |
320 |
375 iReceiveSession->TerminateLcSessionL(); |
321 iReceiveSession->AcceptInvitationL( EFalse ); |
376 EUNIT_ASSERT_EQUALS( TInt( CMceSession::ETerminated ), |
322 |
377 TInt( iReceiveSession->iSession->iState ) ) |
323 EUNIT_ASSERT( iReceiveSession->iSession->iState == |
378 |
324 CMceSession::ETerminated ); |
379 // Reject session, operator variant |
325 |
|
326 // Construct new session and accept it |
|
327 inSession = ConstructInSessionLC( 1, 0 ); |
380 inSession = ConstructInSessionLC( 1, 0 ); |
328 iReceiveSession->IncomingSession( inSession, &container ); |
381 iReceiveSession->IncomingSession( inSession, &container ); |
329 CleanupStack::Pop( inSession ); |
382 CleanupStack::Pop( inSession ); |
330 iReceiveSession->iSession->iState = CMceSession::EProceeding; |
383 iReceiveSession->iSession->iState = CMceSession::EProceeding; |
331 |
384 iReceiveSession->iOperatorVariant = ETrue; |
332 iReceiveSession->AcceptInvitationL( ETrue ); |
385 iReceiveSession->TerminateLcSessionL(); |
333 |
386 EUNIT_ASSERT_EQUALS( TInt( CMceSession::ETerminated ), |
334 EUNIT_ASSERT( iReceiveSession->iSession ); |
387 TInt( iReceiveSession->iSession->iState ) ) |
335 EUNIT_ASSERT( iReceiveSession->iSession == inSession ); |
388 |
336 EUNIT_ASSERT( iReceiveSession->iSession->iState == |
389 // Terminate an established session |
337 CMceSession::EAnswering ); |
390 inSession = ConstructInSessionLC( 1, 0 ); |
338 |
391 iReceiveSession->IncomingSession( inSession, &container ); |
339 |
392 CleanupStack::Pop( inSession ); |
340 } |
393 iReceiveSession->iSession->iState = CMceSession::EEstablished; |
341 |
394 iReceiveSession->iOperatorVariant = EFalse; |
|
395 iReceiveSession->TerminateLcSessionL(); |
|
396 EUNIT_ASSERT_EQUALS( TInt( CMceSession::ETerminating ), |
|
397 TInt( iReceiveSession->iSession->iState ) ) |
|
398 } |
|
399 |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 void UT_CMusEngReceiveSession::UT_RemoteVideoPlayerL() |
|
405 { |
|
406 EUNIT_ASSERT( iReceiveSession->RemoteVideoPlayer() == |
|
407 iReceiveSession->iRemoteVideoPlayer ) |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 void UT_CMusEngReceiveSession::UT_RemoteDisplayName() |
|
415 { |
|
416 |
|
417 // Creating Valid Session |
|
418 CMceInSession* inSession = ConstructInSessionLC( 1, 0 ); |
|
419 iReceiveSession->iSession = inSession; // Transfers ownership |
|
420 CleanupStack::Pop( inSession ); |
|
421 iReceiveSession->CompleteSessionStructureL(); |
|
422 EUNIT_ASSERT( inSession->Streams().Count() == 1 ); |
|
423 |
|
424 |
|
425 // Name is published using publish/subscribe key by Availblity |
|
426 User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, |
|
427 NMusSessionApi::KContactName, |
|
428 KTestContactName ) ); |
|
429 |
|
430 EUNIT_ASSERT_EQUALS ( KTestContactName(), iReceiveSession->RemoteDisplayName() ) |
|
431 |
|
432 |
|
433 User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, |
|
434 NMusSessionApi::KContactName, |
|
435 KNullDesC) ); |
|
436 |
|
437 // Ensure its not null and its not equal |
|
438 EUNIT_ASSERT( KTestContactName() != iReceiveSession->RemoteDisplayName() ); |
|
439 } |
342 |
440 |
343 // ----------------------------------------------------------------------------- |
441 // ----------------------------------------------------------------------------- |
344 // |
442 // |
345 // ----------------------------------------------------------------------------- |
443 // ----------------------------------------------------------------------------- |
346 // |
444 // |
750 CMceMediaStream* audioStream = inSession->Streams()[1]; |
809 CMceMediaStream* audioStream = inSession->Streams()[1]; |
751 |
810 |
752 // Try without a session, nothing happens |
811 // Try without a session, nothing happens |
753 iReceiveSession->StreamStateChanged( *audioStream ); |
812 iReceiveSession->StreamStateChanged( *audioStream ); |
754 |
813 |
755 // Establish session |
814 // Establish session |
756 |
|
757 iReceiveSession->IncomingSession( inSession, &container ); |
815 iReceiveSession->IncomingSession( inSession, &container ); |
758 CleanupStack::Pop( inSession ); |
816 CleanupStack::Pop( inSession ); |
759 iObserver->Reset(); |
817 iLcSessionObserver->Reset(); |
760 |
818 |
761 // Try with audiostream, nothing happens |
819 // Try with audiostream, nothing happens |
762 audioStream->iState = CMceMediaStream::EBuffering; |
820 audioStream->iState = CMceMediaStream::EBuffering; |
763 iReceiveSession->StreamStateChanged( *audioStream ); |
821 iReceiveSession->StreamStateChanged( *audioStream ); |
764 EUNIT_ASSERT( iObserver->IsReseted() ) |
822 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
765 |
823 |
766 // Try with videostream, but without a source, nothing happens |
824 // Try with videostream, but without a source, nothing happens |
767 |
825 CMceRtpSource* rtpSource = |
768 // Needed hacking |
826 static_cast<CMceRtpSource*>( videoStream->Source() ); //hack |
769 CMceRtpSource* rtpSource = |
827 videoStream->iSource = NULL; |
770 static_cast<CMceRtpSource*>( videoStream->Source() ); |
|
771 videoStream->iSource = NULL; |
|
772 |
|
773 iReceiveSession->StreamStateChanged( *videoStream ); |
828 iReceiveSession->StreamStateChanged( *videoStream ); |
774 EUNIT_ASSERT( iObserver->IsReseted() ) |
829 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
775 |
830 |
776 // Try with videostream and a camera source, nothing happens |
831 // Try with videostream and a camera source, nothing happens |
777 |
832 videoStream->iSource = |
778 // Needed hacking |
833 CMceCameraSource::NewL( *iReceiveSession->iManager ); //hack |
779 videoStream->iSource = |
|
780 CMceCameraSource::NewLC( *iReceiveSession->iManager ); |
|
781 CleanupStack::Pop(); |
|
782 |
|
783 iReceiveSession->StreamStateChanged( *videoStream ); |
834 iReceiveSession->StreamStateChanged( *videoStream ); |
784 EUNIT_ASSERT( iObserver->IsReseted() ) |
835 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
785 |
836 |
786 // Remove hacks |
837 // Remove hacks |
787 delete videoStream->iSource; |
838 delete videoStream->iSource; |
788 videoStream->iSource = rtpSource; |
839 videoStream->iSource = rtpSource; |
789 |
840 |
790 // Buffering, normal case |
841 // Buffering, normal case |
791 videoStream->iState = CMceMediaStream::EBuffering; |
842 videoStream->iState = CMceMediaStream::EBuffering; |
792 iReceiveSession->StreamStateChanged( *videoStream ); |
843 iReceiveSession->StreamStateChanged( *videoStream ); |
793 EUNIT_ASSERT( iObserver->iStreamBufferingCalled ) |
844 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
794 iObserver->Reset(); |
845 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
846 EUNIT_ASSERT( iReceiveSession->iBuffered ) |
|
847 iLcSessionObserver->Reset(); |
795 |
848 |
796 // Streaming, normal case |
849 // Streaming, normal case |
797 videoStream->iState = CMceMediaStream::EStreaming; |
850 videoStream->iState = CMceMediaStream::EStreaming; |
|
851 iReceiveSession->iReceiving = EFalse; |
|
852 iReceiveSession->iBuffered = ETrue; |
798 iReceiveSession->StreamStateChanged( *videoStream ); |
853 iReceiveSession->StreamStateChanged( *videoStream ); |
799 EUNIT_ASSERT( iObserver->iStreamStreamingCalled ) |
854 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
800 EUNIT_ASSERT( rtpSource->iInactivityTimer == 2000 ) |
855 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
801 iObserver->Reset(); |
856 EUNIT_ASSERT_EQUALS( KMusEngInactivityTimer, rtpSource->iInactivityTimer ) |
|
857 iLcSessionObserver->Reset(); |
|
858 EUNIT_ASSERT_EQUALS( TInt( iLcUiProvider->iCalledFunction ), |
|
859 TInt( CLcUiProviderStub::EHandleForegroundStatus ) ) |
|
860 iLcUiProvider->Reset(); |
|
861 // Normally background info will be cleared once ui comes to foreground and |
|
862 // notifies engine about it |
|
863 iReceiveSession->iBackground = EFalse; |
|
864 |
|
865 // Streaming, event is received even when already receiving. Streaming |
|
866 // event is anyway notified. |
|
867 videoStream->iState = CMceMediaStream::EStreaming; |
|
868 iReceiveSession->iReceiving = ETrue; |
|
869 iReceiveSession->iBuffered = ETrue; |
|
870 iReceiveSession->StreamStateChanged( *videoStream ); |
|
871 EUNIT_ASSERT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
872 TInt( CLcSessionObserverStub::EPlayerStateChanged ) ) |
|
873 EUNIT_ASSERT_EQUALS( KMusEngInactivityTimer, rtpSource->iInactivityTimer ) |
|
874 iLcSessionObserver->Reset(); |
|
875 EUNIT_ASSERT_EQUALS( TInt( iLcUiProvider->iCalledFunction ), |
|
876 TInt( CLcUiProviderStub::EUnknown ) ) |
|
877 |
|
878 // Streaming and receiving started already. Streaming is not notified because |
|
879 // of buffering event hasn't been received |
|
880 videoStream->iState = CMceMediaStream::EStreaming; |
|
881 iReceiveSession->iReceiving = ETrue; |
|
882 iReceiveSession->iBuffered = EFalse; |
|
883 iReceiveSession->StreamStateChanged( *videoStream ); |
|
884 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
885 iLcSessionObserver->Reset(); |
|
886 |
|
887 // Streaming, receiving not started and buffering not happened ( means no packet |
|
888 // received yet. Ignore this event too. |
|
889 videoStream->iState = CMceMediaStream::EStreaming; |
|
890 iReceiveSession->iReceiving = EFalse; |
|
891 iReceiveSession->iBuffered = EFalse; |
|
892 iReceiveSession->StreamStateChanged( *videoStream ); |
|
893 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
|
894 iLcSessionObserver->Reset(); |
|
895 |
|
896 // Streaming, receiving not started and buffering happened. |
|
897 // Enabling RTP timer leaves. Should be a failure case. |
|
898 videoStream->iState = CMceMediaStream::EStreaming; |
|
899 iReceiveSession->iReceiving = EFalse; |
|
900 iReceiveSession->iBuffered = ETrue; |
|
901 iReceiveSession->StreamStateChanged( *videoStream ); |
|
902 EUNIT_ASSERT_NOT_EQUALS( TInt( iLcSessionObserver->iCalledFunction ), |
|
903 TInt( CLcSessionObserverStub::EPlayerFailed ) ) |
|
904 iLcSessionObserver->Reset(); |
802 |
905 |
803 // Try default behaviors |
906 // Try default behaviors |
804 videoStream->iState = CMceMediaStream::EIdle; |
907 videoStream->iState = CMceMediaStream::EIdle; |
805 iReceiveSession->StreamStateChanged( *videoStream ); |
908 iReceiveSession->StreamStateChanged( *videoStream ); |
806 EUNIT_ASSERT( iObserver->iStreamIdleCalled ); |
909 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ) |
807 |
|
808 } |
910 } |
809 |
911 |
810 |
912 |
811 // ----------------------------------------------------------------------------- |
913 // ----------------------------------------------------------------------------- |
812 // |
914 // |
1162 EUNIT_ASSERT_EQUALS( inSession->Streams().Count(), 1 ) |
1263 EUNIT_ASSERT_EQUALS( inSession->Streams().Count(), 1 ) |
1163 EUNIT_ASSERT_EQUALS( inSession->Streams()[0]->Type(), KMceVideo ) |
1264 EUNIT_ASSERT_EQUALS( inSession->Streams()[0]->Type(), KMceVideo ) |
1164 EUNIT_ASSERT_EQUALS( inSession->Bundles().Count(), 0 ) |
1265 EUNIT_ASSERT_EQUALS( inSession->Bundles().Count(), 0 ) |
1165 |
1266 |
1166 |
1267 |
1167 // Session with bandwidth attribute at sessionlevel |
1268 // Session with bandwidth attributes b=AS and b=TIAS at session and media |
1168 // -> bandwidth is taken in use at session level |
1269 // levels -> b=AS is taken in use at session level (b=TIAS is ignored) |
1169 // |
1270 // |
1170 delete iReceiveSession->iSession; |
1271 delete iReceiveSession->iSession; |
1171 iReceiveSession->iSession = NULL; |
1272 iReceiveSession->iSession = NULL; |
1172 |
1273 |
1173 inSession = ConstructInSessionLC( 1, 0 ); |
1274 inSession = ConstructInSessionLC( 1, 0 ); |
1174 CDesC8Array* sdpLines = new ( ELeave ) CDesC8ArrayFlat( 1 ); |
1275 //setting session level SDP attributes |
|
1276 CDesC8Array* sdpLines = new ( ELeave ) CDesC8ArrayFlat( 2 ); |
1175 CleanupStack::PushL( sdpLines ); |
1277 CleanupStack::PushL( sdpLines ); |
1176 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
1278 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
|
1279 sdpLines->AppendL( KMusEngSessionSdpLineTiasLine() ); |
1177 inSession->SetSessionSDPLinesL( sdpLines ); |
1280 inSession->SetSessionSDPLinesL( sdpLines ); |
1178 CleanupStack::Pop( sdpLines ); |
1281 CleanupStack::Pop( sdpLines ); |
1179 |
1282 |
|
1283 //setting media level SDP attributes |
|
1284 sdpLines = new ( ELeave ) CDesC8ArrayFlat( 2 ); |
|
1285 CleanupStack::PushL( sdpLines ); |
|
1286 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
|
1287 sdpLines->AppendL( KMusEngSessionSdpLineTiasLine() ); |
|
1288 inSession->Streams()[ 0 ]->SetMediaAttributeLinesL( sdpLines ); |
|
1289 CleanupStack::Pop( sdpLines ); |
|
1290 |
1180 // Transfers ownership |
1291 // Transfers ownership |
1181 iReceiveSession->iSession = inSession; |
1292 iReceiveSession->iSession = inSession; |
1182 CleanupStack::Pop( inSession ); |
1293 CleanupStack::Pop( inSession ); |
1183 |
1294 |
1184 iReceiveSession->CompleteSessionStructureL(); |
1295 iReceiveSession->CompleteSessionStructureL(); |
1185 |
1296 |
1186 MDesC8Array* newSdpLines = iReceiveSession->iSession->SessionSDPLinesL(); |
1297 // Ensure there is only b=AS and no b=TIAS present at session level |
1187 CleanupDeletePushL( newSdpLines ); |
1298 MDesC8Array* newSdpLines = iReceiveSession->iSession->iSessionSDPLines; |
1188 TBool bandwidthFoundFromSessionLevel( EFalse ); |
1299 TBool bandwidthFoundFromSessionLevel = EFalse; |
|
1300 TBool tiasFoundFromSessionLevel = EFalse; |
1189 for ( TInt i = 0; newSdpLines && i < newSdpLines->MdcaCount(); i++ ) |
1301 for ( TInt i = 0; newSdpLines && i < newSdpLines->MdcaCount(); i++ ) |
1190 { |
1302 { |
1191 if ( newSdpLines->MdcaPoint( i ).Compare( |
1303 if ( newSdpLines->MdcaPoint( i ).Compare( |
1192 KMusEngSessionSdpLineBandwidthField() ) == 0 ) |
1304 KMusEngSessionSdpLineBandwidthField() ) == 0 ) |
1193 { |
1305 { |
1194 bandwidthFoundFromSessionLevel = ETrue; |
1306 bandwidthFoundFromSessionLevel = ETrue; |
1195 } |
1307 } |
|
1308 else if ( newSdpLines->MdcaPoint( i ).Find( |
|
1309 KMusEngSessionSdpLineTiasLine() ) == 0 ) |
|
1310 { |
|
1311 tiasFoundFromSessionLevel = ETrue; |
|
1312 } |
1196 } |
1313 } |
1197 EUNIT_ASSERT( bandwidthFoundFromSessionLevel ); |
1314 EUNIT_ASSERT( bandwidthFoundFromSessionLevel ); |
1198 CleanupStack::PopAndDestroy( newSdpLines ); |
1315 EUNIT_ASSERT( !tiasFoundFromSessionLevel ); |
1199 |
1316 |
1200 newSdpLines = iReceiveSession->iSession->Streams()[ 0 ]->MediaAttributeLinesL(); |
1317 // Ensure there is no bandwidth attributes at media level |
1201 CleanupDeletePushL( newSdpLines ); |
1318 newSdpLines = iReceiveSession->iSession->Streams()[ 0 ]->iMediaSDPLines; |
1202 TBool bandwidthFoundFromMediaLevel( EFalse ); |
1319 EUNIT_ASSERT( !newSdpLines->MdcaCount() ); |
|
1320 |
|
1321 |
|
1322 // Session with bandwidth AS and TIAS attributes at media level |
|
1323 // -> bandwidth AS is taken in use at media level |
|
1324 // |
|
1325 delete iReceiveSession->iSession; |
|
1326 iReceiveSession->iSession = NULL; |
|
1327 |
|
1328 inSession = ConstructInSessionLC( 1, 0 ); |
|
1329 |
|
1330 sdpLines = new ( ELeave ) CDesC8ArrayFlat( 2 ); |
|
1331 CleanupStack::PushL( sdpLines ); |
|
1332 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
|
1333 sdpLines->AppendL( KMusEngSessionSdpLineTiasLine() ); |
|
1334 inSession->Streams()[ 0 ]->SetMediaAttributeLinesL( sdpLines ); |
|
1335 CleanupStack::Pop( sdpLines ); |
|
1336 |
|
1337 // Transfers ownership |
|
1338 iReceiveSession->iSession = inSession; |
|
1339 CleanupStack::Pop( inSession ); |
|
1340 |
|
1341 iReceiveSession->CompleteSessionStructureL(); |
|
1342 |
|
1343 // Ensure there is no bandwidth attribute at session level |
|
1344 newSdpLines = iReceiveSession->iSession->iSessionSDPLines; |
|
1345 bandwidthFoundFromSessionLevel = EFalse; |
1203 for ( TInt i = 0; newSdpLines && i < newSdpLines->MdcaCount(); i++ ) |
1346 for ( TInt i = 0; newSdpLines && i < newSdpLines->MdcaCount(); i++ ) |
1204 { |
1347 { |
1205 if ( newSdpLines->MdcaPoint( i ).Compare( |
1348 if ( newSdpLines->MdcaPoint( i ).Compare( |
1206 KMusEngSessionSdpLineBandwidthField() ) == 0 ) |
1349 KMusEngSessionSdpLineBandwidthField() ) == 0 |
|
1350 || newSdpLines->MdcaPoint( i ).Find( |
|
1351 KMusEngSessionSdpLineTiasLine() ) == 0 ) |
1207 { |
1352 { |
1208 bandwidthFoundFromMediaLevel = ETrue; |
1353 bandwidthFoundFromSessionLevel = ETrue; |
1209 } |
1354 } |
1210 } |
1355 } |
1211 EUNIT_ASSERT( !bandwidthFoundFromMediaLevel ); |
1356 EUNIT_ASSERT( !bandwidthFoundFromSessionLevel ); |
1212 CleanupStack::PopAndDestroy( newSdpLines ); |
1357 |
1213 |
1358 // Ensure media level has only b=AS attribute |
1214 // Session with bandwidth attribute at media level |
1359 newSdpLines = iReceiveSession->iSession->Streams()[ 0 ]->iMediaSDPLines; |
1215 // -> bandwidth is taken in use at media level |
1360 EUNIT_ASSERT( newSdpLines ); |
1216 // |
1361 EUNIT_ASSERT( newSdpLines->MdcaCount() == 1 ); |
|
1362 EUNIT_ASSERT( newSdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineBandwidthField() ); |
|
1363 } |
|
1364 |
|
1365 |
|
1366 // ----------------------------------------------------------------------------- |
|
1367 // |
|
1368 // ----------------------------------------------------------------------------- |
|
1369 // |
|
1370 void UT_CMusEngReceiveSession::UT_CompleteSessionStructureL_SdpBandwidthAttributesL() |
|
1371 { |
|
1372 CRepository::SetStubGlobal( MusSettingsKeys::KVideoBandwidth, |
|
1373 128 ); |
|
1374 |
|
1375 // 1. Session without bandwidth attributes. => b=AS and b=TIAS will be |
|
1376 // taken at media level |
|
1377 CMceInSession* inSession = ConstructInSessionLC( 1, 0 ); |
|
1378 |
|
1379 iReceiveSession->iSession = inSession; // Transfers ownership |
|
1380 CleanupStack::Pop( inSession ); |
|
1381 |
|
1382 iReceiveSession->CompleteSessionStructureL(); |
|
1383 |
|
1384 // Ensure b=AS and b=TIAS present at media level only |
|
1385 MDesC8Array* newSdpLines = iReceiveSession->iSession->iSessionSDPLines; |
|
1386 EUNIT_ASSERT( newSdpLines->MdcaCount() == 1 ); |
|
1387 EUNIT_ASSERT( newSdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() ); |
|
1388 |
|
1389 // Ensure b=AS and b=TIAS present at media level |
|
1390 EUNIT_ASSERT( iReceiveSession->iSession->Streams().Count() > 0 ); |
|
1391 newSdpLines = iReceiveSession->iSession->Streams()[ 0 ]->iMediaSDPLines; |
|
1392 EUNIT_ASSERT( newSdpLines ); |
|
1393 EUNIT_ASSERT( newSdpLines->MdcaCount() == 2 ); |
|
1394 EUNIT_ASSERT( newSdpLines->MdcaPoint( 0 ).Find( |
|
1395 KMusEngSessionSdpLineBandwidthLine() ) == 0 ); |
|
1396 EUNIT_ASSERT( newSdpLines->MdcaPoint( 1 ).Find( |
|
1397 KMusEngSessionSdpLineTiasLine() ) == 0 ); |
|
1398 |
|
1399 |
|
1400 // 2. Session with b=AS bandwidth attribute at session level |
|
1401 // => b=AS and b=TIAS will be taken at session level |
1217 delete iReceiveSession->iSession; |
1402 delete iReceiveSession->iSession; |
1218 iReceiveSession->iSession = NULL; |
1403 iReceiveSession->iSession = NULL; |
1219 |
1404 |
1220 inSession = ConstructInSessionLC( 1, 0 ); |
1405 inSession = ConstructInSessionLC( 1, 0 ); |
1221 |
1406 //setting session level SDP attributes |
|
1407 CDesC8Array* sdpLines = new ( ELeave ) CDesC8ArrayFlat( 1 ); |
|
1408 CleanupStack::PushL( sdpLines ); |
|
1409 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
|
1410 inSession->SetSessionSDPLinesL( sdpLines ); |
|
1411 CleanupStack::Pop( sdpLines ); |
|
1412 |
|
1413 // Transfers ownership |
|
1414 iReceiveSession->iSession = inSession; |
|
1415 CleanupStack::Pop( inSession ); |
|
1416 |
|
1417 iReceiveSession->CompleteSessionStructureL(); |
|
1418 |
|
1419 // Ensure b=AS and b=TIAS present at session level only |
|
1420 newSdpLines = iReceiveSession->iSession->iSessionSDPLines; |
|
1421 EUNIT_ASSERT( newSdpLines ); |
|
1422 EUNIT_ASSERT( newSdpLines->MdcaCount() == 3 ); |
|
1423 EUNIT_ASSERT( newSdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() ); |
|
1424 EUNIT_ASSERT( newSdpLines->MdcaPoint( 1 ).Find ( |
|
1425 KMusEngSessionSdpLineBandwidthLine() ) == 0 ); |
|
1426 EUNIT_ASSERT( newSdpLines->MdcaPoint( 2 ).Find( |
|
1427 KMusEngSessionSdpLineTiasLine() ) == 0 ); |
|
1428 |
|
1429 EUNIT_ASSERT( iReceiveSession->iSession->Streams().Count() > 0 ); |
|
1430 newSdpLines = iReceiveSession->iSession->Streams()[ 0 ]->iMediaSDPLines; |
|
1431 EUNIT_ASSERT( newSdpLines ); |
|
1432 EUNIT_ASSERT( newSdpLines->MdcaCount() == 0 ); |
|
1433 |
|
1434 // 3. Session with b=AS bandwidth attribute at media level |
|
1435 // => b=AS and b=TIAS will be taken at media level |
|
1436 delete iReceiveSession->iSession; |
|
1437 iReceiveSession->iSession = NULL; |
|
1438 |
|
1439 inSession = ConstructInSessionLC( 1, 0 ); |
|
1440 //setting media level SDP attributes |
1222 sdpLines = new ( ELeave ) CDesC8ArrayFlat( 1 ); |
1441 sdpLines = new ( ELeave ) CDesC8ArrayFlat( 1 ); |
1223 CleanupStack::PushL( sdpLines ); |
1442 CleanupStack::PushL( sdpLines ); |
1224 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
1443 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
1225 inSession->Streams()[ 0 ]->SetMediaAttributeLinesL( sdpLines ); |
1444 inSession->Streams()[ 0 ]->SetMediaAttributeLinesL( sdpLines ); |
1226 CleanupStack::Pop( sdpLines ); |
1445 CleanupStack::Pop( sdpLines ); |
1227 |
1446 |
1228 // Transfers ownership |
1447 // Transfers ownership |
1229 iReceiveSession->iSession = inSession; |
1448 iReceiveSession->iSession = inSession; |
1230 CleanupStack::Pop( inSession ); |
1449 CleanupStack::Pop( inSession ); |
1231 |
1450 |
1232 iReceiveSession->CompleteSessionStructureL(); |
1451 iReceiveSession->CompleteSessionStructureL(); |
1233 |
1452 |
1234 newSdpLines = iReceiveSession->iSession->SessionSDPLinesL(); |
1453 // Ensure b=AS and b=TIAS present only at media level |
1235 CleanupDeletePushL( newSdpLines ); |
1454 newSdpLines = iReceiveSession->iSession->iSessionSDPLines; |
1236 bandwidthFoundFromSessionLevel = EFalse; |
1455 EUNIT_ASSERT( newSdpLines ); |
1237 for ( TInt i = 0; newSdpLines && i < newSdpLines->MdcaCount(); i++ ) |
1456 EUNIT_ASSERT( newSdpLines->MdcaCount() == 1 ); |
1238 { |
1457 EUNIT_ASSERT( newSdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() ); |
1239 if ( newSdpLines->MdcaPoint( i ).Compare( |
1458 |
1240 KMusEngSessionSdpLineBandwidthField() ) == 0 ) |
1459 EUNIT_ASSERT( iReceiveSession->iSession->Streams().Count() > 0 ); |
1241 { |
1460 newSdpLines = iReceiveSession->iSession->Streams()[ 0 ]->iMediaSDPLines; |
1242 bandwidthFoundFromSessionLevel = ETrue; |
1461 EUNIT_ASSERT( newSdpLines ); |
1243 } |
1462 EUNIT_ASSERT( newSdpLines->MdcaCount() == 2 ); |
1244 } |
1463 EUNIT_ASSERT( newSdpLines->MdcaPoint( 0 ).Find ( |
1245 EUNIT_ASSERT( !bandwidthFoundFromSessionLevel ); |
1464 KMusEngSessionSdpLineBandwidthLine() ) == 0 ); |
1246 CleanupStack::PopAndDestroy( newSdpLines ); |
1465 EUNIT_ASSERT( newSdpLines->MdcaPoint( 1 ).Find( |
1247 |
1466 KMusEngSessionSdpLineTiasLine() ) == 0 ); |
1248 newSdpLines = iReceiveSession->iSession->Streams()[ 0 ]->MediaAttributeLinesL(); |
1467 |
1249 CleanupDeletePushL( newSdpLines ); |
1468 |
1250 bandwidthFoundFromMediaLevel = EFalse; |
1469 // 4. Session with b=AS attribute at session level and |
1251 for ( TInt i = 0; newSdpLines && i < newSdpLines->MdcaCount(); i++ ) |
1470 // b=AS and b=TIAS at media level |
1252 { |
1471 // => b=AS and b=TIAS will be taken at session and media level |
1253 if ( newSdpLines->MdcaPoint( i ).Compare( |
1472 delete iReceiveSession->iSession; |
1254 KMusEngSessionSdpLineBandwidthField() ) == 0 ) |
1473 iReceiveSession->iSession = NULL; |
1255 { |
1474 |
1256 bandwidthFoundFromMediaLevel = ETrue; |
1475 inSession = ConstructInSessionLC( 1, 0 ); |
1257 } |
1476 //setting session level SDP attributes |
1258 } |
1477 sdpLines = new ( ELeave ) CDesC8ArrayFlat( 1 ); |
1259 EUNIT_ASSERT( bandwidthFoundFromMediaLevel ); |
1478 CleanupStack::PushL( sdpLines ); |
1260 CleanupStack::PopAndDestroy( newSdpLines ); |
1479 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
1261 } |
1480 inSession->SetSessionSDPLinesL( sdpLines ); |
1262 |
1481 CleanupStack::Pop( sdpLines ); |
|
1482 |
|
1483 //setting media level SDP attributes |
|
1484 sdpLines = new ( ELeave ) CDesC8ArrayFlat( 2 ); |
|
1485 CleanupStack::PushL( sdpLines ); |
|
1486 sdpLines->AppendL( KMusEngSessionSdpLineBandwidthField() ); |
|
1487 sdpLines->AppendL( KMusEngSessionSdpLineTiasLine() ); |
|
1488 inSession->Streams()[ 0 ]->SetMediaAttributeLinesL( sdpLines ); |
|
1489 CleanupStack::Pop( sdpLines ); |
|
1490 |
|
1491 // Transfers ownership |
|
1492 iReceiveSession->iSession = inSession; |
|
1493 CleanupStack::Pop( inSession ); |
|
1494 |
|
1495 iReceiveSession->CompleteSessionStructureL(); |
|
1496 |
|
1497 // Ensure b=AS and b=TIAS present at session and media level |
|
1498 newSdpLines = iReceiveSession->iSession->iSessionSDPLines; |
|
1499 EUNIT_ASSERT( newSdpLines ); |
|
1500 EUNIT_ASSERT( newSdpLines->MdcaCount() == 3 ); |
|
1501 EUNIT_ASSERT( newSdpLines->MdcaPoint( 0 ) == KMusEngSessionSdpLineXApplication() ); |
|
1502 EUNIT_ASSERT( newSdpLines->MdcaPoint( 1 ).Find ( |
|
1503 KMusEngSessionSdpLineBandwidthLine() ) == 0 ); |
|
1504 EUNIT_ASSERT( newSdpLines->MdcaPoint( 2 ).Find( |
|
1505 KMusEngSessionSdpLineTiasLine() ) == 0 ); |
|
1506 |
|
1507 EUNIT_ASSERT( iReceiveSession->iSession->Streams().Count() > 0 ); |
|
1508 newSdpLines = iReceiveSession->iSession->Streams()[ 0 ]->iMediaSDPLines; |
|
1509 EUNIT_ASSERT( newSdpLines ); |
|
1510 EUNIT_ASSERT( newSdpLines->MdcaCount() == 2 ); |
|
1511 EUNIT_ASSERT( newSdpLines->MdcaPoint( 0 ).Find ( |
|
1512 KMusEngSessionSdpLineBandwidthLine() ) == 0 ); |
|
1513 EUNIT_ASSERT( newSdpLines->MdcaPoint( 1 ).Find( |
|
1514 KMusEngSessionSdpLineTiasLine() ) == 0 ); |
|
1515 } |
|
1516 |
1263 |
1517 |
1264 // ----------------------------------------------------------------------------- |
1518 // ----------------------------------------------------------------------------- |
1265 // |
1519 // |
1266 // ----------------------------------------------------------------------------- |
1520 // ----------------------------------------------------------------------------- |
1267 // |
1521 // |
1331 // null header |
1585 // null header |
1332 iReceiveSession->ParseAssertedIdentity( &container ); |
1586 iReceiveSession->ParseAssertedIdentity( &container ); |
1333 EUNIT_ASSERT_EQUALS( iReceiveSession->iIdentity, KNullDesC8 ) |
1587 EUNIT_ASSERT_EQUALS( iReceiveSession->iIdentity, KNullDesC8 ) |
1334 } |
1588 } |
1335 |
1589 |
|
1590 // ----------------------------------------------------------------------------- |
|
1591 // |
|
1592 // ----------------------------------------------------------------------------- |
|
1593 // |
|
1594 void UT_CMusEngReceiveSession::UT_ContactSavingLL() |
|
1595 { |
|
1596 ContactEngineStubHelper::Reset(); |
|
1597 |
|
1598 // Saving of contact is done at destruction phase only if originator value |
|
1599 // exists |
|
1600 // |
|
1601 CMusEngReceiveSession* receiveSession = CMusEngReceiveSession::NewL(); |
|
1602 receiveSession->SetLcSessionObserver( iLcSessionObserver ); |
|
1603 delete receiveSession; |
|
1604 receiveSession = NULL; |
|
1605 EUNIT_ASSERT( ContactEngineStubHelper::GetCalledFunction() == EContactEngineStubNone ); |
|
1606 |
|
1607 |
|
1608 User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, |
|
1609 NMusSessionApi::KContactId, |
|
1610 2 ) ); |
|
1611 User::LeaveIfError( RProperty::Set( NMusSessionApi::KCategoryUid, |
|
1612 NMusSessionApi::KTelNumber, |
|
1613 _L("12341234") ) ); |
|
1614 |
|
1615 receiveSession = CMusEngReceiveSession::NewL(); |
|
1616 CleanupStack::PushL( receiveSession ); |
|
1617 receiveSession->SetLcSessionObserver( iLcSessionObserver ); |
|
1618 delete receiveSession->iOriginator; |
|
1619 receiveSession->iOriginator = NULL; |
|
1620 receiveSession->iOriginator = _L8("sip:yep@10.10.10.10").AllocL(); |
|
1621 CleanupStack::PopAndDestroy( receiveSession ); |
|
1622 if ( ContactEngineStubHelper::GetCalledFunction() != EContactEngineStubSetText ) |
|
1623 { |
|
1624 // out-of-memory was trap ignored and saving failed because of that |
|
1625 User::Leave( KErrNoMemory ); |
|
1626 } |
|
1627 EUNIT_ASSERT( ContactEngineStubHelper::GetCalledFunction() == EContactEngineStubSetText ); |
|
1628 } |
|
1629 |
|
1630 // ----------------------------------------------------------------------------- |
|
1631 // |
|
1632 // ----------------------------------------------------------------------------- |
|
1633 // |
|
1634 void UT_CMusEngReceiveSession::UT_IsDisplayActive() |
|
1635 { |
|
1636 // Display is active only if receiving and display is explicitly enabled |
|
1637 CMceInSession* inSession = ConstructInSessionLC( 1, 1 ); |
|
1638 iReceiveSession->iSession = inSession; // Transfers ownership |
|
1639 CleanupStack::Pop( inSession ); |
|
1640 iReceiveSession->EnableDisplayL( ETrue ); |
|
1641 EUNIT_ASSERT( !iReceiveSession->IsDisplayActive() ) |
|
1642 iReceiveSession->iReceiving = ETrue; |
|
1643 EUNIT_ASSERT( iReceiveSession->IsDisplayActive() ) |
|
1644 } |
|
1645 |
|
1646 // ----------------------------------------------------------------------------- |
|
1647 // |
|
1648 // ----------------------------------------------------------------------------- |
|
1649 // |
|
1650 void UT_CMusEngReceiveSession::UT_InactivityTimeoutL() |
|
1651 { |
|
1652 // Not receiving, no effect |
|
1653 iReceiveSession->iReceiving = EFalse; |
|
1654 CMceVideoStream* videoStream = CMceVideoStream::NewLC(); |
|
1655 CMceRtpSource* rtpSource = CMceRtpSource::NewLC(); |
|
1656 iReceiveSession->InactivityTimeout( *videoStream, *rtpSource ); |
|
1657 EUNIT_ASSERT( iLcSessionObserver->IsReseted() ); |
|
1658 |
|
1659 // Receiving, state change is notified and |
|
1660 // receiving and buffering status are cleared |
|
1661 iReceiveSession->iBuffered = ETrue; |
|
1662 iReceiveSession->iReceiving = ETrue; |
|
1663 iReceiveSession->InactivityTimeout( *videoStream, *rtpSource ); |
|
1664 EUNIT_ASSERT_EQUALS( iLcSessionObserver->iCalledFunction, |
|
1665 CLcSessionObserverStub::EPlayerStateChanged ); |
|
1666 EUNIT_ASSERT( !iReceiveSession->iReceiving ); |
|
1667 EUNIT_ASSERT( !iReceiveSession->iBuffered ); |
|
1668 CleanupStack::PopAndDestroy( rtpSource ); |
|
1669 CleanupStack::PopAndDestroy( videoStream ); |
|
1670 } |
|
1671 |
1336 |
1672 |
1337 // TEST TABLE |
1673 // TEST TABLE |
1338 |
1674 |
1339 EUNIT_BEGIN_TEST_TABLE( |
1675 EUNIT_BEGIN_TEST_TABLE( |
1340 UT_CMusEngReceiveSession, |
1676 UT_CMusEngReceiveSession, |