OLD | NEW |
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 Loading... |
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 |
OLD | NEW |