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

Side by Side Diff: webrtc/modules/audio_processing/utility/delay_estimator_unittest.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 int spectrum_size_; 54 int spectrum_size_;
55 // Dummy input spectra. 55 // Dummy input spectra.
56 float far_f_[kSpectrumSize]; 56 float far_f_[kSpectrumSize];
57 float near_f_[kSpectrumSize]; 57 float near_f_[kSpectrumSize];
58 uint16_t far_u16_[kSpectrumSize]; 58 uint16_t far_u16_[kSpectrumSize];
59 uint16_t near_u16_[kSpectrumSize]; 59 uint16_t near_u16_[kSpectrumSize];
60 uint32_t binary_spectrum_[kSequenceLength + kHistorySize]; 60 uint32_t binary_spectrum_[kSequenceLength + kHistorySize];
61 }; 61 };
62 62
63 DelayEstimatorTest::DelayEstimatorTest() 63 DelayEstimatorTest::DelayEstimatorTest()
64 : handle_(NULL), 64 : handle_(nullptr),
65 self_(NULL), 65 self_(nullptr),
66 farend_handle_(NULL), 66 farend_handle_(nullptr),
67 farend_self_(NULL), 67 farend_self_(nullptr),
68 binary_(NULL), 68 binary_(nullptr),
69 binary_farend_(NULL), 69 binary_farend_(nullptr),
70 spectrum_size_(kSpectrumSize) { 70 spectrum_size_(kSpectrumSize) {
71 // Dummy input data are set with more or less arbitrary non-zero values. 71 // Dummy input data are set with more or less arbitrary non-zero values.
72 memset(far_f_, 1, sizeof(far_f_)); 72 memset(far_f_, 1, sizeof(far_f_));
73 memset(near_f_, 2, sizeof(near_f_)); 73 memset(near_f_, 2, sizeof(near_f_));
74 memset(far_u16_, 1, sizeof(far_u16_)); 74 memset(far_u16_, 1, sizeof(far_u16_));
75 memset(near_u16_, 2, sizeof(near_u16_)); 75 memset(near_u16_, 2, sizeof(near_u16_));
76 // Construct a sequence of binary spectra used to verify delay estimate. The 76 // Construct a sequence of binary spectra used to verify delay estimate. The
77 // |kSequenceLength| has to be long enough for the delay estimation to leave 77 // |kSequenceLength| has to be long enough for the delay estimation to leave
78 // the initialized state. 78 // the initialized state.
79 binary_spectrum_[0] = 1; 79 binary_spectrum_[0] = 1;
80 for (int i = 1; i < (kSequenceLength + kHistorySize); i++) { 80 for (int i = 1; i < (kSequenceLength + kHistorySize); i++) {
81 binary_spectrum_[i] = 3 * binary_spectrum_[i - 1]; 81 binary_spectrum_[i] = 3 * binary_spectrum_[i - 1];
82 } 82 }
83 } 83 }
84 84
85 void DelayEstimatorTest::SetUp() { 85 void DelayEstimatorTest::SetUp() {
86 farend_handle_ = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, 86 farend_handle_ = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize,
87 kHistorySize); 87 kHistorySize);
88 ASSERT_TRUE(farend_handle_ != NULL); 88 ASSERT_TRUE(farend_handle_ != nullptr);
89 farend_self_ = reinterpret_cast<DelayEstimatorFarend*>(farend_handle_); 89 farend_self_ = reinterpret_cast<DelayEstimatorFarend*>(farend_handle_);
90 handle_ = WebRtc_CreateDelayEstimator(farend_handle_, kLookahead); 90 handle_ = WebRtc_CreateDelayEstimator(farend_handle_, kLookahead);
91 ASSERT_TRUE(handle_ != NULL); 91 ASSERT_TRUE(handle_ != nullptr);
92 self_ = reinterpret_cast<DelayEstimator*>(handle_); 92 self_ = reinterpret_cast<DelayEstimator*>(handle_);
93 binary_farend_ = WebRtc_CreateBinaryDelayEstimatorFarend(kHistorySize); 93 binary_farend_ = WebRtc_CreateBinaryDelayEstimatorFarend(kHistorySize);
94 ASSERT_TRUE(binary_farend_ != NULL); 94 ASSERT_TRUE(binary_farend_ != nullptr);
95 binary_ = WebRtc_CreateBinaryDelayEstimator(binary_farend_, kLookahead); 95 binary_ = WebRtc_CreateBinaryDelayEstimator(binary_farend_, kLookahead);
96 ASSERT_TRUE(binary_ != NULL); 96 ASSERT_TRUE(binary_ != nullptr);
97 } 97 }
98 98
99 void DelayEstimatorTest::TearDown() { 99 void DelayEstimatorTest::TearDown() {
100 WebRtc_FreeDelayEstimator(handle_); 100 WebRtc_FreeDelayEstimator(handle_);
101 handle_ = NULL; 101 handle_ = nullptr;
102 self_ = NULL; 102 self_ = nullptr;
103 WebRtc_FreeDelayEstimatorFarend(farend_handle_); 103 WebRtc_FreeDelayEstimatorFarend(farend_handle_);
104 farend_handle_ = NULL; 104 farend_handle_ = nullptr;
105 farend_self_ = NULL; 105 farend_self_ = nullptr;
106 WebRtc_FreeBinaryDelayEstimator(binary_); 106 WebRtc_FreeBinaryDelayEstimator(binary_);
107 binary_ = NULL; 107 binary_ = nullptr;
108 WebRtc_FreeBinaryDelayEstimatorFarend(binary_farend_); 108 WebRtc_FreeBinaryDelayEstimatorFarend(binary_farend_);
109 binary_farend_ = NULL; 109 binary_farend_ = nullptr;
110 } 110 }
111 111
112 void DelayEstimatorTest::Init() { 112 void DelayEstimatorTest::Init() {
113 // Initialize Delay Estimator 113 // Initialize Delay Estimator
114 EXPECT_EQ(0, WebRtc_InitDelayEstimatorFarend(farend_handle_)); 114 EXPECT_EQ(0, WebRtc_InitDelayEstimatorFarend(farend_handle_));
115 EXPECT_EQ(0, WebRtc_InitDelayEstimator(handle_)); 115 EXPECT_EQ(0, WebRtc_InitDelayEstimator(handle_));
116 // Verify initialization. 116 // Verify initialization.
117 EXPECT_EQ(0, farend_self_->far_spectrum_initialized); 117 EXPECT_EQ(0, farend_self_->far_spectrum_initialized);
118 EXPECT_EQ(0, self_->near_spectrum_initialized); 118 EXPECT_EQ(0, self_->near_spectrum_initialized);
119 EXPECT_EQ(-2, WebRtc_last_delay(handle_)); // Delay in initial state. 119 EXPECT_EQ(-2, WebRtc_last_delay(handle_)); // Delay in initial state.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // For non-causal systems the delay is equivalent with a negative |offset| of 207 // For non-causal systems the delay is equivalent with a negative |offset| of
208 // the far-end sequence. 208 // the far-end sequence.
209 binary_->robust_validation_enabled = ref_robust_validation; 209 binary_->robust_validation_enabled = ref_robust_validation;
210 binary2->robust_validation_enabled = robust_validation; 210 binary2->robust_validation_enabled = robust_validation;
211 for (int offset = -kLookahead; 211 for (int offset = -kLookahead;
212 offset < kMaxDelay - lookahead_offset - near_offset; 212 offset < kMaxDelay - lookahead_offset - near_offset;
213 offset++) { 213 offset++) {
214 RunBinarySpectra(binary_, binary2, near_offset, lookahead_offset, offset); 214 RunBinarySpectra(binary_, binary2, near_offset, lookahead_offset, offset);
215 } 215 }
216 WebRtc_FreeBinaryDelayEstimator(binary2); 216 WebRtc_FreeBinaryDelayEstimator(binary2);
217 binary2 = NULL; 217 binary2 = nullptr;
218 binary_->robust_validation_enabled = 0; // Reset reference. 218 binary_->robust_validation_enabled = 0; // Reset reference.
219 } 219 }
220 220
221 TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) { 221 TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) {
222 // In this test we verify correct error returns on invalid API calls. 222 // In this test we verify correct error returns on invalid API calls.
223 223
224 // WebRtc_CreateDelayEstimatorFarend() and WebRtc_CreateDelayEstimator() 224 // WebRtc_CreateDelayEstimatorFarend() and WebRtc_CreateDelayEstimator()
225 // should return a NULL pointer on invalid input values. 225 // should return a null pointer on invalid input values.
226 // Make sure we have a non-NULL value at start, so we can detect NULL after 226 // Make sure we have a non-null value at start, so we can detect null after
227 // create failure. 227 // create failure.
228 void* handle = farend_handle_; 228 void* handle = farend_handle_;
229 handle = WebRtc_CreateDelayEstimatorFarend(33, kHistorySize); 229 handle = WebRtc_CreateDelayEstimatorFarend(33, kHistorySize);
230 EXPECT_TRUE(handle == NULL); 230 EXPECT_TRUE(handle == nullptr);
231 handle = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, 1); 231 handle = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, 1);
232 EXPECT_TRUE(handle == NULL); 232 EXPECT_TRUE(handle == nullptr);
233 233
234 handle = handle_; 234 handle = handle_;
235 handle = WebRtc_CreateDelayEstimator(NULL, kLookahead); 235 handle = WebRtc_CreateDelayEstimator(nullptr, kLookahead);
236 EXPECT_TRUE(handle == NULL); 236 EXPECT_TRUE(handle == nullptr);
237 handle = WebRtc_CreateDelayEstimator(farend_handle_, -1); 237 handle = WebRtc_CreateDelayEstimator(farend_handle_, -1);
238 EXPECT_TRUE(handle == NULL); 238 EXPECT_TRUE(handle == nullptr);
239 239
240 // WebRtc_InitDelayEstimatorFarend() and WebRtc_InitDelayEstimator() should 240 // WebRtc_InitDelayEstimatorFarend() and WebRtc_InitDelayEstimator() should
241 // return -1 if we have a NULL pointer as |handle|. 241 // return -1 if we have a null pointer as |handle|.
242 EXPECT_EQ(-1, WebRtc_InitDelayEstimatorFarend(NULL)); 242 EXPECT_EQ(-1, WebRtc_InitDelayEstimatorFarend(nullptr));
243 EXPECT_EQ(-1, WebRtc_InitDelayEstimator(NULL)); 243 EXPECT_EQ(-1, WebRtc_InitDelayEstimator(nullptr));
244 244
245 // WebRtc_AddFarSpectrumFloat() should return -1 if we have: 245 // WebRtc_AddFarSpectrumFloat() should return -1 if we have:
246 // 1) NULL pointer as |handle|. 246 // 1) null pointer as |handle|.
247 // 2) NULL pointer as far-end spectrum. 247 // 2) null pointer as far-end spectrum.
248 // 3) Incorrect spectrum size. 248 // 3) Incorrect spectrum size.
249 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(NULL, far_f_, spectrum_size_)); 249 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(nullptr, far_f_, spectrum_size_));
250 // Use |farend_handle_| which is properly created at SetUp(). 250 // Use |farend_handle_| which is properly created at SetUp().
251 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, NULL, 251 EXPECT_EQ(
252 spectrum_size_)); 252 -1, WebRtc_AddFarSpectrumFloat(farend_handle_, nullptr, spectrum_size_));
253 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, 253 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_,
254 spectrum_size_ + 1)); 254 spectrum_size_ + 1));
255 255
256 // WebRtc_AddFarSpectrumFix() should return -1 if we have: 256 // WebRtc_AddFarSpectrumFix() should return -1 if we have:
257 // 1) NULL pointer as |handle|. 257 // 1) null pointer as |handle|.
258 // 2) NULL pointer as far-end spectrum. 258 // 2) null pointer as far-end spectrum.
259 // 3) Incorrect spectrum size. 259 // 3) Incorrect spectrum size.
260 // 4) Too high precision in far-end spectrum (Q-domain > 15). 260 // 4) Too high precision in far-end spectrum (Q-domain > 15).
261 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(NULL, far_u16_, spectrum_size_, 0)); 261 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(nullptr, far_u16_, spectrum_size_, 0));
262 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, NULL, spectrum_size_, 262 EXPECT_EQ(
263 0)); 263 -1, WebRtc_AddFarSpectrumFix(farend_handle_, nullptr, spectrum_size_, 0));
264 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, 264 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_,
265 spectrum_size_ + 1, 0)); 265 spectrum_size_ + 1, 0));
266 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_, 266 EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_,
267 spectrum_size_, 16)); 267 spectrum_size_, 16));
268 268
269 // WebRtc_set_history_size() should return -1 if: 269 // WebRtc_set_history_size() should return -1 if:
270 // 1) |handle| is a NULL. 270 // 1) |handle| is a null.
271 // 2) |history_size| <= 1. 271 // 2) |history_size| <= 1.
272 EXPECT_EQ(-1, WebRtc_set_history_size(NULL, 1)); 272 EXPECT_EQ(-1, WebRtc_set_history_size(nullptr, 1));
273 EXPECT_EQ(-1, WebRtc_set_history_size(handle_, 1)); 273 EXPECT_EQ(-1, WebRtc_set_history_size(handle_, 1));
274 // WebRtc_history_size() should return -1 if: 274 // WebRtc_history_size() should return -1 if:
275 // 1) NULL pointer input. 275 // 1) null pointer input.
276 EXPECT_EQ(-1, WebRtc_history_size(NULL)); 276 EXPECT_EQ(-1, WebRtc_history_size(nullptr));
277 // 2) there is a mismatch between history size. 277 // 2) there is a mismatch between history size.
278 void* tmp_handle = WebRtc_CreateDelayEstimator(farend_handle_, kHistorySize); 278 void* tmp_handle = WebRtc_CreateDelayEstimator(farend_handle_, kHistorySize);
279 EXPECT_EQ(0, WebRtc_InitDelayEstimator(tmp_handle)); 279 EXPECT_EQ(0, WebRtc_InitDelayEstimator(tmp_handle));
280 EXPECT_EQ(kDifferentHistorySize, 280 EXPECT_EQ(kDifferentHistorySize,
281 WebRtc_set_history_size(tmp_handle, kDifferentHistorySize)); 281 WebRtc_set_history_size(tmp_handle, kDifferentHistorySize));
282 EXPECT_EQ(kDifferentHistorySize, WebRtc_history_size(tmp_handle)); 282 EXPECT_EQ(kDifferentHistorySize, WebRtc_history_size(tmp_handle));
283 EXPECT_EQ(kHistorySize, WebRtc_set_history_size(handle_, kHistorySize)); 283 EXPECT_EQ(kHistorySize, WebRtc_set_history_size(handle_, kHistorySize));
284 EXPECT_EQ(-1, WebRtc_history_size(tmp_handle)); 284 EXPECT_EQ(-1, WebRtc_history_size(tmp_handle));
285 285
286 // WebRtc_set_lookahead() should return -1 if we try a value outside the 286 // WebRtc_set_lookahead() should return -1 if we try a value outside the
287 /// buffer. 287 /// buffer.
288 EXPECT_EQ(-1, WebRtc_set_lookahead(handle_, kLookahead + 1)); 288 EXPECT_EQ(-1, WebRtc_set_lookahead(handle_, kLookahead + 1));
289 EXPECT_EQ(-1, WebRtc_set_lookahead(handle_, -1)); 289 EXPECT_EQ(-1, WebRtc_set_lookahead(handle_, -1));
290 290
291 // WebRtc_set_allowed_offset() should return -1 if we have: 291 // WebRtc_set_allowed_offset() should return -1 if we have:
292 // 1) NULL pointer as |handle|. 292 // 1) null pointer as |handle|.
293 // 2) |allowed_offset| < 0. 293 // 2) |allowed_offset| < 0.
294 EXPECT_EQ(-1, WebRtc_set_allowed_offset(NULL, 0)); 294 EXPECT_EQ(-1, WebRtc_set_allowed_offset(nullptr, 0));
295 EXPECT_EQ(-1, WebRtc_set_allowed_offset(handle_, -1)); 295 EXPECT_EQ(-1, WebRtc_set_allowed_offset(handle_, -1));
296 296
297 EXPECT_EQ(-1, WebRtc_get_allowed_offset(NULL)); 297 EXPECT_EQ(-1, WebRtc_get_allowed_offset(nullptr));
298 298
299 // WebRtc_enable_robust_validation() should return -1 if we have: 299 // WebRtc_enable_robust_validation() should return -1 if we have:
300 // 1) NULL pointer as |handle|. 300 // 1) null pointer as |handle|.
301 // 2) Incorrect |enable| value (not 0 or 1). 301 // 2) Incorrect |enable| value (not 0 or 1).
302 EXPECT_EQ(-1, WebRtc_enable_robust_validation(NULL, kEnable[0])); 302 EXPECT_EQ(-1, WebRtc_enable_robust_validation(nullptr, kEnable[0]));
303 EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, -1)); 303 EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, -1));
304 EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, 2)); 304 EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, 2));
305 305
306 // WebRtc_is_robust_validation_enabled() should return -1 if we have NULL 306 // WebRtc_is_robust_validation_enabled() should return -1 if we have null
307 // pointer as |handle|. 307 // pointer as |handle|.
308 EXPECT_EQ(-1, WebRtc_is_robust_validation_enabled(NULL)); 308 EXPECT_EQ(-1, WebRtc_is_robust_validation_enabled(nullptr));
309 309
310 // WebRtc_DelayEstimatorProcessFloat() should return -1 if we have: 310 // WebRtc_DelayEstimatorProcessFloat() should return -1 if we have:
311 // 1) NULL pointer as |handle|. 311 // 1) null pointer as |handle|.
312 // 2) NULL pointer as near-end spectrum. 312 // 2) null pointer as near-end spectrum.
313 // 3) Incorrect spectrum size. 313 // 3) Incorrect spectrum size.
314 // 4) Non matching history sizes if multiple delay estimators using the same 314 // 4) Non matching history sizes if multiple delay estimators using the same
315 // far-end reference. 315 // far-end reference.
316 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(NULL, near_f_, 316 EXPECT_EQ(
317 spectrum_size_)); 317 -1, WebRtc_DelayEstimatorProcessFloat(nullptr, near_f_, spectrum_size_));
318 // Use |handle_| which is properly created at SetUp(). 318 // Use |handle_| which is properly created at SetUp().
319 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, NULL, 319 EXPECT_EQ(
320 spectrum_size_)); 320 -1, WebRtc_DelayEstimatorProcessFloat(handle_, nullptr, spectrum_size_));
321 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, 321 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_,
322 spectrum_size_ + 1)); 322 spectrum_size_ + 1));
323 // |tmp_handle| is already in a non-matching state. 323 // |tmp_handle| is already in a non-matching state.
324 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(tmp_handle, 324 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(tmp_handle,
325 near_f_, 325 near_f_,
326 spectrum_size_)); 326 spectrum_size_));
327 327
328 // WebRtc_DelayEstimatorProcessFix() should return -1 if we have: 328 // WebRtc_DelayEstimatorProcessFix() should return -1 if we have:
329 // 1) NULL pointer as |handle|. 329 // 1) null pointer as |handle|.
330 // 2) NULL pointer as near-end spectrum. 330 // 2) null pointer as near-end spectrum.
331 // 3) Incorrect spectrum size. 331 // 3) Incorrect spectrum size.
332 // 4) Too high precision in near-end spectrum (Q-domain > 15). 332 // 4) Too high precision in near-end spectrum (Q-domain > 15).
333 // 5) Non matching history sizes if multiple delay estimators using the same 333 // 5) Non matching history sizes if multiple delay estimators using the same
334 // far-end reference. 334 // far-end reference.
335 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(NULL, near_u16_, spectrum_size_, 335 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(nullptr, near_u16_,
336 0)); 336 spectrum_size_, 0));
337 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, NULL, spectrum_size_, 337 EXPECT_EQ(
338 0)); 338 -1, WebRtc_DelayEstimatorProcessFix(handle_, nullptr, spectrum_size_, 0));
339 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, 339 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_,
340 spectrum_size_ + 1, 0)); 340 spectrum_size_ + 1, 0));
341 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, 341 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_,
342 spectrum_size_, 16)); 342 spectrum_size_, 16));
343 // |tmp_handle| is already in a non-matching state. 343 // |tmp_handle| is already in a non-matching state.
344 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(tmp_handle, 344 EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(tmp_handle,
345 near_u16_, 345 near_u16_,
346 spectrum_size_, 346 spectrum_size_,
347 0)); 347 0));
348 WebRtc_FreeDelayEstimator(tmp_handle); 348 WebRtc_FreeDelayEstimator(tmp_handle);
349 349
350 // WebRtc_last_delay() should return -1 if we have a NULL pointer as |handle|. 350 // WebRtc_last_delay() should return -1 if we have a null pointer as |handle|.
351 EXPECT_EQ(-1, WebRtc_last_delay(NULL)); 351 EXPECT_EQ(-1, WebRtc_last_delay(nullptr));
352 352
353 // Free any local memory if needed. 353 // Free any local memory if needed.
354 WebRtc_FreeDelayEstimator(handle); 354 WebRtc_FreeDelayEstimator(handle);
355 } 355 }
356 356
357 TEST_F(DelayEstimatorTest, VerifyAllowedOffset) { 357 TEST_F(DelayEstimatorTest, VerifyAllowedOffset) {
358 // Is set to zero by default. 358 // Is set to zero by default.
359 EXPECT_EQ(0, WebRtc_get_allowed_offset(handle_)); 359 EXPECT_EQ(0, WebRtc_get_allowed_offset(handle_));
360 for (int i = 1; i >= 0; i--) { 360 for (int i = 1; i >= 0; i--) {
361 EXPECT_EQ(0, WebRtc_set_allowed_offset(handle_, i)); 361 EXPECT_EQ(0, WebRtc_set_allowed_offset(handle_, i));
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 468 }
469 469
470 TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfBinaryEstimatorFarend) { 470 TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfBinaryEstimatorFarend) {
471 // In this test we verify correct output on invalid API calls to the Binary 471 // In this test we verify correct output on invalid API calls to the Binary
472 // Delay Estimator (far-end part). 472 // Delay Estimator (far-end part).
473 473
474 BinaryDelayEstimatorFarend* binary = binary_farend_; 474 BinaryDelayEstimatorFarend* binary = binary_farend_;
475 // WebRtc_CreateBinaryDelayEstimatorFarend() should return -1 if the input 475 // WebRtc_CreateBinaryDelayEstimatorFarend() should return -1 if the input
476 // history size is less than 2. This is to make sure the buffer shifting 476 // history size is less than 2. This is to make sure the buffer shifting
477 // applies properly. 477 // applies properly.
478 // Make sure we have a non-NULL value at start, so we can detect NULL after 478 // Make sure we have a non-null value at start, so we can detect null after
479 // create failure. 479 // create failure.
480 binary = WebRtc_CreateBinaryDelayEstimatorFarend(1); 480 binary = WebRtc_CreateBinaryDelayEstimatorFarend(1);
481 EXPECT_TRUE(binary == NULL); 481 EXPECT_TRUE(binary == nullptr);
482 } 482 }
483 483
484 TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfBinaryEstimator) { 484 TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfBinaryEstimator) {
485 // In this test we verify correct output on invalid API calls to the Binary 485 // In this test we verify correct output on invalid API calls to the Binary
486 // Delay Estimator. 486 // Delay Estimator.
487 487
488 BinaryDelayEstimator* binary_handle = binary_; 488 BinaryDelayEstimator* binary_handle = binary_;
489 // WebRtc_CreateBinaryDelayEstimator() should return -1 if we have a NULL 489 // WebRtc_CreateBinaryDelayEstimator() should return -1 if we have a null
490 // pointer as |binary_farend| or invalid input values. Upon failure, the 490 // pointer as |binary_farend| or invalid input values. Upon failure, the
491 // |binary_handle| should be NULL. 491 // |binary_handle| should be null.
492 // Make sure we have a non-NULL value at start, so we can detect NULL after 492 // Make sure we have a non-null value at start, so we can detect null after
493 // create failure. 493 // create failure.
494 binary_handle = WebRtc_CreateBinaryDelayEstimator(NULL, kLookahead); 494 binary_handle = WebRtc_CreateBinaryDelayEstimator(nullptr, kLookahead);
495 EXPECT_TRUE(binary_handle == NULL); 495 EXPECT_TRUE(binary_handle == nullptr);
496 binary_handle = WebRtc_CreateBinaryDelayEstimator(binary_farend_, -1); 496 binary_handle = WebRtc_CreateBinaryDelayEstimator(binary_farend_, -1);
497 EXPECT_TRUE(binary_handle == NULL); 497 EXPECT_TRUE(binary_handle == nullptr);
498 } 498 }
499 499
500 TEST_F(DelayEstimatorTest, MeanEstimatorFix) { 500 TEST_F(DelayEstimatorTest, MeanEstimatorFix) {
501 // In this test we verify that we update the mean value in correct direction 501 // In this test we verify that we update the mean value in correct direction
502 // only. With "direction" we mean increase or decrease. 502 // only. With "direction" we mean increase or decrease.
503 503
504 int32_t mean_value = 4000; 504 int32_t mean_value = 4000;
505 int32_t mean_value_before = mean_value; 505 int32_t mean_value_before = mean_value;
506 int32_t new_mean_value = mean_value * 2; 506 int32_t new_mean_value = mean_value * 2;
507 507
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 // estimator. 572 // estimator.
573 573
574 binary_->allowed_offset = 10; 574 binary_->allowed_offset = 10;
575 RunBinarySpectraTest(0, 0, 0, 0); 575 RunBinarySpectraTest(0, 0, 0, 0);
576 binary_->allowed_offset = 0; // Reset reference. 576 binary_->allowed_offset = 0; // Reset reference.
577 } 577 }
578 578
579 TEST_F(DelayEstimatorTest, VerifyLookaheadAtCreate) { 579 TEST_F(DelayEstimatorTest, VerifyLookaheadAtCreate) {
580 void* farend_handle = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize, 580 void* farend_handle = WebRtc_CreateDelayEstimatorFarend(kSpectrumSize,
581 kMaxDelay); 581 kMaxDelay);
582 ASSERT_TRUE(farend_handle != NULL); 582 ASSERT_TRUE(farend_handle != nullptr);
583 void* handle = WebRtc_CreateDelayEstimator(farend_handle, kLookahead); 583 void* handle = WebRtc_CreateDelayEstimator(farend_handle, kLookahead);
584 ASSERT_TRUE(handle != NULL); 584 ASSERT_TRUE(handle != nullptr);
585 EXPECT_EQ(kLookahead, WebRtc_lookahead(handle)); 585 EXPECT_EQ(kLookahead, WebRtc_lookahead(handle));
586 WebRtc_FreeDelayEstimator(handle); 586 WebRtc_FreeDelayEstimator(handle);
587 WebRtc_FreeDelayEstimatorFarend(farend_handle); 587 WebRtc_FreeDelayEstimatorFarend(farend_handle);
588 } 588 }
589 589
590 TEST_F(DelayEstimatorTest, VerifyLookaheadIsSetAndKeptAfterInit) { 590 TEST_F(DelayEstimatorTest, VerifyLookaheadIsSetAndKeptAfterInit) {
591 EXPECT_EQ(kLookahead, WebRtc_lookahead(handle_)); 591 EXPECT_EQ(kLookahead, WebRtc_lookahead(handle_));
592 EXPECT_EQ(kDifferentLookahead, 592 EXPECT_EQ(kDifferentLookahead,
593 WebRtc_set_lookahead(handle_, kDifferentLookahead)); 593 WebRtc_set_lookahead(handle_, kDifferentLookahead));
594 EXPECT_EQ(kDifferentLookahead, WebRtc_lookahead(handle_)); 594 EXPECT_EQ(kDifferentLookahead, WebRtc_lookahead(handle_));
(...skipping 14 matching lines...) Expand all
609 EXPECT_EQ(kDifferentHistorySize, WebRtc_history_size(handle_)); 609 EXPECT_EQ(kDifferentHistorySize, WebRtc_history_size(handle_));
610 EXPECT_EQ(0, WebRtc_InitDelayEstimator(handle_)); 610 EXPECT_EQ(0, WebRtc_InitDelayEstimator(handle_));
611 EXPECT_EQ(kDifferentHistorySize, WebRtc_history_size(handle_)); 611 EXPECT_EQ(kDifferentHistorySize, WebRtc_history_size(handle_));
612 EXPECT_EQ(0, WebRtc_InitDelayEstimatorFarend(farend_handle_)); 612 EXPECT_EQ(0, WebRtc_InitDelayEstimatorFarend(farend_handle_));
613 EXPECT_EQ(kDifferentHistorySize, WebRtc_history_size(handle_)); 613 EXPECT_EQ(kDifferentHistorySize, WebRtc_history_size(handle_));
614 } 614 }
615 615
616 // TODO(bjornv): Add tests for SoftReset...(...). 616 // TODO(bjornv): Add tests for SoftReset...(...).
617 617
618 } // namespace 618 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698