Commit 2e57c5a4 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Factor AudioCapturerSourceTestingPlatformSupport out of processed_local_audio_source_test.cc

... so that it can be used on more testing files.

Note that, given that one of the methods reimplemented need access
blink::WebLocalFrame, the newly added files can not reside in
renderer/platform/testing, where other similar files are.

BUG=787254
R=guidou@chromium.org

Change-Id: I1dd6154407d744daab6cdbad0003bf2ddafe7485
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1873986
Auto-Submit: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#709074}
parent 53b2989a
...@@ -103,6 +103,8 @@ jumbo_source_set("test_support") { ...@@ -103,6 +103,8 @@ jumbo_source_set("test_support") {
"mock_media_stream_registry.cc", "mock_media_stream_registry.cc",
"mock_media_stream_video_sink.cc", "mock_media_stream_video_sink.cc",
"mock_media_stream_video_source.cc", "mock_media_stream_video_source.cc",
"testing_platform_support_with_mock_audio_capture_source.cc",
"testing_platform_support_with_mock_audio_capture_source.h",
] ]
deps = [ deps = [
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "third_party/blink/public/web/modules/mediastream/processed_local_audio_source.h" #include "third_party/blink/public/web/modules/mediastream/processed_local_audio_source.h"
#include "third_party/blink/public/web/modules/webrtc/webrtc_audio_device_impl.h" #include "third_party/blink/public/web/modules/webrtc/webrtc_audio_device_impl.h"
#include "third_party/blink/public/web/web_heap.h" #include "third_party/blink/public/web/web_heap.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h" #include "third_party/blink/renderer/modules/mediastream/testing_platform_support_with_mock_audio_capture_source.h"
using ::testing::_; using ::testing::_;
using ::testing::AtLeast; using ::testing::AtLeast;
...@@ -49,49 +49,6 @@ constexpr int kExpectedSourceBufferSize = kRequestedBufferSize; ...@@ -49,49 +49,6 @@ constexpr int kExpectedSourceBufferSize = kRequestedBufferSize;
// output end of its FIFO. // output end of its FIFO.
constexpr int kExpectedOutputBufferSize = kSampleRate / 100; constexpr int kExpectedOutputBufferSize = kSampleRate / 100;
class MockAudioCapturerSource : public media::AudioCapturerSource {
public:
MockAudioCapturerSource();
MOCK_METHOD2(Initialize,
void(const media::AudioParameters& params,
CaptureCallback* callback));
MOCK_METHOD0(Start, void());
MOCK_METHOD0(Stop, void());
MOCK_METHOD1(SetAutomaticGainControl, void(bool enable));
void SetVolume(double volume) override {}
void SetOutputDeviceForAec(const std::string& output_device_id) override {}
protected:
~MockAudioCapturerSource() override;
};
MockAudioCapturerSource::MockAudioCapturerSource() {}
MockAudioCapturerSource::~MockAudioCapturerSource() {}
// Test Platform implementation that overrides the known methods needed
// by the tests, including creation of AudioCapturerSource instances.
class AudioCapturerSourceTestingPlatformSupport
: public TestingPlatformSupport {
public:
AudioCapturerSourceTestingPlatformSupport() = default;
scoped_refptr<media::AudioCapturerSource> NewAudioCapturerSource(
WebLocalFrame* web_frame,
const media::AudioSourceParameters& params) override {
// The |web_frame| is irrelevant here, so we use MSG_ROUTING_NONE directly.
EXPECT_EQ(nullptr, web_frame);
return mock_audio_capturer_source_;
}
MockAudioCapturerSource* mock_audio_capturer_source() {
return mock_audio_capturer_source_.get();
}
private:
scoped_refptr<MockAudioCapturerSource> mock_audio_capturer_source_ =
base::MakeRefCounted<MockAudioCapturerSource>();
};
class MockMediaStreamAudioSink : public WebMediaStreamAudioSink { class MockMediaStreamAudioSink : public WebMediaStreamAudioSink {
public: public:
MockMediaStreamAudioSink() {} MockMediaStreamAudioSink() {}
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/mediastream/testing_platform_support_with_mock_audio_capture_source.h"
namespace blink {
scoped_refptr<media::AudioCapturerSource>
AudioCapturerSourceTestingPlatformSupport::NewAudioCapturerSource(
WebLocalFrame* web_frame,
const media::AudioSourceParameters& params) {
EXPECT_EQ(nullptr, web_frame);
return mock_audio_capturer_source_;
}
} // namespace blink
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_TESTING_PLATFORM_SUPPORT_WITH_MOCK_AUDIO_CAPTURE_SOURCE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_TESTING_PLATFORM_SUPPORT_WITH_MOCK_AUDIO_CAPTURE_SOURCE_H_
#include <string>
#include "base/memory/scoped_refptr.h"
#include "media/base/audio_capturer_source.h"
#include "media/base/audio_parameters.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h"
namespace blink {
namespace {
class MockAudioCapturerSource : public media::AudioCapturerSource {
public:
MockAudioCapturerSource() = default;
MOCK_METHOD2(Initialize,
void(const media::AudioParameters& params,
CaptureCallback* callback));
MOCK_METHOD0(Start, void());
MOCK_METHOD0(Stop, void());
MOCK_METHOD1(SetAutomaticGainControl, void(bool enable));
void SetVolume(double volume) override {}
void SetOutputDeviceForAec(const std::string& output_device_id) override {}
protected:
~MockAudioCapturerSource() override = default;
};
} // namespace
// Test Platform implementation that overrides the known methods needed
// by the tests, including creation of AudioCapturerSource instances.
class AudioCapturerSourceTestingPlatformSupport
: public IOTaskRunnerTestingPlatformSupport {
public:
AudioCapturerSourceTestingPlatformSupport() = default;
scoped_refptr<media::AudioCapturerSource> NewAudioCapturerSource(
WebLocalFrame* web_frame,
const media::AudioSourceParameters& params) override;
MockAudioCapturerSource* mock_audio_capturer_source() {
return mock_audio_capturer_source_.get();
}
private:
scoped_refptr<MockAudioCapturerSource> mock_audio_capturer_source_ =
base::MakeRefCounted<MockAudioCapturerSource>();
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_TESTING_PLATFORM_SUPPORT_WITH_MOCK_AUDIO_CAPTURE_SOURCE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment