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