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

Side by Side Diff: media/audio/audio_parameters_unittest.cc

Issue 1275783003: Add a virtual beamforming audio device on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mcasas comments Created 5 years, 3 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "media/audio/audio_parameters.h" 7 #include "media/audio/audio_parameters.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace media { 10 namespace media {
11 11
12 TEST(AudioParameters, Constructor_Default) { 12 TEST(AudioParameters, Constructor_Default) {
13 AudioParameters::Format expected_format = AudioParameters::AUDIO_PCM_LINEAR; 13 AudioParameters::Format expected_format = AudioParameters::AUDIO_PCM_LINEAR;
14 int expected_bits = 0; 14 int expected_bits = 0;
15 int expected_channels = 0; 15 int expected_channels = 0;
16 ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_NONE; 16 ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_NONE;
17 int expected_rate = 0; 17 int expected_rate = 0;
18 int expected_samples = 0; 18 int expected_samples = 0;
19 std::vector<Point> expected_mic_positions;
20 AudioParameters::PlatformEffectsMask expected_effects =
21 AudioParameters::NO_EFFECTS;
19 22
20 AudioParameters params; 23 AudioParameters params;
21 24
22 EXPECT_EQ(expected_format, params.format()); 25 EXPECT_EQ(expected_format, params.format());
23 EXPECT_EQ(expected_bits, params.bits_per_sample()); 26 EXPECT_EQ(expected_bits, params.bits_per_sample());
24 EXPECT_EQ(expected_channels, params.channels()); 27 EXPECT_EQ(expected_channels, params.channels());
25 EXPECT_EQ(expected_channel_layout, params.channel_layout()); 28 EXPECT_EQ(expected_channel_layout, params.channel_layout());
26 EXPECT_EQ(expected_rate, params.sample_rate()); 29 EXPECT_EQ(expected_rate, params.sample_rate());
27 EXPECT_EQ(expected_samples, params.frames_per_buffer()); 30 EXPECT_EQ(expected_samples, params.frames_per_buffer());
31 EXPECT_EQ(expected_mic_positions, params.mic_positions());
32 EXPECT_EQ(expected_effects, params.effects());
28 } 33 }
29 34
30 TEST(AudioParameters, Constructor_ParameterValues) { 35 TEST(AudioParameters, Constructor_ParameterValues) {
31 AudioParameters::Format expected_format = 36 AudioParameters::Format expected_format =
32 AudioParameters::AUDIO_PCM_LOW_LATENCY; 37 AudioParameters::AUDIO_PCM_LOW_LATENCY;
33 int expected_bits = 16; 38 int expected_bits = 16;
34 int expected_channels = 6; 39 int expected_channels = 6;
35 ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_5_1; 40 ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_5_1;
36 int expected_rate = 44100; 41 int expected_rate = 44100;
37 int expected_samples = 880; 42 int expected_samples = 880;
43 std::vector<Point> expected_mic_positions(2, Point(0, 0, 0));
44 AudioParameters::PlatformEffectsMask expected_effects =
45 AudioParameters::ECHO_CANCELLER;
38 46
39 AudioParameters params(expected_format, expected_channel_layout, 47 AudioParameters params(expected_format, expected_channel_layout,
40 expected_rate, expected_bits, expected_samples); 48 expected_rate, expected_bits, expected_samples,
49 expected_mic_positions, expected_effects);
41 50
42 EXPECT_EQ(expected_format, params.format()); 51 EXPECT_EQ(expected_format, params.format());
43 EXPECT_EQ(expected_bits, params.bits_per_sample()); 52 EXPECT_EQ(expected_bits, params.bits_per_sample());
44 EXPECT_EQ(expected_channels, params.channels()); 53 EXPECT_EQ(expected_channels, params.channels());
45 EXPECT_EQ(expected_channel_layout, params.channel_layout()); 54 EXPECT_EQ(expected_channel_layout, params.channel_layout());
46 EXPECT_EQ(expected_rate, params.sample_rate()); 55 EXPECT_EQ(expected_rate, params.sample_rate());
47 EXPECT_EQ(expected_samples, params.frames_per_buffer()); 56 EXPECT_EQ(expected_samples, params.frames_per_buffer());
57 EXPECT_EQ(expected_mic_positions, params.mic_positions());
58 EXPECT_EQ(expected_effects, params.effects());
48 } 59 }
49 60
50 TEST(AudioParameters, GetBytesPerBuffer) { 61 TEST(AudioParameters, GetBytesPerBuffer) {
51 EXPECT_EQ(100, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 62 EXPECT_EQ(100, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
52 CHANNEL_LAYOUT_MONO, 1000, 8, 100) 63 CHANNEL_LAYOUT_MONO, 1000, 8, 100)
53 .GetBytesPerBuffer()); 64 .GetBytesPerBuffer());
54 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 65 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
55 CHANNEL_LAYOUT_MONO, 1000, 16, 100) 66 CHANNEL_LAYOUT_MONO, 1000, 16, 100)
56 .GetBytesPerBuffer()); 67 .GetBytesPerBuffer());
57 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 68 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // Verify that a value is never less than itself. 212 // Verify that a value is never less than itself.
202 EXPECT_FALSE(values[i] < values[i]); 213 EXPECT_FALSE(values[i] < values[i]);
203 } 214 }
204 } 215 }
205 216
206 TEST(AudioParameters, Constructor_ValidChannelCounts) { 217 TEST(AudioParameters, Constructor_ValidChannelCounts) {
207 int expected_channels = 8; 218 int expected_channels = 8;
208 ChannelLayout expected_layout = CHANNEL_LAYOUT_5_1; 219 ChannelLayout expected_layout = CHANNEL_LAYOUT_5_1;
209 220
210 AudioParameters params(AudioParameters::AUDIO_PCM_LOW_LATENCY, 221 AudioParameters params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
211 expected_layout, expected_channels, 44100, 16, 880, 222 expected_channels, expected_layout, 44100, 16, 880);
212 AudioParameters::NO_EFFECTS);
213 223
214 EXPECT_EQ(expected_channels, params.channels()); 224 EXPECT_EQ(expected_channels, params.channels());
215 EXPECT_EQ(expected_layout, params.channel_layout()); 225 EXPECT_EQ(expected_layout, params.channel_layout());
216 EXPECT_FALSE(params.IsValid()); 226 EXPECT_FALSE(params.IsValid());
217 227
218 expected_layout = CHANNEL_LAYOUT_DISCRETE; 228 expected_layout = CHANNEL_LAYOUT_DISCRETE;
219 params.Reset(AudioParameters::AUDIO_PCM_LOW_LATENCY, expected_layout, 229 params.Reset(AudioParameters::AUDIO_PCM_LOW_LATENCY, expected_layout,
220 expected_channels, 44100, 16, 880); 230 expected_channels, 44100, 16, 880);
221 231
222 EXPECT_EQ(expected_channels, params.channels()); 232 EXPECT_EQ(expected_channels, params.channels());
223 EXPECT_EQ(expected_layout, params.channel_layout()); 233 EXPECT_EQ(expected_layout, params.channel_layout());
224 EXPECT_TRUE(params.IsValid()); 234 EXPECT_TRUE(params.IsValid());
225 } 235 }
226 236
227 } // namespace media 237 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698