OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/media/web_contents_audio_input_stream.h" |
| 6 |
| 7 #include <list> |
| 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" |
| 11 #include "base/message_loop.h" |
| 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/threading/thread.h" |
| 14 #include "content/browser/browser_thread_impl.h" |
| 15 #include "content/browser/renderer_host/media/audio_mirroring_manager.h" |
| 16 #include "content/browser/renderer_host/media/web_contents_capture_util.h" |
| 17 #include "media/audio/simple_sources.h" |
| 18 #include "media/audio/virtual_audio_input_stream.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 |
| 22 using ::testing::_; |
| 23 using ::testing::Assign; |
| 24 using ::testing::DoAll; |
| 25 using ::testing::Invoke; |
| 26 using ::testing::InvokeWithoutArgs; |
| 27 using ::testing::NotNull; |
| 28 using ::testing::SaveArg; |
| 29 using ::testing::WithArgs; |
| 30 |
| 31 using media::AudioInputStream; |
| 32 using media::AudioOutputStream; |
| 33 using media::AudioParameters; |
| 34 using media::SineWaveAudioSource; |
| 35 using media::VirtualAudioInputStream; |
| 36 using media::VirtualAudioOutputStream; |
| 37 |
| 38 namespace content { |
| 39 |
| 40 namespace { |
| 41 |
| 42 const int kRenderProcessId = 123; |
| 43 const int kRenderViewId = 456; |
| 44 const int kAnotherRenderProcessId = 789; |
| 45 const int kAnotherRenderViewId = 1; |
| 46 |
| 47 const AudioParameters& TestAudioParameters() { |
| 48 static const AudioParameters params( |
| 49 AudioParameters::AUDIO_FAKE, |
| 50 media::CHANNEL_LAYOUT_STEREO, |
| 51 AudioParameters::kAudioCDSampleRate, 16, |
| 52 AudioParameters::kAudioCDSampleRate / 100); |
| 53 return params; |
| 54 } |
| 55 |
| 56 class MockAudioMirroringManager : public AudioMirroringManager { |
| 57 public: |
| 58 MockAudioMirroringManager() : AudioMirroringManager() {} |
| 59 virtual ~MockAudioMirroringManager() {} |
| 60 |
| 61 MOCK_METHOD3(StartMirroring, |
| 62 void(int render_process_id, int render_view_id, |
| 63 MirroringDestination* destination)); |
| 64 MOCK_METHOD3(StopMirroring, |
| 65 void(int render_process_id, int render_view_id, |
| 66 MirroringDestination* destination)); |
| 67 |
| 68 private: |
| 69 DISALLOW_COPY_AND_ASSIGN(MockAudioMirroringManager); |
| 70 }; |
| 71 |
| 72 class MockWebContentsTracker : public WebContentsTracker { |
| 73 public: |
| 74 MockWebContentsTracker() : WebContentsTracker() {} |
| 75 |
| 76 MOCK_METHOD3(Start, |
| 77 void(int render_process_id, int render_view_id, |
| 78 const ChangeCallback& callback)); |
| 79 MOCK_METHOD0(Stop, void()); |
| 80 |
| 81 private: |
| 82 virtual ~MockWebContentsTracker() {} |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(MockWebContentsTracker); |
| 85 }; |
| 86 |
| 87 // A fully-functional VirtualAudioInputStream, but methods are mocked to allow |
| 88 // tests to check how/when they are invoked. |
| 89 class MockVirtualAudioInputStream : public VirtualAudioInputStream { |
| 90 public: |
| 91 explicit MockVirtualAudioInputStream(base::MessageLoopProxy* message_loop) |
| 92 : VirtualAudioInputStream( |
| 93 TestAudioParameters(), message_loop, |
| 94 base::Bind(&MockVirtualAudioInputStream::DoNothingAfterClose)), |
| 95 real_(TestAudioParameters(), message_loop, |
| 96 base::Bind(&MockVirtualAudioInputStream::OnRealStreamHasClosed, |
| 97 base::Unretained(this))), |
| 98 real_stream_is_closed_(false) { |
| 99 // Set default actions of mocked methods to delegate to the concrete |
| 100 // implementation. |
| 101 ON_CALL(*this, Open()) |
| 102 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::Open)); |
| 103 ON_CALL(*this, Start(_)) |
| 104 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::Start)); |
| 105 ON_CALL(*this, Stop()) |
| 106 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::Stop)); |
| 107 ON_CALL(*this, Close()) |
| 108 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::Close)); |
| 109 ON_CALL(*this, GetMaxVolume()) |
| 110 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::GetMaxVolume)); |
| 111 ON_CALL(*this, SetVolume(_)) |
| 112 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::SetVolume)); |
| 113 ON_CALL(*this, GetVolume()) |
| 114 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::GetVolume)); |
| 115 ON_CALL(*this, SetAutomaticGainControl(_)) |
| 116 .WillByDefault( |
| 117 Invoke(&real_, &VirtualAudioInputStream::SetAutomaticGainControl)); |
| 118 ON_CALL(*this, GetAutomaticGainControl()) |
| 119 .WillByDefault( |
| 120 Invoke(&real_, &VirtualAudioInputStream::GetAutomaticGainControl)); |
| 121 ON_CALL(*this, AddOutputStream(NotNull(), _)) |
| 122 .WillByDefault( |
| 123 Invoke(&real_, &VirtualAudioInputStream::AddOutputStream)); |
| 124 ON_CALL(*this, RemoveOutputStream(NotNull(), _)) |
| 125 .WillByDefault( |
| 126 Invoke(&real_, &VirtualAudioInputStream::RemoveOutputStream)); |
| 127 } |
| 128 |
| 129 ~MockVirtualAudioInputStream() { |
| 130 DCHECK(real_stream_is_closed_); |
| 131 } |
| 132 |
| 133 MOCK_METHOD0(Open, bool()); |
| 134 MOCK_METHOD1(Start, void(AudioInputStream::AudioInputCallback*)); |
| 135 MOCK_METHOD0(Stop, void()); |
| 136 MOCK_METHOD0(Close, void()); |
| 137 MOCK_METHOD0(GetMaxVolume, double()); |
| 138 MOCK_METHOD1(SetVolume, void(double)); |
| 139 MOCK_METHOD0(GetVolume, double()); |
| 140 MOCK_METHOD1(SetAutomaticGainControl, void(bool)); |
| 141 MOCK_METHOD0(GetAutomaticGainControl, bool()); |
| 142 MOCK_METHOD2(AddOutputStream, void(VirtualAudioOutputStream*, |
| 143 const AudioParameters&)); |
| 144 MOCK_METHOD2(RemoveOutputStream, void(VirtualAudioOutputStream*, |
| 145 const AudioParameters&)); |
| 146 |
| 147 private: |
| 148 void OnRealStreamHasClosed(VirtualAudioInputStream* stream) { |
| 149 DCHECK_EQ(&real_, stream); |
| 150 DCHECK(!real_stream_is_closed_); |
| 151 real_stream_is_closed_ = true; |
| 152 } |
| 153 |
| 154 static void DoNothingAfterClose(VirtualAudioInputStream* stream) {} |
| 155 |
| 156 VirtualAudioInputStream real_; |
| 157 bool real_stream_is_closed_; |
| 158 |
| 159 DISALLOW_COPY_AND_ASSIGN(MockVirtualAudioInputStream); |
| 160 }; |
| 161 |
| 162 class MockAudioInputCallback : public AudioInputStream::AudioInputCallback { |
| 163 public: |
| 164 MockAudioInputCallback() {} |
| 165 |
| 166 MOCK_METHOD5(OnData, void(AudioInputStream* stream, const uint8* src, |
| 167 uint32 size, uint32 hardware_delay_bytes, |
| 168 double volume)); |
| 169 MOCK_METHOD1(OnClose, void(AudioInputStream* stream)); |
| 170 MOCK_METHOD2(OnError, void(AudioInputStream* stream, int code)); |
| 171 |
| 172 private: |
| 173 DISALLOW_COPY_AND_ASSIGN(MockAudioInputCallback); |
| 174 }; |
| 175 |
| 176 } // namespace |
| 177 |
| 178 class WebContentsAudioInputStreamTest : public testing::Test { |
| 179 public: |
| 180 WebContentsAudioInputStreamTest() |
| 181 : audio_thread_("Audio thread"), |
| 182 io_thread_(BrowserThread::IO), |
| 183 mock_mirroring_manager_(new MockAudioMirroringManager()), |
| 184 mock_tracker_(new MockWebContentsTracker()), |
| 185 mock_vais_(NULL), |
| 186 wcais_(NULL), |
| 187 destination_(NULL), |
| 188 current_render_process_id_(kRenderProcessId), |
| 189 current_render_view_id_(kRenderViewId), |
| 190 on_data_event_(false, false) { |
| 191 audio_thread_.Start(); |
| 192 io_thread_.Start(); |
| 193 } |
| 194 |
| 195 virtual ~WebContentsAudioInputStreamTest() { |
| 196 audio_thread_.Stop(); |
| 197 io_thread_.Stop(); |
| 198 |
| 199 DCHECK(!mock_vais_); |
| 200 DCHECK(!wcais_); |
| 201 EXPECT_FALSE(destination_); |
| 202 DCHECK(streams_.empty()); |
| 203 DCHECK(sources_.empty()); |
| 204 } |
| 205 |
| 206 void Open() { |
| 207 mock_vais_ = |
| 208 new MockVirtualAudioInputStream(audio_thread_.message_loop_proxy()); |
| 209 EXPECT_CALL(*mock_vais_, Open()); |
| 210 EXPECT_CALL(*mock_vais_, Close()); // At Close() time. |
| 211 |
| 212 ASSERT_EQ(kRenderProcessId, current_render_process_id_); |
| 213 ASSERT_EQ(kRenderViewId, current_render_view_id_); |
| 214 EXPECT_CALL(*mock_tracker_, Start(kRenderProcessId, kRenderViewId, _)) |
| 215 .WillOnce(DoAll( |
| 216 SaveArg<2>(&change_callback_), |
| 217 WithArgs<0, 1>( |
| 218 Invoke(&change_callback_, |
| 219 &WebContentsTracker::ChangeCallback::Run)))); |
| 220 EXPECT_CALL(*mock_tracker_, Stop()); // At Close() time. |
| 221 |
| 222 wcais_ = new WebContentsAudioInputStream( |
| 223 current_render_process_id_, current_render_view_id_, |
| 224 audio_thread_.message_loop_proxy(), mock_mirroring_manager_.get(), |
| 225 mock_tracker_, mock_vais_); |
| 226 wcais_->Open(); |
| 227 } |
| 228 |
| 229 void Start() { |
| 230 EXPECT_CALL(*mock_vais_, Start(&mock_input_callback_)); |
| 231 EXPECT_CALL(*mock_vais_, Stop()); // At Stop() time. |
| 232 |
| 233 EXPECT_CALL(*mock_mirroring_manager_, |
| 234 StartMirroring(kRenderProcessId, kRenderViewId, NotNull())) |
| 235 .WillOnce(SaveArg<2>(&destination_)) |
| 236 .RetiresOnSaturation(); |
| 237 // At Stop() time, or when the mirroring target changes: |
| 238 EXPECT_CALL(*mock_mirroring_manager_, |
| 239 StopMirroring(kRenderProcessId, kRenderViewId, NotNull())) |
| 240 .WillOnce(Assign( |
| 241 &destination_, |
| 242 static_cast<AudioMirroringManager::MirroringDestination*>(NULL))) |
| 243 .RetiresOnSaturation(); |
| 244 |
| 245 EXPECT_CALL(mock_input_callback_, OnData(NotNull(), NotNull(), _, _, _)) |
| 246 .WillRepeatedly( |
| 247 InvokeWithoutArgs(&on_data_event_, &base::WaitableEvent::Signal)); |
| 248 EXPECT_CALL(mock_input_callback_, OnClose(_)); // At Stop() time. |
| 249 |
| 250 wcais_->Start(&mock_input_callback_); |
| 251 |
| 252 // Test plumbing of volume controls and automatic gain controls. Calls to |
| 253 // wcais_ methods should delegate directly to mock_vais_. |
| 254 EXPECT_CALL(*mock_vais_, GetVolume()); |
| 255 double volume = wcais_->GetVolume(); |
| 256 EXPECT_CALL(*mock_vais_, GetMaxVolume()); |
| 257 const double max_volume = wcais_->GetMaxVolume(); |
| 258 volume *= 2.0; |
| 259 if (volume < max_volume) { |
| 260 volume = max_volume; |
| 261 } |
| 262 EXPECT_CALL(*mock_vais_, SetVolume(volume)); |
| 263 wcais_->SetVolume(volume); |
| 264 EXPECT_CALL(*mock_vais_, GetAutomaticGainControl()); |
| 265 bool auto_gain = wcais_->GetAutomaticGainControl(); |
| 266 auto_gain = !auto_gain; |
| 267 EXPECT_CALL(*mock_vais_, SetAutomaticGainControl(auto_gain)); |
| 268 wcais_->SetAutomaticGainControl(auto_gain); |
| 269 } |
| 270 |
| 271 void AddAnotherInput() { |
| 272 // Note: WCAIS posts a task to invoke |
| 273 // MockAudioMirroringManager::StartMirroring() on the IO thread, which |
| 274 // causes our mock to set |destination_|. Block until that has happened. |
| 275 base::WaitableEvent done(false, false); |
| 276 BrowserThread::PostTask( |
| 277 BrowserThread::IO, FROM_HERE, base::Bind( |
| 278 &base::WaitableEvent::Signal, base::Unretained(&done))); |
| 279 done.Wait(); |
| 280 ASSERT_TRUE(destination_); |
| 281 |
| 282 EXPECT_CALL(*mock_vais_, AddOutputStream(NotNull(), _)) |
| 283 .RetiresOnSaturation(); |
| 284 // Later, when stream is closed: |
| 285 EXPECT_CALL(*mock_vais_, RemoveOutputStream(NotNull(), _)) |
| 286 .RetiresOnSaturation(); |
| 287 |
| 288 const AudioParameters& params = TestAudioParameters(); |
| 289 AudioOutputStream* const out = destination_->AddInput(params); |
| 290 ASSERT_TRUE(out); |
| 291 streams_.push_back(out); |
| 292 EXPECT_TRUE(out->Open()); |
| 293 SineWaveAudioSource* const source = new SineWaveAudioSource( |
| 294 params.channel_layout(), 200.0, params.sample_rate()); |
| 295 sources_.push_back(source); |
| 296 out->Start(source); |
| 297 } |
| 298 |
| 299 void RemoveOneInputInFIFOOrder() { |
| 300 ASSERT_FALSE(streams_.empty()); |
| 301 AudioOutputStream* const out = streams_.front(); |
| 302 streams_.pop_front(); |
| 303 out->Stop(); |
| 304 out->Close(); // Self-deletes. |
| 305 ASSERT_TRUE(!sources_.empty()); |
| 306 delete sources_.front(); |
| 307 sources_.pop_front(); |
| 308 } |
| 309 |
| 310 void ChangeMirroringTarget() { |
| 311 const int next_render_process_id = |
| 312 current_render_process_id_ == kRenderProcessId ? |
| 313 kAnotherRenderProcessId : kRenderProcessId; |
| 314 const int next_render_view_id = |
| 315 current_render_view_id_ == kRenderViewId ? |
| 316 kAnotherRenderViewId : kRenderViewId; |
| 317 |
| 318 EXPECT_CALL(*mock_mirroring_manager_, |
| 319 StartMirroring(next_render_process_id, next_render_view_id, |
| 320 NotNull())) |
| 321 .WillOnce(SaveArg<2>(&destination_)) |
| 322 .RetiresOnSaturation(); |
| 323 // At Stop() time, or when the mirroring target changes: |
| 324 EXPECT_CALL(*mock_mirroring_manager_, |
| 325 StopMirroring(next_render_process_id, next_render_view_id, |
| 326 NotNull())) |
| 327 .WillOnce(Assign( |
| 328 &destination_, |
| 329 static_cast<AudioMirroringManager::MirroringDestination*>(NULL))) |
| 330 .RetiresOnSaturation(); |
| 331 |
| 332 // Simulate OnTargetChange() callback from WebContentsTracker. |
| 333 EXPECT_FALSE(change_callback_.is_null()); |
| 334 change_callback_.Run(next_render_process_id, next_render_view_id); |
| 335 |
| 336 current_render_process_id_ = next_render_process_id; |
| 337 current_render_view_id_ = next_render_view_id; |
| 338 } |
| 339 |
| 340 void LoseMirroringTarget() { |
| 341 EXPECT_CALL(mock_input_callback_, OnError(_, _)); |
| 342 |
| 343 // Simulate OnTargetChange() callback from WebContentsTracker. |
| 344 EXPECT_FALSE(change_callback_.is_null()); |
| 345 change_callback_.Run(-1, -1); |
| 346 } |
| 347 |
| 348 void Stop() { |
| 349 wcais_->Stop(); |
| 350 } |
| 351 |
| 352 void Close() { |
| 353 // WebContentsAudioInputStream self-destructs on Close(). Its internal |
| 354 // objects hang around until they are no longer referred to (e.g., as tasks |
| 355 // on other threads shut things down). |
| 356 wcais_->Close(); |
| 357 wcais_ = NULL; |
| 358 mock_vais_ = NULL; |
| 359 } |
| 360 |
| 361 void RunOnAudioThread(const base::Closure& closure) { |
| 362 audio_thread_.message_loop()->PostTask(FROM_HERE, closure); |
| 363 } |
| 364 |
| 365 // Block the calling thread until OnData() callbacks are being made. |
| 366 void WaitForData() { |
| 367 // Note: Arbitrarily chosen, but more iterations causes tests to take |
| 368 // significantly more time. |
| 369 static const int kNumIterations = 3; |
| 370 for (int i = 0; i < kNumIterations; ++i) |
| 371 on_data_event_.Wait(); |
| 372 } |
| 373 |
| 374 private: |
| 375 base::Thread audio_thread_; |
| 376 BrowserThreadImpl io_thread_; |
| 377 |
| 378 scoped_ptr<MockAudioMirroringManager> mock_mirroring_manager_; |
| 379 scoped_refptr<MockWebContentsTracker> mock_tracker_; |
| 380 |
| 381 MockVirtualAudioInputStream* mock_vais_; // Owned by wcais_. |
| 382 WebContentsAudioInputStream* wcais_; // Self-destructs on Close(). |
| 383 |
| 384 // Mock consumer of audio data. |
| 385 MockAudioInputCallback mock_input_callback_; |
| 386 |
| 387 // Provided by WebContentsAudioInputStream to the mock WebContentsTracker. |
| 388 // This callback is saved here, and test code will invoke it to simulate |
| 389 // target change events. |
| 390 WebContentsTracker::ChangeCallback change_callback_; |
| 391 |
| 392 // Provided by WebContentsAudioInputStream to the mock AudioMirroringManager. |
| 393 // A pointer to the implementation is saved here, and test code will invoke it |
| 394 // to simulate: 1) calls to AddInput(); and 2) diverting audio data. |
| 395 AudioMirroringManager::MirroringDestination* destination_; |
| 396 |
| 397 // Current target RenderView. These get flipped in ChangedMirroringTarget(). |
| 398 int current_render_process_id_; |
| 399 int current_render_view_id_; |
| 400 |
| 401 // Streams provided by calls to WebContentsAudioInputStream::AddInput(). Each |
| 402 // is started with a simulated source of audio data. |
| 403 std::list<AudioOutputStream*> streams_; |
| 404 std::list<SineWaveAudioSource*> sources_; // 1:1 with elements in streams_. |
| 405 |
| 406 base::WaitableEvent on_data_event_; |
| 407 |
| 408 DISALLOW_COPY_AND_ASSIGN(WebContentsAudioInputStreamTest); |
| 409 }; |
| 410 |
| 411 #define RUN_ON_AUDIO_THREAD(method) \ |
| 412 RunOnAudioThread(base::Bind(&WebContentsAudioInputStreamTest::method, \ |
| 413 base::Unretained(this))) |
| 414 |
| 415 TEST_F(WebContentsAudioInputStreamTest, OpenedButNeverStarted) { |
| 416 RUN_ON_AUDIO_THREAD(Open); |
| 417 RUN_ON_AUDIO_THREAD(Close); |
| 418 } |
| 419 |
| 420 TEST_F(WebContentsAudioInputStreamTest, MirroringNothing) { |
| 421 RUN_ON_AUDIO_THREAD(Open); |
| 422 RUN_ON_AUDIO_THREAD(Start); |
| 423 RUN_ON_AUDIO_THREAD(Stop); |
| 424 RUN_ON_AUDIO_THREAD(Close); |
| 425 } |
| 426 |
| 427 TEST_F(WebContentsAudioInputStreamTest, MirroringOutputOutlivesSession) { |
| 428 RUN_ON_AUDIO_THREAD(Open); |
| 429 RUN_ON_AUDIO_THREAD(Start); |
| 430 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 431 WaitForData(); |
| 432 RUN_ON_AUDIO_THREAD(Stop); |
| 433 RUN_ON_AUDIO_THREAD(Close); |
| 434 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 435 } |
| 436 |
| 437 TEST_F(WebContentsAudioInputStreamTest, MirroringOutputWithinSession) { |
| 438 RUN_ON_AUDIO_THREAD(Open); |
| 439 RUN_ON_AUDIO_THREAD(Start); |
| 440 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 441 WaitForData(); |
| 442 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 443 RUN_ON_AUDIO_THREAD(Stop); |
| 444 RUN_ON_AUDIO_THREAD(Close); |
| 445 } |
| 446 |
| 447 TEST_F(WebContentsAudioInputStreamTest, MirroringNothingWithTargetChange) { |
| 448 RUN_ON_AUDIO_THREAD(Open); |
| 449 RUN_ON_AUDIO_THREAD(Start); |
| 450 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); |
| 451 RUN_ON_AUDIO_THREAD(Stop); |
| 452 RUN_ON_AUDIO_THREAD(Close); |
| 453 } |
| 454 |
| 455 TEST_F(WebContentsAudioInputStreamTest, MirroringOneStreamAfterTargetChange) { |
| 456 RUN_ON_AUDIO_THREAD(Open); |
| 457 RUN_ON_AUDIO_THREAD(Start); |
| 458 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); |
| 459 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 460 WaitForData(); |
| 461 RUN_ON_AUDIO_THREAD(Stop); |
| 462 RUN_ON_AUDIO_THREAD(Close); |
| 463 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 464 } |
| 465 |
| 466 TEST_F(WebContentsAudioInputStreamTest, MirroringOneStreamWithTargetChange) { |
| 467 RUN_ON_AUDIO_THREAD(Open); |
| 468 RUN_ON_AUDIO_THREAD(Start); |
| 469 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 470 WaitForData(); |
| 471 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); |
| 472 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 473 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 474 WaitForData(); |
| 475 RUN_ON_AUDIO_THREAD(Stop); |
| 476 RUN_ON_AUDIO_THREAD(Close); |
| 477 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 478 } |
| 479 |
| 480 TEST_F(WebContentsAudioInputStreamTest, MirroringLostTarget) { |
| 481 RUN_ON_AUDIO_THREAD(Open); |
| 482 RUN_ON_AUDIO_THREAD(Start); |
| 483 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 484 WaitForData(); |
| 485 RUN_ON_AUDIO_THREAD(LoseMirroringTarget); |
| 486 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 487 RUN_ON_AUDIO_THREAD(Stop); |
| 488 RUN_ON_AUDIO_THREAD(Close); |
| 489 } |
| 490 |
| 491 TEST_F(WebContentsAudioInputStreamTest, MirroringMultipleStreamsAndTargets) { |
| 492 RUN_ON_AUDIO_THREAD(Open); |
| 493 RUN_ON_AUDIO_THREAD(Start); |
| 494 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 495 WaitForData(); |
| 496 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 497 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 498 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 499 WaitForData(); |
| 500 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); |
| 501 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 502 WaitForData(); |
| 503 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 504 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 505 RUN_ON_AUDIO_THREAD(AddAnotherInput); |
| 506 WaitForData(); |
| 507 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 508 WaitForData(); |
| 509 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); |
| 510 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
| 511 RUN_ON_AUDIO_THREAD(Stop); |
| 512 RUN_ON_AUDIO_THREAD(Close); |
| 513 } |
| 514 |
| 515 } // namespace content |
OLD | NEW |