OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/media/capture/web_contents_audio_input_stream.h" | 5 #include "content/browser/media/capture/web_contents_audio_input_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 : thread_bundle_(new TestBrowserThreadBundle( | 181 : thread_bundle_(new TestBrowserThreadBundle( |
182 TestBrowserThreadBundle::REAL_IO_THREAD)), | 182 TestBrowserThreadBundle::REAL_IO_THREAD)), |
183 audio_thread_("Audio thread"), | 183 audio_thread_("Audio thread"), |
184 mock_mirroring_manager_(new MockAudioMirroringManager()), | 184 mock_mirroring_manager_(new MockAudioMirroringManager()), |
185 mock_tracker_(new MockWebContentsTracker()), | 185 mock_tracker_(new MockWebContentsTracker()), |
186 mock_vais_(NULL), | 186 mock_vais_(NULL), |
187 wcais_(NULL), | 187 wcais_(NULL), |
188 destination_(NULL), | 188 destination_(NULL), |
189 current_render_process_id_(kRenderProcessId), | 189 current_render_process_id_(kRenderProcessId), |
190 current_render_frame_id_(kRenderFrameId), | 190 current_render_frame_id_(kRenderFrameId), |
191 on_data_event_(false, false) { | 191 on_data_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 192 base::WaitableEvent::InitialState::NOT_SIGNALED) { |
192 audio_thread_.Start(); | 193 audio_thread_.Start(); |
193 } | 194 } |
194 | 195 |
195 ~WebContentsAudioInputStreamTest() override { | 196 ~WebContentsAudioInputStreamTest() override { |
196 audio_thread_.Stop(); | 197 audio_thread_.Stop(); |
197 thread_bundle_.reset(); | 198 thread_bundle_.reset(); |
198 | 199 |
199 DCHECK(!mock_vais_); | 200 DCHECK(!mock_vais_); |
200 DCHECK(!wcais_); | 201 DCHECK(!wcais_); |
201 EXPECT_FALSE(destination_); | 202 EXPECT_FALSE(destination_); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 bool auto_gain = wcais_->GetAutomaticGainControl(); | 264 bool auto_gain = wcais_->GetAutomaticGainControl(); |
264 auto_gain = !auto_gain; | 265 auto_gain = !auto_gain; |
265 EXPECT_CALL(*mock_vais_, SetAutomaticGainControl(auto_gain)); | 266 EXPECT_CALL(*mock_vais_, SetAutomaticGainControl(auto_gain)); |
266 wcais_->SetAutomaticGainControl(auto_gain); | 267 wcais_->SetAutomaticGainControl(auto_gain); |
267 } | 268 } |
268 | 269 |
269 void AddAnotherInput() { | 270 void AddAnotherInput() { |
270 // Note: WCAIS posts a task to invoke | 271 // Note: WCAIS posts a task to invoke |
271 // MockAudioMirroringManager::StartMirroring() on the IO thread, which | 272 // MockAudioMirroringManager::StartMirroring() on the IO thread, which |
272 // causes our mock to set |destination_|. Block until that has happened. | 273 // causes our mock to set |destination_|. Block until that has happened. |
273 base::WaitableEvent done(false, false); | 274 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 275 base::WaitableEvent::InitialState::NOT_SIGNALED); |
274 BrowserThread::PostTask( | 276 BrowserThread::PostTask( |
275 BrowserThread::IO, FROM_HERE, base::Bind( | 277 BrowserThread::IO, FROM_HERE, base::Bind( |
276 &base::WaitableEvent::Signal, base::Unretained(&done))); | 278 &base::WaitableEvent::Signal, base::Unretained(&done))); |
277 done.Wait(); | 279 done.Wait(); |
278 ASSERT_TRUE(destination_); | 280 ASSERT_TRUE(destination_); |
279 | 281 |
280 EXPECT_CALL(*mock_vais_, AddOutputStream(NotNull(), _)) | 282 EXPECT_CALL(*mock_vais_, AddOutputStream(NotNull(), _)) |
281 .RetiresOnSaturation(); | 283 .RetiresOnSaturation(); |
282 // Later, when stream is closed: | 284 // Later, when stream is closed: |
283 EXPECT_CALL(*mock_vais_, RemoveOutputStream(NotNull(), _)) | 285 EXPECT_CALL(*mock_vais_, RemoveOutputStream(NotNull(), _)) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 WaitForData(); | 498 WaitForData(); |
497 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); | 499 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
498 WaitForData(); | 500 WaitForData(); |
499 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); | 501 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); |
500 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); | 502 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
501 RUN_ON_AUDIO_THREAD(Stop); | 503 RUN_ON_AUDIO_THREAD(Stop); |
502 RUN_ON_AUDIO_THREAD(Close); | 504 RUN_ON_AUDIO_THREAD(Close); |
503 } | 505 } |
504 | 506 |
505 } // namespace content | 507 } // namespace content |
OLD | NEW |