Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: webrtc/api/peerconnectioninterface_unittest.cc

Issue 1871993002: Only generate one CNAME per PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renaming: cname -> rtcp_cname. Modified the peerconnectioninterface unit tests. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/pc/mediasession.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 927 }
928 928
929 void AddVideoTrack(const std::string& track_id, 929 void AddVideoTrack(const std::string& track_id,
930 MediaStreamInterface* stream) { 930 MediaStreamInterface* stream) {
931 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( 931 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
932 webrtc::VideoTrack::Create(track_id, 932 webrtc::VideoTrack::Create(track_id,
933 webrtc::FakeVideoTrackSource::Create())); 933 webrtc::FakeVideoTrackSource::Create()));
934 ASSERT_TRUE(stream->AddTrack(video_track)); 934 ASSERT_TRUE(stream->AddTrack(video_track));
935 } 935 }
936 936
937 rtc::scoped_ptr<SessionDescriptionInterface> CreateOfferWithOneAudioStream() {
938 CreatePeerConnection();
939 AddVoiceStream(kStreamLabel1);
940 rtc::scoped_ptr<SessionDescriptionInterface> offer;
941 EXPECT_TRUE(DoCreateOffer(&offer, nullptr));
942 return offer;
943 }
944
945 rtc::scoped_ptr<SessionDescriptionInterface>
946 CreateAnswerWithOneAudioStream() {
947 rtc::scoped_ptr<SessionDescriptionInterface> offer =
948 CreateOfferWithOneAudioStream();
949 EXPECT_TRUE(DoSetRemoteDescription(offer.release()));
950 rtc::scoped_ptr<SessionDescriptionInterface> answer;
951 EXPECT_TRUE(DoCreateAnswer(&answer, nullptr));
952 return answer;
953 }
954
955 const std::string& GetFirstAudioStreamCname(
956 const SessionDescriptionInterface* desc) {
957 const cricket::ContentInfo* audio_content =
958 cricket::GetFirstAudioContent(desc->description());
959 const cricket::AudioContentDescription* audio_desc =
960 static_cast<const cricket::AudioContentDescription*>(
961 audio_content->description);
962 return audio_desc->streams()[0].cname;
963 }
964
937 cricket::FakePortAllocator* port_allocator_ = nullptr; 965 cricket::FakePortAllocator* port_allocator_ = nullptr;
938 scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; 966 scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_;
939 scoped_refptr<PeerConnectionInterface> pc_; 967 scoped_refptr<PeerConnectionInterface> pc_;
940 MockPeerConnectionObserver observer_; 968 MockPeerConnectionObserver observer_;
941 rtc::scoped_refptr<StreamCollection> reference_collection_; 969 rtc::scoped_refptr<StreamCollection> reference_collection_;
942 }; 970 };
943 971
972 // Generate different CNAMEs when PeerConnections are created.
973 // The CNAMEs are expected to be generated randomly. It is possible
974 // that the test fails, though the possibility is very low.
975 TEST_F(PeerConnectionInterfaceTest, CnameGenerationInOffer) {
976 rtc::scoped_ptr<SessionDescriptionInterface> offer1 =
977 CreateOfferWithOneAudioStream();
978 rtc::scoped_ptr<SessionDescriptionInterface> offer2 =
979 CreateOfferWithOneAudioStream();
980 EXPECT_NE(GetFirstAudioStreamCname(offer1.get()),
981 GetFirstAudioStreamCname(offer2.get()));
982 }
983
984 TEST_F(PeerConnectionInterfaceTest, CnameGenerationInAnswer) {
985 rtc::scoped_ptr<SessionDescriptionInterface> answer1 =
986 CreateAnswerWithOneAudioStream();
987 rtc::scoped_ptr<SessionDescriptionInterface> answer2 =
988 CreateAnswerWithOneAudioStream();
989 EXPECT_NE(GetFirstAudioStreamCname(answer1.get()),
990 GetFirstAudioStreamCname(answer2.get()));
991 }
992
944 TEST_F(PeerConnectionInterfaceTest, 993 TEST_F(PeerConnectionInterfaceTest,
945 CreatePeerConnectionWithDifferentConfigurations) { 994 CreatePeerConnectionWithDifferentConfigurations) {
946 CreatePeerConnectionWithDifferentConfigurations(); 995 CreatePeerConnectionWithDifferentConfigurations();
947 } 996 }
948 997
949 TEST_F(PeerConnectionInterfaceTest, AddStreams) { 998 TEST_F(PeerConnectionInterfaceTest, AddStreams) {
950 CreatePeerConnection(); 999 CreatePeerConnection();
951 AddVideoStream(kStreamLabel1); 1000 AddVideoStream(kStreamLabel1);
952 AddVoiceStream(kStreamLabel2); 1001 AddVoiceStream(kStreamLabel2);
953 ASSERT_EQ(2u, pc_->local_streams()->count()); 1002 ASSERT_EQ(2u, pc_->local_streams()->count());
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 FakeConstraints updated_answer_c; 2710 FakeConstraints updated_answer_c;
2662 answer_c.SetMandatoryReceiveAudio(false); 2711 answer_c.SetMandatoryReceiveAudio(false);
2663 answer_c.SetMandatoryReceiveVideo(false); 2712 answer_c.SetMandatoryReceiveVideo(false);
2664 2713
2665 cricket::MediaSessionOptions updated_answer_options; 2714 cricket::MediaSessionOptions updated_answer_options;
2666 EXPECT_TRUE( 2715 EXPECT_TRUE(
2667 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options)); 2716 ParseConstraintsForAnswer(&updated_answer_c, &updated_answer_options));
2668 EXPECT_TRUE(updated_answer_options.has_audio()); 2717 EXPECT_TRUE(updated_answer_options.has_audio());
2669 EXPECT_TRUE(updated_answer_options.has_video()); 2718 EXPECT_TRUE(updated_answer_options.has_video());
2670 } 2719 }
OLDNEW
« no previous file with comments | « webrtc/api/peerconnection.cc ('k') | webrtc/pc/mediasession.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698