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 |
463 // Tests that a callback is fired when initialization completes on a track. | 470 // Tests that a callback is fired when initialization completes on a track. |
464 TEST_F(MediaStreamAudioTest, CallbackOnTrackInitialization) { | 471 TEST_F(MediaStreamAudioTest, MAYBE_CallbackOnTrackInitialization) { |
465 // Create a source, connect it to track, and connect the track to a | 472 // Create a source, connect it to track, and connect the track to a |
466 // sink. | 473 // sink. |
467 blink_audio_source_.setExtraData(new FakeMediaStreamAudioSource()); | 474 blink_audio_source_.setExtraData(new FakeMediaStreamAudioSource()); |
468 ASSERT_TRUE(source()); | 475 ASSERT_TRUE(source()); |
469 EXPECT_TRUE(source()->ConnectToTrack(blink_audio_track_)); | 476 EXPECT_TRUE(source()->ConnectToTrack(blink_audio_track_)); |
470 ASSERT_TRUE(track()); | 477 ASSERT_TRUE(track()); |
471 FakeMediaStreamAudioSink sink; | 478 FakeMediaStreamAudioSink sink; |
472 ASSERT_TRUE(!sink.params().IsValid()); | 479 ASSERT_TRUE(!sink.params().IsValid()); |
473 track()->AddSink(&sink); | 480 track()->AddSink(&sink); |
474 // The test callback is not thread-safe, so needs to be called on the | 481 // The test callback is not thread-safe, so needs to be called on the |
475 // current thread, not the thread from which it is triggered. | 482 // current thread, not the thread from which it is triggered. |
476 track()->SetFormatConfiguredCallback(media::BindToCurrentLoop(base::Bind( | 483 track()->SetFormatConfiguredCallback(media::BindToCurrentLoop(base::Bind( |
477 &MediaStreamAudioTest::CallbackFunction, base::Unretained(this)))); | 484 &MediaStreamAudioTest::CallbackFunction, base::Unretained(this)))); |
478 EXPECT_FALSE(callback_is_called_); | 485 EXPECT_FALSE(callback_is_called_); |
479 // Wait until valid parameters are propagated to the sink, and then confirm | 486 // Wait until valid parameters are propagated to the sink, and then confirm |
480 // the parameters are correct at the track and the sink. | 487 // the parameters are correct at the track and the sink. |
481 while (!sink.params().IsValid()) | 488 while (!sink.params().IsValid()) |
482 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); | 489 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); |
483 // Since the callback is waiting to run on this thread, we have to run | 490 // Since the callback is waiting to run on this thread, we have to run |
484 // an event loop. | 491 // an event loop. |
485 base::RunLoop().RunUntilIdle(); | 492 base::RunLoop().RunUntilIdle(); |
486 EXPECT_TRUE(callback_is_called_); | 493 EXPECT_TRUE(callback_is_called_); |
487 track()->RemoveSink(&sink); | 494 track()->RemoveSink(&sink); |
488 } | 495 } |
489 | 496 |
490 } // namespace content | 497 } // namespace content |
OLD | NEW |