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

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

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright years Created 8 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/audio/audio_parameters.cc ('k') | media/audio/audio_util.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) 2011 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/string_number_conversions.h" 6 #include "base/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 TEST(AudioParameters, Constructor_Default) { 10 TEST(AudioParameters, Constructor_Default) {
11 AudioParameters::Format expected_format = AudioParameters::AUDIO_PCM_LINEAR; 11 AudioParameters::Format expected_format = AudioParameters::AUDIO_PCM_LINEAR;
12 int expected_bits = 0; 12 int expected_bits = 0;
13 int expected_channels = 0; 13 int expected_channels = 0;
14 ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_NONE; 14 ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_NONE;
15 int expected_rate = 0; 15 int expected_rate = 0;
16 int expected_samples = 0; 16 int expected_samples = 0;
17 17
18 AudioParameters params; 18 AudioParameters params;
19 19
20 EXPECT_EQ(expected_format, params.format); 20 EXPECT_EQ(expected_format, params.format());
21 EXPECT_EQ(expected_bits, params.bits_per_sample); 21 EXPECT_EQ(expected_bits, params.bits_per_sample());
22 EXPECT_EQ(expected_channels, params.channels); 22 EXPECT_EQ(expected_channels, params.channels());
23 EXPECT_EQ(expected_channel_layout, params.channel_layout); 23 EXPECT_EQ(expected_channel_layout, params.channel_layout());
24 EXPECT_EQ(expected_rate, params.sample_rate); 24 EXPECT_EQ(expected_rate, params.sample_rate());
25 EXPECT_EQ(expected_samples, params.samples_per_packet); 25 EXPECT_EQ(expected_samples, params.frames_per_buffer());
26 } 26 }
27 27
28 TEST(AudioParameters, Constructor_ParameterValues) { 28 TEST(AudioParameters, Constructor_ParameterValues) {
29 AudioParameters::Format expected_format = 29 AudioParameters::Format expected_format =
30 AudioParameters::AUDIO_PCM_LOW_LATENCY; 30 AudioParameters::AUDIO_PCM_LOW_LATENCY;
31 int expected_bits = 16; 31 int expected_bits = 16;
32 int expected_channels = 6; 32 int expected_channels = 6;
33 ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_5POINT1; 33 ChannelLayout expected_channel_layout = CHANNEL_LAYOUT_5_1;
34 int expected_rate = 44100; 34 int expected_rate = 44100;
35 int expected_samples = 880; 35 int expected_samples = 880;
36 36
37 AudioParameters params(expected_format, expected_channel_layout, 37 AudioParameters params(expected_format, expected_channel_layout,
38 expected_rate, expected_bits, expected_samples); 38 expected_rate, expected_bits, expected_samples);
39 39
40 EXPECT_EQ(expected_format, params.format); 40 EXPECT_EQ(expected_format, params.format());
41 EXPECT_EQ(expected_bits, params.bits_per_sample); 41 EXPECT_EQ(expected_bits, params.bits_per_sample());
42 EXPECT_EQ(expected_channels, params.channels); 42 EXPECT_EQ(expected_channels, params.channels());
43 EXPECT_EQ(expected_channel_layout, params.channel_layout); 43 EXPECT_EQ(expected_channel_layout, params.channel_layout());
44 EXPECT_EQ(expected_rate, params.sample_rate); 44 EXPECT_EQ(expected_rate, params.sample_rate());
45 EXPECT_EQ(expected_samples, params.samples_per_packet); 45 EXPECT_EQ(expected_samples, params.frames_per_buffer());
46 } 46 }
47 47
48 TEST(AudioParameters, GetPacketSize) { 48 TEST(AudioParameters, GetBytesPerBuffer) {
49 EXPECT_EQ(100, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 49 EXPECT_EQ(100, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
50 CHANNEL_LAYOUT_MONO, 1000, 8, 100) 50 CHANNEL_LAYOUT_MONO, 1000, 8, 100)
51 .GetPacketSize()); 51 .GetBytesPerBuffer());
52 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 52 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
53 CHANNEL_LAYOUT_MONO, 1000, 16, 100) 53 CHANNEL_LAYOUT_MONO, 1000, 16, 100)
54 .GetPacketSize()); 54 .GetBytesPerBuffer());
55 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 55 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
56 CHANNEL_LAYOUT_STEREO, 1000, 8, 100) 56 CHANNEL_LAYOUT_STEREO, 1000, 8, 100)
57 .GetPacketSize()); 57 .GetBytesPerBuffer());
58 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 58 EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
59 CHANNEL_LAYOUT_MONO, 1000, 8, 200) 59 CHANNEL_LAYOUT_MONO, 1000, 8, 200)
60 .GetPacketSize()); 60 .GetBytesPerBuffer());
61 EXPECT_EQ(800, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 61 EXPECT_EQ(800, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
62 CHANNEL_LAYOUT_STEREO, 1000, 16, 200) 62 CHANNEL_LAYOUT_STEREO, 1000, 16, 200)
63 .GetPacketSize()); 63 .GetBytesPerBuffer());
64 } 64 }
65 65
66 TEST(AudioParameters, GetBytesPerSecond) { 66 TEST(AudioParameters, GetBytesPerSecond) {
67 EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 67 EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
68 CHANNEL_LAYOUT_NONE, 0, 0, 0) 68 CHANNEL_LAYOUT_NONE, 0, 0, 0)
69 .GetBytesPerSecond()); 69 .GetBytesPerSecond());
70 EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 70 EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
71 CHANNEL_LAYOUT_STEREO, 0, 0, 0) 71 CHANNEL_LAYOUT_STEREO, 0, 0, 0)
72 .GetBytesPerSecond()); 72 .GetBytesPerSecond());
73 EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 73 EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 for (size_t i = 0; i < arraysize(values); ++i) { 156 for (size_t i = 0; i < arraysize(values); ++i) {
157 for (size_t j = 0; j < arraysize(values); ++j) { 157 for (size_t j = 0; j < arraysize(values); ++j) {
158 SCOPED_TRACE("i=" + base::IntToString(i) + " j=" + base::IntToString(j)); 158 SCOPED_TRACE("i=" + base::IntToString(i) + " j=" + base::IntToString(j));
159 EXPECT_EQ(i < j, target(values[i], values[j])); 159 EXPECT_EQ(i < j, target(values[i], values[j]));
160 } 160 }
161 161
162 // Verify that a value is never less than itself. 162 // Verify that a value is never less than itself.
163 EXPECT_FALSE(target(values[i], values[i])); 163 EXPECT_FALSE(target(values[i], values[i]));
164 } 164 }
165 } 165 }
OLDNEW
« no previous file with comments | « media/audio/audio_parameters.cc ('k') | media/audio/audio_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698