OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "media/audio/audio_output_dispatcher_impl.h" | 10 #include "media/audio/audio_output_dispatcher_impl.h" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 EXPECT_CALL(okay_stream, Close()) | 610 EXPECT_CALL(okay_stream, Close()) |
611 .Times(1); | 611 .Times(1); |
612 | 612 |
613 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); | 613 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); |
614 EXPECT_TRUE(proxy->Open()); | 614 EXPECT_TRUE(proxy->Open()); |
615 proxy->Close(); | 615 proxy->Close(); |
616 WaitForCloseTimer(kTestCloseDelayMs); | 616 WaitForCloseTimer(kTestCloseDelayMs); |
617 } | 617 } |
618 | 618 |
619 // Simulate failures to open both the low latency and the fallback high latency | 619 // Simulate failures to open both the low latency and the fallback high latency |
620 // stream and ensure AudioOutputResampler terminates normally. | 620 // stream and ensure AudioOutputResampler falls back to a fake stream. |
621 TEST_F(AudioOutputResamplerTest, LowLatencyFallbackFailed) { | 621 TEST_F(AudioOutputResamplerTest, HighLatencyFallbackFailed) { |
| 622 MockAudioOutputStream okay_stream(&manager_, params_); |
| 623 |
622 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) | 624 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) |
623 .Times(2) | 625 .Times(2) |
624 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL))); | 626 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL))); |
625 | 627 |
| 628 // To prevent shared memory issues the sample rate and buffer size should |
| 629 // match the input stream parameters. |
| 630 EXPECT_CALL(manager(), MakeAudioOutputStream(AllOf( |
| 631 testing::Property(&AudioParameters::format, AudioParameters::AUDIO_FAKE), |
| 632 testing::Property(&AudioParameters::sample_rate, params_.sample_rate()), |
| 633 testing::Property( |
| 634 &AudioParameters::frames_per_buffer, params_.frames_per_buffer())))) |
| 635 .Times(1) |
| 636 .WillOnce(Return(&okay_stream)); |
| 637 EXPECT_CALL(okay_stream, Open()) |
| 638 .WillOnce(Return(true)); |
| 639 EXPECT_CALL(okay_stream, Close()) |
| 640 .Times(1); |
| 641 |
| 642 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); |
| 643 EXPECT_TRUE(proxy->Open()); |
| 644 proxy->Close(); |
| 645 WaitForCloseTimer(kTestCloseDelayMs); |
| 646 } |
| 647 |
| 648 // Simulate failures to open both the low latency, the fallback high latency |
| 649 // stream, and the fake audio output stream and ensure AudioOutputResampler |
| 650 // terminates normally. |
| 651 TEST_F(AudioOutputResamplerTest, AllFallbackFailed) { |
| 652 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) |
| 653 .Times(3) |
| 654 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL))); |
| 655 |
626 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); | 656 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); |
627 EXPECT_FALSE(proxy->Open()); | 657 EXPECT_FALSE(proxy->Open()); |
628 proxy->Close(); | 658 proxy->Close(); |
629 WaitForCloseTimer(kTestCloseDelayMs); | 659 WaitForCloseTimer(kTestCloseDelayMs); |
630 } | 660 } |
631 | 661 |
632 // Simulate an eventual OpenStream() failure; i.e. successful OpenStream() calls | 662 // Simulate an eventual OpenStream() failure; i.e. successful OpenStream() calls |
633 // eventually followed by one which fails; root cause of http://crbug.com/150619 | 663 // eventually followed by one which fails; root cause of http://crbug.com/150619 |
634 TEST_F(AudioOutputResamplerTest, LowLatencyOpenEventuallyFails) { | 664 TEST_F(AudioOutputResamplerTest, LowLatencyOpenEventuallyFails) { |
635 MockAudioOutputStream stream1(&manager_, params_); | 665 MockAudioOutputStream stream1(&manager_, params_); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 WaitForCloseTimer(kTestCloseDelayMs); | 726 WaitForCloseTimer(kTestCloseDelayMs); |
697 EXPECT_TRUE(stream1.stop_called()); | 727 EXPECT_TRUE(stream1.stop_called()); |
698 EXPECT_TRUE(stream1.start_called()); | 728 EXPECT_TRUE(stream1.start_called()); |
699 EXPECT_TRUE(stream2.stop_called()); | 729 EXPECT_TRUE(stream2.stop_called()); |
700 EXPECT_TRUE(stream2.start_called()); | 730 EXPECT_TRUE(stream2.start_called()); |
701 EXPECT_FALSE(stream3.stop_called()); | 731 EXPECT_FALSE(stream3.stop_called()); |
702 EXPECT_FALSE(stream3.start_called()); | 732 EXPECT_FALSE(stream3.start_called()); |
703 } | 733 } |
704 | 734 |
705 } // namespace media | 735 } // namespace media |
OLD | NEW |