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/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 "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 860 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) | 860 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) |
| 861 .Times(2) | 861 .Times(2) |
| 862 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL))); | 862 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL))); |
| 863 | 863 |
| 864 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); | 864 AudioOutputProxy* proxy = new AudioOutputProxy(resampler_); |
| 865 EXPECT_FALSE(proxy->Open()); | 865 EXPECT_FALSE(proxy->Open()); |
| 866 proxy->Close(); | 866 proxy->Close(); |
| 867 WaitForCloseTimer(kTestCloseDelayMs); | 867 WaitForCloseTimer(kTestCloseDelayMs); |
| 868 } | 868 } |
| 869 | 869 |
| 870 // Simulate an eventual OpenStream() failure; i.e. successful OpenStream() calls | |
| 871 // eventually followed by one which fails; root cause of http://crbug.com/150619 | |
| 872 TEST_F(AudioOutputResamplerTest, LowLatencyOpenEventuallyFails) { | |
|
tommi (sloooow) - chröme
2012/09/21 08:46:27
nice!
henrika (OOO until Aug 14)
2012/09/21 09:27:40
+1
| |
| 873 MockAudioOutputStream stream1(params_); | |
| 874 MockAudioOutputStream stream2(params_); | |
| 875 MockAudioOutputStream stream3(params_); | |
| 876 | |
| 877 // Setup the mock such that all three streams are successfully created. | |
| 878 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) | |
| 879 .WillOnce(Return(&stream1)) | |
| 880 .WillOnce(Return(&stream2)) | |
| 881 .WillOnce(Return(&stream3)) | |
| 882 .WillRepeatedly(Return(static_cast<AudioOutputStream*>(NULL))); | |
| 883 | |
| 884 // Stream1 should be able to successfully open and start. | |
| 885 EXPECT_CALL(stream1, Open()) | |
| 886 .WillOnce(Return(true)); | |
| 887 EXPECT_CALL(stream1, Close()) | |
| 888 .Times(1); | |
| 889 EXPECT_CALL(stream1, SetVolume(_)) | |
| 890 .Times(1); | |
| 891 | |
| 892 // Stream2 should also be able to successfully open and start. | |
| 893 EXPECT_CALL(stream2, Open()) | |
| 894 .WillOnce(Return(true)); | |
| 895 EXPECT_CALL(stream2, Close()) | |
| 896 .Times(1); | |
| 897 EXPECT_CALL(stream2, SetVolume(_)) | |
| 898 .Times(1); | |
| 899 | |
| 900 // Stream3 should fail on Open() (yet still be closed since | |
| 901 // MakeAudioOutputStream returned a valid AudioOutputStream object). | |
| 902 EXPECT_CALL(stream3, Open()) | |
| 903 .WillOnce(Return(false)); | |
| 904 EXPECT_CALL(stream3, Close()) | |
| 905 .Times(1); | |
| 906 | |
| 907 // Open and start the first proxy and stream. | |
| 908 AudioOutputProxy* proxy1 = new AudioOutputProxy(resampler_); | |
| 909 EXPECT_TRUE(proxy1->Open()); | |
| 910 proxy1->Start(&callback_); | |
| 911 OnStart(); | |
| 912 | |
| 913 // Open and start the second proxy and stream. | |
| 914 AudioOutputProxy* proxy2 = new AudioOutputProxy(resampler_); | |
| 915 EXPECT_TRUE(proxy2->Open()); | |
| 916 proxy2->Start(&callback_); | |
| 917 OnStart(); | |
| 918 | |
| 919 // Attempt to open the third stream which should fail. | |
| 920 AudioOutputProxy* proxy3 = new AudioOutputProxy(resampler_); | |
| 921 EXPECT_FALSE(proxy3->Open()); | |
| 922 | |
| 923 // Perform the required Stop()/Close() shutdown dance for each proxy. Under | |
| 924 // the hood each proxy should correctly call CloseStream() if OpenStream() | |
| 925 // succeeded or not. | |
| 926 proxy3->Stop(); | |
| 927 proxy3->Close(); | |
| 928 proxy2->Stop(); | |
| 929 proxy2->Close(); | |
| 930 proxy1->Stop(); | |
| 931 proxy1->Close(); | |
| 932 | |
| 933 // Wait for all of the messages to fly and then verify stream behavior. | |
| 934 WaitForCloseTimer(kTestCloseDelayMs); | |
| 935 EXPECT_TRUE(stream1.stop_called()); | |
| 936 EXPECT_TRUE(stream1.start_called()); | |
| 937 EXPECT_TRUE(stream2.stop_called()); | |
| 938 EXPECT_TRUE(stream2.start_called()); | |
| 939 EXPECT_FALSE(stream3.stop_called()); | |
| 940 EXPECT_FALSE(stream3.start_called()); | |
| 941 } | |
| 942 | |
| 870 } // namespace media | 943 } // namespace media |
| OLD | NEW |