Commit 0d96f15b authored by rkc's avatar rkc Committed by Commit bot

Enhance audio player tests.

Enhance the audio player tests to cover multiple loops over the data and
odd sizes of data.

R=ckehoe@chromium.org
BUG=None.

Review URL: https://codereview.chromium.org/886593005

Cr-Commit-Position: refs/heads/master@{#313752}
parent f3b7c52a
...@@ -99,13 +99,19 @@ class AudioPlayerTest : public testing::Test, ...@@ -99,13 +99,19 @@ class AudioPlayerTest : public testing::Test,
void PlayAndVerifySamples( void PlayAndVerifySamples(
const scoped_refptr<media::AudioBusRefCounted>& samples) { const scoped_refptr<media::AudioBusRefCounted>& samples) {
DCHECK_LT(samples->frames(), kMaxFrameCount);
buffer_ = media::AudioBus::Create(1, kMaxFrameCount); buffer_ = media::AudioBus::Create(1, kMaxFrameCount);
buffer_index_ = 0;
player_->Play(samples); player_->Play(samples);
player_->FlushAudioLoopForTesting(); player_->FlushAudioLoopForTesting();
player_->Stop();
int differences = 0; int differences = 0;
for (int i = 0; i < samples->frames(); ++i) for (int i = 0; i < kMaxFrameCount; ++i) {
differences += (buffer_->channel(0)[i] != samples->channel(0)[i]); differences += (buffer_->channel(0)[i] !=
samples->channel(0)[i % samples->frames()]);
}
ASSERT_EQ(0, differences); ASSERT_EQ(0, differences);
buffer_.reset(); buffer_.reset();
...@@ -125,7 +131,7 @@ class AudioPlayerTest : public testing::Test, ...@@ -125,7 +131,7 @@ class AudioPlayerTest : public testing::Test,
} }
static const int kDefaultFrameCount = 1024; static const int kDefaultFrameCount = 1024;
static const int kMaxFrameCount = 1024 * 10; static const int kMaxFrameCount = 1024 * 100;
scoped_ptr<media::AudioBus> buffer_; scoped_ptr<media::AudioBus> buffer_;
int buffer_index_; int buffer_index_;
...@@ -180,11 +186,25 @@ TEST_F(AudioPlayerTest, OutOfOrderPlayAndStopMultiple) { ...@@ -180,11 +186,25 @@ TEST_F(AudioPlayerTest, OutOfOrderPlayAndStopMultiple) {
} }
TEST_F(AudioPlayerTest, PlayingEndToEnd) { TEST_F(AudioPlayerTest, PlayingEndToEnd) {
const int kNumSamples = kDefaultFrameCount * 10; const int kNumSamples = kDefaultFrameCount * 7 + 321;
CreatePlayer();
PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples));
DeletePlayer();
}
TEST_F(AudioPlayerTest, PlayingEndToEndRepeated) {
const int kNumSamples = kDefaultFrameCount * 7 + 537;
CreatePlayer(); CreatePlayer();
PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples)); PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples));
PlayAndVerifySamples(
CreateRandomAudioRefCounted(0x7331, 1, kNumSamples - 3123));
PlayAndVerifySamples(CreateRandomAudioRefCounted(0xf00d, 1, kNumSamples * 2));
DeletePlayer(); DeletePlayer();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment