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

Unified Diff: media/base/audio_block_fifo_unittest.cc

Issue 510073002: Reland 501823002: Used native deinterleaved and float point format for the input streams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: uint8 -> float Created 6 years, 4 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 | « media/base/audio_block_fifo.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_block_fifo_unittest.cc
diff --git a/media/base/audio_block_fifo_unittest.cc b/media/base/audio_block_fifo_unittest.cc
index 8e8b5e071521896dfc2e0ef953ef1f1e02125165..f1ed228f8d0891718291455d8e71a29ff080ba38 100644
--- a/media/base/audio_block_fifo_unittest.cc
+++ b/media/base/audio_block_fifo_unittest.cc
@@ -8,29 +8,48 @@
namespace media {
class AudioBlockFifoTest : public testing::Test {
- public:
+ protected:
AudioBlockFifoTest() {}
virtual ~AudioBlockFifoTest() {}
- void PushAndVerify(AudioBlockFifo* fifo, int frames_to_push,
- int channels, int block_frames, int max_frames) {
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AudioBlockFifoTest);
+};
+
+class AudioBlockFifoFormatTest : public AudioBlockFifoTest,
+ public testing::WithParamInterface<bool> {
+ protected:
+ void PushAndVerify(AudioBlockFifo* fifo,
+ int frames_to_push,
+ int channels,
+ int block_frames,
+ int max_frames) {
const int bytes_per_sample = 2;
const int data_byte_size = bytes_per_sample * channels * frames_to_push;
- scoped_ptr<uint8[]> data(new uint8[data_byte_size]);
- memset(data.get(), 0, data_byte_size);
-
- for (int filled_frames = max_frames - fifo->GetUnfilledFrames();
- filled_frames + frames_to_push <= max_frames;) {
- fifo->Push(data.get(), frames_to_push, bytes_per_sample);
- filled_frames += frames_to_push;
- EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames());
- EXPECT_EQ(static_cast<int>(filled_frames / block_frames),
- fifo->available_blocks());
+ if (GetParam()) {
+ scoped_ptr<media::AudioBus> data =
+ AudioBus::Create(channels, frames_to_push);
+ for (int filled_frames = max_frames - fifo->GetUnfilledFrames();
+ filled_frames + frames_to_push <= max_frames;) {
+ fifo->Push(data.get());
+ filled_frames += frames_to_push;
+ EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames());
+ EXPECT_EQ(static_cast<int>(filled_frames / block_frames),
+ fifo->available_blocks());
+ }
+ } else {
+ scoped_ptr<uint8[]> data(new uint8[data_byte_size]);
+ memset(data.get(), 0, data_byte_size);
+ for (int filled_frames = max_frames - fifo->GetUnfilledFrames();
+ filled_frames + frames_to_push <= max_frames;) {
+ fifo->Push(data.get(), frames_to_push, bytes_per_sample);
+ filled_frames += frames_to_push;
+ EXPECT_EQ(max_frames - filled_frames, fifo->GetUnfilledFrames());
+ EXPECT_EQ(static_cast<int>(filled_frames / block_frames),
+ fifo->available_blocks());
+ }
}
}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AudioBlockFifoTest);
};
// Verify that construction works as intended.
@@ -44,7 +63,7 @@ TEST_F(AudioBlockFifoTest, Construct) {
}
// Pushes audio bus objects to/from a FIFO up to different degrees.
-TEST_F(AudioBlockFifoTest, Push) {
+TEST_P(AudioBlockFifoFormatTest, Push) {
const int channels = 2;
const int frames = 128;
const int blocks = 2;
@@ -65,7 +84,7 @@ TEST_F(AudioBlockFifoTest, Push) {
// Perform a sequence of Push/Consume calls to different degrees, and verify
// things are correct.
-TEST_F(AudioBlockFifoTest, PushAndConsume) {
+TEST_P(AudioBlockFifoFormatTest, PushAndConsume) {
const int channels = 2;
const int frames = 441;
const int blocks = 4;
@@ -100,10 +119,9 @@ TEST_F(AudioBlockFifoTest, PushAndConsume) {
fifo.Clear();
int new_push_frames = 128;
// Change the input frame and try to fill up the FIFO.
- PushAndVerify(&fifo, new_push_frames, channels, frames,
- frames * blocks);
+ PushAndVerify(&fifo, new_push_frames, channels, frames, frames * blocks);
EXPECT_TRUE(fifo.GetUnfilledFrames() != 0);
- EXPECT_TRUE(fifo.available_blocks() == blocks -1);
+ EXPECT_TRUE(fifo.available_blocks() == blocks - 1);
// Consume all the existing filled blocks of data.
while (fifo.available_blocks()) {
@@ -122,14 +140,13 @@ TEST_F(AudioBlockFifoTest, PushAndConsume) {
// Completely fill up the buffer again.
new_push_frames = frames * blocks - remain_frames;
- PushAndVerify(&fifo, new_push_frames, channels, frames,
- frames * blocks);
+ PushAndVerify(&fifo, new_push_frames, channels, frames, frames * blocks);
EXPECT_TRUE(fifo.GetUnfilledFrames() == 0);
EXPECT_TRUE(fifo.available_blocks() == blocks);
}
// Perform a sequence of Push/Consume calls to a 1 block FIFO.
-TEST_F(AudioBlockFifoTest, PushAndConsumeOneBlockFifo) {
+TEST_P(AudioBlockFifoFormatTest, PushAndConsumeOneBlockFifo) {
static const int channels = 2;
static const int frames = 441;
static const int blocks = 1;
@@ -146,4 +163,8 @@ TEST_F(AudioBlockFifoTest, PushAndConsumeOneBlockFifo) {
EXPECT_TRUE(fifo.GetUnfilledFrames() == frames);
}
+INSTANTIATE_TEST_CASE_P(AudioBlockFifoTests,
+ AudioBlockFifoFormatTest,
+ ::testing::Values(false, true));
+
} // namespace media
« no previous file with comments | « media/base/audio_block_fifo.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698