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/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "media/audio/audio_manager.h" | 9 #include "media/audio/audio_manager.h" |
10 #include "media/audio/audio_manager_base.h" | 10 #include "media/audio/audio_manager_base.h" |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 // Wait for all of the messages to fly and then verify stream behavior. | 741 // Wait for all of the messages to fly and then verify stream behavior. |
742 WaitForCloseTimer(kTestCloseDelayMs); | 742 WaitForCloseTimer(kTestCloseDelayMs); |
743 EXPECT_TRUE(stream1.stop_called()); | 743 EXPECT_TRUE(stream1.stop_called()); |
744 EXPECT_TRUE(stream1.start_called()); | 744 EXPECT_TRUE(stream1.start_called()); |
745 EXPECT_TRUE(stream2.stop_called()); | 745 EXPECT_TRUE(stream2.stop_called()); |
746 EXPECT_TRUE(stream2.start_called()); | 746 EXPECT_TRUE(stream2.start_called()); |
747 EXPECT_FALSE(stream3.stop_called()); | 747 EXPECT_FALSE(stream3.stop_called()); |
748 EXPECT_FALSE(stream3.start_called()); | 748 EXPECT_FALSE(stream3.start_called()); |
749 } | 749 } |
750 | 750 |
751 // Ensures the methods used to fix audio output wedges are working correctly. | |
752 TEST_F(AudioOutputResamplerTest, WedgeFix) { | |
753 MockAudioOutputStream stream1(&manager_, params_); | |
754 MockAudioOutputStream stream2(&manager_, params_); | |
755 MockAudioOutputStream stream3(&manager_, params_); | |
756 | |
757 // Setup the mock such that all three streams are successfully created. | |
758 EXPECT_CALL(manager(), MakeAudioOutputStream(_, _, _)) | |
759 .WillOnce(Return(&stream1)) | |
760 .WillOnce(Return(&stream2)) | |
761 .WillOnce(Return(&stream3)); | |
762 | |
763 // Stream1 should be able to successfully open and start. | |
764 EXPECT_CALL(stream1, Open()) | |
765 .WillOnce(Return(true)); | |
766 EXPECT_CALL(stream1, Close()); | |
767 EXPECT_CALL(stream1, SetVolume(_)); | |
768 EXPECT_CALL(stream2, Open()) | |
769 .WillOnce(Return(true)); | |
770 EXPECT_CALL(stream2, Close()); | |
771 | |
772 // Open and start the first proxy and stream. | |
773 AudioOutputProxy* proxy1 = new AudioOutputProxy(resampler_.get()); | |
774 EXPECT_TRUE(proxy1->Open()); | |
775 proxy1->Start(&callback_); | |
776 OnStart(); | |
777 | |
778 // Open, but do not start the second proxy. | |
779 AudioOutputProxy* proxy2 = new AudioOutputProxy(resampler_.get()); | |
780 EXPECT_TRUE(proxy2->Open()); | |
781 | |
782 // Wait for stream to timeout and shutdown. | |
783 WaitForCloseTimer(kTestCloseDelayMs); | |
784 | |
785 resampler_->CloseStreamsForWedgeFix(); | |
786 | |
787 // Stream3 should take Stream1's place after RestartStreamsForWedgeFix(). | |
788 EXPECT_CALL(stream3, Open()) | |
789 .WillOnce(Return(true)); | |
790 EXPECT_CALL(stream3, Close()); | |
791 EXPECT_CALL(stream3, SetVolume(_)); | |
792 | |
793 resampler_->RestartStreamsForWedgeFix(); | |
794 OnStart(); | |
795 | |
796 // Perform the required Stop()/Close() shutdown dance for each proxy. | |
797 proxy2->Close(); | |
798 proxy1->Stop(); | |
799 proxy1->Close(); | |
800 | |
801 // Wait for all of the messages to fly and then verify stream behavior. | |
802 WaitForCloseTimer(kTestCloseDelayMs); | |
803 EXPECT_TRUE(stream1.stop_called()); | |
804 EXPECT_TRUE(stream1.start_called()); | |
805 EXPECT_FALSE(stream2.stop_called()); | |
806 EXPECT_FALSE(stream2.start_called()); | |
807 EXPECT_TRUE(stream3.stop_called()); | |
808 EXPECT_TRUE(stream3.start_called()); | |
809 } | |
810 | |
811 } // namespace media | 751 } // namespace media |
OLD | NEW |