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

Side by Side Diff: webrtc/audio/time_interval_unittest.cc

Issue 2979833002: Add a histogram metric tracking for how long audio RTP packets are sent (Closed)
Patch Set: Adjust for comments. Created 3 years, 5 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/audio/time_interval.h"
12 #include "webrtc/rtc_base/fakeclock.h"
13 #include "webrtc/rtc_base/timedelta.h"
14 #include "webrtc/test/gtest.h"
15
16 namespace webrtc {
17
18 TEST(TimeIntervalTest, TimeInMs) {
19 rtc::ScopedFakeClock fake_clock;
20 TimeInterval interval;
21 interval.Extend();
22 fake_clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(100));
23 interval.Extend();
24 EXPECT_EQ(interval.Length(), 100);
25 }
26
27 TEST(TimeIntervalTest, Empty) {
28 TimeInterval interval;
29 EXPECT_TRUE(interval.Empty());
30 interval.Extend();
31 EXPECT_FALSE(interval.Empty());
32 interval.Extend(200);
33 EXPECT_FALSE(interval.Empty());
34 }
35
36 TEST(TimeIntervalTest, MonotoneIncreasing) {
37 const size_t point_count = 7;
38 const int64_t interval_points[] = {3, 2, 5, 0, 4, 1, 6};
39 const int64_t interval_differences[] = {0, 1, 3, 5, 5, 5, 6};
40 TimeInterval interval;
41 EXPECT_TRUE(interval.Empty());
42 for (size_t i = 0; i < point_count; ++i) {
43 interval.Extend(interval_points[i]);
44 EXPECT_EQ(interval_differences[i], interval.Length());
45 }
46 }
47
48 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698