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

Side by Side Diff: content/browser/renderer_host/media/media_devices_dispatcher_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/media_devices_dispatcher_host.h" 5 #include "content/browser/renderer_host/media/media_devices_dispatcher_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
19 #include "component/arc/video_facing.h"
19 #include "content/browser/renderer_host/media/media_stream_manager.h" 20 #include "content/browser/renderer_host/media/media_stream_manager.h"
20 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 21 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
21 #include "content/browser/renderer_host/media/video_capture_manager.h" 22 #include "content/browser/renderer_host/media/video_capture_manager.h"
22 #include "content/public/browser/media_device_id.h" 23 #include "content/public/browser/media_device_id.h"
23 #include "content/public/test/mock_resource_context.h" 24 #include "content/public/test/mock_resource_context.h"
24 #include "content/public/test/test_browser_context.h" 25 #include "content/public/test/test_browser_context.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 26 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "media/audio/audio_device_description.h" 27 #include "media/audio/audio_device_description.h"
27 #include "media/audio/mock_audio_manager.h" 28 #include "media/audio/mock_audio_manager.h"
28 #include "media/base/media_switches.h" 29 #include "media/base/media_switches.h"
(...skipping 28 matching lines...) Expand all
57 void(MediaDeviceType, uint32_t, const MediaDeviceInfoArray&)); 58 void(MediaDeviceType, uint32_t, const MediaDeviceInfoArray&));
58 59
59 ::mojom::MediaDevicesListenerPtr CreateInterfacePtrAndBind() { 60 ::mojom::MediaDevicesListenerPtr CreateInterfacePtrAndBind() {
60 return binding_.CreateInterfacePtrAndBind(); 61 return binding_.CreateInterfacePtrAndBind();
61 } 62 }
62 63
63 private: 64 private:
64 mojo::Binding<::mojom::MediaDevicesListener> binding_; 65 mojo::Binding<::mojom::MediaDevicesListener> binding_;
65 }; 66 };
66 67
68 class MockVideoCaptureObserver : public component::VideoCaptureObserver {
69 public:
70 MOCK_METHOD1(OnVideoCaptureStarted, void(component::VideoFacingMode));
71 MOCK_METHOD1(OnVideoCaptureStopped, void(component::VideoFacingMode));
72 };
73
67 } // namespace 74 } // namespace
68 75
69 class MediaDevicesDispatcherHostTest : public testing::Test { 76 class MediaDevicesDispatcherHostTest : public testing::Test {
70 public: 77 public:
71 MediaDevicesDispatcherHostTest() 78 MediaDevicesDispatcherHostTest()
72 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 79 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
73 origin_(GURL("https://test.com")) { 80 origin_(GURL("https://test.com")) {
74 // Make sure we use fake devices to avoid long delays. 81 // Make sure we use fake devices to avoid long delays.
75 base::CommandLine::ForCurrentProcess()->AppendSwitch( 82 base::CommandLine::ForCurrentProcess()->AppendSwitch(
76 switches::kUseFakeDeviceForMediaStream); 83 switches::kUseFakeDeviceForMediaStream);
77 audio_manager_.reset( 84 audio_manager_.reset(
78 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())); 85 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get()),
86 new MockVideoCaptureObserver());
79 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 87 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get()));
80 88
81 MockResourceContext* mock_resource_context = 89 MockResourceContext* mock_resource_context =
82 static_cast<MockResourceContext*>( 90 static_cast<MockResourceContext*>(
83 browser_context_.GetResourceContext()); 91 browser_context_.GetResourceContext());
84 92
85 host_ = base::MakeUnique<MediaDevicesDispatcherHost>( 93 host_ = base::MakeUnique<MediaDevicesDispatcherHost>(
86 kProcessId, kRenderId, mock_resource_context->GetMediaDeviceIDSalt(), 94 kProcessId, kRenderId, mock_resource_context->GetMediaDeviceIDSalt(),
87 media_stream_manager_.get()); 95 media_stream_manager_.get());
88 } 96 }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 #if defined(OS_WIN) 342 #if defined(OS_WIN)
335 // On Windows, the underlying MediaStreamManager uses a separate thread for 343 // On Windows, the underlying MediaStreamManager uses a separate thread for
336 // video capture which must be flushed to guarantee that the callback bound to 344 // video capture which must be flushed to guarantee that the callback bound to
337 // EnumerateDevices above is invoked before the end of this test's body. 345 // EnumerateDevices above is invoked before the end of this test's body.
338 media_stream_manager_->FlushVideoCaptureThreadForTesting(); 346 media_stream_manager_->FlushVideoCaptureThreadForTesting();
339 base::RunLoop().RunUntilIdle(); 347 base::RunLoop().RunUntilIdle();
340 #endif 348 #endif
341 } 349 }
342 350
343 }; // namespace content 351 }; // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698