OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 EXPECT_EQ(PeerConnectionInterface::kIceConnectionClosed, | 1861 EXPECT_EQ(PeerConnectionInterface::kIceConnectionClosed, |
1862 pc_->ice_connection_state()); | 1862 pc_->ice_connection_state()); |
1863 EXPECT_EQ(PeerConnectionInterface::kIceGatheringComplete, | 1863 EXPECT_EQ(PeerConnectionInterface::kIceGatheringComplete, |
1864 pc_->ice_gathering_state()); | 1864 pc_->ice_gathering_state()); |
1865 | 1865 |
1866 EXPECT_EQ(1u, pc_->local_streams()->count()); | 1866 EXPECT_EQ(1u, pc_->local_streams()->count()); |
1867 EXPECT_EQ(1u, pc_->remote_streams()->count()); | 1867 EXPECT_EQ(1u, pc_->remote_streams()->count()); |
1868 | 1868 |
1869 scoped_refptr<MediaStreamInterface> remote_stream = | 1869 scoped_refptr<MediaStreamInterface> remote_stream = |
1870 pc_->remote_streams()->at(0); | 1870 pc_->remote_streams()->at(0); |
1871 EXPECT_EQ(MediaStreamTrackInterface::kEnded, | 1871 // Track state may be updated asynchronously. |
1872 remote_stream->GetVideoTracks()[0]->state()); | |
1873 // Audio source state changes are posted. | |
1874 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, | 1872 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, |
1875 remote_stream->GetAudioTracks()[0]->state(), 10); | 1873 remote_stream->GetAudioTracks()[0]->state(), kTimeout); |
| 1874 EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, |
| 1875 remote_stream->GetVideoTracks()[0]->state(), kTimeout); |
1876 } | 1876 } |
1877 | 1877 |
1878 // Test that PeerConnection methods fails gracefully after | 1878 // Test that PeerConnection methods fails gracefully after |
1879 // PeerConnection::Close has been called. | 1879 // PeerConnection::Close has been called. |
1880 TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) { | 1880 TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) { |
1881 CreatePeerConnection(); | 1881 CreatePeerConnection(); |
1882 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); | 1882 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label"); |
1883 CreateOfferAsRemoteDescription(); | 1883 CreateOfferAsRemoteDescription(); |
1884 CreateAnswerAsLocalDescription(); | 1884 CreateAnswerAsLocalDescription(); |
1885 | 1885 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1988 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms2 = | 1988 rtc::scoped_ptr<SessionDescriptionInterface> desc_ms2 = |
1989 CreateSessionDescriptionAndReference(1, 1); | 1989 CreateSessionDescriptionAndReference(1, 1); |
1990 MockTrackObserver audio_track_observer(audio_track2); | 1990 MockTrackObserver audio_track_observer(audio_track2); |
1991 MockTrackObserver video_track_observer(video_track2); | 1991 MockTrackObserver video_track_observer(video_track2); |
1992 | 1992 |
1993 EXPECT_CALL(audio_track_observer, OnChanged()).Times(Exactly(1)); | 1993 EXPECT_CALL(audio_track_observer, OnChanged()).Times(Exactly(1)); |
1994 EXPECT_CALL(video_track_observer, OnChanged()).Times(Exactly(1)); | 1994 EXPECT_CALL(video_track_observer, OnChanged()).Times(Exactly(1)); |
1995 EXPECT_TRUE(DoSetRemoteDescription(desc_ms2.release())); | 1995 EXPECT_TRUE(DoSetRemoteDescription(desc_ms2.release())); |
1996 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), | 1996 EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(), |
1997 reference_collection_)); | 1997 reference_collection_)); |
1998 // Audio source state changes are posted. | 1998 // Track state may be updated asynchronously. |
1999 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded, | 1999 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded, |
2000 audio_track2->state(), 1); | 2000 audio_track2->state(), kTimeout); |
2001 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, video_track2->state()); | 2001 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded, |
| 2002 video_track2->state(), kTimeout); |
2002 } | 2003 } |
2003 | 2004 |
2004 // This tests that remote tracks are ended if a local session description is set | 2005 // This tests that remote tracks are ended if a local session description is set |
2005 // that rejects the media content type. | 2006 // that rejects the media content type. |
2006 TEST_F(PeerConnectionInterfaceTest, RejectMediaContent) { | 2007 TEST_F(PeerConnectionInterfaceTest, RejectMediaContent) { |
2007 FakeConstraints constraints; | 2008 FakeConstraints constraints; |
2008 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 2009 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
2009 true); | 2010 true); |
2010 CreatePeerConnection(&constraints); | 2011 CreatePeerConnection(&constraints); |
2011 // First create and set a remote offer, then reject its video content in our | 2012 // First create and set a remote offer, then reject its video content in our |
(...skipping 24 matching lines...) Expand all Loading... |
2036 rtc::scoped_ptr<SessionDescriptionInterface> local_offer; | 2037 rtc::scoped_ptr<SessionDescriptionInterface> local_offer; |
2037 EXPECT_TRUE(DoCreateOffer(&local_offer, nullptr)); | 2038 EXPECT_TRUE(DoCreateOffer(&local_offer, nullptr)); |
2038 video_info = local_offer->description()->GetContentByName("video"); | 2039 video_info = local_offer->description()->GetContentByName("video"); |
2039 ASSERT_TRUE(video_info != nullptr); | 2040 ASSERT_TRUE(video_info != nullptr); |
2040 video_info->rejected = true; | 2041 video_info->rejected = true; |
2041 cricket::ContentInfo* audio_info = | 2042 cricket::ContentInfo* audio_info = |
2042 local_offer->description()->GetContentByName("audio"); | 2043 local_offer->description()->GetContentByName("audio"); |
2043 ASSERT_TRUE(audio_info != nullptr); | 2044 ASSERT_TRUE(audio_info != nullptr); |
2044 audio_info->rejected = true; | 2045 audio_info->rejected = true; |
2045 EXPECT_TRUE(DoSetLocalDescription(local_offer.release())); | 2046 EXPECT_TRUE(DoSetLocalDescription(local_offer.release())); |
2046 EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, remote_video->state()); | 2047 // Track state may be updated asynchronously. |
2047 // Audio source state changes are posted. | |
2048 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded, | 2048 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded, |
2049 remote_audio->state(), 1); | 2049 remote_audio->state(), kTimeout); |
| 2050 EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded, |
| 2051 remote_video->state(), kTimeout); |
2050 } | 2052 } |
2051 | 2053 |
2052 // This tests that we won't crash if the remote track has been removed outside | 2054 // This tests that we won't crash if the remote track has been removed outside |
2053 // of PeerConnection and then PeerConnection tries to reject the track. | 2055 // of PeerConnection and then PeerConnection tries to reject the track. |
2054 TEST_F(PeerConnectionInterfaceTest, RemoveTrackThenRejectMediaContent) { | 2056 TEST_F(PeerConnectionInterfaceTest, RemoveTrackThenRejectMediaContent) { |
2055 FakeConstraints constraints; | 2057 FakeConstraints constraints; |
2056 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, | 2058 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, |
2057 true); | 2059 true); |
2058 CreatePeerConnection(&constraints); | 2060 CreatePeerConnection(&constraints); |
2059 CreateAndSetRemoteOffer(kSdpStringWithStream1); | 2061 CreateAndSetRemoteOffer(kSdpStringWithStream1); |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 FakeConstraints updated_answer_c; | 2738 FakeConstraints updated_answer_c; |
2737 answer_c.SetMandatoryReceiveAudio(false); | 2739 answer_c.SetMandatoryReceiveAudio(false); |
2738 answer_c.SetMandatoryReceiveVideo(false); | 2740 answer_c.SetMandatoryReceiveVideo(false); |
2739 | 2741 |
2740 cricket::MediaSessionOptions updated_answer_options; | 2742 cricket::MediaSessionOptions updated_answer_options; |
2741 EXPECT_TRUE( | 2743 EXPECT_TRUE( |
2742 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); | 2744 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
2743 EXPECT_TRUE(updated_answer_options.has_audio()); | 2745 EXPECT_TRUE(updated_answer_options.has_audio()); |
2744 EXPECT_TRUE(updated_answer_options.has_video()); | 2746 EXPECT_TRUE(updated_answer_options.has_video()); |
2745 } | 2747 } |
OLD | NEW |