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

Side by Side Diff: webrtc/modules/audio_mixer/test/audio_frame_manipulator_unittest.cc

Issue 2398083005: Changed ramping functionality of the AudioMixer. (Closed)
Patch Set: Added tests for Ramp and changed arg order in Ramp. Created 4 years, 2 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 /*
the sun 2016/10/11 10:57:05 This file should live next to the .h and .cc - no
aleloi 2016/10/11 11:27:26 Done.
hlundin-webrtc 2016/10/11 11:29:58 Acknowledged.
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 <algorithm>
12
13 #include "webrtc/modules/audio_mixer/audio_frame_manipulator.h"
14 #include "webrtc/modules/include/module_common_types.h"
15 #include "webrtc/test/gmock.h"
hlundin-webrtc 2016/10/11 11:29:58 gmock -> gtest You are not using mocks.
aleloi 2016/10/11 12:43:14 Done.
16
17 namespace webrtc {
18 namespace {
19
20 void FillFrameWithConstants(int samples_per_channel,
the sun 2016/10/11 10:57:05 size_t
aleloi 2016/10/11 11:27:26 Done.
21 int number_of_channels,
the sun 2016/10/11 10:57:05 size_t
aleloi 2016/10/11 11:27:26 Done.
22 int value,
the sun 2016/10/11 10:57:06 int16_t
aleloi 2016/10/11 11:27:26 Of course! Thanks for noticing :)
23 AudioFrame* frame) {
24 frame->num_channels_ = number_of_channels;
25 frame->samples_per_channel_ = samples_per_channel;
26 std::fill(frame->data_,
27 frame->data_ + samples_per_channel * number_of_channels, value);
28 }
29 } // namespace
30
31 TEST(AudioFrameManipulator, CompareForwardRampWithExpectedResult) {
the sun 2016/10/11 10:57:06 Add "Stereo" to the name here
aleloi 2016/10/11 11:27:26 Done.
32 constexpr int samples_per_channel = 5;
the sun 2016/10/11 10:57:06 Although there's been debate around the naming of
aleloi 2016/10/11 11:27:26 You are correct, I missed that.
hlundin-webrtc 2016/10/11 11:29:58 Debate it has been. I prefer kConstantName, but I
33 constexpr int number_of_channels = 2;
34
35 // Create a frame with values 5, 5, 5, ... and channels & samples as above.
36 AudioFrame frame;
37 FillFrameWithConstants(samples_per_channel, number_of_channels, 5, &frame);
38
39 Ramp(0, 1, &frame);
the sun 2016/10/11 10:57:05 0.0f, 1.0f
aleloi 2016/10/11 11:27:26 Done.
40
41 const int total_samples = samples_per_channel * number_of_channels;
42 const int16_t expected_result[total_samples] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
43 EXPECT_TRUE(
44 std::equal(frame.data_, frame.data_ + total_samples, expected_result));
45 }
46
47 TEST(AudioFrameManipulator, CompareBackwardRampWithExpectedResultMono) {
48 constexpr int samples_per_channel = 5;
49 constexpr int number_of_channels = 1;
50
51 // Create a frame with values 5, 5, 5, ... and channels & samples as above.
52 AudioFrame frame;
53 FillFrameWithConstants(samples_per_channel, number_of_channels, 5, &frame);
54
55 Ramp(1, 0, &frame);
56
57 const int total_samples = samples_per_channel * number_of_channels;
58 const int16_t expected_result[total_samples] = {5, 4, 3, 2, 1};
59 EXPECT_TRUE(
60 std::equal(frame.data_, frame.data_ + total_samples, expected_result));
61 }
62
63 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698