summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_parameters_unittest.cc
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 23:21:03 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 23:21:03 +0000
commit08bff2cc79f4fd0b5f78f8b07babf2c6bbb4a9c0 (patch)
tree59ade6118ab9e3a9ff70eedbcf468cc2b2934fb6 /media/audio/audio_parameters_unittest.cc
parentb481edbd6eb1803a01704f0c7d3aeeda7f1ec962 (diff)
downloadchromium_src-08bff2cc79f4fd0b5f78f8b07babf2c6bbb4a9c0.zip
chromium_src-08bff2cc79f4fd0b5f78f8b07babf2c6bbb4a9c0.tar.gz
chromium_src-08bff2cc79f4fd0b5f78f8b07babf2c6bbb4a9c0.tar.bz2
Replace AudioDecoder::media_format() with AudioDecoderConfig.
Also includes some cleanup for AudioParameter users including a new helper method GetBytesPerSecond(). BUG=28206 TEST=media_unittests, test_shell_tests, etc... Review URL: http://codereview.chromium.org/6903007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_parameters_unittest.cc')
-rw-r--r--media/audio/audio_parameters_unittest.cc50
1 files changed, 49 insertions, 1 deletions
diff --git a/media/audio/audio_parameters_unittest.cc b/media/audio/audio_parameters_unittest.cc
index 61b8ad0..9f5bb2b 100644
--- a/media/audio/audio_parameters_unittest.cc
+++ b/media/audio/audio_parameters_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,6 +7,41 @@
#include "media/audio/audio_parameters.h"
#include "testing/gtest/include/gtest/gtest.h"
+using media::AudioDecoderConfig;
+
+TEST(AudioParameters, Constructor_Default) {
+ AudioParameters::Format expected_format = AudioParameters::AUDIO_PCM_LINEAR;
+ int expected_bits = 0;
+ int expected_channels = 0;
+ int expected_rate = 0;
+ int expected_samples = 0;
+
+ AudioParameters params;
+
+ EXPECT_EQ(expected_format, params.format);
+ EXPECT_EQ(expected_bits, params.bits_per_sample);
+ EXPECT_EQ(expected_channels, params.channels);
+ EXPECT_EQ(expected_rate, params.sample_rate);
+ EXPECT_EQ(expected_samples, params.samples_per_packet);
+}
+
+TEST(AudioParameters, Constructor_AudioDecoderConfig) {
+ AudioParameters::Format expected_format = AudioParameters::AUDIO_PCM_LINEAR;
+ int expected_bits = 8;
+ int expected_channels = 2;
+ int expected_rate = 44000;
+ int expected_samples = 0;
+
+ AudioDecoderConfig config(expected_bits, expected_channels, expected_rate);
+ AudioParameters params(config);
+
+ EXPECT_EQ(expected_format, params.format);
+ EXPECT_EQ(expected_bits, params.bits_per_sample);
+ EXPECT_EQ(expected_channels, params.channels);
+ EXPECT_EQ(expected_rate, params.sample_rate);
+ EXPECT_EQ(expected_samples, params.samples_per_packet);
+}
+
TEST(AudioParameters, GetPacketSize) {
EXPECT_EQ(100, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
1, 1000, 8, 100).GetPacketSize());
@@ -20,6 +55,19 @@ TEST(AudioParameters, GetPacketSize) {
2, 1000, 16, 200).GetPacketSize());
}
+TEST(AudioParameters, GetBytesPerSecond) {
+ EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
+ 0, 0, 0, 0).GetBytesPerSecond());
+ EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
+ 2, 0, 0, 0).GetBytesPerSecond());
+ EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
+ 0, 100, 0, 0).GetBytesPerSecond());
+ EXPECT_EQ(0, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
+ 0, 0, 8, 0).GetBytesPerSecond());
+ EXPECT_EQ(200, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
+ 2, 100, 8, 0).GetBytesPerSecond());
+}
+
TEST(AudioParameters, Compare) {
AudioParameters values[] = {
AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 1, 1000, 8, 100),