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

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..88faf8c50480331fb8113bc02fcc58703c90c57d 100644
--- a/components/copresence/mediums/audio/audio_player_unittest.cc
+++ b/components/copresence/mediums/audio/audio_player_unittest.cc
@@ -104,8 +104,10 @@ class AudioPlayerTest : public testing::Test,
player_->FlushAudioLoopForTesting();
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 +127,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,7 +182,18 @@ TEST_F(AudioPlayerTest, OutOfOrderPlayAndStopMultiple) {
}
TEST_F(AudioPlayerTest, PlayingEndToEnd) {
- const int kNumSamples = kDefaultFrameCount * 10;
+ // Ensure that kNumsamples is never over kMaxFrameCount.
Charlie 2015/01/29 17:35:03 This and the additional instance below should be D
rkc 2015/01/29 17:42:42 Added the DCHECK to PlayAndVerifySamples instead,
+ const int kNumSamples = kDefaultFrameCount * 32;
+ CreatePlayer();
+
+ PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples));
+
+ DeletePlayer();
+}
+
+TEST_F(AudioPlayerTest, PlayingEndToEndOddSizes) {
+ // Ensure that kNumsamples is never over kMaxFrameCount.
+ const int kNumSamples = kDefaultFrameCount * 7 + 321;
CreatePlayer();
PlayAndVerifySamples(CreateRandomAudioRefCounted(0x1337, 1, kNumSamples));
« 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