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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host_unittest.cc

Issue 2634263002: Pass camera facing info to audio client (Closed)
Patch Set: Pass VideoCaptureObserver as ctor parameter Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/audio_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_renderer_host.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/sync_socket.h" 16 #include "base/sync_socket.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "component/arc/video_facing.h"
18 #include "content/browser/media/capture/audio_mirroring_manager.h" 19 #include "content/browser/media/capture/audio_mirroring_manager.h"
19 #include "content/browser/media/media_internals.h" 20 #include "content/browser/media/media_internals.h"
20 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 21 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
21 #include "content/browser/renderer_host/media/media_stream_manager.h" 22 #include "content/browser/renderer_host/media/media_stream_manager.h"
22 #include "content/common/media/audio_messages.h" 23 #include "content/common/media/audio_messages.h"
23 #include "content/public/browser/media_device_id.h" 24 #include "content/public/browser/media_device_id.h"
24 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
25 #include "content/public/test/mock_render_process_host.h" 26 #include "content/public/test/mock_render_process_host.h"
26 #include "content/public/test/test_browser_context.h" 27 #include "content/public/test/test_browser_context.h"
27 #include "content/public/test/test_browser_thread_bundle.h" 28 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 std::string GetAssociatedOutputDeviceID( 115 std::string GetAssociatedOutputDeviceID(
115 const std::string& input_id) override { 116 const std::string& input_id) override {
116 auto it = associations_.find(input_id); 117 auto it = associations_.find(input_id);
117 return it == associations_.end() ? "" : it->second; 118 return it == associations_.end() ? "" : it->second;
118 } 119 }
119 120
120 private: 121 private:
121 std::map<std::string, std::string> associations_; 122 std::map<std::string, std::string> associations_;
122 }; 123 };
123 124
125 class MockVideoCaptureObserver : public component::VideoCaptureObserver {
126 public:
127 MOCK_METHOD1(OnVideoCaptureStarted, void(component::VideoFacingMode));
128 MOCK_METHOD1(OnVideoCaptureStopped, void(component::VideoFacingMode));
129 };
130
124 } // namespace 131 } // namespace
125 132
126 class MockAudioRendererHost : public AudioRendererHost { 133 class MockAudioRendererHost : public AudioRendererHost {
127 public: 134 public:
128 MockAudioRendererHost(base::RunLoop* auth_run_loop, 135 MockAudioRendererHost(base::RunLoop* auth_run_loop,
129 int render_process_id, 136 int render_process_id,
130 media::AudioManager* audio_manager, 137 media::AudioManager* audio_manager,
131 AudioMirroringManager* mirroring_manager, 138 AudioMirroringManager* mirroring_manager,
132 MediaStreamManager* media_stream_manager, 139 MediaStreamManager* media_stream_manager,
133 const std::string& salt) 140 const std::string& salt)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 class AudioRendererHostTest : public testing::Test { 238 class AudioRendererHostTest : public testing::Test {
232 public: 239 public:
233 AudioRendererHostTest() 240 AudioRendererHostTest()
234 : log_factory(base::MakeUnique<media::FakeAudioLogFactory>()), 241 : log_factory(base::MakeUnique<media::FakeAudioLogFactory>()),
235 audio_manager_(base::MakeUnique<FakeAudioManagerWithAssociations>( 242 audio_manager_(base::MakeUnique<FakeAudioManagerWithAssociations>(
236 base::ThreadTaskRunnerHandle::Get(), 243 base::ThreadTaskRunnerHandle::Get(),
237 log_factory.get())), 244 log_factory.get())),
238 render_process_host_(&browser_context_, &auth_run_loop_) { 245 render_process_host_(&browser_context_, &auth_run_loop_) {
239 base::CommandLine::ForCurrentProcess()->AppendSwitch( 246 base::CommandLine::ForCurrentProcess()->AppendSwitch(
240 switches::kUseFakeDeviceForMediaStream); 247 switches::kUseFakeDeviceForMediaStream);
241 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 248 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get(), new MockVideoCaptureObserver()));
242 host_ = new MockAudioRendererHost( 249 host_ = new MockAudioRendererHost(
243 &auth_run_loop_, render_process_host_.GetID(), audio_manager_.get(), 250 &auth_run_loop_, render_process_host_.GetID(), audio_manager_.get(),
244 &mirroring_manager_, media_stream_manager_.get(), kSalt); 251 &mirroring_manager_, media_stream_manager_.get(), kSalt);
245 252
246 // Simulate IPC channel connected. 253 // Simulate IPC channel connected.
247 host_->set_peer_process_for_testing(base::Process::Current()); 254 host_->set_peer_process_for_testing(base::Process::Current());
248 } 255 }
249 256
250 ~AudioRendererHostTest() override { 257 ~AudioRendererHostTest() override {
251 // Simulate closing the IPC channel and give the audio thread time to close 258 // Simulate closing the IPC channel and give the audio thread time to close
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 } 623 }
617 624
618 TEST_F(AudioRendererHostTest, CreateFailsForInvalidRenderFrame) { 625 TEST_F(AudioRendererHostTest, CreateFailsForInvalidRenderFrame) {
619 CreateWithInvalidRenderFrameId(); 626 CreateWithInvalidRenderFrameId();
620 Close(); 627 Close();
621 } 628 }
622 629
623 // TODO(hclam): Add tests for data conversation in low latency mode. 630 // TODO(hclam): Add tests for data conversation in low latency mode.
624 631
625 } // namespace content 632 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698