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 #include "webrtc/common_audio/vad/vad_unittest.h" | 11 #include "webrtc/common_audio/vad/vad_unittest.h" |
12 | 12 |
13 #include <stdlib.h> | 13 #include <stdlib.h> |
14 | 14 |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
| 17 #include "webrtc/base/arraysize.h" |
17 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
18 #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" |
19 #include "webrtc/common_audio/vad/include/webrtc_vad.h" | 20 #include "webrtc/common_audio/vad/include/webrtc_vad.h" |
20 #include "webrtc/typedefs.h" | 21 #include "webrtc/typedefs.h" |
21 | 22 |
22 VadTest::VadTest() {} | 23 VadTest::VadTest() {} |
23 | 24 |
24 void VadTest::SetUp() {} | 25 void VadTest::SetUp() {} |
25 | 26 |
26 void VadTest::TearDown() {} | 27 void VadTest::TearDown() {} |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 123 } |
123 } | 124 } |
124 | 125 |
125 WebRtcVad_Free(handle); | 126 WebRtcVad_Free(handle); |
126 } | 127 } |
127 | 128 |
128 TEST_F(VadTest, ValidRatesFrameLengths) { | 129 TEST_F(VadTest, ValidRatesFrameLengths) { |
129 // This test verifies valid and invalid rate/frame_length combinations. We | 130 // This test verifies valid and invalid rate/frame_length combinations. We |
130 // loop through some sampling rates and frame lengths from negative values to | 131 // loop through some sampling rates and frame lengths from negative values to |
131 // values larger than possible. | 132 // values larger than possible. |
132 const int kNumRates = 12; | 133 const int kRates[] = { |
133 const int kRates[kNumRates] = { | |
134 -8000, -4000, 0, 4000, 8000, 8001, 15999, 16000, 32000, 48000, 48001, 96000 | 134 -8000, -4000, 0, 4000, 8000, 8001, 15999, 16000, 32000, 48000, 48001, 96000 |
135 }; | 135 }; |
136 | 136 |
137 const int kNumFrameLengths = 13; | 137 const int kFrameLengths[] = { |
138 const int kFrameLengths[kNumFrameLengths] = { | |
139 -10, 0, 80, 81, 159, 160, 240, 320, 480, 640, 960, 1440, 2000 | 138 -10, 0, 80, 81, 159, 160, 240, 320, 480, 640, 960, 1440, 2000 |
140 }; | 139 }; |
141 | 140 |
142 for (int i = 0; i < kNumRates; i++) { | 141 for (size_t i = 0; i < arraysize(kRates); i++) { |
143 for (int j = 0; j < kNumFrameLengths; j++) { | 142 for (size_t j = 0; j < arraysize(kFrameLengths); j++) { |
144 if (ValidRatesAndFrameLengths(kRates[i], kFrameLengths[j])) { | 143 if (ValidRatesAndFrameLengths(kRates[i], kFrameLengths[j])) { |
145 EXPECT_EQ(0, WebRtcVad_ValidRateAndFrameLength(kRates[i], | 144 EXPECT_EQ(0, WebRtcVad_ValidRateAndFrameLength(kRates[i], |
146 kFrameLengths[j])); | 145 kFrameLengths[j])); |
147 } else { | 146 } else { |
148 EXPECT_EQ(-1, WebRtcVad_ValidRateAndFrameLength(kRates[i], | 147 EXPECT_EQ(-1, WebRtcVad_ValidRateAndFrameLength(kRates[i], |
149 kFrameLengths[j])); | 148 kFrameLengths[j])); |
150 } | 149 } |
151 } | 150 } |
152 } | 151 } |
153 } | 152 } |
154 | 153 |
155 // TODO(bjornv): Add a process test, run on file. | 154 // TODO(bjornv): Add a process test, run on file. |
156 | 155 |
157 } // namespace | 156 } // namespace |
OLD | NEW |