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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 } | 928 } |
929 | 929 |
930 void AddVideoTrack(const std::string& track_id, | 930 void AddVideoTrack(const std::string& track_id, |
931 MediaStreamInterface* stream) { | 931 MediaStreamInterface* stream) { |
932 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( | 932 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( |
933 webrtc::VideoTrack::Create(track_id, | 933 webrtc::VideoTrack::Create(track_id, |
934 webrtc::FakeVideoTrackSource::Create())); | 934 webrtc::FakeVideoTrackSource::Create())); |
935 ASSERT_TRUE(stream->AddTrack(video_track)); | 935 ASSERT_TRUE(stream->AddTrack(video_track)); |
936 } | 936 } |
937 | 937 |
938 void GetStreamCnameInOfferAnswer(std::string& cname, bool is_offer) { | |
pthatcher1
2016/05/05 18:50:51
I think it would be cleaner to break this up into
Zhi Huang
2016/05/06 01:36:53
This looks nice!
| |
939 CreatePeerConnection(); | |
940 AddVoiceStream(kStreamLabel1); | |
941 scoped_ptr<SessionDescriptionInterface> offer; | |
942 ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); | |
943 | |
944 const cricket::ContentInfo* audio_content = | |
945 cricket::GetFirstAudioContent(offer->description()); | |
946 const cricket::AudioContentDescription* audio_desc = | |
947 static_cast<const cricket::AudioContentDescription*>( | |
948 audio_content->description); | |
949 if (is_offer) { | |
950 cname = audio_desc->streams()[0].cname; | |
951 return; | |
952 } | |
953 | |
954 EXPECT_TRUE(DoSetRemoteDescription(offer.release())); | |
955 rtc::scoped_ptr<SessionDescriptionInterface> answer; | |
956 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr)); | |
957 audio_content = cricket::GetFirstAudioContent(answer->description()); | |
958 audio_desc = static_cast<const cricket::AudioContentDescription*>( | |
959 audio_content->description); | |
960 cname = audio_desc->streams()[0].cname; | |
961 } | |
962 | |
963 void GetStreamCnameInOffer(std::string& cname) { | |
964 GetStreamCnameInOfferAnswer(cname, true); | |
965 } | |
966 | |
967 void GetStreamCnameInAnswer(std::string& cname) { | |
968 GetStreamCnameInOfferAnswer(cname, false); | |
pthatcher1
2016/05/05 18:50:51
Instead of passing in a non-const ref, please pass
| |
969 } | |
970 | |
938 cricket::FakePortAllocator* port_allocator_ = nullptr; | 971 cricket::FakePortAllocator* port_allocator_ = nullptr; |
939 scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; | 972 scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; |
940 scoped_refptr<PeerConnectionInterface> pc_; | 973 scoped_refptr<PeerConnectionInterface> pc_; |
941 MockPeerConnectionObserver observer_; | 974 MockPeerConnectionObserver observer_; |
942 rtc::scoped_refptr<StreamCollection> reference_collection_; | 975 rtc::scoped_refptr<StreamCollection> reference_collection_; |
943 }; | 976 }; |
944 | 977 |
978 // Generate different CNAMEs when PeerConnections are created. | |
979 // The CNAME will be generated randomly. It is possible that | |
980 // the test fails, though the possibility is low. | |
981 TEST_F(PeerConnectionInterfaceTest, CnameGenerationInOffer) { | |
982 std::string cname1, cname2; | |
983 GetStreamCnameInOffer(cname1); | |
984 GetStreamCnameInOffer(cname2); | |
985 EXPECT_NE(cname1, cname2); | |
986 } | |
987 | |
988 TEST_F(PeerConnectionInterfaceTest, CnameGenerationInAnswer) { | |
989 std::string cname1, cname2; | |
990 GetStreamCnameInAnswer(cname1); | |
991 GetStreamCnameInAnswer(cname2); | |
992 EXPECT_NE(cname1, cname2); | |
993 } | |
994 | |
945 TEST_F(PeerConnectionInterfaceTest, | 995 TEST_F(PeerConnectionInterfaceTest, |
946 CreatePeerConnectionWithDifferentConfigurations) { | 996 CreatePeerConnectionWithDifferentConfigurations) { |
947 CreatePeerConnectionWithDifferentConfigurations(); | 997 CreatePeerConnectionWithDifferentConfigurations(); |
948 } | 998 } |
949 | 999 |
950 TEST_F(PeerConnectionInterfaceTest, AddStreams) { | 1000 TEST_F(PeerConnectionInterfaceTest, AddStreams) { |
951 CreatePeerConnection(); | 1001 CreatePeerConnection(); |
952 AddVideoStream(kStreamLabel1); | 1002 AddVideoStream(kStreamLabel1); |
953 AddVoiceStream(kStreamLabel2); | 1003 AddVoiceStream(kStreamLabel2); |
954 ASSERT_EQ(2u, pc_->local_streams()->count()); | 1004 ASSERT_EQ(2u, pc_->local_streams()->count()); |
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2662 FakeConstraints updated_answer_c; | 2712 FakeConstraints updated_answer_c; |
2663 answer_c.SetMandatoryReceiveAudio(false); | 2713 answer_c.SetMandatoryReceiveAudio(false); |
2664 answer_c.SetMandatoryReceiveVideo(false); | 2714 answer_c.SetMandatoryReceiveVideo(false); |
2665 | 2715 |
2666 cricket::MediaSessionOptions updated_answer_options; | 2716 cricket::MediaSessionOptions updated_answer_options; |
2667 EXPECT_TRUE( | 2717 EXPECT_TRUE( |
2668 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); | 2718 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); |
2669 EXPECT_TRUE(updated_answer_options.has_audio()); | 2719 EXPECT_TRUE(updated_answer_options.has_audio()); |
2670 EXPECT_TRUE(updated_answer_options.has_video()); | 2720 EXPECT_TRUE(updated_answer_options.has_video()); |
2671 } | 2721 } |
OLD | NEW |