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

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

Issue 2120273004: Getting rid of AudioHardwareConfig and its synchronous IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased to guidou@ changes, dropped unknown frame id and default param caching Created 4 years, 5 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 // 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
3 // found in the LICENSE file.
4
5 #include "build/build_config.h"
6 #include "media/base/audio_hardware_config.h"
7 #include "media/base/audio_parameters.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace media {
11
12 static const int kOutputBufferSize = 2048;
13 static const int kOutputSampleRate = 48000;
14 static const ChannelLayout kOutputChannelLayout = CHANNEL_LAYOUT_STEREO;
15 static const int kInputSampleRate = 44100;
16 static const ChannelLayout kInputChannelLayout = CHANNEL_LAYOUT_STEREO;
17
18 TEST(AudioHardwareConfig, Getters) {
19 AudioParameters input_params(
20 AudioParameters::AUDIO_PCM_LOW_LATENCY,
21 kInputChannelLayout,
22 kInputSampleRate,
23 16,
24 kOutputBufferSize);
25
26 AudioParameters output_params(
27 AudioParameters::AUDIO_PCM_LOW_LATENCY,
28 kOutputChannelLayout,
29 kOutputSampleRate,
30 16,
31 kOutputBufferSize);
32
33 AudioHardwareConfig fake_config(input_params, output_params);
34
35 EXPECT_EQ(kOutputBufferSize, fake_config.GetOutputBufferSize());
36 EXPECT_EQ(kOutputSampleRate, fake_config.GetOutputSampleRate());
37 EXPECT_EQ(kInputSampleRate, fake_config.GetInputSampleRate());
38 EXPECT_EQ(kInputChannelLayout, fake_config.GetInputChannelLayout());
39 }
40
41 TEST(AudioHardwareConfig, Setters) {
42 AudioParameters input_params(
43 AudioParameters::AUDIO_PCM_LOW_LATENCY,
44 kInputChannelLayout,
45 kInputSampleRate,
46 16,
47 kOutputBufferSize);
48
49 AudioParameters output_params(
50 AudioParameters::AUDIO_PCM_LOW_LATENCY,
51 kOutputChannelLayout,
52 kOutputSampleRate,
53 16,
54 kOutputBufferSize);
55
56 AudioHardwareConfig fake_config(input_params, output_params);
57
58 // Verify output parameters.
59 const int kNewOutputBufferSize = kOutputBufferSize * 2;
60 const int kNewOutputSampleRate = kOutputSampleRate * 2;
61 EXPECT_NE(kNewOutputBufferSize, fake_config.GetOutputBufferSize());
62 EXPECT_NE(kNewOutputSampleRate, fake_config.GetOutputSampleRate());
63
64 AudioParameters new_output_params(
65 AudioParameters::AUDIO_PCM_LOW_LATENCY,
66 kOutputChannelLayout,
67 kNewOutputSampleRate,
68 16,
69 kNewOutputBufferSize);
70 fake_config.UpdateOutputConfig(new_output_params);
71 EXPECT_EQ(kNewOutputBufferSize, fake_config.GetOutputBufferSize());
72 EXPECT_EQ(kNewOutputSampleRate, fake_config.GetOutputSampleRate());
73
74 // Verify input parameters.
75 const int kNewInputSampleRate = kInputSampleRate * 2;
76 const ChannelLayout kNewInputChannelLayout = CHANNEL_LAYOUT_MONO;
77 EXPECT_NE(kNewInputSampleRate, fake_config.GetInputSampleRate());
78 EXPECT_NE(kNewInputChannelLayout, fake_config.GetInputChannelLayout());
79
80 AudioParameters new_input_params(
81 AudioParameters::AUDIO_PCM_LOW_LATENCY,
82 kNewInputChannelLayout,
83 kNewInputSampleRate,
84 16,
85 kOutputBufferSize);
86 fake_config.UpdateInputConfig(new_input_params);
87 EXPECT_EQ(kNewInputSampleRate, fake_config.GetInputSampleRate());
88 EXPECT_EQ(kNewInputChannelLayout, fake_config.GetInputChannelLayout());
89 }
90
91 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698