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

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler_unittest.cc

Issue 2759953003: Interface RTCRtpReceiver and RTCPeerConnection.getReceivers() added. (Closed)
Patch Set: Addressed/added comments Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map>
9 #include <memory> 10 #include <memory>
10 #include <set> 11 #include <set>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
(...skipping 20 matching lines...) Expand all
39 #include "third_party/WebKit/public/platform/WebMediaStream.h" 40 #include "third_party/WebKit/public/platform/WebMediaStream.h"
40 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 41 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
41 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 42 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
42 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" 43 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h"
43 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandler.h" 44 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandler.h"
44 #include "third_party/WebKit/public/platform/WebRTCDataChannelHandler.h" 45 #include "third_party/WebKit/public/platform/WebRTCDataChannelHandler.h"
45 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" 46 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h"
46 #include "third_party/WebKit/public/platform/WebRTCError.h" 47 #include "third_party/WebKit/public/platform/WebRTCError.h"
47 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" 48 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h"
48 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandlerClient.h " 49 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandlerClient.h "
50 #include "third_party/WebKit/public/platform/WebRTCRtpReceiver.h"
49 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" 51 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h"
50 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" 52 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h"
51 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h" 53 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h"
52 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" 54 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h"
53 #include "third_party/WebKit/public/platform/WebURL.h" 55 #include "third_party/WebKit/public/platform/WebURL.h"
54 #include "third_party/WebKit/public/web/WebHeap.h" 56 #include "third_party/WebKit/public/web/WebHeap.h"
55 #include "third_party/webrtc/api/peerconnectioninterface.h" 57 #include "third_party/webrtc/api/peerconnectioninterface.h"
56 #include "third_party/webrtc/stats/test/rtcteststats.h" 58 #include "third_party/webrtc/stats/test/rtcteststats.h"
57 59
58 static const char kDummySdp[] = "dummy sdp"; 60 static const char kDummySdp[] = "dummy sdp";
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 } 872 }
871 EXPECT_EQ(members.size(), static_cast<size_t>(14)); 873 EXPECT_EQ(members.size(), static_cast<size_t>(14));
872 } else { 874 } else {
873 NOTREACHED(); 875 NOTREACHED();
874 } 876 }
875 } 877 }
876 EXPECT_EQ(undefined_stats_count, 1); 878 EXPECT_EQ(undefined_stats_count, 1);
877 EXPECT_EQ(defined_stats_count, 1); 879 EXPECT_EQ(defined_stats_count, 1);
878 } 880 }
879 881
882 TEST_F(RTCPeerConnectionHandlerTest, GetReceivers) {
883 std::vector<blink::WebMediaStream> remote_streams;
884
885 pc_handler_->observer()->OnAddStream(
886 AddRemoteMockMediaStream("stream0", "video0", "audio0"));
887 base::RunLoop().RunUntilIdle();
888 remote_streams.push_back(mock_client_->remote_stream());
889 pc_handler_->observer()->OnAddStream(
890 AddRemoteMockMediaStream("stream1", "video1", "audio1"));
891 base::RunLoop().RunUntilIdle();
892 remote_streams.push_back(mock_client_->remote_stream());
893 pc_handler_->observer()->OnAddStream(
894 AddRemoteMockMediaStream("stream2", "video2", "audio2"));
895 base::RunLoop().RunUntilIdle();
896 remote_streams.push_back(mock_client_->remote_stream());
897
898 std::set<std::string> expected_remote_track_ids;
899 expected_remote_track_ids.insert("video0");
900 expected_remote_track_ids.insert("audio0");
901 expected_remote_track_ids.insert("video1");
902 expected_remote_track_ids.insert("audio1");
903 expected_remote_track_ids.insert("video2");
904 expected_remote_track_ids.insert("audio2");
905
906 std::set<std::string> remote_track_ids;
907 for (const auto& remote_stream : remote_streams) {
908 blink::WebVector<blink::WebMediaStreamTrack> tracks;
909 remote_stream.audioTracks(tracks);
910 for (const auto& audio_track : tracks) {
911 remote_track_ids.insert(audio_track.id().utf8());
912 }
913 remote_stream.videoTracks(tracks);
914 for (const auto& video_track : tracks) {
915 remote_track_ids.insert(video_track.id().utf8());
916 }
917 }
918 EXPECT_EQ(expected_remote_track_ids, remote_track_ids);
919
920 blink::WebVector<std::unique_ptr<blink::WebRTCRtpReceiver>> receivers =
921 pc_handler_->getReceivers();
922 EXPECT_EQ(remote_track_ids.size(), receivers.size());
923 std::set<uintptr_t> receiver_ids;
924 std::set<std::string> receiver_track_ids;
925 for (const auto& receiver : receivers) {
926 receiver_ids.insert(receiver->id());
927 receiver_track_ids.insert(receiver->track().id().utf8());
928 }
929 EXPECT_EQ(expected_remote_track_ids.size(), receiver_ids.size());
930 EXPECT_EQ(expected_remote_track_ids.size(), receiver_track_ids.size());
931 }
932
880 TEST_F(RTCPeerConnectionHandlerTest, OnSignalingChange) { 933 TEST_F(RTCPeerConnectionHandlerTest, OnSignalingChange) {
881 testing::InSequence sequence; 934 testing::InSequence sequence;
882 935
883 webrtc::PeerConnectionInterface::SignalingState new_state = 936 webrtc::PeerConnectionInterface::SignalingState new_state =
884 webrtc::PeerConnectionInterface::kHaveRemoteOffer; 937 webrtc::PeerConnectionInterface::kHaveRemoteOffer;
885 EXPECT_CALL(*mock_tracker_.get(), TrackSignalingStateChange( 938 EXPECT_CALL(*mock_tracker_.get(), TrackSignalingStateChange(
886 pc_handler_.get(), 939 pc_handler_.get(),
887 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer)); 940 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer));
888 EXPECT_CALL(*mock_client_.get(), didChangeSignalingState( 941 EXPECT_CALL(*mock_client_.get(), didChangeSignalingState(
889 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer)); 942 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer));
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 testing::Ref(tracks[0]))); 1359 testing::Ref(tracks[0])));
1307 1360
1308 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender( 1361 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender(
1309 pc_handler_->createDTMFSender(tracks[0])); 1362 pc_handler_->createDTMFSender(tracks[0]));
1310 EXPECT_TRUE(sender.get()); 1363 EXPECT_TRUE(sender.get());
1311 1364
1312 StopAllTracks(local_stream); 1365 StopAllTracks(local_stream);
1313 } 1366 }
1314 1367
1315 } // namespace content 1368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698