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

Unified Diff: webrtc/pc/statscollector_unittest.cc

Issue 2943073002: Fix uploading of available send bitrate statistics. (Closed)
Patch Set: Fixes uploading of available send bitrate statistics and adds unit test verifying audio BWE reportiā€¦ 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/pc/statscollector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/pc/statscollector_unittest.cc
diff --git a/webrtc/pc/statscollector_unittest.cc b/webrtc/pc/statscollector_unittest.cc
index e9a2c5c9d56deddf7dc48b563ce391b0b688a6a8..165457c9c82493b1e181c4f36958e5c724f969a8 100644
--- a/webrtc/pc/statscollector_unittest.cc
+++ b/webrtc/pc/statscollector_unittest.cc
@@ -900,8 +900,75 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
EXPECT_EQ(kBytesSentString, result);
}
-// Test that BWE information is reported via stats.
-TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) {
+// Test that audio BWE information is reported via stats.
+TEST_F(StatsCollectorTest, AudioBandwidthEstimationInfoIsReported) {
+ StatsCollectorForTest stats(&pc_);
+
+ EXPECT_CALL(session_, GetLocalCertificate(_, _))
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
+ .WillRepeatedly(Return(nullptr));
+
+ const char kAudioChannelName[] = "audio";
+
+ InitSessionStats(kAudioChannelName);
+ EXPECT_CALL(session_, GetStats(_))
+ .WillRepeatedly(Invoke([this](const ChannelNamePairs&) {
+ return std::unique_ptr<SessionStats>(new SessionStats(session_stats_));
+ }));
+
+ MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
+ cricket::VoiceChannel voice_channel(
+ worker_thread_, network_thread_, nullptr, nullptr, media_channel,
+ kAudioChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired);
+
+ StatsReports reports; // returned values.
+ cricket::VoiceSenderInfo voice_sender_info;
+ cricket::VoiceMediaInfo stats_read;
+ // Set up an SSRC just to test that we get both kinds of stats back: SSRC and
+ // BWE.
+ const int64_t kBytesSent = 12345678901234LL;
+ const std::string kBytesSentString("12345678901234");
+
+ AddOutgoingAudioTrackStats();
+ stats.AddStream(stream_);
+
+ // Construct a stats value to read.
+ voice_sender_info.add_ssrc(1234);
+ voice_sender_info.bytes_sent = kBytesSent;
+ stats_read.senders.push_back(voice_sender_info);
+
+ webrtc::Call::Stats call_stats;
+ const int kSendBandwidth = 1234567;
+ const int kRecvBandwidth = 12345678;
+ const int kPacerDelay = 123;
+ call_stats.send_bandwidth_bps = kSendBandwidth;
+ call_stats.recv_bandwidth_bps = kRecvBandwidth;
+ call_stats.pacer_delay_ms = kPacerDelay;
+ EXPECT_CALL(session_, GetCallStats()).WillRepeatedly(Return(call_stats));
+ EXPECT_CALL(session_, voice_channel()).WillRepeatedly(Return(&voice_channel));
+ EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
+ EXPECT_CALL(*media_channel, GetStats(_))
+ .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true)));
+
+ stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
+ stats.GetStats(NULL, &reports);
+ std::string result =
+ ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameBytesSent);
+ EXPECT_EQ(kBytesSentString, result);
+ result = ExtractBweStatsValue(
+ reports, StatsReport::kStatsValueNameAvailableSendBandwidth);
+ EXPECT_EQ(rtc::ToString(kSendBandwidth), result);
+ result = ExtractBweStatsValue(
+ reports, StatsReport::kStatsValueNameAvailableReceiveBandwidth);
+ EXPECT_EQ(rtc::ToString(kRecvBandwidth), result);
+ result =
+ ExtractBweStatsValue(reports, StatsReport::kStatsValueNameBucketDelay);
+ EXPECT_EQ(rtc::ToString(kPacerDelay), result);
+}
+
+// Test that video BWE information is reported via stats.
+TEST_F(StatsCollectorTest, VideoBandwidthEstimationInfoIsReported) {
StatsCollectorForTest stats(&pc_);
EXPECT_CALL(session_, GetLocalCertificate(_, _))
« no previous file with comments | « webrtc/pc/statscollector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698