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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 | 1256 |
1257 // Mock the session to return the desired candidates. | 1257 // Mock the session to return the desired candidates. |
1258 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( | 1258 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( |
1259 [&session_stats](const ChannelNamePairs&) { | 1259 [&session_stats](const ChannelNamePairs&) { |
1260 return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); | 1260 return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); |
1261 })); | 1261 })); |
1262 | 1262 |
1263 // Mock the session to return bandwidth estimation info. These should only | 1263 // Mock the session to return bandwidth estimation info. These should only |
1264 // be used for a selected candidate pair. | 1264 // be used for a selected candidate pair. |
1265 cricket::VideoMediaInfo video_media_info; | 1265 cricket::VideoMediaInfo video_media_info; |
| 1266 video_media_info.bw_estimations.push_back(cricket::BandwidthEstimationInfo()); |
| 1267 video_media_info.bw_estimations[0].available_send_bandwidth = 8888; |
| 1268 video_media_info.bw_estimations[0].available_recv_bandwidth = 9999; |
1266 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1269 EXPECT_CALL(*video_media_channel, GetStats(_)) |
1267 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1270 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
1268 EXPECT_CALL(test_->session(), video_channel()) | 1271 EXPECT_CALL(test_->session(), video_channel()) |
1269 .WillRepeatedly(Return(&video_channel)); | 1272 .WillRepeatedly(Return(&video_channel)); |
1270 | 1273 |
1271 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1274 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1272 | 1275 |
1273 RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" + | 1276 RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" + |
1274 local_candidate->id() + "_" + | 1277 local_candidate->id() + "_" + |
1275 remote_candidate->id(), | 1278 remote_candidate->id(), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 EXPECT_EQ( | 1338 EXPECT_EQ( |
1336 expected_pair, | 1339 expected_pair, |
1337 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); | 1340 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); |
1338 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); | 1341 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); |
1339 | 1342 |
1340 // Make pair the current pair, clear bandwidth and "GetStats" again. | 1343 // Make pair the current pair, clear bandwidth and "GetStats" again. |
1341 session_stats.transport_stats["transport"] | 1344 session_stats.transport_stats["transport"] |
1342 .channel_stats[0] | 1345 .channel_stats[0] |
1343 .connection_infos[0] | 1346 .connection_infos[0] |
1344 .best_connection = true; | 1347 .best_connection = true; |
| 1348 video_media_info.bw_estimations[0].available_send_bandwidth = 0; |
| 1349 video_media_info.bw_estimations[0].available_recv_bandwidth = 0; |
1345 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1350 EXPECT_CALL(*video_media_channel, GetStats(_)) |
1346 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1351 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
1347 collector_->ClearCachedStatsReport(); | 1352 collector_->ClearCachedStatsReport(); |
1348 report = GetStatsReport(); | 1353 report = GetStatsReport(); |
1349 // |expected_pair.available_[outgoing/incoming]_bitrate| should still be | 1354 // |expected_pair.available_[outgoing/incoming]_bitrate| should still be |
1350 // undefined because bandwidth is not set. | 1355 // undefined because bandwidth is not set. |
1351 ASSERT_TRUE(report->Get(expected_pair.id())); | 1356 ASSERT_TRUE(report->Get(expected_pair.id())); |
1352 EXPECT_EQ( | 1357 EXPECT_EQ( |
1353 expected_pair, | 1358 expected_pair, |
1354 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); | 1359 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); |
1355 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); | 1360 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); |
1356 | 1361 |
1357 // Set bandwidth and "GetStats" again. | 1362 // Set bandwidth and "GetStats" again. |
1358 webrtc::Call::Stats call_stats; | 1363 video_media_info.bw_estimations[0].available_send_bandwidth = 888; |
1359 const int kSendBandwidth = 888; | 1364 video_media_info.bw_estimations[0].available_recv_bandwidth = 999; |
1360 call_stats.send_bandwidth_bps = kSendBandwidth; | |
1361 const int kRecvBandwidth = 999; | |
1362 call_stats.recv_bandwidth_bps = kRecvBandwidth; | |
1363 EXPECT_CALL(test_->session(), GetCallStats()) | |
1364 .WillRepeatedly(Return(call_stats)); | |
1365 EXPECT_CALL(*video_media_channel, GetStats(_)) | 1365 EXPECT_CALL(*video_media_channel, GetStats(_)) |
1366 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); | 1366 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); |
1367 collector_->ClearCachedStatsReport(); | 1367 collector_->ClearCachedStatsReport(); |
1368 report = GetStatsReport(); | 1368 report = GetStatsReport(); |
1369 expected_pair.available_outgoing_bitrate = kSendBandwidth; | 1369 expected_pair.available_outgoing_bitrate = 888; |
1370 expected_pair.available_incoming_bitrate = kRecvBandwidth; | 1370 expected_pair.available_incoming_bitrate = 999; |
1371 ASSERT_TRUE(report->Get(expected_pair.id())); | 1371 ASSERT_TRUE(report->Get(expected_pair.id())); |
1372 EXPECT_EQ( | 1372 EXPECT_EQ( |
1373 expected_pair, | 1373 expected_pair, |
1374 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); | 1374 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); |
1375 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); | 1375 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); |
1376 | 1376 |
1377 RTCLocalIceCandidateStats expected_local_candidate( | 1377 RTCLocalIceCandidateStats expected_local_candidate( |
1378 *expected_pair.local_candidate_id, report->timestamp_us()); | 1378 *expected_pair.local_candidate_id, report->timestamp_us()); |
1379 expected_local_candidate.transport_id = *expected_pair.transport_id; | 1379 expected_local_candidate.transport_id = *expected_pair.transport_id; |
1380 expected_local_candidate.ip = "42.42.42.42"; | 1380 expected_local_candidate.ip = "42.42.42.42"; |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 2313 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
2314 }; | 2314 }; |
2315 | 2315 |
2316 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 2316 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
2317 collector_->VerifyThreadUsageAndResultsMerging(); | 2317 collector_->VerifyThreadUsageAndResultsMerging(); |
2318 } | 2318 } |
2319 | 2319 |
2320 } // namespace | 2320 } // namespace |
2321 | 2321 |
2322 } // namespace webrtc | 2322 } // namespace webrtc |
OLD | NEW |