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

Side by Side Diff: webrtc/modules/video_coding/histogram_unittest.cc

Issue 1715673002: Implement the NackModule as part of the new jitter buffer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Format Created 4 years, 9 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 (c) 2016 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 "testing/gtest/include/gtest/gtest.h"
12 #include "webrtc/modules/video_coding/histogram.h"
13
14 namespace webrtc {
15 namespace video_coding {
16
17 class TestHistogram : public ::testing::Test {
18 protected:
19 TestHistogram() : histogram_(5, 10) {}
20 Histogram histogram_;
21 };
22
23 TEST_F(TestHistogram, NumValues) {
24 EXPECT_EQ(0ul, histogram_.NumValues());
25 histogram_.Add(0);
26 EXPECT_EQ(1ul, histogram_.NumValues());
27 }
28
29 TEST_F(TestHistogram, InverseCdf) {
30 histogram_.Add(0);
31 histogram_.Add(1);
32 histogram_.Add(2);
33 histogram_.Add(3);
34 histogram_.Add(4);
35 EXPECT_EQ(5ul, histogram_.NumValues());
36 EXPECT_EQ(1ul, histogram_.InverseCdf(0.2f));
37 EXPECT_EQ(2ul, histogram_.InverseCdf(0.2000001f));
38 EXPECT_EQ(4ul, histogram_.InverseCdf(0.8f));
39
40 histogram_.Add(0);
41 EXPECT_EQ(6ul, histogram_.NumValues());
42 EXPECT_EQ(1ul, histogram_.InverseCdf(0.2f));
43 EXPECT_EQ(1ul, histogram_.InverseCdf(0.2000001f));
44 }
45
46 TEST_F(TestHistogram, ReplaceOldValues) {
47 histogram_.Add(0);
48 histogram_.Add(0);
49 histogram_.Add(0);
50 histogram_.Add(0);
51 histogram_.Add(0);
52 histogram_.Add(1);
53 histogram_.Add(1);
54 histogram_.Add(1);
55 histogram_.Add(1);
56 histogram_.Add(1);
57 EXPECT_EQ(10ul, histogram_.NumValues());
58 EXPECT_EQ(1ul, histogram_.InverseCdf(0.5f));
59 EXPECT_EQ(2ul, histogram_.InverseCdf(0.5000001f));
60
61 histogram_.Add(4);
62 histogram_.Add(4);
63 histogram_.Add(4);
64 histogram_.Add(4);
65 EXPECT_EQ(10ul, histogram_.NumValues());
66 EXPECT_EQ(1ul, histogram_.InverseCdf(0.1f));
67 EXPECT_EQ(2ul, histogram_.InverseCdf(0.5f));
68
69 histogram_.Add(20);
70 EXPECT_EQ(10ul, histogram_.NumValues());
71 EXPECT_EQ(2ul, histogram_.InverseCdf(0.5f));
72 EXPECT_EQ(5ul, histogram_.InverseCdf(0.5000001f));
73 }
74
75 } // namespace video_coding
76 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698