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

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

Issue 2697033006: Switching MediaStreamManager from using AudioManager to AudioSystem (Closed)
Patch Set: weak pointers removed Created 3 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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "content/browser/renderer_host/media/media_stream_manager.h" 21 #include "content/browser/renderer_host/media/media_stream_manager.h"
22 #include "content/browser/renderer_host/media/media_stream_requester.h" 22 #include "content/browser/renderer_host/media/media_stream_requester.h"
23 #include "content/browser/renderer_host/media/video_capture_host.h" 23 #include "content/browser/renderer_host/media/video_capture_host.h"
24 #include "content/browser/renderer_host/media/video_capture_manager.h" 24 #include "content/browser/renderer_host/media/video_capture_manager.h"
25 #include "content/common/media/media_devices.h" 25 #include "content/common/media/media_devices.h"
26 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
27 #include "content/public/test/mock_resource_context.h" 27 #include "content/public/test/mock_resource_context.h"
28 #include "content/public/test/test_browser_context.h" 28 #include "content/public/test/test_browser_context.h"
29 #include "content/public/test/test_browser_thread_bundle.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "content/test/test_content_browser_client.h" 30 #include "content/test/test_content_browser_client.h"
31 #include "media/audio/audio_system_impl.h"
31 #include "media/audio/mock_audio_manager.h" 32 #include "media/audio/mock_audio_manager.h"
32 #include "media/base/media_switches.h" 33 #include "media/base/media_switches.h"
33 #include "media/capture/video_capture_types.h" 34 #include "media/capture/video_capture_types.h"
34 #include "mojo/public/cpp/bindings/binding.h" 35 #include "mojo/public/cpp/bindings/binding.h"
35 #include "net/url_request/url_request_context.h" 36 #include "net/url_request/url_request_context.h"
36 #include "testing/gmock/include/gmock/gmock.h" 37 #include "testing/gmock/include/gmock/gmock.h"
37 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
38 39
39 using ::testing::_; 40 using ::testing::_;
40 using ::testing::AnyNumber; 41 using ::testing::AnyNumber;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // This is an integration test of VideoCaptureHost in conjunction with 110 // This is an integration test of VideoCaptureHost in conjunction with
110 // MediaStreamManager, VideoCaptureManager, VideoCaptureController, and 111 // MediaStreamManager, VideoCaptureManager, VideoCaptureController, and
111 // VideoCaptureDevice. 112 // VideoCaptureDevice.
112 class VideoCaptureTest : public testing::Test, 113 class VideoCaptureTest : public testing::Test,
113 public mojom::VideoCaptureObserver { 114 public mojom::VideoCaptureObserver {
114 public: 115 public:
115 VideoCaptureTest() 116 VideoCaptureTest()
116 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 117 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
117 audio_manager_( 118 audio_manager_(
118 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())), 119 new media::MockAudioManager(base::ThreadTaskRunnerHandle::Get())),
120 audio_system_(media::AudioSystemImpl::Create(audio_manager_.get())),
119 task_runner_(base::ThreadTaskRunnerHandle::Get()), 121 task_runner_(base::ThreadTaskRunnerHandle::Get()),
120 opened_session_id_(kInvalidMediaCaptureSessionId), 122 opened_session_id_(kInvalidMediaCaptureSessionId),
121 observer_binding_(this) {} 123 observer_binding_(this) {}
122 124
123 void SetUp() override { 125 void SetUp() override {
124 SetBrowserClientForTesting(&browser_client_); 126 SetBrowserClientForTesting(&browser_client_);
125 127
126 base::CommandLine::ForCurrentProcess()->AppendSwitch( 128 base::CommandLine::ForCurrentProcess()->AppendSwitch(
127 switches::kUseFakeDeviceForMediaStream); 129 switches::kUseFakeDeviceForMediaStream);
128 base::CommandLine::ForCurrentProcess()->AppendSwitch( 130 base::CommandLine::ForCurrentProcess()->AppendSwitch(
129 switches::kUseFakeUIForMediaStream); 131 switches::kUseFakeUIForMediaStream);
130 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 132 media_stream_manager_ =
133 base::MakeUnique<MediaStreamManager>(audio_system_.get());
131 134
132 // Create a Host and connect it to a simulated IPC channel. 135 // Create a Host and connect it to a simulated IPC channel.
133 host_.reset(new VideoCaptureHost(media_stream_manager_.get())); 136 host_.reset(new VideoCaptureHost(media_stream_manager_.get()));
134 137
135 OpenSession(); 138 OpenSession();
136 } 139 }
137 140
138 void TearDown() override { 141 void TearDown() override {
139 Mock::VerifyAndClearExpectations(host_.get()); 142 Mock::VerifyAndClearExpectations(host_.get());
140 EXPECT_TRUE(host_->controllers_.empty()); 143 EXPECT_TRUE(host_->controllers_.empty());
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 307
305 private: 308 private:
306 // |media_stream_manager_| needs to outlive |thread_bundle_| because it is a 309 // |media_stream_manager_| needs to outlive |thread_bundle_| because it is a
307 // MessageLoop::DestructionObserver. 310 // MessageLoop::DestructionObserver.
308 StrictMock<MockMediaStreamRequester> stream_requester_; 311 StrictMock<MockMediaStreamRequester> stream_requester_;
309 std::unique_ptr<MediaStreamManager> media_stream_manager_; 312 std::unique_ptr<MediaStreamManager> media_stream_manager_;
310 const content::TestBrowserThreadBundle thread_bundle_; 313 const content::TestBrowserThreadBundle thread_bundle_;
311 // |audio_manager_| needs to outlive |thread_bundle_| because it uses the 314 // |audio_manager_| needs to outlive |thread_bundle_| because it uses the
312 // underlying message loop. 315 // underlying message loop.
313 media::ScopedAudioManagerPtr audio_manager_; 316 media::ScopedAudioManagerPtr audio_manager_;
317 std::unique_ptr<media::AudioSystem> audio_system_;
314 content::TestBrowserContext browser_context_; 318 content::TestBrowserContext browser_context_;
315 content::TestContentBrowserClient browser_client_; 319 content::TestContentBrowserClient browser_client_;
316 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 320 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
317 int opened_session_id_; 321 int opened_session_id_;
318 std::string opened_device_label_; 322 std::string opened_device_label_;
319 323
320 std::unique_ptr<VideoCaptureHost> host_; 324 std::unique_ptr<VideoCaptureHost> host_;
321 mojo::Binding<mojom::VideoCaptureObserver> observer_binding_; 325 mojo::Binding<mojom::VideoCaptureObserver> observer_binding_;
322 326
323 DISALLOW_COPY_AND_ASSIGN(VideoCaptureTest); 327 DISALLOW_COPY_AND_ASSIGN(VideoCaptureTest);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 StartCapture(); 366 StartCapture();
363 367
364 // When the session is closed via the stream without stopping capture, the 368 // When the session is closed via the stream without stopping capture, the
365 // ENDED event is sent. 369 // ENDED event is sent.
366 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED)); 370 EXPECT_CALL(*this, OnStateChanged(mojom::VideoCaptureState::ENDED));
367 CloseSession(); 371 CloseSession();
368 base::RunLoop().RunUntilIdle(); 372 base::RunLoop().RunUntilIdle();
369 } 373 }
370 374
371 } // namespace content 375 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/media_stream_manager_unittest.cc ('k') | media/audio/audio_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698