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

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

Issue 2597963002: RTCIceCandidateStats.transportId added and collected. (Closed)
Patch Set: Created 3 years, 12 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 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 EXPECT_EQ(info->ders.size(), info->fingerprints.size()); 153 EXPECT_EQ(info->ders.size(), info->fingerprints.size());
154 return info; 154 return info;
155 } 155 }
156 156
157 std::unique_ptr<cricket::Candidate> CreateFakeCandidate( 157 std::unique_ptr<cricket::Candidate> CreateFakeCandidate(
158 const std::string& hostname, 158 const std::string& hostname,
159 int port, 159 int port,
160 const std::string& protocol, 160 const std::string& protocol,
161 const std::string& candidate_type, 161 const std::string& candidate_type,
162 uint32_t priority) { 162 uint32_t priority,
163 int component = 0,
164 const std::string& transport_name = "") {
Taylor Brandstetter 2016/12/22 19:28:31 As mentioned in other comments, I wouldn't use the
hbos 2016/12/23 14:25:17 Done.
163 std::unique_ptr<cricket::Candidate> candidate(new cricket::Candidate()); 165 std::unique_ptr<cricket::Candidate> candidate(new cricket::Candidate());
164 candidate->set_address(rtc::SocketAddress(hostname, port)); 166 candidate->set_address(rtc::SocketAddress(hostname, port));
165 candidate->set_protocol(protocol); 167 candidate->set_protocol(protocol);
166 candidate->set_type(candidate_type); 168 candidate->set_type(candidate_type);
167 candidate->set_priority(priority); 169 candidate->set_priority(priority);
170 candidate->set_component(component);
171 candidate->set_transport_name(transport_name);
168 return candidate; 172 return candidate;
169 } 173 }
170 174
171 class FakeAudioProcessorForStats 175 class FakeAudioProcessorForStats
172 : public rtc::RefCountedObject<AudioProcessorInterface> { 176 : public rtc::RefCountedObject<AudioProcessorInterface> {
173 public: 177 public:
174 FakeAudioProcessorForStats( 178 FakeAudioProcessorForStats(
175 AudioProcessorInterface::AudioProcessorStats stats) 179 AudioProcessorInterface::AudioProcessorStats stats)
176 : stats_(stats) { 180 : stats_(stats) {
177 } 181 }
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 report->Get(expected_data_channel3.id())->cast_to< 916 report->Get(expected_data_channel3.id())->cast_to<
913 RTCDataChannelStats>()); 917 RTCDataChannelStats>());
914 } 918 }
915 919
916 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { 920 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) {
917 // Candidates in the first transport stats. 921 // Candidates in the first transport stats.
918 std::unique_ptr<cricket::Candidate> a_local_host = CreateFakeCandidate( 922 std::unique_ptr<cricket::Candidate> a_local_host = CreateFakeCandidate(
919 "1.2.3.4", 5, 923 "1.2.3.4", 5,
920 "a_local_host's protocol", 924 "a_local_host's protocol",
921 cricket::LOCAL_PORT_TYPE, 925 cricket::LOCAL_PORT_TYPE,
922 0); 926 0,
927 cricket::ICE_CANDIDATE_COMPONENT_RTP,
928 "a");
923 RTCLocalIceCandidateStats expected_a_local_host( 929 RTCLocalIceCandidateStats expected_a_local_host(
924 "RTCIceCandidate_" + a_local_host->id(), 0); 930 "RTCIceCandidate_" + a_local_host->id(), 0);
925 expected_a_local_host.ip = "1.2.3.4"; 931 expected_a_local_host.ip = "1.2.3.4";
926 expected_a_local_host.port = 5; 932 expected_a_local_host.port = 5;
927 expected_a_local_host.protocol = "a_local_host's protocol"; 933 expected_a_local_host.protocol = "a_local_host's protocol";
928 expected_a_local_host.candidate_type = "host"; 934 expected_a_local_host.candidate_type = "host";
929 expected_a_local_host.priority = 0; 935 expected_a_local_host.priority = 0;
936 expected_a_local_host.transport_id = "RTCTransport_a_" +
937 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP);
930 938
931 std::unique_ptr<cricket::Candidate> a_remote_srflx = CreateFakeCandidate( 939 std::unique_ptr<cricket::Candidate> a_remote_srflx = CreateFakeCandidate(
932 "6.7.8.9", 10, 940 "6.7.8.9", 10,
933 "remote_srflx's protocol", 941 "remote_srflx's protocol",
934 cricket::STUN_PORT_TYPE, 942 cricket::STUN_PORT_TYPE,
935 1); 943 1,
944 cricket::ICE_CANDIDATE_COMPONENT_RTP,
945 "a");
936 RTCRemoteIceCandidateStats expected_a_remote_srflx( 946 RTCRemoteIceCandidateStats expected_a_remote_srflx(
937 "RTCIceCandidate_" + a_remote_srflx->id(), 0); 947 "RTCIceCandidate_" + a_remote_srflx->id(), 0);
938 expected_a_remote_srflx.ip = "6.7.8.9"; 948 expected_a_remote_srflx.ip = "6.7.8.9";
939 expected_a_remote_srflx.port = 10; 949 expected_a_remote_srflx.port = 10;
940 expected_a_remote_srflx.protocol = "remote_srflx's protocol"; 950 expected_a_remote_srflx.protocol = "remote_srflx's protocol";
941 expected_a_remote_srflx.candidate_type = "srflx"; 951 expected_a_remote_srflx.candidate_type = "srflx";
942 expected_a_remote_srflx.priority = 1; 952 expected_a_remote_srflx.priority = 1;
953 expected_a_remote_srflx.transport_id = "RTCTransport_a_" +
954 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP);
943 955
944 std::unique_ptr<cricket::Candidate> a_local_prflx = CreateFakeCandidate( 956 std::unique_ptr<cricket::Candidate> a_local_prflx = CreateFakeCandidate(
945 "11.12.13.14", 15, 957 "11.12.13.14", 15,
946 "a_local_prflx's protocol", 958 "a_local_prflx's protocol",
947 cricket::PRFLX_PORT_TYPE, 959 cricket::PRFLX_PORT_TYPE,
948 2); 960 2,
961 cricket::ICE_CANDIDATE_COMPONENT_RTCP,
962 "a");
949 RTCLocalIceCandidateStats expected_a_local_prflx( 963 RTCLocalIceCandidateStats expected_a_local_prflx(
950 "RTCIceCandidate_" + a_local_prflx->id(), 0); 964 "RTCIceCandidate_" + a_local_prflx->id(), 0);
951 expected_a_local_prflx.ip = "11.12.13.14"; 965 expected_a_local_prflx.ip = "11.12.13.14";
952 expected_a_local_prflx.port = 15; 966 expected_a_local_prflx.port = 15;
953 expected_a_local_prflx.protocol = "a_local_prflx's protocol"; 967 expected_a_local_prflx.protocol = "a_local_prflx's protocol";
954 expected_a_local_prflx.candidate_type = "prflx"; 968 expected_a_local_prflx.candidate_type = "prflx";
955 expected_a_local_prflx.priority = 2; 969 expected_a_local_prflx.priority = 2;
970 expected_a_local_prflx.transport_id = "RTCTransport_a_" +
971 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTCP);
956 972
957 std::unique_ptr<cricket::Candidate> a_remote_relay = CreateFakeCandidate( 973 std::unique_ptr<cricket::Candidate> a_remote_relay = CreateFakeCandidate(
958 "16.17.18.19", 20, 974 "16.17.18.19", 20,
959 "a_remote_relay's protocol", 975 "a_remote_relay's protocol",
960 cricket::RELAY_PORT_TYPE, 976 cricket::RELAY_PORT_TYPE,
961 3); 977 3,
978 cricket::ICE_CANDIDATE_COMPONENT_RTCP,
979 "a");
962 RTCRemoteIceCandidateStats expected_a_remote_relay( 980 RTCRemoteIceCandidateStats expected_a_remote_relay(
963 "RTCIceCandidate_" + a_remote_relay->id(), 0); 981 "RTCIceCandidate_" + a_remote_relay->id(), 0);
964 expected_a_remote_relay.ip = "16.17.18.19"; 982 expected_a_remote_relay.ip = "16.17.18.19";
965 expected_a_remote_relay.port = 20; 983 expected_a_remote_relay.port = 20;
966 expected_a_remote_relay.protocol = "a_remote_relay's protocol"; 984 expected_a_remote_relay.protocol = "a_remote_relay's protocol";
967 expected_a_remote_relay.candidate_type = "relay"; 985 expected_a_remote_relay.candidate_type = "relay";
968 expected_a_remote_relay.priority = 3; 986 expected_a_remote_relay.priority = 3;
987 expected_a_remote_relay.transport_id = "RTCTransport_a_" +
988 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTCP);
969 989
970 // Candidates in the second transport stats. 990 // Candidates in the second transport stats.
971 std::unique_ptr<cricket::Candidate> b_local = CreateFakeCandidate( 991 std::unique_ptr<cricket::Candidate> b_local = CreateFakeCandidate(
972 "42.42.42.42", 42, 992 "42.42.42.42", 42,
973 "b_local's protocol", 993 "b_local's protocol",
974 cricket::LOCAL_PORT_TYPE, 994 cricket::LOCAL_PORT_TYPE,
975 42); 995 42);
976 RTCLocalIceCandidateStats expected_b_local( 996 RTCLocalIceCandidateStats expected_b_local(
977 "RTCIceCandidate_" + b_local->id(), 0); 997 "RTCIceCandidate_" + b_local->id(), 0);
978 expected_b_local.ip = "42.42.42.42"; 998 expected_b_local.ip = "42.42.42.42";
(...skipping 10 matching lines...) Expand all
989 RTCRemoteIceCandidateStats expected_b_remote( 1009 RTCRemoteIceCandidateStats expected_b_remote(
990 "RTCIceCandidate_" + b_remote->id(), 0); 1010 "RTCIceCandidate_" + b_remote->id(), 0);
991 expected_b_remote.ip = "42.42.42.42"; 1011 expected_b_remote.ip = "42.42.42.42";
992 expected_b_remote.port = 42; 1012 expected_b_remote.port = 42;
993 expected_b_remote.protocol = "b_remote's protocol"; 1013 expected_b_remote.protocol = "b_remote's protocol";
994 expected_b_remote.candidate_type = "host"; 1014 expected_b_remote.candidate_type = "host";
995 expected_b_remote.priority = 42; 1015 expected_b_remote.priority = 42;
996 1016
997 SessionStats session_stats; 1017 SessionStats session_stats;
998 1018
999 cricket::TransportChannelStats a_transport_channel_stats; 1019 cricket::TransportChannelStats a_transport_channel_stats_rtp;
1000 a_transport_channel_stats.connection_infos.push_back( 1020 a_transport_channel_stats_rtp.component =
1021 cricket::ICE_CANDIDATE_COMPONENT_RTP;
1022 a_transport_channel_stats_rtp.connection_infos.push_back(
1001 cricket::ConnectionInfo()); 1023 cricket::ConnectionInfo());
1002 a_transport_channel_stats.connection_infos[0].local_candidate = 1024 a_transport_channel_stats_rtp.connection_infos[0].local_candidate =
1003 *a_local_host.get(); 1025 *a_local_host.get();
1004 a_transport_channel_stats.connection_infos[0].remote_candidate = 1026 a_transport_channel_stats_rtp.connection_infos[0].remote_candidate =
1005 *a_remote_srflx.get(); 1027 *a_remote_srflx.get();
1006 a_transport_channel_stats.connection_infos.push_back( 1028 cricket::TransportChannelStats a_transport_channel_stats_rtcp;
1029 a_transport_channel_stats_rtcp.component =
1030 cricket::ICE_CANDIDATE_COMPONENT_RTCP;
1031 a_transport_channel_stats_rtcp.connection_infos.push_back(
1007 cricket::ConnectionInfo()); 1032 cricket::ConnectionInfo());
1008 a_transport_channel_stats.connection_infos[1].local_candidate = 1033 a_transport_channel_stats_rtcp.connection_infos[0].local_candidate =
1009 *a_local_prflx.get(); 1034 *a_local_prflx.get();
1010 a_transport_channel_stats.connection_infos[1].remote_candidate = 1035 a_transport_channel_stats_rtcp.connection_infos[0].remote_candidate =
1011 *a_remote_relay.get(); 1036 *a_remote_relay.get();
1012 session_stats.transport_stats["a"].transport_name = "a"; 1037 session_stats.transport_stats["a"].transport_name = "a";
1013 session_stats.transport_stats["a"].channel_stats.push_back( 1038 session_stats.transport_stats["a"].channel_stats.push_back(
1014 a_transport_channel_stats); 1039 a_transport_channel_stats_rtp);
1040 session_stats.transport_stats["a"].channel_stats.push_back(
1041 a_transport_channel_stats_rtcp);
1015 1042
1016 cricket::TransportChannelStats b_transport_channel_stats; 1043 cricket::TransportChannelStats b_transport_channel_stats;
1017 b_transport_channel_stats.connection_infos.push_back( 1044 b_transport_channel_stats.connection_infos.push_back(
1018 cricket::ConnectionInfo()); 1045 cricket::ConnectionInfo());
1019 b_transport_channel_stats.connection_infos[0].local_candidate = 1046 b_transport_channel_stats.connection_infos[0].local_candidate =
1020 *b_local.get(); 1047 *b_local.get();
1021 b_transport_channel_stats.connection_infos[0].remote_candidate = 1048 b_transport_channel_stats.connection_infos[0].remote_candidate =
1022 *b_remote.get(); 1049 *b_remote.get();
1023 session_stats.transport_stats["b"].transport_name = "b"; 1050 session_stats.transport_stats["b"].transport_name = "b";
1024 session_stats.transport_stats["b"].channel_stats.push_back( 1051 session_stats.transport_stats["b"].channel_stats.push_back(
(...skipping 24 matching lines...) Expand all
1049 report->Get(expected_a_remote_relay.id())->cast_to< 1076 report->Get(expected_a_remote_relay.id())->cast_to<
1050 RTCRemoteIceCandidateStats>()); 1077 RTCRemoteIceCandidateStats>());
1051 EXPECT_TRUE(report->Get(expected_b_local.id())); 1078 EXPECT_TRUE(report->Get(expected_b_local.id()));
1052 EXPECT_EQ(expected_b_local, 1079 EXPECT_EQ(expected_b_local,
1053 report->Get(expected_b_local.id())->cast_to< 1080 report->Get(expected_b_local.id())->cast_to<
1054 RTCLocalIceCandidateStats>()); 1081 RTCLocalIceCandidateStats>());
1055 EXPECT_TRUE(report->Get(expected_b_remote.id())); 1082 EXPECT_TRUE(report->Get(expected_b_remote.id()));
1056 EXPECT_EQ(expected_b_remote, 1083 EXPECT_EQ(expected_b_remote,
1057 report->Get(expected_b_remote.id())->cast_to< 1084 report->Get(expected_b_remote.id())->cast_to<
1058 RTCRemoteIceCandidateStats>()); 1085 RTCRemoteIceCandidateStats>());
1086
1087 EXPECT_TRUE(report->Get(*expected_a_local_host.transport_id));
1088 EXPECT_TRUE(report->Get(*expected_a_remote_srflx.transport_id));
1089 EXPECT_TRUE(report->Get(*expected_a_local_prflx.transport_id));
1090 EXPECT_TRUE(report->Get(*expected_a_remote_relay.transport_id));
1059 } 1091 }
1060 1092
1061 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { 1093 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
1062 std::unique_ptr<cricket::Candidate> local_candidate = CreateFakeCandidate( 1094 std::unique_ptr<cricket::Candidate> local_candidate = CreateFakeCandidate(
1063 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42); 1095 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42);
1064 std::unique_ptr<cricket::Candidate> remote_candidate = CreateFakeCandidate( 1096 std::unique_ptr<cricket::Candidate> remote_candidate = CreateFakeCandidate(
1065 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42); 1097 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42);
1066 1098
1067 SessionStats session_stats; 1099 SessionStats session_stats;
1068 1100
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; 2018 rtc::scoped_refptr<FakeRTCStatsCollector> collector_;
1987 }; 2019 };
1988 2020
1989 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { 2021 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) {
1990 collector_->VerifyThreadUsageAndResultsMerging(); 2022 collector_->VerifyThreadUsageAndResultsMerging();
1991 } 2023 }
1992 2024
1993 } // namespace 2025 } // namespace
1994 2026
1995 } // namespace webrtc 2027 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698