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

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

Issue 2799363005: Removing public access to AudioManager device info interface. (Closed)
Patch Set: rebase Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/audio/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/renderer_audio_output_stream_facto ry_context_impl.h" 5 #include "content/browser/renderer_host/media/renderer_audio_output_stream_facto ry_context_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 108 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
109 media::AudioLogFactory* audio_log_factory) 109 media::AudioLogFactory* audio_log_factory)
110 : media::AudioManagerBase(task_runner, 110 : media::AudioManagerBase(task_runner,
111 worker_task_runner, 111 worker_task_runner,
112 audio_log_factory) { 112 audio_log_factory) {
113 ON_CALL(*this, HasAudioOutputDevices()).WillByDefault(Return(true)); 113 ON_CALL(*this, HasAudioOutputDevices()).WillByDefault(Return(true));
114 } 114 }
115 115
116 ~MockAudioManager() override { Shutdown(); } 116 ~MockAudioManager() override { Shutdown(); }
117 117
118 MOCK_METHOD0(HasAudioOutputDevices, bool());
119 MOCK_METHOD0(HasAudioInputDevices, bool());
120 MOCK_METHOD0(GetName, const char*());
121
122 MOCK_METHOD2(MakeLinearOutputStream, 118 MOCK_METHOD2(MakeLinearOutputStream,
123 media::AudioOutputStream*(const media::AudioParameters& params, 119 media::AudioOutputStream*(const media::AudioParameters& params,
124 const LogCallback& log_callback)); 120 const LogCallback& log_callback));
125 MOCK_METHOD3(MakeLowLatencyOutputStream, 121 MOCK_METHOD3(MakeLowLatencyOutputStream,
126 media::AudioOutputStream*(const media::AudioParameters& params, 122 media::AudioOutputStream*(const media::AudioParameters& params,
127 const std::string& device_id, 123 const std::string& device_id,
128 const LogCallback& log_callback)); 124 const LogCallback& log_callback));
129 MOCK_METHOD3(MakeLinearInputStream, 125 MOCK_METHOD3(MakeLinearInputStream,
130 media::AudioInputStream*(const media::AudioParameters& params, 126 media::AudioInputStream*(const media::AudioParameters& params,
131 const std::string& device_id, 127 const std::string& device_id,
132 const LogCallback& log_callback)); 128 const LogCallback& log_callback));
133 MOCK_METHOD3(MakeLowLatencyInputStream, 129 MOCK_METHOD3(MakeLowLatencyInputStream,
134 media::AudioInputStream*(const media::AudioParameters& params, 130 media::AudioInputStream*(const media::AudioParameters& params,
135 const std::string& device_id, 131 const std::string& device_id,
136 const LogCallback& log_callback)); 132 const LogCallback& log_callback));
137 MOCK_METHOD2(GetPreferredOutputStreamParameters, 133
138 media::AudioParameters(const std::string& device_id, 134 protected:
139 const media::AudioParameters& params)); 135 MOCK_METHOD0(HasAudioOutputDevices, bool());
136 MOCK_METHOD0(HasAudioInputDevices, bool());
137 MOCK_METHOD0(GetName, const char*());
138 media::AudioParameters GetPreferredOutputStreamParameters(
139 const std::string& device_id,
140 const media::AudioParameters& params) {
141 return GetTestAudioParameters();
142 }
140 }; 143 };
141 144
142 class MockAudioOutputStream : public media::AudioOutputStream, 145 class MockAudioOutputStream : public media::AudioOutputStream,
143 public base::PlatformThread::Delegate { 146 public base::PlatformThread::Delegate {
144 public: 147 public:
145 explicit MockAudioOutputStream(MockAudioManager* audio_manager) 148 explicit MockAudioOutputStream(MockAudioManager* audio_manager)
146 : done_(base::WaitableEvent::ResetPolicy::MANUAL, 149 : done_(base::WaitableEvent::ResetPolicy::MANUAL,
147 base::WaitableEvent::InitialState::NOT_SIGNALED), 150 base::WaitableEvent::InitialState::NOT_SIGNALED),
148 audio_manager_(audio_manager) {} 151 audio_manager_(audio_manager) {}
149 152
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // Sets up the factory on the IO thread and runs client code on the UI thread. 334 // Sets up the factory on the IO thread and runs client code on the UI thread.
332 // Send a sine wave from the client and makes sure it's received by the output 335 // Send a sine wave from the client and makes sure it's received by the output
333 // stream. 336 // stream.
334 MockAudioOutputStream* stream = new MockAudioOutputStream( 337 MockAudioOutputStream* stream = new MockAudioOutputStream(
335 static_cast<MockAudioManager*>(audio_manager_.get())); 338 static_cast<MockAudioManager*>(audio_manager_.get()));
336 339
337 // Make sure the mock audio manager uses our mock stream. 340 // Make sure the mock audio manager uses our mock stream.
338 EXPECT_CALL(*static_cast<MockAudioManager*>(audio_manager_.get()), 341 EXPECT_CALL(*static_cast<MockAudioManager*>(audio_manager_.get()),
339 MakeLowLatencyOutputStream(_, "", _)) 342 MakeLowLatencyOutputStream(_, "", _))
340 .WillOnce(Return(stream)); 343 .WillOnce(Return(stream));
341 EXPECT_CALL(*static_cast<MockAudioManager*>(audio_manager_.get()),
342 GetPreferredOutputStreamParameters(_, _))
343 .WillRepeatedly(Return(GetTestAudioParameters()));
344 344
345 AudioOutputStreamFactoryPtr factory_ptr; 345 AudioOutputStreamFactoryPtr factory_ptr;
346 BrowserThread::PostTask( 346 BrowserThread::PostTask(
347 BrowserThread::IO, FROM_HERE, 347 BrowserThread::IO, FROM_HERE,
348 base::Bind(&RendererAudioOutputStreamFactoryIntegrationTest:: 348 base::Bind(&RendererAudioOutputStreamFactoryIntegrationTest::
349 CreateAndBindFactory, 349 CreateAndBindFactory,
350 base::Unretained(this), 350 base::Unretained(this),
351 base::Passed(mojo::MakeRequest(&factory_ptr)))); 351 base::Passed(mojo::MakeRequest(&factory_ptr))));
352 352
353 AudioOutputStreamProviderPtr provider_ptr; 353 AudioOutputStreamProviderPtr provider_ptr;
(...skipping 20 matching lines...) Expand all
374 base::Bind(&TestIPCClient::Start, base::Unretained(&client))); 374 base::Bind(&TestIPCClient::Start, base::Unretained(&client)));
375 SyncWithAllThreads(); 375 SyncWithAllThreads();
376 stream_ptr->Play(); 376 stream_ptr->Play();
377 SyncWithAllThreads(); 377 SyncWithAllThreads();
378 } // Joining client thread. 378 } // Joining client thread.
379 stream_ptr.reset(); 379 stream_ptr.reset();
380 SyncWithAllThreads(); 380 SyncWithAllThreads();
381 } 381 }
382 382
383 } // namespace content 383 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/audio/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698