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