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

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

Issue 2759953003: Interface RTCRtpReceiver and RTCPeerConnection.getReceivers() added. (Closed)
Patch Set: DISALLOW_COPY_AND_ASSIGN 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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 } 874 }
873 EXPECT_EQ(members.size(), static_cast<size_t>(14)); 875 EXPECT_EQ(members.size(), static_cast<size_t>(14));
874 } else { 876 } else {
875 NOTREACHED(); 877 NOTREACHED();
876 } 878 }
877 } 879 }
878 EXPECT_EQ(undefined_stats_count, 1); 880 EXPECT_EQ(undefined_stats_count, 1);
879 EXPECT_EQ(defined_stats_count, 1); 881 EXPECT_EQ(defined_stats_count, 1);
880 } 882 }
881 883
884 TEST_F(RTCPeerConnectionHandlerTest, GetReceivers) {
885 std::vector<blink::WebMediaStream> remote_streams;
886
887 pc_handler_->observer()->OnAddStream(
888 AddRemoteMockMediaStream("stream0", "video0", "audio0"));
889 base::RunLoop().RunUntilIdle();
890 remote_streams.push_back(mock_client_->remote_stream());
891 pc_handler_->observer()->OnAddStream(
892 AddRemoteMockMediaStream("stream1", "video1", "audio1"));
893 base::RunLoop().RunUntilIdle();
894 remote_streams.push_back(mock_client_->remote_stream());
895 pc_handler_->observer()->OnAddStream(
896 AddRemoteMockMediaStream("stream2", "video2", "audio2"));
897 base::RunLoop().RunUntilIdle();
898 remote_streams.push_back(mock_client_->remote_stream());
899
900 std::set<std::string> expected_remote_track_ids;
901 expected_remote_track_ids.insert("video0");
902 expected_remote_track_ids.insert("audio0");
903 expected_remote_track_ids.insert("video1");
904 expected_remote_track_ids.insert("audio1");
905 expected_remote_track_ids.insert("video2");
906 expected_remote_track_ids.insert("audio2");
907
908 std::set<std::string> remote_track_ids;
909 for (const auto& remote_stream : remote_streams) {
910 blink::WebVector<blink::WebMediaStreamTrack> tracks;
911 remote_stream.audioTracks(tracks);
912 for (const auto& audio_track : tracks) {
913 remote_track_ids.insert(audio_track.id().utf8());
914 }
915 remote_stream.videoTracks(tracks);
916 for (const auto& video_track : tracks) {
917 remote_track_ids.insert(video_track.id().utf8());
918 }
919 }
920 EXPECT_EQ(expected_remote_track_ids, remote_track_ids);
921
922 blink::WebVector<std::unique_ptr<blink::WebRTCRtpReceiver>> receivers =
923 pc_handler_->getReceivers();
924 EXPECT_EQ(remote_track_ids.size(), receivers.size());
925 std::set<uintptr_t> receiver_ids;
926 std::set<std::string> receiver_track_ids;
927 for (const auto& receiver : receivers) {
928 receiver_ids.insert(receiver->id());
929 receiver_track_ids.insert(receiver->track().id().utf8());
930 }
931 EXPECT_EQ(expected_remote_track_ids.size(), receiver_ids.size());
932 EXPECT_EQ(expected_remote_track_ids.size(), receiver_track_ids.size());
933 }
934
882 TEST_F(RTCPeerConnectionHandlerTest, OnSignalingChange) { 935 TEST_F(RTCPeerConnectionHandlerTest, OnSignalingChange) {
883 testing::InSequence sequence; 936 testing::InSequence sequence;
884 937
885 webrtc::PeerConnectionInterface::SignalingState new_state = 938 webrtc::PeerConnectionInterface::SignalingState new_state =
886 webrtc::PeerConnectionInterface::kHaveRemoteOffer; 939 webrtc::PeerConnectionInterface::kHaveRemoteOffer;
887 EXPECT_CALL(*mock_tracker_.get(), TrackSignalingStateChange( 940 EXPECT_CALL(*mock_tracker_.get(), TrackSignalingStateChange(
888 pc_handler_.get(), 941 pc_handler_.get(),
889 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer)); 942 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer));
890 EXPECT_CALL(*mock_client_.get(), didChangeSignalingState( 943 EXPECT_CALL(*mock_client_.get(), didChangeSignalingState(
891 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer)); 944 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer));
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 testing::Ref(tracks[0]))); 1361 testing::Ref(tracks[0])));
1309 1362
1310 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender( 1363 std::unique_ptr<blink::WebRTCDTMFSenderHandler> sender(
1311 pc_handler_->createDTMFSender(tracks[0])); 1364 pc_handler_->createDTMFSender(tracks[0]));
1312 EXPECT_TRUE(sender.get()); 1365 EXPECT_TRUE(sender.get());
1313 1366
1314 StopAllTracks(local_stream); 1367 StopAllTracks(local_stream);
1315 } 1368 }
1316 1369
1317 } // namespace content 1370 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_peer_connection_handler.cc ('k') | content/renderer/media/webrtc/rtc_rtp_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698