| 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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 *stats = session_stats; | 931 *stats = session_stats; |
| 932 return true; | 932 return true; |
| 933 })); | 933 })); |
| 934 | 934 |
| 935 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 935 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 936 ExpectReportContainsCandidatePair( | 936 ExpectReportContainsCandidatePair( |
| 937 report, session_stats.transport_stats["transport"]); | 937 report, session_stats.transport_stats["transport"]); |
| 938 } | 938 } |
| 939 | 939 |
| 940 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { | 940 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { |
| 941 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | |
| 942 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), | |
| 943 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; | |
| 944 const RTCStats* stats = report->Get("RTCPeerConnection"); | |
| 945 EXPECT_TRUE(stats); | |
| 946 { | 941 { |
| 947 // Expected stats with no data channels | 942 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 948 const RTCPeerConnectionStats& pcstats = | 943 RTCPeerConnectionStats expected("RTCPeerConnection", |
| 949 stats->cast_to<RTCPeerConnectionStats>(); | 944 report->timestamp_us()); |
| 950 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(0)); | 945 expected.data_channels_opened = 0; |
| 951 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(0)); | 946 expected.data_channels_closed = 0; |
| 947 EXPECT_TRUE(report->Get("RTCPeerConnection")); |
| 948 EXPECT_EQ(expected, |
| 949 report->Get("RTCPeerConnection")->cast_to< |
| 950 RTCPeerConnectionStats>()); |
| 952 } | 951 } |
| 953 | 952 |
| 954 test_->data_channels().push_back( | 953 rtc::scoped_refptr<DataChannel> dummy_channel_a = DataChannel::Create( |
| 955 new MockDataChannel(0, DataChannelInterface::kConnecting)); | 954 nullptr, cricket::DCT_NONE, "DummyChannelA", InternalDataChannelInit()); |
| 956 test_->data_channels().push_back( | 955 rtc::scoped_refptr<DataChannel> dummy_channel_b = DataChannel::Create( |
| 957 new MockDataChannel(1, DataChannelInterface::kOpen)); | 956 nullptr, cricket::DCT_NONE, "DummyChannelB", InternalDataChannelInit()); |
| 958 test_->data_channels().push_back( | |
| 959 new MockDataChannel(2, DataChannelInterface::kClosing)); | |
| 960 test_->data_channels().push_back( | |
| 961 new MockDataChannel(3, DataChannelInterface::kClosed)); | |
| 962 | 957 |
| 963 collector_->ClearCachedStatsReport(); | 958 collector_->OnDataChannelOpenedForTesting(dummy_channel_a.get()); |
| 964 report = GetStatsReport(); | 959 // Closing a channel that is not opened should not affect the counts. |
| 965 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), | 960 collector_->OnDataChannelClosedForTesting(dummy_channel_b.get()); |
| 966 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; | 961 |
| 967 stats = report->Get("RTCPeerConnection"); | |
| 968 ASSERT_TRUE(stats); | |
| 969 { | 962 { |
| 970 // Expected stats with the above four data channels | 963 collector_->ClearCachedStatsReport(); |
| 971 // TODO(hbos): When the |RTCPeerConnectionStats| is the number of data | 964 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 972 // channels that have been opened and closed, not the numbers currently | 965 RTCPeerConnectionStats expected("RTCPeerConnection", |
| 973 // open/closed, we would expect opened >= closed and (opened - closed) to be | 966 report->timestamp_us()); |
| 974 // the number currently open. crbug.com/636818. | 967 expected.data_channels_opened = 1; |
| 975 const RTCPeerConnectionStats& pcstats = | 968 expected.data_channels_closed = 0; |
| 976 stats->cast_to<RTCPeerConnectionStats>(); | 969 EXPECT_TRUE(report->Get("RTCPeerConnection")); |
| 977 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); | 970 EXPECT_EQ(expected, |
| 978 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); | 971 report->Get("RTCPeerConnection")->cast_to< |
| 972 RTCPeerConnectionStats>()); |
| 973 } |
| 974 |
| 975 collector_->OnDataChannelOpenedForTesting(dummy_channel_b.get()); |
| 976 collector_->OnDataChannelClosedForTesting(dummy_channel_b.get()); |
| 977 |
| 978 { |
| 979 collector_->ClearCachedStatsReport(); |
| 980 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 981 RTCPeerConnectionStats expected("RTCPeerConnection", |
| 982 report->timestamp_us()); |
| 983 expected.data_channels_opened = 2; |
| 984 expected.data_channels_closed = 1; |
| 985 EXPECT_TRUE(report->Get("RTCPeerConnection")); |
| 986 EXPECT_EQ(expected, |
| 987 report->Get("RTCPeerConnection")->cast_to< |
| 988 RTCPeerConnectionStats>()); |
| 979 } | 989 } |
| 980 } | 990 } |
| 981 | 991 |
| 982 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { | 992 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { |
| 983 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 993 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
| 984 cricket::VoiceChannel voice_channel( | 994 cricket::VoiceChannel voice_channel( |
| 985 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 995 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
| 986 voice_media_channel, nullptr, "VoiceContentName", false); | 996 voice_media_channel, nullptr, "VoiceContentName", false); |
| 987 | 997 |
| 988 cricket::VoiceMediaInfo voice_media_info; | 998 cricket::VoiceMediaInfo voice_media_info; |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1323 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
| 1314 }; | 1324 }; |
| 1315 | 1325 |
| 1316 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1326 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
| 1317 collector_->VerifyThreadUsageAndResultsMerging(); | 1327 collector_->VerifyThreadUsageAndResultsMerging(); |
| 1318 } | 1328 } |
| 1319 | 1329 |
| 1320 } // namespace | 1330 } // namespace |
| 1321 | 1331 |
| 1322 } // namespace webrtc | 1332 } // namespace webrtc |
| OLD | NEW |