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

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

Issue 1915523002: Add a default implementation in metrics_default.cc of histograms methods in system_wrappers/interfac (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/end_to_end_tests.cc ('k') | webrtc/video/send_statistics_proxy_unittest.cc » ('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 (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 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
11 #include "webrtc/video/send_delay_stats.h" 11 #include "webrtc/video/send_delay_stats.h"
12 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "webrtc/system_wrappers/include/metrics.h" 14 #include "webrtc/system_wrappers/include/metrics.h"
15 #include "webrtc/test/histogram.h" 15 #include "webrtc/system_wrappers/include/metrics_default.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 namespace { 18 namespace {
19 const uint32_t kSsrc1 = 17; 19 const uint32_t kSsrc1 = 17;
20 const uint32_t kSsrc2 = 42; 20 const uint32_t kSsrc2 = 42;
21 const uint32_t kRtxSsrc1 = 18; 21 const uint32_t kRtxSsrc1 = 18;
22 const uint32_t kRtxSsrc2 = 43; 22 const uint32_t kRtxSsrc2 = 43;
23 const uint16_t kPacketId = 2345; 23 const uint16_t kPacketId = 2345;
24 const int64_t kMaxPacketDelayMs = 11000; 24 const int64_t kMaxPacketDelayMs = 11000;
25 const int kMinRequiredSamples = 200; 25 const int kMinRequiredSamples = 200;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 clock_.AdvanceTimeMilliseconds(kMaxPacketDelayMs); // 0xffff, 0 -> old. 95 clock_.AdvanceTimeMilliseconds(kMaxPacketDelayMs); // 0xffff, 0 -> old.
96 OnSendPacket(2u, kSsrc1, kCaptureTimeMs + 2); 96 OnSendPacket(2u, kSsrc1, kCaptureTimeMs + 2);
97 97
98 EXPECT_FALSE(OnSentPacket(0xffffu)); // Old removed. 98 EXPECT_FALSE(OnSentPacket(0xffffu)); // Old removed.
99 EXPECT_FALSE(OnSentPacket(0u)); // Old removed. 99 EXPECT_FALSE(OnSentPacket(0u)); // Old removed.
100 EXPECT_TRUE(OnSentPacket(1u)); 100 EXPECT_TRUE(OnSentPacket(1u));
101 EXPECT_TRUE(OnSentPacket(2u)); 101 EXPECT_TRUE(OnSentPacket(2u));
102 } 102 }
103 103
104 TEST_F(SendDelayStatsTest, HistogramsAreUpdated) { 104 TEST_F(SendDelayStatsTest, HistogramsAreUpdated) {
105 test::ClearHistograms(); 105 metrics::Reset();
106 const int64_t kDelayMs1 = 5; 106 const int64_t kDelayMs1 = 5;
107 const int64_t kDelayMs2 = 10; 107 const int64_t kDelayMs2 = 10;
108 uint16_t id = 0; 108 uint16_t id = 0;
109 for (int i = 0; i < kMinRequiredSamples; ++i) { 109 for (int i = 0; i < kMinRequiredSamples; ++i) {
110 OnSendPacket(++id, kSsrc1); 110 OnSendPacket(++id, kSsrc1);
111 clock_.AdvanceTimeMilliseconds(kDelayMs1); 111 clock_.AdvanceTimeMilliseconds(kDelayMs1);
112 EXPECT_TRUE(OnSentPacket(id)); 112 EXPECT_TRUE(OnSentPacket(id));
113 OnSendPacket(++id, kSsrc2); 113 OnSendPacket(++id, kSsrc2);
114 clock_.AdvanceTimeMilliseconds(kDelayMs2); 114 clock_.AdvanceTimeMilliseconds(kDelayMs2);
115 EXPECT_TRUE(OnSentPacket(id)); 115 EXPECT_TRUE(OnSentPacket(id));
116 } 116 }
117 stats_.reset(); 117 stats_.reset();
118 EXPECT_EQ(2, test::NumHistogramSamples("WebRTC.Video.SendDelayInMs")); 118 EXPECT_EQ(2, metrics::NumSamples("WebRTC.Video.SendDelayInMs"));
119 EXPECT_EQ(kDelayMs2, test::LastHistogramSample("WebRTC.Video.SendDelayInMs")); 119 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendDelayInMs", kDelayMs1));
120 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendDelayInMs", kDelayMs2));
120 } 121 }
121 122
122 } // namespace webrtc 123 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/end_to_end_tests.cc ('k') | webrtc/video/send_statistics_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698