OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 // Use CreateHistUnittestFile.m to generate the input file. | 11 // Use CreateHistUnittestFile.m to generate the input file. |
12 | 12 |
13 #include "webrtc/modules/audio_processing/agc/histogram.h" | 13 #include "webrtc/modules/audio_processing/agc/histogram.h" |
14 | 14 |
15 #include <stdio.h> | 15 #include <stdio.h> |
16 #include <cmath> | 16 #include <cmath> |
| 17 #include <memory> |
17 | 18 |
18 #include "gtest/gtest.h" | 19 #include "gtest/gtest.h" |
19 #include "webrtc/test/testsupport/fileutils.h" | 20 #include "webrtc/test/testsupport/fileutils.h" |
20 #include "webrtc/modules/audio_processing/agc/utility.h" | 21 #include "webrtc/modules/audio_processing/agc/utility.h" |
21 | 22 |
22 namespace webrtc { | 23 namespace webrtc { |
23 | 24 |
24 struct InputOutput { | 25 struct InputOutput { |
25 double rms; | 26 double rms; |
26 double activity_probability; | 27 double activity_probability; |
27 double audio_content; | 28 double audio_content; |
28 double loudness; | 29 double loudness; |
29 }; | 30 }; |
30 | 31 |
31 const double kRelativeErrTol = 1e-10; | 32 const double kRelativeErrTol = 1e-10; |
32 | 33 |
33 class HistogramTest : public ::testing::Test { | 34 class HistogramTest : public ::testing::Test { |
34 protected: | 35 protected: |
35 void RunTest(bool enable_circular_buff, | 36 void RunTest(bool enable_circular_buff, |
36 const char* filename); | 37 const char* filename); |
37 | 38 |
38 private: | 39 private: |
39 void TestClean(); | 40 void TestClean(); |
40 rtc::scoped_ptr<Histogram> hist_; | 41 std::unique_ptr<Histogram> hist_; |
41 }; | 42 }; |
42 | 43 |
43 void HistogramTest::TestClean() { | 44 void HistogramTest::TestClean() { |
44 EXPECT_EQ(hist_->CurrentRms(), 7.59621091765857e-02); | 45 EXPECT_EQ(hist_->CurrentRms(), 7.59621091765857e-02); |
45 EXPECT_EQ(hist_->AudioContent(), 0); | 46 EXPECT_EQ(hist_->AudioContent(), 0); |
46 EXPECT_EQ(hist_->num_updates(), 0); | 47 EXPECT_EQ(hist_->num_updates(), 0); |
47 } | 48 } |
48 | 49 |
49 void HistogramTest::RunTest(bool enable_circular_buff, const char* filename) { | 50 void HistogramTest::RunTest(bool enable_circular_buff, const char* filename) { |
50 FILE* in_file = fopen(filename, "rb"); | 51 FILE* in_file = fopen(filename, "rb"); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 "dat").c_str()); | 96 "dat").c_str()); |
96 } | 97 } |
97 | 98 |
98 TEST_F(HistogramTest, InactiveCircularBuffer) { | 99 TEST_F(HistogramTest, InactiveCircularBuffer) { |
99 RunTest(false, | 100 RunTest(false, |
100 test::ResourcePath("audio_processing/agc/agc_no_circular_buffer", | 101 test::ResourcePath("audio_processing/agc/agc_no_circular_buffer", |
101 "dat").c_str()); | 102 "dat").c_str()); |
102 } | 103 } |
103 | 104 |
104 } // namespace webrtc | 105 } // namespace webrtc |
OLD | NEW |