diff options
Diffstat (limited to 'webrtc/video/send_statistics_proxy_unittest.cc')
-rw-r--r-- | webrtc/video/send_statistics_proxy_unittest.cc | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc index 8e6b7bcab3..fc1f3fdbde 100644 --- a/webrtc/video/send_statistics_proxy_unittest.cc +++ b/webrtc/video/send_statistics_proxy_unittest.cc @@ -16,6 +16,7 @@ #include <vector> #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/test/histogram.h" namespace webrtc { @@ -28,8 +29,9 @@ class SendStatisticsProxyTest : public ::testing::Test { protected: virtual void SetUp() { - statistics_proxy_.reset( - new SendStatisticsProxy(&fake_clock_, GetTestConfig())); + statistics_proxy_.reset(new SendStatisticsProxy( + &fake_clock_, GetTestConfig(), + VideoEncoderConfig::ContentType::kRealtimeVideo)); expected_ = VideoSendStream::Stats(); } @@ -287,6 +289,33 @@ TEST_F(SendStatisticsProxyTest, SendSideDelay) { ExpectEqual(expected_, stats); } +TEST_F(SendStatisticsProxyTest, OnEncodedFrame) { + const int kEncodeTimeMs = 11; + statistics_proxy_->OnEncodedFrame(kEncodeTimeMs); + + VideoSendStream::Stats stats = statistics_proxy_->GetStats(); + EXPECT_EQ(kEncodeTimeMs, stats.avg_encode_time_ms); +} + +TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { + test::ClearHistograms(); + const int kMinRequiredSamples = 200; + const int kWidth = 640; + const int kHeight = 480; + + for (int i = 0; i < kMinRequiredSamples; ++i) + statistics_proxy_->OnIncomingFrame(kWidth, kHeight); + + // No switch, stats not should be updated. + statistics_proxy_->SetContentType( + VideoEncoderConfig::ContentType::kRealtimeVideo); + EXPECT_EQ(0, test::NumHistogramSamples("WebRTC.Video.InputWidthInPixels")); + + // Switch to screenshare, real-time stats should be updated. + statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); + EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.InputWidthInPixels")); +} + TEST_F(SendStatisticsProxyTest, NoSubstreams) { uint32_t excluded_ssrc = std::max( |