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

Side by Side Diff: webrtc/video/receive_statistics_proxy_unittest.cc

Issue 3002593002: Fix incorrect InterframeDelayMaxInMs histogram metrics (Closed)
Patch Set: Created 3 years, 4 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/video/receive_statistics_proxy.cc ('k') | no next file » | 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 12 matching lines...) Expand all
23 23
24 namespace webrtc { 24 namespace webrtc {
25 namespace { 25 namespace {
26 const int64_t kFreqOffsetProcessIntervalInMs = 40000; 26 const int64_t kFreqOffsetProcessIntervalInMs = 40000;
27 const uint32_t kLocalSsrc = 123; 27 const uint32_t kLocalSsrc = 123;
28 const uint32_t kRemoteSsrc = 456; 28 const uint32_t kRemoteSsrc = 456;
29 const int kMinRequiredSamples = 200; 29 const int kMinRequiredSamples = 200;
30 } // namespace 30 } // namespace
31 31
32 // TODO(sakal): ReceiveStatisticsProxy is lacking unittesting. 32 // TODO(sakal): ReceiveStatisticsProxy is lacking unittesting.
33 class ReceiveStatisticsProxyTest : public ::testing::Test { 33 class ReceiveStatisticsProxyTest
34 : public ::testing::TestWithParam<webrtc::VideoContentType> {
34 public: 35 public:
35 ReceiveStatisticsProxyTest() : fake_clock_(1234), config_(GetTestConfig()) {} 36 ReceiveStatisticsProxyTest() : fake_clock_(1234), config_(GetTestConfig()) {}
36 virtual ~ReceiveStatisticsProxyTest() {} 37 virtual ~ReceiveStatisticsProxyTest() {}
37 38
38 protected: 39 protected:
39 virtual void SetUp() { 40 virtual void SetUp() {
40 metrics::Reset(); 41 metrics::Reset();
41 statistics_proxy_.reset(new ReceiveStatisticsProxy(&config_, &fake_clock_)); 42 statistics_proxy_.reset(new ReceiveStatisticsProxy(&config_, &fake_clock_));
42 } 43 }
43 44
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 1, metrics::NumEvents("WebRTC.Video.FirPacketsSentPerMinute", 712 1, metrics::NumEvents("WebRTC.Video.FirPacketsSentPerMinute",
712 kFirPackets * 60 / metrics::kMinRunTimeInSeconds)); 713 kFirPackets * 60 / metrics::kMinRunTimeInSeconds));
713 EXPECT_EQ( 714 EXPECT_EQ(
714 1, metrics::NumEvents("WebRTC.Video.PliPacketsSentPerMinute", 715 1, metrics::NumEvents("WebRTC.Video.PliPacketsSentPerMinute",
715 kPliPackets * 60 / metrics::kMinRunTimeInSeconds)); 716 kPliPackets * 60 / metrics::kMinRunTimeInSeconds));
716 EXPECT_EQ( 717 EXPECT_EQ(
717 1, metrics::NumEvents("WebRTC.Video.NackPacketsSentPerMinute", 718 1, metrics::NumEvents("WebRTC.Video.NackPacketsSentPerMinute",
718 kNackPackets * 60 / metrics::kMinRunTimeInSeconds)); 719 kNackPackets * 60 / metrics::kMinRunTimeInSeconds));
719 } 720 }
720 721
722 INSTANTIATE_TEST_CASE_P(ContentTypes,
723 ReceiveStatisticsProxyTest,
724 ::testing::Values(VideoContentType::UNSPECIFIED,
725 VideoContentType::SCREENSHARE));
726
727 TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysAreReported) {
728 const VideoContentType content_type = GetParam();
729 const int kInterFrameDelayMs = 33;
730 for (int i = 0; i < kMinRequiredSamples; ++i) {
731 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
732 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
733 }
734 // One extra with with double the interval.
735 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
736 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
737
738 statistics_proxy_.reset();
739 const int kExpectedInterFrame =
740 (kInterFrameDelayMs * (kMinRequiredSamples - 1) +
741 kInterFrameDelayMs * 2) /
742 kMinRequiredSamples;
743 switch (content_type) {
744 case VideoContentType::UNSPECIFIED:
745 EXPECT_EQ(kExpectedInterFrame,
746 metrics::MinSample("WebRTC.Video.InterframeDelayInMs"));
747 EXPECT_EQ(kInterFrameDelayMs * 2,
748 metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs"));
749 break;
750 case VideoContentType::SCREENSHARE:
751 EXPECT_EQ(
752 kExpectedInterFrame,
753 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs"));
754 EXPECT_EQ(kInterFrameDelayMs * 2,
755 metrics::MinSample(
756 "WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
757 break;
758 default:
759 RTC_NOTREACHED();
760 }
761 }
762
763 TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithValidAverage) {
764 const VideoContentType content_type = GetParam();
765 const int kInterFrameDelayMs = 33;
766 for (int i = 0; i < kMinRequiredSamples; ++i) {
767 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
768 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
769 }
770
771 // |kMinRequiredSamples| samples, and thereby intervals, is required. That
772 // means we're one frame short of having a valid data set.
773 statistics_proxy_.reset();
774 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs"));
775 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs"));
776 EXPECT_EQ(
777 0, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs"));
778 EXPECT_EQ(0, metrics::NumSamples(
779 "WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
780 }
781
721 } // namespace webrtc 782 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/receive_statistics_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698