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

Unified Diff: media/blink/webaudiosourceprovider_impl_unittest.cc

Issue 1781043002: media::WebAudioSourceProviderImpl, add support for getting a copy of passing AudioBuses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: last round of comments from dalecurtis@ Created 4 years, 9 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/blink/webaudiosourceprovider_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webaudiosourceprovider_impl_unittest.cc
diff --git a/media/blink/webaudiosourceprovider_impl_unittest.cc b/media/blink/webaudiosourceprovider_impl_unittest.cc
index f5efffbf3e50bfe1612ab207035beaa20d9b9f97..cc92aa91889a1032d6d7e581b0e13eb16ee21fc5 100644
--- a/media/blink/webaudiosourceprovider_impl_unittest.cc
+++ b/media/blink/webaudiosourceprovider_impl_unittest.cc
@@ -4,6 +4,7 @@
#include <stddef.h>
+#include "base/bind.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
@@ -15,6 +16,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/platform/WebAudioSourceProviderClient.h"
+using ::testing::_;
+
namespace media {
namespace {
@@ -85,6 +88,19 @@ class WebAudioSourceProviderImplTest
// blink::WebAudioSourceProviderClient implementation.
MOCK_METHOD2(setFormat, void(size_t numberOfChannels, float sampleRate));
+ // CopyAudioCB. Added forwarder method due to GMock troubles with scoped_ptr.
+ MOCK_METHOD3(DoCopyAudioCB,
+ void(AudioBus*, uint32_t delay_milliseconds, int sample_rate));
+ void OnAudioBus(scoped_ptr<AudioBus> bus,
+ uint32_t delay_milliseconds,
+ int sample_rate) {
+ DoCopyAudioCB(bus.get(), delay_milliseconds, sample_rate);
+ }
+
+ int Render(AudioBus* audio_bus) {
+ return wasp_impl_->RenderForTesting(audio_bus);
+ }
+
protected:
AudioParameters params_;
FakeAudioRenderCallback fake_callback_;
@@ -117,7 +133,6 @@ TEST_F(WebAudioSourceProviderImplTest, SetClientBeforeInitialize) {
// Verify AudioRendererSink functionality w/ and w/o a client.
TEST_F(WebAudioSourceProviderImplTest, SinkMethods) {
wasp_impl_->Initialize(params_, &fake_callback_);
- ASSERT_EQ(mock_sink_->callback(), &fake_callback_);
// Without a client all WASP calls should fall through to the underlying sink.
CallAllSinkMethodsAndVerify(true);
@@ -240,4 +255,22 @@ TEST_F(WebAudioSourceProviderImplTest, ProvideInput) {
ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get()));
}
+// Verify CopyAudioCB is called if registered.
+TEST_F(WebAudioSourceProviderImplTest, CopyAudioCB) {
+ testing::InSequence s;
+ wasp_impl_->Initialize(params_, &fake_callback_);
+ wasp_impl_->SetCopyAudioCallback(base::Bind(
+ &WebAudioSourceProviderImplTest::OnAudioBus, base::Unretained(this)));
+
+ const scoped_ptr<AudioBus> bus1 = AudioBus::Create(params_);
+ EXPECT_CALL(*this, DoCopyAudioCB(_, 0, params_.sample_rate())).Times(1);
+ Render(bus1.get());
+
+ wasp_impl_->ClearCopyAudioCallback();
+ EXPECT_CALL(*this, DoCopyAudioCB(_, _, _)).Times(0);
+ Render(bus1.get());
+
+ testing::Mock::VerifyAndClear(mock_sink_.get());
+}
+
} // namespace media
« no previous file with comments | « media/blink/webaudiosourceprovider_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698