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

Side by Side Diff: webrtc/modules/audio_coding/neteq/normal_unittest.cc

Issue 1290113002: NetEq: Implement logging of Delayed Packet Outage Events (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rename InputAudioFile::Move to InputAudioFile::Seek Created 5 years, 4 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
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 // Unit tests for Normal class. 11 // Unit tests for Normal class.
12 12
13 #include "webrtc/modules/audio_coding/neteq/normal.h" 13 #include "webrtc/modules/audio_coding/neteq/normal.h"
14 14
15 #include <vector> 15 #include <vector>
16 16
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webrtc/base/scoped_ptr.h" 18 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
20 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h" 20 #include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h"
21 #include "webrtc/modules/audio_coding/neteq/background_noise.h" 21 #include "webrtc/modules/audio_coding/neteq/background_noise.h"
22 #include "webrtc/modules/audio_coding/neteq/expand.h" 22 #include "webrtc/modules/audio_coding/neteq/expand.h"
23 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h" 23 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h"
24 #include "webrtc/modules/audio_coding/neteq/mock/mock_expand.h" 24 #include "webrtc/modules/audio_coding/neteq/mock/mock_expand.h"
25 #include "webrtc/modules/audio_coding/neteq/random_vector.h" 25 #include "webrtc/modules/audio_coding/neteq/random_vector.h"
26 #include "webrtc/modules/audio_coding/neteq/statistics_calculator.h"
26 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" 27 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h"
27 28
28 using ::testing::_; 29 using ::testing::_;
29 30
30 namespace webrtc { 31 namespace webrtc {
31 32
32 TEST(Normal, CreateAndDestroy) { 33 TEST(Normal, CreateAndDestroy) {
33 MockDecoderDatabase db; 34 MockDecoderDatabase db;
34 int fs = 8000; 35 int fs = 8000;
35 size_t channels = 1; 36 size_t channels = 1;
36 BackgroundNoise bgn(channels); 37 BackgroundNoise bgn(channels);
37 SyncBuffer sync_buffer(1, 1000); 38 SyncBuffer sync_buffer(1, 1000);
38 RandomVector random_vector; 39 RandomVector random_vector;
39 Expand expand(&bgn, &sync_buffer, &random_vector, fs, channels); 40 StatisticsCalculator statistics;
41 Expand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs, channels);
40 Normal normal(fs, &db, bgn, &expand); 42 Normal normal(fs, &db, bgn, &expand);
41 EXPECT_CALL(db, Die()); // Called when |db| goes out of scope. 43 EXPECT_CALL(db, Die()); // Called when |db| goes out of scope.
42 } 44 }
43 45
44 TEST(Normal, AvoidDivideByZero) { 46 TEST(Normal, AvoidDivideByZero) {
45 WebRtcSpl_Init(); 47 WebRtcSpl_Init();
46 MockDecoderDatabase db; 48 MockDecoderDatabase db;
47 int fs = 8000; 49 int fs = 8000;
48 size_t channels = 1; 50 size_t channels = 1;
49 BackgroundNoise bgn(channels); 51 BackgroundNoise bgn(channels);
50 SyncBuffer sync_buffer(1, 1000); 52 SyncBuffer sync_buffer(1, 1000);
51 RandomVector random_vector; 53 RandomVector random_vector;
52 MockExpand expand(&bgn, &sync_buffer, &random_vector, fs, channels); 54 StatisticsCalculator statistics;
55 MockExpand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs,
56 channels);
53 Normal normal(fs, &db, bgn, &expand); 57 Normal normal(fs, &db, bgn, &expand);
54 58
55 int16_t input[1000] = {0}; 59 int16_t input[1000] = {0};
56 rtc::scoped_ptr<int16_t[]> mute_factor_array(new int16_t[channels]); 60 rtc::scoped_ptr<int16_t[]> mute_factor_array(new int16_t[channels]);
57 for (size_t i = 0; i < channels; ++i) { 61 for (size_t i = 0; i < channels; ++i) {
58 mute_factor_array[i] = 16384; 62 mute_factor_array[i] = 16384;
59 } 63 }
60 AudioMultiVector output(channels); 64 AudioMultiVector output(channels);
61 65
62 // Zero input length. 66 // Zero input length.
(...skipping 23 matching lines...) Expand all
86 } 90 }
87 91
88 TEST(Normal, InputLengthAndChannelsDoNotMatch) { 92 TEST(Normal, InputLengthAndChannelsDoNotMatch) {
89 WebRtcSpl_Init(); 93 WebRtcSpl_Init();
90 MockDecoderDatabase db; 94 MockDecoderDatabase db;
91 int fs = 8000; 95 int fs = 8000;
92 size_t channels = 2; 96 size_t channels = 2;
93 BackgroundNoise bgn(channels); 97 BackgroundNoise bgn(channels);
94 SyncBuffer sync_buffer(channels, 1000); 98 SyncBuffer sync_buffer(channels, 1000);
95 RandomVector random_vector; 99 RandomVector random_vector;
96 MockExpand expand(&bgn, &sync_buffer, &random_vector, fs, channels); 100 StatisticsCalculator statistics;
101 MockExpand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs,
102 channels);
97 Normal normal(fs, &db, bgn, &expand); 103 Normal normal(fs, &db, bgn, &expand);
98 104
99 int16_t input[1000] = {0}; 105 int16_t input[1000] = {0};
100 rtc::scoped_ptr<int16_t[]> mute_factor_array(new int16_t[channels]); 106 rtc::scoped_ptr<int16_t[]> mute_factor_array(new int16_t[channels]);
101 for (size_t i = 0; i < channels; ++i) { 107 for (size_t i = 0; i < channels; ++i) {
102 mute_factor_array[i] = 16384; 108 mute_factor_array[i] = 16384;
103 } 109 }
104 AudioMultiVector output(channels); 110 AudioMultiVector output(channels);
105 111
106 // Let the number of samples be one sample less than 80 samples per channel. 112 // Let the number of samples be one sample less than 80 samples per channel.
107 size_t input_len = 80 * channels - 1; 113 size_t input_len = 80 * channels - 1;
108 EXPECT_EQ( 114 EXPECT_EQ(
109 0, 115 0,
110 normal.Process( 116 normal.Process(
111 input, input_len, kModeExpand, mute_factor_array.get(), &output)); 117 input, input_len, kModeExpand, mute_factor_array.get(), &output));
112 EXPECT_EQ(0u, output.Size()); 118 EXPECT_EQ(0u, output.Size());
113 119
114 EXPECT_CALL(db, Die()); // Called when |db| goes out of scope. 120 EXPECT_CALL(db, Die()); // Called when |db| goes out of scope.
115 EXPECT_CALL(expand, Die()); // Called when |expand| goes out of scope. 121 EXPECT_CALL(expand, Die()); // Called when |expand| goes out of scope.
116 } 122 }
117 123
118 // TODO(hlundin): Write more tests. 124 // TODO(hlundin): Write more tests.
119 125
120 } // namespace webrtc 126 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.cc ('k') | webrtc/modules/audio_coding/neteq/statistics_calculator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698