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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 EXPECT_EQ(*cert_stats.base64_certificate, cert_info.pems[i]); | 532 EXPECT_EQ(*cert_stats.base64_certificate, cert_info.pems[i]); |
533 if (i + 1 < cert_info.fingerprints.size()) { | 533 if (i + 1 < cert_info.fingerprints.size()) { |
534 EXPECT_EQ(*cert_stats.issuer_certificate_id, | 534 EXPECT_EQ(*cert_stats.issuer_certificate_id, |
535 "RTCCertificate_" + cert_info.fingerprints[i + 1]); | 535 "RTCCertificate_" + cert_info.fingerprints[i + 1]); |
536 } else { | 536 } else { |
537 EXPECT_FALSE(cert_stats.issuer_certificate_id.is_defined()); | 537 EXPECT_FALSE(cert_stats.issuer_certificate_id.is_defined()); |
538 } | 538 } |
539 } | 539 } |
540 } | 540 } |
541 | 541 |
542 void ExpectReportContainsDataChannel( | |
543 const rtc::scoped_refptr<const RTCStatsReport>& report, | |
544 const DataChannel& data_channel) { | |
545 const RTCStats* stats = report->Get("RTCDataChannel_" + | |
546 rtc::ToString<>(data_channel.id())); | |
547 EXPECT_TRUE(stats); | |
548 const RTCDataChannelStats& data_channel_stats = | |
549 stats->cast_to<const RTCDataChannelStats>(); | |
550 EXPECT_EQ(*data_channel_stats.label, data_channel.label()); | |
551 EXPECT_EQ(*data_channel_stats.protocol, data_channel.protocol()); | |
552 EXPECT_EQ(*data_channel_stats.datachannelid, data_channel.id()); | |
553 EXPECT_EQ(*data_channel_stats.state, | |
554 DataStateToRTCDataChannelStateForTesting(data_channel.state())); | |
555 EXPECT_EQ(*data_channel_stats.messages_sent, data_channel.messages_sent()); | |
556 EXPECT_EQ(*data_channel_stats.bytes_sent, data_channel.bytes_sent()); | |
557 EXPECT_EQ(*data_channel_stats.messages_received, | |
558 data_channel.messages_received()); | |
559 EXPECT_EQ(*data_channel_stats.bytes_received, | |
560 data_channel.bytes_received()); | |
561 } | |
562 | |
563 protected: | 542 protected: |
564 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; | 543 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; |
565 rtc::scoped_refptr<RTCStatsCollector> collector_; | 544 rtc::scoped_refptr<RTCStatsCollector> collector_; |
566 }; | 545 }; |
567 | 546 |
568 TEST_F(RTCStatsCollectorTest, SingleCallback) { | 547 TEST_F(RTCStatsCollectorTest, SingleCallback) { |
569 rtc::scoped_refptr<const RTCStatsReport> result; | 548 rtc::scoped_refptr<const RTCStatsReport> result; |
570 collector_->GetStatsReport(RTCStatsObtainer::Create(&result)); | 549 collector_->GetStatsReport(RTCStatsObtainer::Create(&result)); |
571 EXPECT_TRUE_WAIT(result, kGetStatsReportTimeoutMs); | 550 EXPECT_TRUE_WAIT(result, kGetStatsReportTimeoutMs); |
572 } | 551 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 return static_cast<rtc::SSLCertificate*>(nullptr); | 856 return static_cast<rtc::SSLCertificate*>(nullptr); |
878 })); | 857 })); |
879 | 858 |
880 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 859 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
881 ExpectReportContainsCertificateInfo(report, *local_certinfo.get()); | 860 ExpectReportContainsCertificateInfo(report, *local_certinfo.get()); |
882 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get()); | 861 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get()); |
883 } | 862 } |
884 | 863 |
885 TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) { | 864 TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) { |
886 test_->data_channels().push_back( | 865 test_->data_channels().push_back( |
887 new MockDataChannel(0, DataChannelInterface::kConnecting)); | 866 new MockDataChannel( |
| 867 0, "MockDataChannel0", DataChannelInterface::kConnecting, "udp", |
| 868 1, 2, 3, 4)); |
| 869 RTCDataChannelStats expected_data_channel0("RTCDataChannel_0", 0); |
| 870 expected_data_channel0.label = "MockDataChannel0"; |
| 871 expected_data_channel0.protocol = "udp"; |
| 872 expected_data_channel0.datachannelid = 0; |
| 873 expected_data_channel0.state = "connecting"; |
| 874 expected_data_channel0.messages_sent = 1; |
| 875 expected_data_channel0.bytes_sent = 2; |
| 876 expected_data_channel0.messages_received = 3; |
| 877 expected_data_channel0.bytes_received = 4; |
| 878 |
888 test_->data_channels().push_back( | 879 test_->data_channels().push_back( |
889 new MockDataChannel(1, DataChannelInterface::kOpen)); | 880 new MockDataChannel( |
| 881 1, "MockDataChannel1", DataChannelInterface::kOpen, "tcp", |
| 882 5, 6, 7, 8)); |
| 883 RTCDataChannelStats expected_data_channel1("RTCDataChannel_1", 0); |
| 884 expected_data_channel1.label = "MockDataChannel1"; |
| 885 expected_data_channel1.protocol = "tcp"; |
| 886 expected_data_channel1.datachannelid = 1; |
| 887 expected_data_channel1.state = "open"; |
| 888 expected_data_channel1.messages_sent = 5; |
| 889 expected_data_channel1.bytes_sent = 6; |
| 890 expected_data_channel1.messages_received = 7; |
| 891 expected_data_channel1.bytes_received = 8; |
| 892 |
890 test_->data_channels().push_back( | 893 test_->data_channels().push_back( |
891 new MockDataChannel(2, DataChannelInterface::kClosing)); | 894 new MockDataChannel( |
| 895 2, "MockDataChannel2", DataChannelInterface::kClosing, "udp", |
| 896 9, 10, 11, 12)); |
| 897 RTCDataChannelStats expected_data_channel2("RTCDataChannel_2", 0); |
| 898 expected_data_channel2.label = "MockDataChannel2"; |
| 899 expected_data_channel2.protocol = "udp"; |
| 900 expected_data_channel2.datachannelid = 2; |
| 901 expected_data_channel2.state = "closing"; |
| 902 expected_data_channel2.messages_sent = 9; |
| 903 expected_data_channel2.bytes_sent = 10; |
| 904 expected_data_channel2.messages_received = 11; |
| 905 expected_data_channel2.bytes_received = 12; |
| 906 |
892 test_->data_channels().push_back( | 907 test_->data_channels().push_back( |
893 new MockDataChannel(3, DataChannelInterface::kClosed)); | 908 new MockDataChannel( |
| 909 3, "MockDataChannel3", DataChannelInterface::kClosed, "tcp", |
| 910 13, 14, 15, 16)); |
| 911 RTCDataChannelStats expected_data_channel3("RTCDataChannel_3", 0); |
| 912 expected_data_channel3.label = "MockDataChannel3"; |
| 913 expected_data_channel3.protocol = "tcp"; |
| 914 expected_data_channel3.datachannelid = 3; |
| 915 expected_data_channel3.state = "closed"; |
| 916 expected_data_channel3.messages_sent = 13; |
| 917 expected_data_channel3.bytes_sent = 14; |
| 918 expected_data_channel3.messages_received = 15; |
| 919 expected_data_channel3.bytes_received = 16; |
894 | 920 |
895 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 921 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
896 ExpectReportContainsDataChannel(report, *test_->data_channels()[0]); | 922 ASSERT_TRUE(report->Get(expected_data_channel0.id())); |
897 ExpectReportContainsDataChannel(report, *test_->data_channels()[1]); | 923 EXPECT_EQ(expected_data_channel0, |
898 ExpectReportContainsDataChannel(report, *test_->data_channels()[2]); | 924 report->Get(expected_data_channel0.id())->cast_to< |
899 ExpectReportContainsDataChannel(report, *test_->data_channels()[3]); | 925 RTCDataChannelStats>()); |
900 | 926 ASSERT_TRUE(report->Get(expected_data_channel1.id())); |
901 test_->data_channels().clear(); | 927 EXPECT_EQ(expected_data_channel1, |
902 test_->data_channels().push_back( | 928 report->Get(expected_data_channel1.id())->cast_to< |
903 new MockDataChannel(0, DataChannelInterface::kConnecting, | 929 RTCDataChannelStats>()); |
904 1, 2, 3, 4)); | 930 ASSERT_TRUE(report->Get(expected_data_channel2.id())); |
905 test_->data_channels().push_back( | 931 EXPECT_EQ(expected_data_channel2, |
906 new MockDataChannel(1, DataChannelInterface::kOpen, | 932 report->Get(expected_data_channel2.id())->cast_to< |
907 5, 6, 7, 8)); | 933 RTCDataChannelStats>()); |
908 test_->data_channels().push_back( | 934 ASSERT_TRUE(report->Get(expected_data_channel3.id())); |
909 new MockDataChannel(2, DataChannelInterface::kClosing, | 935 EXPECT_EQ(expected_data_channel3, |
910 9, 10, 11, 12)); | 936 report->Get(expected_data_channel3.id())->cast_to< |
911 test_->data_channels().push_back( | 937 RTCDataChannelStats>()); |
912 new MockDataChannel(3, DataChannelInterface::kClosed, | |
913 13, 14, 15, 16)); | |
914 | |
915 collector_->ClearCachedStatsReport(); | |
916 report = GetStatsReport(); | |
917 ExpectReportContainsDataChannel(report, *test_->data_channels()[0]); | |
918 ExpectReportContainsDataChannel(report, *test_->data_channels()[1]); | |
919 ExpectReportContainsDataChannel(report, *test_->data_channels()[2]); | |
920 ExpectReportContainsDataChannel(report, *test_->data_channels()[3]); | |
921 } | 938 } |
922 | 939 |
923 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { | 940 TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { |
924 // Candidates in the first transport stats. | 941 // Candidates in the first transport stats. |
925 std::unique_ptr<cricket::Candidate> a_local_host = CreateFakeCandidate( | 942 std::unique_ptr<cricket::Candidate> a_local_host = CreateFakeCandidate( |
926 "1.2.3.4", 5, | 943 "1.2.3.4", 5, |
927 "a_local_host's protocol", | 944 "a_local_host's protocol", |
928 cricket::LOCAL_PORT_TYPE, | 945 cricket::LOCAL_PORT_TYPE, |
929 0); | 946 0); |
930 std::unique_ptr<cricket::Candidate> a_remote_srflx = CreateFakeCandidate( | 947 std::unique_ptr<cricket::Candidate> a_remote_srflx = CreateFakeCandidate( |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 expected_pair.writable = true; | 1063 expected_pair.writable = true; |
1047 expected_pair.bytes_sent = 42; | 1064 expected_pair.bytes_sent = 42; |
1048 expected_pair.bytes_received = 1234; | 1065 expected_pair.bytes_received = 1234; |
1049 expected_pair.current_round_trip_time = 1.337; | 1066 expected_pair.current_round_trip_time = 1.337; |
1050 expected_pair.requests_received = 2020; | 1067 expected_pair.requests_received = 2020; |
1051 expected_pair.requests_sent = 2000; | 1068 expected_pair.requests_sent = 2000; |
1052 expected_pair.responses_received = 4321; | 1069 expected_pair.responses_received = 4321; |
1053 expected_pair.responses_sent = 1000; | 1070 expected_pair.responses_sent = 1000; |
1054 expected_pair.consent_requests_sent = (2020 - 2000); | 1071 expected_pair.consent_requests_sent = (2020 - 2000); |
1055 | 1072 |
1056 EXPECT_TRUE(report->Get(expected_pair.id())); | 1073 ASSERT_TRUE(report->Get(expected_pair.id())); |
1057 EXPECT_EQ( | 1074 EXPECT_EQ( |
1058 expected_pair, | 1075 expected_pair, |
1059 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); | 1076 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); |
1060 | 1077 |
1061 EXPECT_TRUE(report->Get(*expected_pair.local_candidate_id)); | 1078 ASSERT_TRUE(report->Get(*expected_pair.local_candidate_id)); |
1062 ExpectReportContainsCandidate(report, connection_info.local_candidate, true); | 1079 ExpectReportContainsCandidate(report, connection_info.local_candidate, true); |
1063 EXPECT_TRUE(report->Get(*expected_pair.remote_candidate_id)); | 1080 ASSERT_TRUE(report->Get(*expected_pair.remote_candidate_id)); |
1064 ExpectReportContainsCandidate(report, connection_info.remote_candidate, | 1081 ExpectReportContainsCandidate(report, connection_info.remote_candidate, |
1065 false); | 1082 false); |
1066 } | 1083 } |
1067 | 1084 |
1068 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { | 1085 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { |
1069 { | 1086 { |
1070 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1087 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1071 RTCPeerConnectionStats expected("RTCPeerConnection", | 1088 RTCPeerConnectionStats expected("RTCPeerConnection", |
1072 report->timestamp_us()); | 1089 report->timestamp_us()); |
1073 expected.data_channels_opened = 0; | 1090 expected.data_channels_opened = 0; |
1074 expected.data_channels_closed = 0; | 1091 expected.data_channels_closed = 0; |
1075 EXPECT_TRUE(report->Get("RTCPeerConnection")); | 1092 ASSERT_TRUE(report->Get("RTCPeerConnection")); |
1076 EXPECT_EQ(expected, | 1093 EXPECT_EQ(expected, |
1077 report->Get("RTCPeerConnection")->cast_to< | 1094 report->Get("RTCPeerConnection")->cast_to< |
1078 RTCPeerConnectionStats>()); | 1095 RTCPeerConnectionStats>()); |
1079 } | 1096 } |
1080 | 1097 |
1081 rtc::scoped_refptr<DataChannel> dummy_channel_a = DataChannel::Create( | 1098 rtc::scoped_refptr<DataChannel> dummy_channel_a = DataChannel::Create( |
1082 nullptr, cricket::DCT_NONE, "DummyChannelA", InternalDataChannelInit()); | 1099 nullptr, cricket::DCT_NONE, "DummyChannelA", InternalDataChannelInit()); |
1083 test_->pc().SignalDataChannelCreated(dummy_channel_a.get()); | 1100 test_->pc().SignalDataChannelCreated(dummy_channel_a.get()); |
1084 rtc::scoped_refptr<DataChannel> dummy_channel_b = DataChannel::Create( | 1101 rtc::scoped_refptr<DataChannel> dummy_channel_b = DataChannel::Create( |
1085 nullptr, cricket::DCT_NONE, "DummyChannelB", InternalDataChannelInit()); | 1102 nullptr, cricket::DCT_NONE, "DummyChannelB", InternalDataChannelInit()); |
1086 test_->pc().SignalDataChannelCreated(dummy_channel_b.get()); | 1103 test_->pc().SignalDataChannelCreated(dummy_channel_b.get()); |
1087 | 1104 |
1088 dummy_channel_a->SignalOpened(dummy_channel_a.get()); | 1105 dummy_channel_a->SignalOpened(dummy_channel_a.get()); |
1089 // Closing a channel that is not opened should not affect the counts. | 1106 // Closing a channel that is not opened should not affect the counts. |
1090 dummy_channel_b->SignalClosed(dummy_channel_b.get()); | 1107 dummy_channel_b->SignalClosed(dummy_channel_b.get()); |
1091 | 1108 |
1092 { | 1109 { |
1093 collector_->ClearCachedStatsReport(); | 1110 collector_->ClearCachedStatsReport(); |
1094 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1111 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1095 RTCPeerConnectionStats expected("RTCPeerConnection", | 1112 RTCPeerConnectionStats expected("RTCPeerConnection", |
1096 report->timestamp_us()); | 1113 report->timestamp_us()); |
1097 expected.data_channels_opened = 1; | 1114 expected.data_channels_opened = 1; |
1098 expected.data_channels_closed = 0; | 1115 expected.data_channels_closed = 0; |
1099 EXPECT_TRUE(report->Get("RTCPeerConnection")); | 1116 ASSERT_TRUE(report->Get("RTCPeerConnection")); |
1100 EXPECT_EQ(expected, | 1117 EXPECT_EQ(expected, |
1101 report->Get("RTCPeerConnection")->cast_to< | 1118 report->Get("RTCPeerConnection")->cast_to< |
1102 RTCPeerConnectionStats>()); | 1119 RTCPeerConnectionStats>()); |
1103 } | 1120 } |
1104 | 1121 |
1105 dummy_channel_b->SignalOpened(dummy_channel_b.get()); | 1122 dummy_channel_b->SignalOpened(dummy_channel_b.get()); |
1106 dummy_channel_b->SignalClosed(dummy_channel_b.get()); | 1123 dummy_channel_b->SignalClosed(dummy_channel_b.get()); |
1107 | 1124 |
1108 { | 1125 { |
1109 collector_->ClearCachedStatsReport(); | 1126 collector_->ClearCachedStatsReport(); |
1110 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1127 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1111 RTCPeerConnectionStats expected("RTCPeerConnection", | 1128 RTCPeerConnectionStats expected("RTCPeerConnection", |
1112 report->timestamp_us()); | 1129 report->timestamp_us()); |
1113 expected.data_channels_opened = 2; | 1130 expected.data_channels_opened = 2; |
1114 expected.data_channels_closed = 1; | 1131 expected.data_channels_closed = 1; |
1115 EXPECT_TRUE(report->Get("RTCPeerConnection")); | 1132 ASSERT_TRUE(report->Get("RTCPeerConnection")); |
1116 EXPECT_EQ(expected, | 1133 EXPECT_EQ(expected, |
1117 report->Get("RTCPeerConnection")->cast_to< | 1134 report->Get("RTCPeerConnection")->cast_to< |
1118 RTCPeerConnectionStats>()); | 1135 RTCPeerConnectionStats>()); |
1119 } | 1136 } |
1120 } | 1137 } |
1121 | 1138 |
1122 TEST_F(RTCStatsCollectorTest, | 1139 TEST_F(RTCStatsCollectorTest, |
1123 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Audio) { | 1140 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Audio) { |
1124 rtc::scoped_refptr<StreamCollection> local_streams = | 1141 rtc::scoped_refptr<StreamCollection> local_streams = |
1125 StreamCollection::Create(); | 1142 StreamCollection::Create(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 remote_stream->AddTrack(remote_audio_track); | 1179 remote_stream->AddTrack(remote_audio_track); |
1163 | 1180 |
1164 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1181 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1165 | 1182 |
1166 RTCMediaStreamStats expected_local_stream( | 1183 RTCMediaStreamStats expected_local_stream( |
1167 "RTCMediaStream_LocalStreamLabel", report->timestamp_us()); | 1184 "RTCMediaStream_LocalStreamLabel", report->timestamp_us()); |
1168 expected_local_stream.stream_identifier = local_stream->label(); | 1185 expected_local_stream.stream_identifier = local_stream->label(); |
1169 expected_local_stream.track_ids = std::vector<std::string>(); | 1186 expected_local_stream.track_ids = std::vector<std::string>(); |
1170 expected_local_stream.track_ids->push_back( | 1187 expected_local_stream.track_ids->push_back( |
1171 "RTCMediaStreamTrack_LocalAudioTrackID"); | 1188 "RTCMediaStreamTrack_LocalAudioTrackID"); |
1172 EXPECT_TRUE(report->Get(expected_local_stream.id())); | 1189 ASSERT_TRUE(report->Get(expected_local_stream.id())); |
1173 EXPECT_EQ(expected_local_stream, | 1190 EXPECT_EQ(expected_local_stream, |
1174 report->Get(expected_local_stream.id())->cast_to< | 1191 report->Get(expected_local_stream.id())->cast_to< |
1175 RTCMediaStreamStats>()); | 1192 RTCMediaStreamStats>()); |
1176 | 1193 |
1177 RTCMediaStreamStats expected_remote_stream( | 1194 RTCMediaStreamStats expected_remote_stream( |
1178 "RTCMediaStream_RemoteStreamLabel", report->timestamp_us()); | 1195 "RTCMediaStream_RemoteStreamLabel", report->timestamp_us()); |
1179 expected_remote_stream.stream_identifier = remote_stream->label(); | 1196 expected_remote_stream.stream_identifier = remote_stream->label(); |
1180 expected_remote_stream.track_ids = std::vector<std::string>(); | 1197 expected_remote_stream.track_ids = std::vector<std::string>(); |
1181 expected_remote_stream.track_ids->push_back( | 1198 expected_remote_stream.track_ids->push_back( |
1182 "RTCMediaStreamTrack_RemoteAudioTrackID"); | 1199 "RTCMediaStreamTrack_RemoteAudioTrackID"); |
1183 EXPECT_TRUE(report->Get(expected_remote_stream.id())); | 1200 ASSERT_TRUE(report->Get(expected_remote_stream.id())); |
1184 EXPECT_EQ(expected_remote_stream, | 1201 EXPECT_EQ(expected_remote_stream, |
1185 report->Get(expected_remote_stream.id())->cast_to< | 1202 report->Get(expected_remote_stream.id())->cast_to< |
1186 RTCMediaStreamStats>()); | 1203 RTCMediaStreamStats>()); |
1187 | 1204 |
1188 RTCMediaStreamTrackStats expected_local_audio_track( | 1205 RTCMediaStreamTrackStats expected_local_audio_track( |
1189 "RTCMediaStreamTrack_LocalAudioTrackID", report->timestamp_us()); | 1206 "RTCMediaStreamTrack_LocalAudioTrackID", report->timestamp_us()); |
1190 expected_local_audio_track.track_identifier = local_audio_track->id(); | 1207 expected_local_audio_track.track_identifier = local_audio_track->id(); |
1191 expected_local_audio_track.remote_source = false; | 1208 expected_local_audio_track.remote_source = false; |
1192 expected_local_audio_track.ended = true; | 1209 expected_local_audio_track.ended = true; |
1193 expected_local_audio_track.detached = false; | 1210 expected_local_audio_track.detached = false; |
1194 expected_local_audio_track.audio_level = 1.0; | 1211 expected_local_audio_track.audio_level = 1.0; |
1195 expected_local_audio_track.echo_return_loss = 42.0; | 1212 expected_local_audio_track.echo_return_loss = 42.0; |
1196 expected_local_audio_track.echo_return_loss_enhancement = 52.0; | 1213 expected_local_audio_track.echo_return_loss_enhancement = 52.0; |
1197 EXPECT_TRUE(report->Get(expected_local_audio_track.id())); | 1214 ASSERT_TRUE(report->Get(expected_local_audio_track.id())); |
1198 EXPECT_EQ(expected_local_audio_track, | 1215 EXPECT_EQ(expected_local_audio_track, |
1199 report->Get(expected_local_audio_track.id())->cast_to< | 1216 report->Get(expected_local_audio_track.id())->cast_to< |
1200 RTCMediaStreamTrackStats>()); | 1217 RTCMediaStreamTrackStats>()); |
1201 | 1218 |
1202 RTCMediaStreamTrackStats expected_remote_audio_track( | 1219 RTCMediaStreamTrackStats expected_remote_audio_track( |
1203 "RTCMediaStreamTrack_RemoteAudioTrackID", report->timestamp_us()); | 1220 "RTCMediaStreamTrack_RemoteAudioTrackID", report->timestamp_us()); |
1204 expected_remote_audio_track.track_identifier = remote_audio_track->id(); | 1221 expected_remote_audio_track.track_identifier = remote_audio_track->id(); |
1205 expected_remote_audio_track.remote_source = true; | 1222 expected_remote_audio_track.remote_source = true; |
1206 expected_remote_audio_track.ended = false; | 1223 expected_remote_audio_track.ended = false; |
1207 expected_remote_audio_track.detached = false; | 1224 expected_remote_audio_track.detached = false; |
1208 expected_remote_audio_track.audio_level = 0.0; | 1225 expected_remote_audio_track.audio_level = 0.0; |
1209 expected_remote_audio_track.echo_return_loss = 13.0; | 1226 expected_remote_audio_track.echo_return_loss = 13.0; |
1210 expected_remote_audio_track.echo_return_loss_enhancement = 37.0; | 1227 expected_remote_audio_track.echo_return_loss_enhancement = 37.0; |
1211 EXPECT_TRUE(report->Get(expected_remote_audio_track.id())); | 1228 ASSERT_TRUE(report->Get(expected_remote_audio_track.id())); |
1212 EXPECT_EQ(expected_remote_audio_track, | 1229 EXPECT_EQ(expected_remote_audio_track, |
1213 report->Get(expected_remote_audio_track.id())->cast_to< | 1230 report->Get(expected_remote_audio_track.id())->cast_to< |
1214 RTCMediaStreamTrackStats>()); | 1231 RTCMediaStreamTrackStats>()); |
1215 } | 1232 } |
1216 | 1233 |
1217 TEST_F(RTCStatsCollectorTest, | 1234 TEST_F(RTCStatsCollectorTest, |
1218 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Audio_Defaults) { | 1235 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Audio_Defaults) { |
1219 rtc::scoped_refptr<StreamCollection> local_streams = | 1236 rtc::scoped_refptr<StreamCollection> local_streams = |
1220 StreamCollection::Create(); | 1237 StreamCollection::Create(); |
1221 EXPECT_CALL(test_->pc(), local_streams()) | 1238 EXPECT_CALL(test_->pc(), local_streams()) |
(...skipping 19 matching lines...) Expand all Loading... |
1241 | 1258 |
1242 RTCMediaStreamTrackStats expected_local_audio_track( | 1259 RTCMediaStreamTrackStats expected_local_audio_track( |
1243 "RTCMediaStreamTrack_LocalAudioTrackID", report->timestamp_us()); | 1260 "RTCMediaStreamTrack_LocalAudioTrackID", report->timestamp_us()); |
1244 expected_local_audio_track.track_identifier = local_audio_track->id(); | 1261 expected_local_audio_track.track_identifier = local_audio_track->id(); |
1245 expected_local_audio_track.remote_source = false; | 1262 expected_local_audio_track.remote_source = false; |
1246 expected_local_audio_track.ended = true; | 1263 expected_local_audio_track.ended = true; |
1247 expected_local_audio_track.detached = false; | 1264 expected_local_audio_track.detached = false; |
1248 expected_local_audio_track.audio_level = 1.0; | 1265 expected_local_audio_track.audio_level = 1.0; |
1249 // Should be undefined: |expected_local_audio_track.echo_return_loss| and | 1266 // Should be undefined: |expected_local_audio_track.echo_return_loss| and |
1250 // |expected_local_audio_track.echo_return_loss_enhancement|. | 1267 // |expected_local_audio_track.echo_return_loss_enhancement|. |
1251 EXPECT_TRUE(report->Get(expected_local_audio_track.id())); | 1268 ASSERT_TRUE(report->Get(expected_local_audio_track.id())); |
1252 EXPECT_EQ(expected_local_audio_track, | 1269 EXPECT_EQ(expected_local_audio_track, |
1253 report->Get(expected_local_audio_track.id())->cast_to< | 1270 report->Get(expected_local_audio_track.id())->cast_to< |
1254 RTCMediaStreamTrackStats>()); | 1271 RTCMediaStreamTrackStats>()); |
1255 } | 1272 } |
1256 | 1273 |
1257 TEST_F(RTCStatsCollectorTest, | 1274 TEST_F(RTCStatsCollectorTest, |
1258 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Video) { | 1275 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Video) { |
1259 rtc::scoped_refptr<StreamCollection> local_streams = | 1276 rtc::scoped_refptr<StreamCollection> local_streams = |
1260 StreamCollection::Create(); | 1277 StreamCollection::Create(); |
1261 rtc::scoped_refptr<StreamCollection> remote_streams = | 1278 rtc::scoped_refptr<StreamCollection> remote_streams = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 remote_stream->AddTrack(remote_video_track); | 1316 remote_stream->AddTrack(remote_video_track); |
1300 | 1317 |
1301 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1318 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1302 | 1319 |
1303 RTCMediaStreamStats expected_local_stream( | 1320 RTCMediaStreamStats expected_local_stream( |
1304 "RTCMediaStream_LocalStreamLabel", report->timestamp_us()); | 1321 "RTCMediaStream_LocalStreamLabel", report->timestamp_us()); |
1305 expected_local_stream.stream_identifier = local_stream->label(); | 1322 expected_local_stream.stream_identifier = local_stream->label(); |
1306 expected_local_stream.track_ids = std::vector<std::string>(); | 1323 expected_local_stream.track_ids = std::vector<std::string>(); |
1307 expected_local_stream.track_ids->push_back( | 1324 expected_local_stream.track_ids->push_back( |
1308 "RTCMediaStreamTrack_LocalVideoTrackID"); | 1325 "RTCMediaStreamTrack_LocalVideoTrackID"); |
1309 EXPECT_TRUE(report->Get(expected_local_stream.id())); | 1326 ASSERT_TRUE(report->Get(expected_local_stream.id())); |
1310 EXPECT_EQ(expected_local_stream, | 1327 EXPECT_EQ(expected_local_stream, |
1311 report->Get(expected_local_stream.id())->cast_to< | 1328 report->Get(expected_local_stream.id())->cast_to< |
1312 RTCMediaStreamStats>()); | 1329 RTCMediaStreamStats>()); |
1313 | 1330 |
1314 RTCMediaStreamStats expected_remote_stream( | 1331 RTCMediaStreamStats expected_remote_stream( |
1315 "RTCMediaStream_RemoteStreamLabel", report->timestamp_us()); | 1332 "RTCMediaStream_RemoteStreamLabel", report->timestamp_us()); |
1316 expected_remote_stream.stream_identifier = remote_stream->label(); | 1333 expected_remote_stream.stream_identifier = remote_stream->label(); |
1317 expected_remote_stream.track_ids = std::vector<std::string>(); | 1334 expected_remote_stream.track_ids = std::vector<std::string>(); |
1318 expected_remote_stream.track_ids->push_back( | 1335 expected_remote_stream.track_ids->push_back( |
1319 "RTCMediaStreamTrack_RemoteVideoTrackID"); | 1336 "RTCMediaStreamTrack_RemoteVideoTrackID"); |
1320 EXPECT_TRUE(report->Get(expected_remote_stream.id())); | 1337 ASSERT_TRUE(report->Get(expected_remote_stream.id())); |
1321 EXPECT_EQ(expected_remote_stream, | 1338 EXPECT_EQ(expected_remote_stream, |
1322 report->Get(expected_remote_stream.id())->cast_to< | 1339 report->Get(expected_remote_stream.id())->cast_to< |
1323 RTCMediaStreamStats>()); | 1340 RTCMediaStreamStats>()); |
1324 | 1341 |
1325 RTCMediaStreamTrackStats expected_local_video_track( | 1342 RTCMediaStreamTrackStats expected_local_video_track( |
1326 "RTCMediaStreamTrack_LocalVideoTrackID", report->timestamp_us()); | 1343 "RTCMediaStreamTrack_LocalVideoTrackID", report->timestamp_us()); |
1327 expected_local_video_track.track_identifier = local_video_track->id(); | 1344 expected_local_video_track.track_identifier = local_video_track->id(); |
1328 expected_local_video_track.remote_source = false; | 1345 expected_local_video_track.remote_source = false; |
1329 expected_local_video_track.ended = false; | 1346 expected_local_video_track.ended = false; |
1330 expected_local_video_track.detached = false; | 1347 expected_local_video_track.detached = false; |
1331 expected_local_video_track.frame_width = 1234; | 1348 expected_local_video_track.frame_width = 1234; |
1332 expected_local_video_track.frame_height = 4321; | 1349 expected_local_video_track.frame_height = 4321; |
1333 EXPECT_TRUE(report->Get(expected_local_video_track.id())); | 1350 ASSERT_TRUE(report->Get(expected_local_video_track.id())); |
1334 EXPECT_EQ(expected_local_video_track, | 1351 EXPECT_EQ(expected_local_video_track, |
1335 report->Get(expected_local_video_track.id())->cast_to< | 1352 report->Get(expected_local_video_track.id())->cast_to< |
1336 RTCMediaStreamTrackStats>()); | 1353 RTCMediaStreamTrackStats>()); |
1337 | 1354 |
1338 RTCMediaStreamTrackStats expected_remote_video_track( | 1355 RTCMediaStreamTrackStats expected_remote_video_track( |
1339 "RTCMediaStreamTrack_RemoteVideoTrackID", report->timestamp_us()); | 1356 "RTCMediaStreamTrack_RemoteVideoTrackID", report->timestamp_us()); |
1340 expected_remote_video_track.track_identifier = remote_video_track->id(); | 1357 expected_remote_video_track.track_identifier = remote_video_track->id(); |
1341 expected_remote_video_track.remote_source = true; | 1358 expected_remote_video_track.remote_source = true; |
1342 expected_remote_video_track.ended = true; | 1359 expected_remote_video_track.ended = true; |
1343 expected_remote_video_track.detached = false; | 1360 expected_remote_video_track.detached = false; |
1344 expected_remote_video_track.frame_width = 1234; | 1361 expected_remote_video_track.frame_width = 1234; |
1345 expected_remote_video_track.frame_height = 4321; | 1362 expected_remote_video_track.frame_height = 4321; |
1346 EXPECT_TRUE(report->Get(expected_remote_video_track.id())); | 1363 ASSERT_TRUE(report->Get(expected_remote_video_track.id())); |
1347 EXPECT_EQ(expected_remote_video_track, | 1364 EXPECT_EQ(expected_remote_video_track, |
1348 report->Get(expected_remote_video_track.id())->cast_to< | 1365 report->Get(expected_remote_video_track.id())->cast_to< |
1349 RTCMediaStreamTrackStats>()); | 1366 RTCMediaStreamTrackStats>()); |
1350 } | 1367 } |
1351 | 1368 |
1352 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { | 1369 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { |
1353 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 1370 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
1354 cricket::VoiceChannel voice_channel( | 1371 cricket::VoiceChannel voice_channel( |
1355 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 1372 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
1356 voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled, | 1373 voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 expected_audio.bytes_received = 3; | 1428 expected_audio.bytes_received = 3; |
1412 expected_audio.packets_lost = 42; | 1429 expected_audio.packets_lost = 42; |
1413 expected_audio.jitter = 4.5; | 1430 expected_audio.jitter = 4.5; |
1414 expected_audio.fraction_lost = 5.5; | 1431 expected_audio.fraction_lost = 5.5; |
1415 | 1432 |
1416 ASSERT(report->Get(expected_audio.id())); | 1433 ASSERT(report->Get(expected_audio.id())); |
1417 const RTCInboundRTPStreamStats& audio = report->Get( | 1434 const RTCInboundRTPStreamStats& audio = report->Get( |
1418 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); | 1435 expected_audio.id())->cast_to<RTCInboundRTPStreamStats>(); |
1419 EXPECT_EQ(audio, expected_audio); | 1436 EXPECT_EQ(audio, expected_audio); |
1420 | 1437 |
1421 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); | 1438 ASSERT_TRUE(report->Get(*expected_audio.transport_id)); |
1422 EXPECT_TRUE(report->Get(*expected_audio.codec_id)); | 1439 ASSERT_TRUE(report->Get(*expected_audio.codec_id)); |
1423 } | 1440 } |
1424 | 1441 |
1425 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { | 1442 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Video) { |
1426 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); | 1443 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); |
1427 cricket::VideoChannel video_channel( | 1444 cricket::VideoChannel video_channel( |
1428 test_->worker_thread(), test_->network_thread(), video_media_channel, | 1445 test_->worker_thread(), test_->network_thread(), video_media_channel, |
1429 nullptr, "VideoContentName", kDefaultRtcpEnabled, kDefaultSrtpRequired); | 1446 nullptr, "VideoContentName", kDefaultRtcpEnabled, kDefaultSrtpRequired); |
1430 | 1447 |
1431 cricket::VideoMediaInfo video_media_info; | 1448 cricket::VideoMediaInfo video_media_info; |
1432 | 1449 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 expected_video.packets_received = 2; | 1504 expected_video.packets_received = 2; |
1488 expected_video.bytes_received = 3; | 1505 expected_video.bytes_received = 3; |
1489 expected_video.packets_lost = 42; | 1506 expected_video.packets_lost = 42; |
1490 expected_video.fraction_lost = 4.5; | 1507 expected_video.fraction_lost = 4.5; |
1491 | 1508 |
1492 ASSERT(report->Get(expected_video.id())); | 1509 ASSERT(report->Get(expected_video.id())); |
1493 const RTCInboundRTPStreamStats& video = report->Get( | 1510 const RTCInboundRTPStreamStats& video = report->Get( |
1494 expected_video.id())->cast_to<RTCInboundRTPStreamStats>(); | 1511 expected_video.id())->cast_to<RTCInboundRTPStreamStats>(); |
1495 EXPECT_EQ(video, expected_video); | 1512 EXPECT_EQ(video, expected_video); |
1496 | 1513 |
1497 EXPECT_TRUE(report->Get(*expected_video.transport_id)); | 1514 ASSERT_TRUE(report->Get(*expected_video.transport_id)); |
1498 EXPECT_TRUE(report->Get(*video.codec_id)); | 1515 ASSERT_TRUE(report->Get(*video.codec_id)); |
1499 } | 1516 } |
1500 | 1517 |
1501 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { | 1518 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Audio) { |
1502 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 1519 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
1503 cricket::VoiceChannel voice_channel( | 1520 cricket::VoiceChannel voice_channel( |
1504 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 1521 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
1505 voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled, | 1522 voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled, |
1506 kDefaultSrtpRequired); | 1523 kDefaultSrtpRequired); |
1507 | 1524 |
1508 cricket::VoiceMediaInfo voice_media_info; | 1525 cricket::VoiceMediaInfo voice_media_info; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 expected_audio.codec_id = "RTCCodec_OutboundAudio_42"; | 1572 expected_audio.codec_id = "RTCCodec_OutboundAudio_42"; |
1556 expected_audio.packets_sent = 2; | 1573 expected_audio.packets_sent = 2; |
1557 expected_audio.bytes_sent = 3; | 1574 expected_audio.bytes_sent = 3; |
1558 expected_audio.round_trip_time = 4.5; | 1575 expected_audio.round_trip_time = 4.5; |
1559 | 1576 |
1560 ASSERT(report->Get(expected_audio.id())); | 1577 ASSERT(report->Get(expected_audio.id())); |
1561 const RTCOutboundRTPStreamStats& audio = report->Get( | 1578 const RTCOutboundRTPStreamStats& audio = report->Get( |
1562 expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>(); | 1579 expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>(); |
1563 EXPECT_EQ(audio, expected_audio); | 1580 EXPECT_EQ(audio, expected_audio); |
1564 | 1581 |
1565 EXPECT_TRUE(report->Get(*expected_audio.transport_id)); | 1582 ASSERT_TRUE(report->Get(*expected_audio.transport_id)); |
1566 EXPECT_TRUE(report->Get(*expected_audio.codec_id)); | 1583 ASSERT_TRUE(report->Get(*expected_audio.codec_id)); |
1567 } | 1584 } |
1568 | 1585 |
1569 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) { | 1586 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Video) { |
1570 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); | 1587 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); |
1571 cricket::VideoChannel video_channel( | 1588 cricket::VideoChannel video_channel( |
1572 test_->worker_thread(), test_->network_thread(), video_media_channel, | 1589 test_->worker_thread(), test_->network_thread(), video_media_channel, |
1573 nullptr, "VideoContentName", kDefaultRtcpEnabled, kDefaultSrtpRequired); | 1590 nullptr, "VideoContentName", kDefaultRtcpEnabled, kDefaultSrtpRequired); |
1574 | 1591 |
1575 cricket::VideoMediaInfo video_media_info; | 1592 cricket::VideoMediaInfo video_media_info; |
1576 | 1593 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 expected_video.nack_count = 4; | 1645 expected_video.nack_count = 4; |
1629 expected_video.packets_sent = 5; | 1646 expected_video.packets_sent = 5; |
1630 expected_video.bytes_sent = 6; | 1647 expected_video.bytes_sent = 6; |
1631 expected_video.round_trip_time = 7.5; | 1648 expected_video.round_trip_time = 7.5; |
1632 | 1649 |
1633 ASSERT(report->Get(expected_video.id())); | 1650 ASSERT(report->Get(expected_video.id())); |
1634 const RTCOutboundRTPStreamStats& video = report->Get( | 1651 const RTCOutboundRTPStreamStats& video = report->Get( |
1635 expected_video.id())->cast_to<RTCOutboundRTPStreamStats>(); | 1652 expected_video.id())->cast_to<RTCOutboundRTPStreamStats>(); |
1636 EXPECT_EQ(video, expected_video); | 1653 EXPECT_EQ(video, expected_video); |
1637 | 1654 |
1638 EXPECT_TRUE(report->Get(*expected_video.transport_id)); | 1655 ASSERT_TRUE(report->Get(*expected_video.transport_id)); |
1639 EXPECT_TRUE(report->Get(*expected_video.codec_id)); | 1656 ASSERT_TRUE(report->Get(*expected_video.codec_id)); |
1640 } | 1657 } |
1641 | 1658 |
1642 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Default) { | 1659 TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRTPStreamStats_Default) { |
1643 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 1660 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
1644 cricket::VoiceChannel voice_channel( | 1661 cricket::VoiceChannel voice_channel( |
1645 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 1662 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
1646 voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled, | 1663 voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled, |
1647 kDefaultSrtpRequired); | 1664 kDefaultSrtpRequired); |
1648 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); | 1665 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); |
1649 cricket::VideoChannel video_channel( | 1666 cricket::VideoChannel video_channel( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1793 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1777 | 1794 |
1778 RTCTransportStats expected_rtp_transport( | 1795 RTCTransportStats expected_rtp_transport( |
1779 "RTCTransport_transport_" + | 1796 "RTCTransport_transport_" + |
1780 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP), | 1797 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP), |
1781 report->timestamp_us()); | 1798 report->timestamp_us()); |
1782 expected_rtp_transport.bytes_sent = 42; | 1799 expected_rtp_transport.bytes_sent = 42; |
1783 expected_rtp_transport.bytes_received = 1337; | 1800 expected_rtp_transport.bytes_received = 1337; |
1784 expected_rtp_transport.active_connection = false; | 1801 expected_rtp_transport.active_connection = false; |
1785 | 1802 |
1786 EXPECT_TRUE(report->Get(expected_rtp_transport.id())); | 1803 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); |
1787 EXPECT_EQ( | 1804 EXPECT_EQ( |
1788 expected_rtp_transport, | 1805 expected_rtp_transport, |
1789 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); | 1806 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); |
1790 | 1807 |
1791 cricket::ConnectionInfo rtcp_connection_info; | 1808 cricket::ConnectionInfo rtcp_connection_info; |
1792 rtcp_connection_info.best_connection = false; | 1809 rtcp_connection_info.best_connection = false; |
1793 rtcp_connection_info.local_candidate = *rtcp_local_candidate.get(); | 1810 rtcp_connection_info.local_candidate = *rtcp_local_candidate.get(); |
1794 rtcp_connection_info.remote_candidate = *rtcp_remote_candidate.get(); | 1811 rtcp_connection_info.remote_candidate = *rtcp_remote_candidate.get(); |
1795 rtcp_connection_info.sent_total_bytes = 1337; | 1812 rtcp_connection_info.sent_total_bytes = 1337; |
1796 rtcp_connection_info.recv_total_bytes = 42; | 1813 rtcp_connection_info.recv_total_bytes = 42; |
(...skipping 11 matching lines...) Expand all Loading... |
1808 RTCTransportStats expected_rtcp_transport( | 1825 RTCTransportStats expected_rtcp_transport( |
1809 "RTCTransport_transport_" + | 1826 "RTCTransport_transport_" + |
1810 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTCP), | 1827 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTCP), |
1811 report->timestamp_us()); | 1828 report->timestamp_us()); |
1812 expected_rtcp_transport.bytes_sent = 1337; | 1829 expected_rtcp_transport.bytes_sent = 1337; |
1813 expected_rtcp_transport.bytes_received = 42; | 1830 expected_rtcp_transport.bytes_received = 42; |
1814 expected_rtcp_transport.active_connection = false; | 1831 expected_rtcp_transport.active_connection = false; |
1815 | 1832 |
1816 expected_rtp_transport.rtcp_transport_stats_id = expected_rtcp_transport.id(); | 1833 expected_rtp_transport.rtcp_transport_stats_id = expected_rtcp_transport.id(); |
1817 | 1834 |
1818 EXPECT_TRUE(report->Get(expected_rtp_transport.id())); | 1835 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); |
1819 EXPECT_EQ( | 1836 EXPECT_EQ( |
1820 expected_rtp_transport, | 1837 expected_rtp_transport, |
1821 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); | 1838 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); |
1822 EXPECT_TRUE(report->Get(expected_rtcp_transport.id())); | 1839 ASSERT_TRUE(report->Get(expected_rtcp_transport.id())); |
1823 EXPECT_EQ( | 1840 EXPECT_EQ( |
1824 expected_rtcp_transport, | 1841 expected_rtcp_transport, |
1825 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); | 1842 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); |
1826 | 1843 |
1827 // Get stats with an active connection. | 1844 // Get stats with an active connection. |
1828 session_stats.transport_stats["transport"] | 1845 session_stats.transport_stats["transport"] |
1829 .channel_stats[1] | 1846 .channel_stats[1] |
1830 .connection_infos[0] | 1847 .connection_infos[0] |
1831 .best_connection = true; | 1848 .best_connection = true; |
1832 | 1849 |
1833 collector_->ClearCachedStatsReport(); | 1850 collector_->ClearCachedStatsReport(); |
1834 report = GetStatsReport(); | 1851 report = GetStatsReport(); |
1835 | 1852 |
1836 expected_rtcp_transport.active_connection = true; | 1853 expected_rtcp_transport.active_connection = true; |
1837 expected_rtcp_transport.selected_candidate_pair_id = | 1854 expected_rtcp_transport.selected_candidate_pair_id = |
1838 "RTCIceCandidatePair_" + rtcp_local_candidate->id() + "_" + | 1855 "RTCIceCandidatePair_" + rtcp_local_candidate->id() + "_" + |
1839 rtcp_remote_candidate->id(); | 1856 rtcp_remote_candidate->id(); |
1840 | 1857 |
1841 EXPECT_TRUE(report->Get(expected_rtp_transport.id())); | 1858 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); |
1842 EXPECT_EQ( | 1859 EXPECT_EQ( |
1843 expected_rtp_transport, | 1860 expected_rtp_transport, |
1844 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); | 1861 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); |
1845 EXPECT_TRUE(report->Get(expected_rtcp_transport.id())); | 1862 ASSERT_TRUE(report->Get(expected_rtcp_transport.id())); |
1846 EXPECT_EQ( | 1863 EXPECT_EQ( |
1847 expected_rtcp_transport, | 1864 expected_rtcp_transport, |
1848 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); | 1865 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); |
1849 | 1866 |
1850 // Get stats with certificates. | 1867 // Get stats with certificates. |
1851 std::unique_ptr<CertificateInfo> local_certinfo = | 1868 std::unique_ptr<CertificateInfo> local_certinfo = |
1852 CreateFakeCertificateAndInfoFromDers( | 1869 CreateFakeCertificateAndInfoFromDers( |
1853 std::vector<std::string>({ "(local) local", "(local) chain" })); | 1870 std::vector<std::string>({ "(local) local", "(local) chain" })); |
1854 std::unique_ptr<CertificateInfo> remote_certinfo = | 1871 std::unique_ptr<CertificateInfo> remote_certinfo = |
1855 CreateFakeCertificateAndInfoFromDers( | 1872 CreateFakeCertificateAndInfoFromDers( |
(...skipping 21 matching lines...) Expand all Loading... |
1877 expected_rtp_transport.local_certificate_id = | 1894 expected_rtp_transport.local_certificate_id = |
1878 "RTCCertificate_" + local_certinfo->fingerprints[0]; | 1895 "RTCCertificate_" + local_certinfo->fingerprints[0]; |
1879 expected_rtp_transport.remote_certificate_id = | 1896 expected_rtp_transport.remote_certificate_id = |
1880 "RTCCertificate_" + remote_certinfo->fingerprints[0]; | 1897 "RTCCertificate_" + remote_certinfo->fingerprints[0]; |
1881 | 1898 |
1882 expected_rtcp_transport.local_certificate_id = | 1899 expected_rtcp_transport.local_certificate_id = |
1883 *expected_rtp_transport.local_certificate_id; | 1900 *expected_rtp_transport.local_certificate_id; |
1884 expected_rtcp_transport.remote_certificate_id = | 1901 expected_rtcp_transport.remote_certificate_id = |
1885 *expected_rtp_transport.remote_certificate_id; | 1902 *expected_rtp_transport.remote_certificate_id; |
1886 | 1903 |
1887 EXPECT_TRUE(report->Get(expected_rtp_transport.id())); | 1904 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); |
1888 EXPECT_EQ( | 1905 EXPECT_EQ( |
1889 expected_rtp_transport, | 1906 expected_rtp_transport, |
1890 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); | 1907 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); |
1891 EXPECT_TRUE(report->Get(expected_rtcp_transport.id())); | 1908 ASSERT_TRUE(report->Get(expected_rtcp_transport.id())); |
1892 EXPECT_EQ( | 1909 EXPECT_EQ( |
1893 expected_rtcp_transport, | 1910 expected_rtcp_transport, |
1894 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); | 1911 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); |
1895 } | 1912 } |
1896 | 1913 |
1897 class RTCStatsCollectorTestWithFakeCollector : public testing::Test { | 1914 class RTCStatsCollectorTestWithFakeCollector : public testing::Test { |
1898 public: | 1915 public: |
1899 RTCStatsCollectorTestWithFakeCollector() | 1916 RTCStatsCollectorTestWithFakeCollector() |
1900 : test_(new rtc::RefCountedObject<RTCStatsCollectorTestHelper>()), | 1917 : test_(new rtc::RefCountedObject<RTCStatsCollectorTestHelper>()), |
1901 collector_(FakeRTCStatsCollector::Create( | 1918 collector_(FakeRTCStatsCollector::Create( |
1902 &test_->pc(), 50 * rtc::kNumMicrosecsPerMillisec)) { | 1919 &test_->pc(), 50 * rtc::kNumMicrosecsPerMillisec)) { |
1903 } | 1920 } |
1904 | 1921 |
1905 protected: | 1922 protected: |
1906 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; | 1923 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; |
1907 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1924 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
1908 }; | 1925 }; |
1909 | 1926 |
1910 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1927 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
1911 collector_->VerifyThreadUsageAndResultsMerging(); | 1928 collector_->VerifyThreadUsageAndResultsMerging(); |
1912 } | 1929 } |
1913 | 1930 |
1914 } // namespace | 1931 } // namespace |
1915 | 1932 |
1916 } // namespace webrtc | 1933 } // namespace webrtc |
OLD | NEW |