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

Unified Diff: webrtc/video/receive_statistics_proxy_unittest.cc

Issue 2450363003: Add unit tests to ReceiveStatisticsProxy class. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/receive_statistics_proxy_unittest.cc
diff --git a/webrtc/video/receive_statistics_proxy_unittest.cc b/webrtc/video/receive_statistics_proxy_unittest.cc
index b8c4b20f99a304f0a42d612c3288d85ecea76c5a..66856a70ade72fff3c42b9a486f607e075b4c9fb 100644
--- a/webrtc/video/receive_statistics_proxy_unittest.cc
+++ b/webrtc/video/receive_statistics_proxy_unittest.cc
@@ -18,6 +18,9 @@
namespace webrtc {
namespace {
const int64_t kFreqOffsetProcessIntervalInMs = 40000;
+const uint32_t kLocalSsrc = 123;
+const uint32_t kRemoteSsrc = 456;
+const int kMinRequiredSamples = 200;
} // namespace
// TODO(sakal): ReceiveStatisticsProxy is lacking unittesting.
@@ -34,6 +37,8 @@ class ReceiveStatisticsProxyTest : public ::testing::Test {
VideoReceiveStream::Config GetTestConfig() {
VideoReceiveStream::Config config(nullptr);
+ config.rtp.local_ssrc = kLocalSsrc;
+ config.rtp.remote_ssrc = kRemoteSsrc;
return config;
}
@@ -50,6 +55,75 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) {
}
}
+TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsSsrc) {
+ EXPECT_EQ(kRemoteSsrc, statistics_proxy_->GetStats().ssrc);
+}
+
+TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsIncomingPayloadType) {
+ const int kPayloadType = 111;
+ statistics_proxy_->OnIncomingPayloadType(kPayloadType);
+ EXPECT_EQ(kPayloadType, statistics_proxy_->GetStats().current_payload_type);
+}
+
+TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsIncomingRate) {
+ const int kFramerate = 28;
+ const int kBitrateBps = 311000;
+ statistics_proxy_->OnIncomingRate(kFramerate, kBitrateBps);
+ EXPECT_EQ(kFramerate, statistics_proxy_->GetStats().network_frame_rate);
+ EXPECT_EQ(kBitrateBps, statistics_proxy_->GetStats().total_bitrate_bps);
+}
+
+TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDecodeTimingStats) {
+ const int kDecodeMs = 1;
+ const int kMaxDecodeMs = 2;
+ const int kCurrentDelayMs = 3;
+ const int kTargetDelayMs = 4;
+ const int kJitterBufferMs = 5;
+ const int kMinPlayoutDelayMs = 6;
+ const int kRenderDelayMs = 7;
+ const int64_t kRttMs = 8;
+ statistics_proxy_->OnDecoderTiming(
+ kDecodeMs, kMaxDecodeMs, kCurrentDelayMs, kTargetDelayMs, kJitterBufferMs,
+ kMinPlayoutDelayMs, kRenderDelayMs, kRttMs);
+ VideoReceiveStream::Stats stats = statistics_proxy_->GetStats();
+ EXPECT_EQ(kDecodeMs, stats.decode_ms);
+ EXPECT_EQ(kMaxDecodeMs, stats.max_decode_ms);
+ EXPECT_EQ(kCurrentDelayMs, stats.current_delay_ms);
+ EXPECT_EQ(kTargetDelayMs, stats.target_delay_ms);
+ EXPECT_EQ(kJitterBufferMs, stats.jitter_buffer_ms);
+ EXPECT_EQ(kMinPlayoutDelayMs, stats.min_playout_delay_ms);
+ EXPECT_EQ(kRenderDelayMs, stats.render_delay_ms);
+}
+
+TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDiscardedPackets) {
+ const int kDiscardedPackets = 12;
+ statistics_proxy_->OnDiscardedPacketsUpdated(kDiscardedPackets);
+ EXPECT_EQ(kDiscardedPackets, statistics_proxy_->GetStats().discarded_packets);
+}
+
+TEST_F(ReceiveStatisticsProxyTest, LifetimeHistogramIsUpdated) {
+ const int64_t kTimeSec = 3;
+ fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000);
+ // Histograms are updated when the statistics_proxy_ is deleted.
+ statistics_proxy_.reset();
+ EXPECT_EQ(1,
+ metrics::NumSamples("WebRTC.Video.ReceiveStreamLifetimeInSeconds"));
+ EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.ReceiveStreamLifetimeInSeconds",
+ kTimeSec));
+}
+
+TEST_F(ReceiveStatisticsProxyTest, AvSyncOffsetHistogramIsUpdated) {
+ const int64_t kSyncOffsetMs = 22;
+ const double kFreqKhz = 90.0;
+ for (int i = 0; i < kMinRequiredSamples; ++i)
+ statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz);
+ // Histograms are updated when the statistics_proxy_ is deleted.
+ statistics_proxy_.reset();
+ EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.AVSyncOffsetInMs"));
+ EXPECT_EQ(1,
+ metrics::NumEvents("WebRTC.Video.AVSyncOffsetInMs", kSyncOffsetMs));
+}
+
TEST_F(ReceiveStatisticsProxyTest, RtpToNtpFrequencyOffsetHistogramIsUpdated) {
const int64_t kSyncOffsetMs = 22;
const double kFreqKhz = 90.0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698