OLD | NEW |
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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 897 |
898 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { | 898 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { |
899 // Candidates in the first transport stats. | 899 // Candidates in the first transport stats. |
900 std::unique_ptr<cricket::Candidate> a_local_host = CreateFakeCandidate( | 900 std::unique_ptr<cricket::Candidate> a_local_host = CreateFakeCandidate( |
901 "1.2.3.4", 5, | 901 "1.2.3.4", 5, |
902 "a_local_host's protocol", | 902 "a_local_host's protocol", |
903 cricket::LOCAL_PORT_TYPE, | 903 cricket::LOCAL_PORT_TYPE, |
904 0); | 904 0); |
905 RTCLocalIceCandidateStats expected_a_local_host( | 905 RTCLocalIceCandidateStats expected_a_local_host( |
906 "RTCIceCandidate_" + a_local_host->id(), 0); | 906 "RTCIceCandidate_" + a_local_host->id(), 0); |
| 907 expected_a_local_host.transport_id = "RTCTransport_a_0"; |
907 expected_a_local_host.ip = "1.2.3.4"; | 908 expected_a_local_host.ip = "1.2.3.4"; |
908 expected_a_local_host.port = 5; | 909 expected_a_local_host.port = 5; |
909 expected_a_local_host.protocol = "a_local_host's protocol"; | 910 expected_a_local_host.protocol = "a_local_host's protocol"; |
910 expected_a_local_host.candidate_type = "host"; | 911 expected_a_local_host.candidate_type = "host"; |
911 expected_a_local_host.priority = 0; | 912 expected_a_local_host.priority = 0; |
912 EXPECT_FALSE(*expected_a_local_host.is_remote); | 913 EXPECT_FALSE(*expected_a_local_host.is_remote); |
913 | 914 |
914 std::unique_ptr<cricket::Candidate> a_remote_srflx = CreateFakeCandidate( | 915 std::unique_ptr<cricket::Candidate> a_remote_srflx = CreateFakeCandidate( |
915 "6.7.8.9", 10, | 916 "6.7.8.9", 10, |
916 "remote_srflx's protocol", | 917 "remote_srflx's protocol", |
917 cricket::STUN_PORT_TYPE, | 918 cricket::STUN_PORT_TYPE, |
918 1); | 919 1); |
919 RTCRemoteIceCandidateStats expected_a_remote_srflx( | 920 RTCRemoteIceCandidateStats expected_a_remote_srflx( |
920 "RTCIceCandidate_" + a_remote_srflx->id(), 0); | 921 "RTCIceCandidate_" + a_remote_srflx->id(), 0); |
| 922 expected_a_remote_srflx.transport_id = "RTCTransport_a_0"; |
921 expected_a_remote_srflx.ip = "6.7.8.9"; | 923 expected_a_remote_srflx.ip = "6.7.8.9"; |
922 expected_a_remote_srflx.port = 10; | 924 expected_a_remote_srflx.port = 10; |
923 expected_a_remote_srflx.protocol = "remote_srflx's protocol"; | 925 expected_a_remote_srflx.protocol = "remote_srflx's protocol"; |
924 expected_a_remote_srflx.candidate_type = "srflx"; | 926 expected_a_remote_srflx.candidate_type = "srflx"; |
925 expected_a_remote_srflx.priority = 1; | 927 expected_a_remote_srflx.priority = 1; |
926 expected_a_remote_srflx.deleted = false; | 928 expected_a_remote_srflx.deleted = false; |
927 EXPECT_TRUE(*expected_a_remote_srflx.is_remote); | 929 EXPECT_TRUE(*expected_a_remote_srflx.is_remote); |
928 | 930 |
929 std::unique_ptr<cricket::Candidate> a_local_prflx = CreateFakeCandidate( | 931 std::unique_ptr<cricket::Candidate> a_local_prflx = CreateFakeCandidate( |
930 "11.12.13.14", 15, | 932 "11.12.13.14", 15, |
931 "a_local_prflx's protocol", | 933 "a_local_prflx's protocol", |
932 cricket::PRFLX_PORT_TYPE, | 934 cricket::PRFLX_PORT_TYPE, |
933 2); | 935 2); |
934 RTCLocalIceCandidateStats expected_a_local_prflx( | 936 RTCLocalIceCandidateStats expected_a_local_prflx( |
935 "RTCIceCandidate_" + a_local_prflx->id(), 0); | 937 "RTCIceCandidate_" + a_local_prflx->id(), 0); |
| 938 expected_a_local_prflx.transport_id = "RTCTransport_a_0"; |
936 expected_a_local_prflx.ip = "11.12.13.14"; | 939 expected_a_local_prflx.ip = "11.12.13.14"; |
937 expected_a_local_prflx.port = 15; | 940 expected_a_local_prflx.port = 15; |
938 expected_a_local_prflx.protocol = "a_local_prflx's protocol"; | 941 expected_a_local_prflx.protocol = "a_local_prflx's protocol"; |
939 expected_a_local_prflx.candidate_type = "prflx"; | 942 expected_a_local_prflx.candidate_type = "prflx"; |
940 expected_a_local_prflx.priority = 2; | 943 expected_a_local_prflx.priority = 2; |
941 expected_a_local_prflx.deleted = false; | 944 expected_a_local_prflx.deleted = false; |
942 EXPECT_FALSE(*expected_a_local_prflx.is_remote); | 945 EXPECT_FALSE(*expected_a_local_prflx.is_remote); |
943 | 946 |
944 std::unique_ptr<cricket::Candidate> a_remote_relay = CreateFakeCandidate( | 947 std::unique_ptr<cricket::Candidate> a_remote_relay = CreateFakeCandidate( |
945 "16.17.18.19", 20, | 948 "16.17.18.19", 20, |
946 "a_remote_relay's protocol", | 949 "a_remote_relay's protocol", |
947 cricket::RELAY_PORT_TYPE, | 950 cricket::RELAY_PORT_TYPE, |
948 3); | 951 3); |
949 RTCRemoteIceCandidateStats expected_a_remote_relay( | 952 RTCRemoteIceCandidateStats expected_a_remote_relay( |
950 "RTCIceCandidate_" + a_remote_relay->id(), 0); | 953 "RTCIceCandidate_" + a_remote_relay->id(), 0); |
| 954 expected_a_remote_relay.transport_id = "RTCTransport_a_0"; |
951 expected_a_remote_relay.ip = "16.17.18.19"; | 955 expected_a_remote_relay.ip = "16.17.18.19"; |
952 expected_a_remote_relay.port = 20; | 956 expected_a_remote_relay.port = 20; |
953 expected_a_remote_relay.protocol = "a_remote_relay's protocol"; | 957 expected_a_remote_relay.protocol = "a_remote_relay's protocol"; |
954 expected_a_remote_relay.candidate_type = "relay"; | 958 expected_a_remote_relay.candidate_type = "relay"; |
955 expected_a_remote_relay.priority = 3; | 959 expected_a_remote_relay.priority = 3; |
956 expected_a_remote_relay.deleted = false; | 960 expected_a_remote_relay.deleted = false; |
957 EXPECT_TRUE(*expected_a_remote_relay.is_remote); | 961 EXPECT_TRUE(*expected_a_remote_relay.is_remote); |
958 | 962 |
959 // Candidates in the second transport stats. | 963 // Candidates in the second transport stats. |
960 std::unique_ptr<cricket::Candidate> b_local = CreateFakeCandidate( | 964 std::unique_ptr<cricket::Candidate> b_local = CreateFakeCandidate( |
961 "42.42.42.42", 42, | 965 "42.42.42.42", 42, |
962 "b_local's protocol", | 966 "b_local's protocol", |
963 cricket::LOCAL_PORT_TYPE, | 967 cricket::LOCAL_PORT_TYPE, |
964 42); | 968 42); |
965 RTCLocalIceCandidateStats expected_b_local( | 969 RTCLocalIceCandidateStats expected_b_local( |
966 "RTCIceCandidate_" + b_local->id(), 0); | 970 "RTCIceCandidate_" + b_local->id(), 0); |
| 971 expected_b_local.transport_id = "RTCTransport_b_0"; |
967 expected_b_local.ip = "42.42.42.42"; | 972 expected_b_local.ip = "42.42.42.42"; |
968 expected_b_local.port = 42; | 973 expected_b_local.port = 42; |
969 expected_b_local.protocol = "b_local's protocol"; | 974 expected_b_local.protocol = "b_local's protocol"; |
970 expected_b_local.candidate_type = "host"; | 975 expected_b_local.candidate_type = "host"; |
971 expected_b_local.priority = 42; | 976 expected_b_local.priority = 42; |
972 expected_b_local.deleted = false; | 977 expected_b_local.deleted = false; |
973 EXPECT_FALSE(*expected_b_local.is_remote); | 978 EXPECT_FALSE(*expected_b_local.is_remote); |
974 | 979 |
975 std::unique_ptr<cricket::Candidate> b_remote = CreateFakeCandidate( | 980 std::unique_ptr<cricket::Candidate> b_remote = CreateFakeCandidate( |
976 "42.42.42.42", 42, | 981 "42.42.42.42", 42, |
977 "b_remote's protocol", | 982 "b_remote's protocol", |
978 cricket::LOCAL_PORT_TYPE, | 983 cricket::LOCAL_PORT_TYPE, |
979 42); | 984 42); |
980 RTCRemoteIceCandidateStats expected_b_remote( | 985 RTCRemoteIceCandidateStats expected_b_remote( |
981 "RTCIceCandidate_" + b_remote->id(), 0); | 986 "RTCIceCandidate_" + b_remote->id(), 0); |
| 987 expected_b_remote.transport_id = "RTCTransport_b_0"; |
982 expected_b_remote.ip = "42.42.42.42"; | 988 expected_b_remote.ip = "42.42.42.42"; |
983 expected_b_remote.port = 42; | 989 expected_b_remote.port = 42; |
984 expected_b_remote.protocol = "b_remote's protocol"; | 990 expected_b_remote.protocol = "b_remote's protocol"; |
985 expected_b_remote.candidate_type = "host"; | 991 expected_b_remote.candidate_type = "host"; |
986 expected_b_remote.priority = 42; | 992 expected_b_remote.priority = 42; |
987 expected_b_remote.deleted = false; | 993 expected_b_remote.deleted = false; |
988 EXPECT_TRUE(*expected_b_remote.is_remote); | 994 EXPECT_TRUE(*expected_b_remote.is_remote); |
989 | 995 |
990 SessionStats session_stats; | 996 SessionStats session_stats; |
991 | 997 |
(...skipping 26 matching lines...) Expand all Loading... |
1018 b_transport_channel_stats); | 1024 b_transport_channel_stats); |
1019 | 1025 |
1020 // Mock the session to return the desired candidates. | 1026 // Mock the session to return the desired candidates. |
1021 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( | 1027 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( |
1022 [&session_stats](const ChannelNamePairs&) { | 1028 [&session_stats](const ChannelNamePairs&) { |
1023 return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); | 1029 return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); |
1024 })); | 1030 })); |
1025 | 1031 |
1026 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1032 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1027 | 1033 |
1028 EXPECT_TRUE(report->Get(expected_a_local_host.id())); | 1034 ASSERT_TRUE(report->Get(expected_a_local_host.id())); |
1029 EXPECT_EQ(expected_a_local_host, | 1035 EXPECT_EQ(expected_a_local_host, |
1030 report->Get(expected_a_local_host.id())->cast_to< | 1036 report->Get(expected_a_local_host.id())->cast_to< |
1031 RTCLocalIceCandidateStats>()); | 1037 RTCLocalIceCandidateStats>()); |
1032 EXPECT_TRUE(report->Get(expected_a_remote_srflx.id())); | 1038 ASSERT_TRUE(report->Get(expected_a_remote_srflx.id())); |
1033 EXPECT_EQ(expected_a_remote_srflx, | 1039 EXPECT_EQ(expected_a_remote_srflx, |
1034 report->Get(expected_a_remote_srflx.id())->cast_to< | 1040 report->Get(expected_a_remote_srflx.id())->cast_to< |
1035 RTCRemoteIceCandidateStats>()); | 1041 RTCRemoteIceCandidateStats>()); |
1036 EXPECT_TRUE(report->Get(expected_a_local_prflx.id())); | 1042 ASSERT_TRUE(report->Get(expected_a_local_prflx.id())); |
1037 EXPECT_EQ(expected_a_local_prflx, | 1043 EXPECT_EQ(expected_a_local_prflx, |
1038 report->Get(expected_a_local_prflx.id())->cast_to< | 1044 report->Get(expected_a_local_prflx.id())->cast_to< |
1039 RTCLocalIceCandidateStats>()); | 1045 RTCLocalIceCandidateStats>()); |
1040 EXPECT_TRUE(report->Get(expected_a_remote_relay.id())); | 1046 ASSERT_TRUE(report->Get(expected_a_remote_relay.id())); |
1041 EXPECT_EQ(expected_a_remote_relay, | 1047 EXPECT_EQ(expected_a_remote_relay, |
1042 report->Get(expected_a_remote_relay.id())->cast_to< | 1048 report->Get(expected_a_remote_relay.id())->cast_to< |
1043 RTCRemoteIceCandidateStats>()); | 1049 RTCRemoteIceCandidateStats>()); |
1044 EXPECT_TRUE(report->Get(expected_b_local.id())); | 1050 ASSERT_TRUE(report->Get(expected_b_local.id())); |
1045 EXPECT_EQ(expected_b_local, | 1051 EXPECT_EQ(expected_b_local, |
1046 report->Get(expected_b_local.id())->cast_to< | 1052 report->Get(expected_b_local.id())->cast_to< |
1047 RTCLocalIceCandidateStats>()); | 1053 RTCLocalIceCandidateStats>()); |
1048 EXPECT_TRUE(report->Get(expected_b_remote.id())); | 1054 ASSERT_TRUE(report->Get(expected_b_remote.id())); |
1049 EXPECT_EQ(expected_b_remote, | 1055 EXPECT_EQ(expected_b_remote, |
1050 report->Get(expected_b_remote.id())->cast_to< | 1056 report->Get(expected_b_remote.id())->cast_to< |
1051 RTCRemoteIceCandidateStats>()); | 1057 RTCRemoteIceCandidateStats>()); |
| 1058 EXPECT_TRUE(report->Get("RTCTransport_a_0")); |
| 1059 EXPECT_TRUE(report->Get("RTCTransport_b_0")); |
1052 } | 1060 } |
1053 | 1061 |
1054 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { | 1062 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { |
1055 std::unique_ptr<cricket::Candidate> local_candidate = CreateFakeCandidate( | 1063 std::unique_ptr<cricket::Candidate> local_candidate = CreateFakeCandidate( |
1056 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42); | 1064 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42); |
1057 std::unique_ptr<cricket::Candidate> remote_candidate = CreateFakeCandidate( | 1065 std::unique_ptr<cricket::Candidate> remote_candidate = CreateFakeCandidate( |
1058 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42); | 1066 "42.42.42.42", 42, "protocol", cricket::LOCAL_PORT_TYPE, 42); |
1059 | 1067 |
1060 SessionStats session_stats; | 1068 SessionStats session_stats; |
1061 | 1069 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 expected_pair.requests_received = 2020; | 1116 expected_pair.requests_received = 2020; |
1109 expected_pair.requests_sent = 2000; | 1117 expected_pair.requests_sent = 2000; |
1110 expected_pair.responses_received = 4321; | 1118 expected_pair.responses_received = 4321; |
1111 expected_pair.responses_sent = 1000; | 1119 expected_pair.responses_sent = 1000; |
1112 expected_pair.consent_requests_sent = (2020 - 2000); | 1120 expected_pair.consent_requests_sent = (2020 - 2000); |
1113 | 1121 |
1114 ASSERT_TRUE(report->Get(expected_pair.id())); | 1122 ASSERT_TRUE(report->Get(expected_pair.id())); |
1115 EXPECT_EQ( | 1123 EXPECT_EQ( |
1116 expected_pair, | 1124 expected_pair, |
1117 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); | 1125 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); |
| 1126 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); |
1118 | 1127 |
1119 RTCLocalIceCandidateStats expected_local_candidate( | 1128 RTCLocalIceCandidateStats expected_local_candidate( |
1120 *expected_pair.local_candidate_id, report->timestamp_us()); | 1129 *expected_pair.local_candidate_id, report->timestamp_us()); |
| 1130 expected_local_candidate.transport_id = *expected_pair.transport_id; |
1121 expected_local_candidate.ip = "42.42.42.42"; | 1131 expected_local_candidate.ip = "42.42.42.42"; |
1122 expected_local_candidate.port = 42; | 1132 expected_local_candidate.port = 42; |
1123 expected_local_candidate.protocol = "protocol"; | 1133 expected_local_candidate.protocol = "protocol"; |
1124 expected_local_candidate.candidate_type = "host"; | 1134 expected_local_candidate.candidate_type = "host"; |
1125 expected_local_candidate.priority = 42; | 1135 expected_local_candidate.priority = 42; |
1126 expected_local_candidate.deleted = false; | 1136 expected_local_candidate.deleted = false; |
1127 EXPECT_FALSE(*expected_local_candidate.is_remote); | 1137 EXPECT_FALSE(*expected_local_candidate.is_remote); |
1128 ASSERT_TRUE(report->Get(expected_local_candidate.id())); | 1138 ASSERT_TRUE(report->Get(expected_local_candidate.id())); |
1129 EXPECT_EQ(expected_local_candidate, | 1139 EXPECT_EQ(expected_local_candidate, |
1130 report->Get(expected_local_candidate.id())->cast_to< | 1140 report->Get(expected_local_candidate.id())->cast_to< |
1131 RTCLocalIceCandidateStats>()); | 1141 RTCLocalIceCandidateStats>()); |
1132 | 1142 |
1133 RTCRemoteIceCandidateStats expected_remote_candidate( | 1143 RTCRemoteIceCandidateStats expected_remote_candidate( |
1134 *expected_pair.remote_candidate_id, report->timestamp_us()); | 1144 *expected_pair.remote_candidate_id, report->timestamp_us()); |
| 1145 expected_remote_candidate.transport_id = *expected_pair.transport_id; |
1135 expected_remote_candidate.ip = "42.42.42.42"; | 1146 expected_remote_candidate.ip = "42.42.42.42"; |
1136 expected_remote_candidate.port = 42; | 1147 expected_remote_candidate.port = 42; |
1137 expected_remote_candidate.protocol = "protocol"; | 1148 expected_remote_candidate.protocol = "protocol"; |
1138 expected_remote_candidate.candidate_type = "host"; | 1149 expected_remote_candidate.candidate_type = "host"; |
1139 expected_remote_candidate.priority = 42; | 1150 expected_remote_candidate.priority = 42; |
1140 expected_remote_candidate.deleted = false; | 1151 expected_remote_candidate.deleted = false; |
1141 EXPECT_TRUE(*expected_remote_candidate.is_remote); | 1152 EXPECT_TRUE(*expected_remote_candidate.is_remote); |
1142 ASSERT_TRUE(report->Get(expected_remote_candidate.id())); | 1153 ASSERT_TRUE(report->Get(expected_remote_candidate.id())); |
1143 EXPECT_EQ(expected_remote_candidate, | 1154 EXPECT_EQ(expected_remote_candidate, |
1144 report->Get(expected_remote_candidate.id())->cast_to< | 1155 report->Get(expected_remote_candidate.id())->cast_to< |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 2007 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
1997 }; | 2008 }; |
1998 | 2009 |
1999 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 2010 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
2000 collector_->VerifyThreadUsageAndResultsMerging(); | 2011 collector_->VerifyThreadUsageAndResultsMerging(); |
2001 } | 2012 } |
2002 | 2013 |
2003 } // namespace | 2014 } // namespace |
2004 | 2015 |
2005 } // namespace webrtc | 2016 } // namespace webrtc |
OLD | NEW |