| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 // The first track and sink should not have been affected by changing the | 453 // The first track and sink should not have been affected by changing the |
| 454 // enabled state of the second track and sink. They should still be disabled, | 454 // enabled state of the second track and sink. They should still be disabled, |
| 455 // with silent audio being consumed at the sink. | 455 // with silent audio being consumed at the sink. |
| 456 EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, sink.enable_state()); | 456 EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, sink.enable_state()); |
| 457 EXPECT_TRUE(sink.is_audio_silent()); | 457 EXPECT_TRUE(sink.is_audio_silent()); |
| 458 | 458 |
| 459 MediaStreamAudioTrack::From(another_blink_track)->RemoveSink(&another_sink); | 459 MediaStreamAudioTrack::From(another_blink_track)->RemoveSink(&another_sink); |
| 460 track()->RemoveSink(&sink); | 460 track()->RemoveSink(&sink); |
| 461 } | 461 } |
| 462 | 462 |
| 463 // https://crbug.com/709231 tracks test failures on Mac10.9 Tests (dbg). | |
| 464 #if defined(OS_MACOSX) | |
| 465 #define MAYBE_CallbackOnTrackInitialization \ | |
| 466 DISABLED_CallbackOnTrackInitialization | |
| 467 #else | |
| 468 #define MAYBE_CallbackOnTrackInitialization CallbackOnTrackInitialization | |
| 469 #endif | |
| 470 // Tests that a callback is fired when initialization completes on a track. | 463 // Tests that a callback is fired when initialization completes on a track. |
| 471 TEST_F(MediaStreamAudioTest, MAYBE_CallbackOnTrackInitialization) { | 464 TEST_F(MediaStreamAudioTest, CallbackOnTrackInitialization) { |
| 472 // Create a source, connect it to track, and connect the track to a | 465 // Create a source, connect it to track, and connect the track to a |
| 473 // sink. | 466 // sink. |
| 474 blink_audio_source_.setExtraData(new FakeMediaStreamAudioSource()); | 467 blink_audio_source_.setExtraData(new FakeMediaStreamAudioSource()); |
| 475 ASSERT_TRUE(source()); | 468 ASSERT_TRUE(source()); |
| 476 EXPECT_TRUE(source()->ConnectToTrack(blink_audio_track_)); | 469 EXPECT_TRUE(source()->ConnectToTrack(blink_audio_track_)); |
| 477 ASSERT_TRUE(track()); | 470 ASSERT_TRUE(track()); |
| 478 FakeMediaStreamAudioSink sink; | 471 FakeMediaStreamAudioSink sink; |
| 479 ASSERT_TRUE(!sink.params().IsValid()); | 472 ASSERT_TRUE(!sink.params().IsValid()); |
| 480 track()->AddSink(&sink); | 473 track()->AddSink(&sink); |
| 481 // The test callback is not thread-safe, so needs to be called on the | 474 // The test callback is not thread-safe, so needs to be called on the |
| 482 // current thread, not the thread from which it is triggered. | 475 // current thread, not the thread from which it is triggered. |
| 483 track()->SetFormatConfiguredCallback(media::BindToCurrentLoop(base::Bind( | 476 track()->SetFormatConfiguredCallback(media::BindToCurrentLoop(base::Bind( |
| 484 &MediaStreamAudioTest::CallbackFunction, base::Unretained(this)))); | 477 &MediaStreamAudioTest::CallbackFunction, base::Unretained(this)))); |
| 485 EXPECT_FALSE(callback_is_called_); | 478 EXPECT_FALSE(callback_is_called_); |
| 486 // Wait until valid parameters are propagated to the sink, and then confirm | 479 // Wait until valid parameters are propagated to the sink, and then confirm |
| 487 // the parameters are correct at the track and the sink. | 480 // the parameters are correct at the track and the sink. |
| 488 while (!sink.params().IsValid()) | 481 while (!sink.params().IsValid()) |
| 489 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); | 482 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); |
| 490 // Since the callback is waiting to run on this thread, we have to run | 483 // Since the callback is waiting to run on this thread, we have to run |
| 491 // an event loop. | 484 // an event loop. |
| 492 base::RunLoop().RunUntilIdle(); | 485 base::RunLoop().RunUntilIdle(); |
| 493 EXPECT_TRUE(callback_is_called_); | 486 EXPECT_TRUE(callback_is_called_); |
| 494 track()->RemoveSink(&sink); | 487 track()->RemoveSink(&sink); |
| 495 } | 488 } |
| 496 | 489 |
| 497 } // namespace content | 490 } // namespace content |
| OLD | NEW |