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

Side by Side Diff: media/base/audio_hardware_config_unittest.cc

Issue 12662038: Revert 187936 "Pass more detailed audio hardware configuration i..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1440/src/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « media/base/audio_hardware_config.cc ('k') | media/base/channel_layout.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "media/base/audio_hardware_config.h" 5 #include "media/base/audio_hardware_config.h"
6 #include "media/audio/audio_parameters.h"
7 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
8 7
9 namespace media { 8 namespace media {
10 9
11 static const int kOutputBufferSize = 2048; 10 static const int kOutputBufferSize = 2048;
12 static const int kOutputSampleRate = 48000; 11 static const int kOutputSampleRate = 48000;
13 static const ChannelLayout kOutputChannelLayout = CHANNEL_LAYOUT_STEREO;
14 static const int kInputSampleRate = 44100; 12 static const int kInputSampleRate = 44100;
15 static const ChannelLayout kInputChannelLayout = CHANNEL_LAYOUT_STEREO; 13 static const ChannelLayout kInputChannelLayout = CHANNEL_LAYOUT_STEREO;
16 14
17 TEST(AudioHardwareConfig, Getters) { 15 TEST(AudioHardwareConfig, Getters) {
18 AudioParameters input_params( 16 AudioHardwareConfig fake_config(
19 AudioParameters::AUDIO_PCM_LOW_LATENCY, 17 kOutputBufferSize, kOutputSampleRate, kInputSampleRate,
20 kInputChannelLayout, 18 kInputChannelLayout);
21 kInputSampleRate,
22 16,
23 kOutputBufferSize);
24
25 AudioParameters output_params(
26 AudioParameters::AUDIO_PCM_LOW_LATENCY,
27 kOutputChannelLayout,
28 kOutputSampleRate,
29 16,
30 kOutputBufferSize);
31
32 AudioHardwareConfig fake_config(input_params, output_params);
33 19
34 EXPECT_EQ(kOutputBufferSize, fake_config.GetOutputBufferSize()); 20 EXPECT_EQ(kOutputBufferSize, fake_config.GetOutputBufferSize());
35 EXPECT_EQ(kOutputSampleRate, fake_config.GetOutputSampleRate()); 21 EXPECT_EQ(kOutputSampleRate, fake_config.GetOutputSampleRate());
36 EXPECT_EQ(kInputSampleRate, fake_config.GetInputSampleRate()); 22 EXPECT_EQ(kInputSampleRate, fake_config.GetInputSampleRate());
37 EXPECT_EQ(kInputChannelLayout, fake_config.GetInputChannelLayout()); 23 EXPECT_EQ(kInputChannelLayout, fake_config.GetInputChannelLayout());
38 } 24 }
39 25
40 TEST(AudioHardwareConfig, Setters) { 26 TEST(AudioHardwareConfig, Setters) {
41 AudioParameters input_params( 27 AudioHardwareConfig fake_config(
42 AudioParameters::AUDIO_PCM_LOW_LATENCY, 28 kOutputBufferSize, kOutputSampleRate, kInputSampleRate,
43 kInputChannelLayout, 29 kInputChannelLayout);
44 kInputSampleRate,
45 16,
46 kOutputBufferSize);
47
48 AudioParameters output_params(
49 AudioParameters::AUDIO_PCM_LOW_LATENCY,
50 kOutputChannelLayout,
51 kOutputSampleRate,
52 16,
53 kOutputBufferSize);
54
55 AudioHardwareConfig fake_config(input_params, output_params);
56 30
57 // Verify output parameters. 31 // Verify output parameters.
58 const int kNewOutputBufferSize = kOutputBufferSize * 2; 32 const int kNewOutputBufferSize = kOutputBufferSize * 2;
59 const int kNewOutputSampleRate = kOutputSampleRate * 2; 33 const int kNewOutputSampleRate = kOutputSampleRate * 2;
60 EXPECT_NE(kNewOutputBufferSize, fake_config.GetOutputBufferSize()); 34 EXPECT_NE(kNewOutputBufferSize, fake_config.GetOutputBufferSize());
61 EXPECT_NE(kNewOutputSampleRate, fake_config.GetOutputSampleRate()); 35 EXPECT_NE(kNewOutputSampleRate, fake_config.GetOutputSampleRate());
62 36 fake_config.UpdateOutputConfig(kNewOutputBufferSize, kNewOutputSampleRate);
63 AudioParameters new_output_params(
64 AudioParameters::AUDIO_PCM_LOW_LATENCY,
65 kOutputChannelLayout,
66 kNewOutputSampleRate,
67 16,
68 kNewOutputBufferSize);
69 fake_config.UpdateOutputConfig(new_output_params);
70 EXPECT_EQ(kNewOutputBufferSize, fake_config.GetOutputBufferSize()); 37 EXPECT_EQ(kNewOutputBufferSize, fake_config.GetOutputBufferSize());
71 EXPECT_EQ(kNewOutputSampleRate, fake_config.GetOutputSampleRate()); 38 EXPECT_EQ(kNewOutputSampleRate, fake_config.GetOutputSampleRate());
72 39
73 // Verify input parameters. 40 // Verify input parameters.
74 const int kNewInputSampleRate = kInputSampleRate * 2; 41 const int kNewInputSampleRate = kInputSampleRate * 2;
75 const ChannelLayout kNewInputChannelLayout = CHANNEL_LAYOUT_MONO; 42 const ChannelLayout kNewInputChannelLayout = CHANNEL_LAYOUT_MONO;
76 EXPECT_NE(kNewInputSampleRate, fake_config.GetInputSampleRate()); 43 EXPECT_NE(kNewInputSampleRate, fake_config.GetInputSampleRate());
77 EXPECT_NE(kNewInputChannelLayout, fake_config.GetInputChannelLayout()); 44 EXPECT_NE(kNewInputChannelLayout, fake_config.GetInputChannelLayout());
78 45 fake_config.UpdateInputConfig(kNewInputSampleRate, kNewInputChannelLayout);
79 AudioParameters new_input_params(
80 AudioParameters::AUDIO_PCM_LOW_LATENCY,
81 kNewInputChannelLayout,
82 kNewInputSampleRate,
83 16,
84 kOutputBufferSize);
85 fake_config.UpdateInputConfig(new_input_params);
86 EXPECT_EQ(kNewInputSampleRate, fake_config.GetInputSampleRate()); 46 EXPECT_EQ(kNewInputSampleRate, fake_config.GetInputSampleRate());
87 EXPECT_EQ(kNewInputChannelLayout, fake_config.GetInputChannelLayout()); 47 EXPECT_EQ(kNewInputChannelLayout, fake_config.GetInputChannelLayout());
88 } 48 }
89 49
90 } // namespace content 50 } // namespace content
OLDNEW
« no previous file with comments | « media/base/audio_hardware_config.cc ('k') | media/base/channel_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698