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

Unified Diff: content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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: content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc
diff --git a/content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc b/content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc
index 95daa7920ba113226bedcb40fa9aac19657bbd1a..4b29a852385bd6de5e4022b8291a6dead4a8603e 100644
--- a/content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc
+++ b/content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc
@@ -11,13 +11,14 @@
#include "base/message_loop/message_loop.h"
#include "content/child/child_process.h"
#include "content/renderer/media/media_stream.h"
-#include "content/renderer/media/media_stream_audio_source.h"
#include "content/renderer/media/media_stream_video_source.h"
#include "content/renderer/media/media_stream_video_track.h"
+#include "content/renderer/media/mock_audio_device_factory.h"
+#include "content/renderer/media/mock_constraint_factory.h"
#include "content/renderer/media/mock_media_stream_video_source.h"
#include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.h"
-#include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
-#include "content/renderer/media/webrtc_local_audio_track.h"
+#include "content/renderer/media/webrtc/processed_local_audio_source.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/platform/WebMediaStream.h"
#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
@@ -25,6 +26,8 @@
#include "third_party/WebKit/public/platform/WebVector.h"
#include "third_party/WebKit/public/web/WebHeap.h"
+using ::testing::_;
+
namespace content {
class WebRtcMediaStreamAdapterTest : public ::testing::Test {
@@ -48,15 +51,27 @@ class WebRtcMediaStreamAdapterTest : public ::testing::Test {
blink::WebMediaStreamSource::TypeAudio,
"audio",
false /* remote */);
- audio_source.setExtraData(new MediaStreamAudioSource());
-
+ ProcessedLocalAudioSource* const source =
+ new ProcessedLocalAudioSource(
+ -1 /* consumer_render_frame_id is N/A for non-browser tests */,
+ StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "Mock audio device",
+ "mock_audio_device_id",
+ media::AudioParameters::kAudioCDSampleRate,
+ media::CHANNEL_LAYOUT_STEREO,
+ media::AudioParameters::kAudioCDSampleRate / 50),
+ dependency_factory_.get());
+ source->SetAllowInvalidRenderFrameIdForTesting(true);
+ source->SetSourceConstraints(
+ MockConstraintFactory().CreateWebMediaConstraints());
+ audio_source.setExtraData(source); // Takes ownership.
audio_track_vector[0].initialize(audio_source);
- scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter(
- WebRtcLocalAudioTrackAdapter::Create(
- audio_track_vector[0].id().utf8(), nullptr));
- std::unique_ptr<WebRtcLocalAudioTrack> native_track(
- new WebRtcLocalAudioTrack(adapter.get()));
- audio_track_vector[0].setExtraData(native_track.release());
+ EXPECT_CALL(*mock_audio_device_factory_.mock_capturer_source(),
+ Initialize(_, _, -1));
+ EXPECT_CALL(*mock_audio_device_factory_.mock_capturer_source(),
+ SetAutomaticGainControl(true));
+ EXPECT_CALL(*mock_audio_device_factory_.mock_capturer_source(), Start());
+ EXPECT_CALL(*mock_audio_device_factory_.mock_capturer_source(), Stop());
+ CHECK(source->ConnectToTrack(audio_track_vector[0]));
}
blink::WebVector<blink::WebMediaStreamTrack> video_track_vector(
@@ -104,11 +119,12 @@ class WebRtcMediaStreamAdapterTest : public ::testing::Test {
return adapter_->webrtc_media_stream();
}
- protected:
+ private:
base::MessageLoop message_loop_;
std::unique_ptr<ChildProcess> child_process_;
std::unique_ptr<MockPeerConnectionDependencyFactory> dependency_factory_;
std::unique_ptr<WebRtcMediaStreamAdapter> adapter_;
+ MockAudioDeviceFactory mock_audio_device_factory_;
};
TEST_F(WebRtcMediaStreamAdapterTest, CreateWebRtcMediaStream) {
« no previous file with comments | « content/renderer/media/webrtc/webrtc_media_stream_adapter.cc ('k') | content/renderer/media/webrtc_audio_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698