Chromium Code Reviews| 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 .Times(1); | |
| 768 EXPECT_CALL(stream1, SetVolume(_)) | |
| 769 .Times(1); | |
| 770 EXPECT_CALL(stream2, Open()) | |
| 771 .WillOnce(Return(true)); | |
| 772 EXPECT_CALL(stream2, Close()) | |
| 773 .Times(1); | |
| 774 | |
| 775 // Open and start the first proxy and stream. | |
| 776 AudioOutputProxy* proxy1 = new AudioOutputProxy(resampler_.get()); | |
| 777 EXPECT_TRUE(proxy1->Open()); | |
| 778 proxy1->Start(&callback_); | |
| 779 OnStart(); | |
| 780 | |
| 781 // Open, but do not start the second proxy. | |
| 782 AudioOutputProxy* proxy2 = new AudioOutputProxy(resampler_.get()); | |
| 783 EXPECT_TRUE(proxy2->Open()); | |
| 784 | |
| 785 // Wait for stream to timeout and shutdown. | |
| 786 WaitForCloseTimer(kTestCloseDelayMs); | |
| 787 | |
| 788 resampler_->CloseStreamsForWedgeFix(); | |
| 789 | |
| 790 // Stream3 should take Stream1's place after RestartStreamsForWedgeFix(). | |
| 791 EXPECT_CALL(stream3, Open()) | |
| 792 .WillOnce(Return(true)); | |
| 793 EXPECT_CALL(stream3, Close()) | |
| 794 .Times(1); | |
| 795 EXPECT_CALL(stream3, SetVolume(_)) | |
| 796 .Times(1); | |
| 797 | |
| 798 resampler_->RestartStreamsForWedgeFix(); | |
| 799 OnStart(); | |
| 800 | |
| 801 // Perform the required Stop()/Close() shutdown dance for each proxy. | |
| 802 proxy2->Close(); | |
| 803 proxy1->Stop(); | |
| 804 proxy1->Close(); | |
| 805 | |
| 806 // Wait for all of the messages to fly and then verify stream behavior. | |
| 807 WaitForCloseTimer(kTestCloseDelayMs); | |
| 808 EXPECT_TRUE(stream1.stop_called()); | |
| 809 EXPECT_TRUE(stream1.start_called()); | |
| 810 EXPECT_FALSE(stream2.stop_called()); | |
| 811 EXPECT_FALSE(stream2.start_called()); | |
| 812 EXPECT_TRUE(stream3.stop_called()); | |
| 813 EXPECT_TRUE(stream3.start_called()); | |
| 814 } | |
| 815 | |
| 816 | |
|
scherkus (not reviewing)
2013/12/02 21:49:37
remove extra line
| |
| 751 } // namespace media | 817 } // namespace media |
| OLD | NEW |