| 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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 *stats = session_stats; | 1063 *stats = session_stats; |
| 1064 return true; | 1064 return true; |
| 1065 })); | 1065 })); |
| 1066 | 1066 |
| 1067 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1067 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1068 ExpectReportContainsCandidatePair( | 1068 ExpectReportContainsCandidatePair( |
| 1069 report, session_stats.transport_stats["transport"]); | 1069 report, session_stats.transport_stats["transport"]); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { | 1072 TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) { |
| 1073 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | |
| 1074 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), | |
| 1075 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; | |
| 1076 const RTCStats* stats = report->Get("RTCPeerConnection"); | |
| 1077 EXPECT_TRUE(stats); | |
| 1078 { | 1073 { |
| 1079 // Expected stats with no data channels | 1074 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1080 const RTCPeerConnectionStats& pcstats = | 1075 RTCPeerConnectionStats expected("RTCPeerConnection", |
| 1081 stats->cast_to<RTCPeerConnectionStats>(); | 1076 report->timestamp_us()); |
| 1082 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(0)); | 1077 expected.data_channels_opened = 0; |
| 1083 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(0)); | 1078 expected.data_channels_closed = 0; |
| 1079 EXPECT_TRUE(report->Get("RTCPeerConnection")); |
| 1080 EXPECT_EQ(expected, |
| 1081 report->Get("RTCPeerConnection")->cast_to< |
| 1082 RTCPeerConnectionStats>()); |
| 1084 } | 1083 } |
| 1085 | 1084 |
| 1086 test_->data_channels().push_back( | 1085 rtc::scoped_refptr<DataChannel> dummy_channel_a = DataChannel::Create( |
| 1087 new MockDataChannel(0, DataChannelInterface::kConnecting)); | 1086 nullptr, cricket::DCT_NONE, "DummyChannelA", InternalDataChannelInit()); |
| 1088 test_->data_channels().push_back( | 1087 test_->pc().SignalDataChannelCreated(dummy_channel_a.get()); |
| 1089 new MockDataChannel(1, DataChannelInterface::kOpen)); | 1088 rtc::scoped_refptr<DataChannel> dummy_channel_b = DataChannel::Create( |
| 1090 test_->data_channels().push_back( | 1089 nullptr, cricket::DCT_NONE, "DummyChannelB", InternalDataChannelInit()); |
| 1091 new MockDataChannel(2, DataChannelInterface::kClosing)); | 1090 test_->pc().SignalDataChannelCreated(dummy_channel_b.get()); |
| 1092 test_->data_channels().push_back( | |
| 1093 new MockDataChannel(3, DataChannelInterface::kClosed)); | |
| 1094 | 1091 |
| 1095 collector_->ClearCachedStatsReport(); | 1092 dummy_channel_a->SignalOpened(dummy_channel_a.get()); |
| 1096 report = GetStatsReport(); | 1093 // Closing a channel that is not opened should not affect the counts. |
| 1097 EXPECT_EQ(report->GetStatsOfType<RTCPeerConnectionStats>().size(), | 1094 dummy_channel_b->SignalClosed(dummy_channel_b.get()); |
| 1098 static_cast<size_t>(1)) << "Expecting 1 RTCPeerConnectionStats."; | 1095 |
| 1099 stats = report->Get("RTCPeerConnection"); | |
| 1100 ASSERT_TRUE(stats); | |
| 1101 { | 1096 { |
| 1102 // Expected stats with the above four data channels | 1097 collector_->ClearCachedStatsReport(); |
| 1103 // TODO(hbos): When the |RTCPeerConnectionStats| is the number of data | 1098 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1104 // channels that have been opened and closed, not the numbers currently | 1099 RTCPeerConnectionStats expected("RTCPeerConnection", |
| 1105 // open/closed, we would expect opened >= closed and (opened - closed) to be | 1100 report->timestamp_us()); |
| 1106 // the number currently open. crbug.com/636818. | 1101 expected.data_channels_opened = 1; |
| 1107 const RTCPeerConnectionStats& pcstats = | 1102 expected.data_channels_closed = 0; |
| 1108 stats->cast_to<RTCPeerConnectionStats>(); | 1103 EXPECT_TRUE(report->Get("RTCPeerConnection")); |
| 1109 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); | 1104 EXPECT_EQ(expected, |
| 1110 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); | 1105 report->Get("RTCPeerConnection")->cast_to< |
| 1106 RTCPeerConnectionStats>()); |
| 1107 } |
| 1108 |
| 1109 dummy_channel_b->SignalOpened(dummy_channel_b.get()); |
| 1110 dummy_channel_b->SignalClosed(dummy_channel_b.get()); |
| 1111 |
| 1112 { |
| 1113 collector_->ClearCachedStatsReport(); |
| 1114 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 1115 RTCPeerConnectionStats expected("RTCPeerConnection", |
| 1116 report->timestamp_us()); |
| 1117 expected.data_channels_opened = 2; |
| 1118 expected.data_channels_closed = 1; |
| 1119 EXPECT_TRUE(report->Get("RTCPeerConnection")); |
| 1120 EXPECT_EQ(expected, |
| 1121 report->Get("RTCPeerConnection")->cast_to< |
| 1122 RTCPeerConnectionStats>()); |
| 1111 } | 1123 } |
| 1112 } | 1124 } |
| 1113 | 1125 |
| 1114 TEST_F(RTCStatsCollectorTest, | 1126 TEST_F(RTCStatsCollectorTest, |
| 1115 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Audio) { | 1127 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Audio) { |
| 1116 rtc::scoped_refptr<StreamCollection> local_streams = | 1128 rtc::scoped_refptr<StreamCollection> local_streams = |
| 1117 StreamCollection::Create(); | 1129 StreamCollection::Create(); |
| 1118 rtc::scoped_refptr<StreamCollection> remote_streams = | 1130 rtc::scoped_refptr<StreamCollection> remote_streams = |
| 1119 StreamCollection::Create(); | 1131 StreamCollection::Create(); |
| 1120 EXPECT_CALL(test_->pc(), local_streams()) | 1132 EXPECT_CALL(test_->pc(), local_streams()) |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1647 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
| 1636 }; | 1648 }; |
| 1637 | 1649 |
| 1638 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1650 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
| 1639 collector_->VerifyThreadUsageAndResultsMerging(); | 1651 collector_->VerifyThreadUsageAndResultsMerging(); |
| 1640 } | 1652 } |
| 1641 | 1653 |
| 1642 } // namespace | 1654 } // namespace |
| 1643 | 1655 |
| 1644 } // namespace webrtc | 1656 } // namespace webrtc |
| OLD | NEW |