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

Unified Diff: third_party/WebKit/Source/platform/audio/PushPullFIFOTest.cpp

Issue 2777903005: Add WebThread in AudioDestination to support AudioWorkletThread (Closed)
Patch Set: Refactoring WIP (please ignore) Created 3 years, 8 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
Index: third_party/WebKit/Source/platform/audio/PushPullFIFOTest.cpp
diff --git a/third_party/WebKit/Source/platform/audio/PushPullFIFOTest.cpp b/third_party/WebKit/Source/platform/audio/PushPullFIFOTest.cpp
index 9351b4281d13b47fbf34e13dc8b9ae9643a9dabb..0ea8b22c8d9c84363728a148cd3c3b953f14b36b 100644
--- a/third_party/WebKit/Source/platform/audio/PushPullFIFOTest.cpp
+++ b/third_party/WebKit/Source/platform/audio/PushPullFIFOTest.cpp
@@ -15,37 +15,54 @@ namespace blink {
namespace {
+class MockAudioIOCallback : public AudioIOCallback {
+ public:
+ MockAudioIOCallback() {};
+ ~MockAudioIOCallback() {};
+
+ void Render(AudioBus* source_bus,
+ AudioBus* destination_bus,
+ size_t number_of_frames,
+ const AudioIOPosition& output_position) final {}
+};
+
// Check the basic contract of FIFO.
TEST(PushPullFIFOBasicTest, BasicTests) {
// This suppresses the multi-thread warning for GTest. Potently it increases
// the test execution time, but this specific test is very short and simple.
::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ const ThreadIdentifier thread_id = CurrentThread();
+ MockAudioIOCallback* mock_audio_io_callback = new MockAudioIOCallback();
+
// FIFO length exceeding the maximum length allowed will cause crash.
// i.e.) m_fifoLength <= kMaxFIFOLength
- EXPECT_DEATH(new PushPullFIFO(2, PushPullFIFO::kMaxFIFOLength + 1), "");
+ EXPECT_DEATH(new PushPullFIFO(2, PushPullFIFO::kMaxFIFOLength + 1,
+ thread_id, *mock_audio_io_callback),
+ "");
std::unique_ptr<PushPullFIFO> test_fifo =
- WTF::WrapUnique(new PushPullFIFO(2, 1024));
+ WTF::WrapUnique(new PushPullFIFO(2, 1024, thread_id,
+ *mock_audio_io_callback));
// The input bus length must be |AudioUtilities::kRenderQuantumFrames|.
// i.e.) inputBus->length() == kRenderQuantumFrames
- RefPtr<AudioBus> input_bus_of129_frames =
+ RefPtr<AudioBus> input_bus_129_frames =
AudioBus::Create(2, AudioUtilities::kRenderQuantumFrames + 1);
- EXPECT_DEATH(test_fifo->Push(input_bus_of129_frames.Get()), "");
- RefPtr<AudioBus> input_bus_of127_frames =
+ EXPECT_DEATH(test_fifo->Push(input_bus_129_frames.Get()), "");
+ RefPtr<AudioBus> input_bus_127_frames =
AudioBus::Create(2, AudioUtilities::kRenderQuantumFrames - 1);
- EXPECT_DEATH(test_fifo->Push(input_bus_of127_frames.Get()), "");
+ EXPECT_DEATH(test_fifo->Push(input_bus_127_frames.Get()), "");
// Pull request frames cannot exceed the length of output bus.
// i.e.) framesRequested <= outputBus->length()
- RefPtr<AudioBus> output_bus_of512_frames = AudioBus::Create(2, 512);
- EXPECT_DEATH(test_fifo->Pull(output_bus_of512_frames.Get(), 513), "");
+ RefPtr<AudioBus> output_bus_512_frames = AudioBus::Create(2, 512);
+ EXPECT_DEATH(test_fifo->Pull(output_bus_512_frames.Get(), 513), "");
// Pull request frames cannot exceed the length of FIFO.
// i.e.) framesRequested <= m_fifoLength
- RefPtr<AudioBus> output_bus_of1025_frames = AudioBus::Create(2, 1025);
- EXPECT_DEATH(test_fifo->Pull(output_bus_of1025_frames.Get(), 1025), "");
+ RefPtr<AudioBus> output_bus_1025_frames = AudioBus::Create(2, 1025);
+ EXPECT_DEATH(test_fifo->Pull(output_bus_1025_frames.Get(), 1025), "");
}
// Fills each AudioChannel in an AudioBus with a series of linearly increasing
@@ -133,10 +150,13 @@ class PushPullFIFOFeatureTest : public ::testing::TestWithParam<FIFOTestParam> {
TEST_P(PushPullFIFOFeatureTest, FeatureTests) {
const FIFOTestSetup setup = GetParam().setup;
const FIFOTestExpectedState expected_state = GetParam().expected_state;
+ const ThreadIdentifier thread_id = CurrentThread();
+ MockAudioIOCallback* mock_audio_io_callback = new MockAudioIOCallback();
// Create a FIFO with a specified configuration.
std::unique_ptr<PushPullFIFO> fifo = WTF::WrapUnique(
- new PushPullFIFO(setup.number_of_channels, setup.fifo_length));
+ new PushPullFIFO(setup.number_of_channels, setup.fifo_length, thread_id,
+ *mock_audio_io_callback));
RefPtr<AudioBus> output_bus;
@@ -169,7 +189,9 @@ TEST_P(PushPullFIFOFeatureTest, FeatureTests) {
// Verify in-FIFO samples.
for (const auto& sample : expected_state.fifo_samples) {
- EXPECT_TRUE(VerifyBusValueAtIndex(fifo->Bus(), sample.index, sample.value));
+ EXPECT_TRUE(VerifyBusValueAtIndex(fifo->GetFIFOBusForTest(),
+ sample.index,
+ sample.value));
}
// Verify samples from the most recent output bus.

Powered by Google App Engine
This is Rietveld 408576698