Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: webrtc/pc/rtcstatscollector_unittest.cc

Issue 2863123002: Wire up BWE stats through WebrtcSession so that they are filled in both for audio and video calls. (Closed)
Patch Set: Comments addressed." Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/pc/rtcstatscollector.cc ('k') | webrtc/pc/statscollector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
1269 EXPECT_CALL(*video_media_channel, GetStats(_)) 1266 EXPECT_CALL(*video_media_channel, GetStats(_))
1270 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); 1267 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true)));
1271 EXPECT_CALL(test_->session(), video_channel()) 1268 EXPECT_CALL(test_->session(), video_channel())
1272 .WillRepeatedly(Return(&video_channel)); 1269 .WillRepeatedly(Return(&video_channel));
1273 1270
1274 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 1271 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
1275 1272
1276 RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" + 1273 RTCIceCandidatePairStats expected_pair("RTCIceCandidatePair_" +
1277 local_candidate->id() + "_" + 1274 local_candidate->id() + "_" +
1278 remote_candidate->id(), 1275 remote_candidate->id(),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 EXPECT_EQ( 1335 EXPECT_EQ(
1339 expected_pair, 1336 expected_pair,
1340 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); 1337 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>());
1341 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); 1338 EXPECT_TRUE(report->Get(*expected_pair.transport_id));
1342 1339
1343 // Make pair the current pair, clear bandwidth and "GetStats" again. 1340 // Make pair the current pair, clear bandwidth and "GetStats" again.
1344 session_stats.transport_stats["transport"] 1341 session_stats.transport_stats["transport"]
1345 .channel_stats[0] 1342 .channel_stats[0]
1346 .connection_infos[0] 1343 .connection_infos[0]
1347 .best_connection = true; 1344 .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;
1350 EXPECT_CALL(*video_media_channel, GetStats(_)) 1345 EXPECT_CALL(*video_media_channel, GetStats(_))
1351 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true))); 1346 .WillOnce(DoAll(SetArgPointee<0>(video_media_info), Return(true)));
1352 collector_->ClearCachedStatsReport(); 1347 collector_->ClearCachedStatsReport();
1353 report = GetStatsReport(); 1348 report = GetStatsReport();
1354 // |expected_pair.available_[outgoing/incoming]_bitrate| should still be 1349 // |expected_pair.available_[outgoing/incoming]_bitrate| should still be
1355 // undefined because bandwidth is not set. 1350 // undefined because bandwidth is not set.
1356 ASSERT_TRUE(report->Get(expected_pair.id())); 1351 ASSERT_TRUE(report->Get(expected_pair.id()));
1357 EXPECT_EQ( 1352 EXPECT_EQ(
1358 expected_pair, 1353 expected_pair,
1359 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); 1354 report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>());
1360 EXPECT_TRUE(report->Get(*expected_pair.transport_id)); 1355 EXPECT_TRUE(report->Get(*expected_pair.transport_id));
1361 1356
1362 // Set bandwidth and "GetStats" again. 1357 // Set bandwidth and "GetStats" again.
1363 video_media_info.bw_estimations[0].available_send_bandwidth = 888; 1358 webrtc::Call::Stats call_stats;
1364 video_media_info.bw_estimations[0].available_recv_bandwidth = 999; 1359 const int kSendBandwidth = 888;
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 = 888; 1369 expected_pair.available_outgoing_bitrate = kSendBandwidth;
1370 expected_pair.available_incoming_bitrate = 999; 1370 expected_pair.available_incoming_bitrate = kRecvBandwidth;
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
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
OLDNEW
« no previous file with comments | « webrtc/pc/rtcstatscollector.cc ('k') | webrtc/pc/statscollector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698