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

Unified Diff: components/copresence/mediums/audio/audio_player_unittest.cc

Issue 886593005: Enhance audio player tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/copresence/mediums/audio/audio_player_unittest.cc
diff --git a/components/copresence/mediums/audio/audio_player_unittest.cc b/components/copresence/mediums/audio/audio_player_unittest.cc
index 6e5a66e4575dc36d3a5ba0d293e4cd21dc5f28b4..3f264e4603b957cc7439da223402e4175333c8fd 100644
--- a/components/copresence/mediums/audio/audio_player_unittest.cc
+++ b/components/copresence/mediums/audio/audio_player_unittest.cc
@@ -99,13 +99,19 @@ class AudioPlayerTest : public testing::Test,
void PlayAndVerifySamples(
const scoped_refptr<media::AudioBusRefCounted>& samples) {
+ DCHECK_LT(samples->frames(), kMaxFrameCount);
+
buffer_ = media::AudioBus::Create(1, kMaxFrameCount);
+ buffer_index_ = 0;
player_->Play(samples);
player_->FlushAudioLoopForTesting();
+ player_->Stop();
int differences = 0;
- for (int i = 0; i < samples->frames(); ++i)
- differences += (buffer_->channel(0)[i] != samples->channel(0)[i]);
+ for (int i = 0; i < kMaxFrameCount; ++i) {
+ differences += (buffer_->channel(0)[i] !=
+ samples->channel(0)[i % samples->frames()]);
+ }
ASSERT_EQ(0, differences);
buffer_.reset();
@@ -125,7 +131,7 @@ class AudioPlayerTest : public testing::Test,
}
static const int kDefaultFrameCount = 1024;
- static const int kMaxFrameCount = 1024 * 10;
+ static const int kMaxFrameCount = 1024 * 100;
scoped_ptr<media::AudioBus> buffer_;
int buffer_index_;
@@ -180,11 +186,25 @@ TEST_F(AudioPlayerTest, OutOfOrderPlayAndStopMultiple) {
}
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();
PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples));
+ PlayAndVerifySamples(
+ CreateRandomAudioRefCounted(0x7331, 1, kNumSamples - 3123));
+
+ PlayAndVerifySamples(CreateRandomAudioRefCounted(0xf00d, 1, kNumSamples * 2));
+
DeletePlayer();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698