| 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" | |
| 9 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 10 #include "media/audio/audio_manager.h" | 9 #include "media/audio/audio_manager.h" |
| 11 #include "media/audio/audio_manager_base.h" | 10 #include "media/audio/audio_manager_base.h" |
| 12 #include "media/audio/audio_output_dispatcher_impl.h" | 11 #include "media/audio/audio_output_dispatcher_impl.h" |
| 13 #include "media/audio/audio_output_proxy.h" | 12 #include "media/audio/audio_output_proxy.h" |
| 14 #include "media/audio/audio_output_resampler.h" | 13 #include "media/audio/audio_output_resampler.h" |
| 15 #include "media/audio/fake_audio_log_factory.h" | 14 #include "media/audio/fake_audio_log_factory.h" |
| 16 #include "media/audio/fake_audio_output_stream.h" | 15 #include "media/audio/fake_audio_output_stream.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 const AudioParameters& params, | 97 const AudioParameters& params, |
| 99 const std::string& device_id, | 98 const std::string& device_id, |
| 100 const std::string& input_device_id)); | 99 const std::string& input_device_id)); |
| 101 MOCK_METHOD3(MakeAudioOutputStreamProxy, AudioOutputStream*( | 100 MOCK_METHOD3(MakeAudioOutputStreamProxy, AudioOutputStream*( |
| 102 const AudioParameters& params, | 101 const AudioParameters& params, |
| 103 const std::string& device_id, | 102 const std::string& device_id, |
| 104 const std::string& input_device_id)); | 103 const std::string& input_device_id)); |
| 105 MOCK_METHOD2(MakeAudioInputStream, AudioInputStream*( | 104 MOCK_METHOD2(MakeAudioInputStream, AudioInputStream*( |
| 106 const AudioParameters& params, const std::string& device_id)); | 105 const AudioParameters& params, const std::string& device_id)); |
| 107 MOCK_METHOD0(ShowAudioInputSettings, void()); | 106 MOCK_METHOD0(ShowAudioInputSettings, void()); |
| 108 MOCK_METHOD0(GetMessageLoop, scoped_refptr<base::MessageLoopProxy>()); | 107 MOCK_METHOD0(GetTaskRunner, scoped_refptr<base::SingleThreadTaskRunner>()); |
| 109 MOCK_METHOD0(GetWorkerLoop, scoped_refptr<base::MessageLoopProxy>()); | 108 MOCK_METHOD0(GetWorkerTaskRunner, |
| 109 scoped_refptr<base::SingleThreadTaskRunner>()); |
| 110 MOCK_METHOD1(GetAudioInputDeviceNames, void( | 110 MOCK_METHOD1(GetAudioInputDeviceNames, void( |
| 111 media::AudioDeviceNames* device_name)); | 111 media::AudioDeviceNames* device_name)); |
| 112 | 112 |
| 113 MOCK_METHOD1(MakeLinearOutputStream, AudioOutputStream*( | 113 MOCK_METHOD1(MakeLinearOutputStream, AudioOutputStream*( |
| 114 const AudioParameters& params)); | 114 const AudioParameters& params)); |
| 115 MOCK_METHOD3(MakeLowLatencyOutputStream, AudioOutputStream*( | 115 MOCK_METHOD3(MakeLowLatencyOutputStream, AudioOutputStream*( |
| 116 const AudioParameters& params, const std::string& device_id, | 116 const AudioParameters& params, const std::string& device_id, |
| 117 const std::string& input_device_id)); | 117 const std::string& input_device_id)); |
| 118 MOCK_METHOD2(MakeLinearInputStream, AudioInputStream*( | 118 MOCK_METHOD2(MakeLinearInputStream, AudioInputStream*( |
| 119 const AudioParameters& params, const std::string& device_id)); | 119 const AudioParameters& params, const std::string& device_id)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 139 MOCK_METHOD1(OnError, void(AudioOutputStream* stream)); | 139 MOCK_METHOD1(OnError, void(AudioOutputStream* stream)); |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 } // namespace | 142 } // namespace |
| 143 | 143 |
| 144 namespace media { | 144 namespace media { |
| 145 | 145 |
| 146 class AudioOutputProxyTest : public testing::Test { | 146 class AudioOutputProxyTest : public testing::Test { |
| 147 protected: | 147 protected: |
| 148 virtual void SetUp() { | 148 virtual void SetUp() { |
| 149 EXPECT_CALL(manager_, GetMessageLoop()) | 149 EXPECT_CALL(manager_, GetTaskRunner()) |
| 150 .WillRepeatedly(Return(message_loop_.message_loop_proxy())); | 150 .WillRepeatedly(Return(message_loop_.message_loop_proxy())); |
| 151 EXPECT_CALL(manager_, GetWorkerLoop()) | 151 EXPECT_CALL(manager_, GetWorkerTaskRunner()) |
| 152 .WillRepeatedly(Return(message_loop_.message_loop_proxy())); | 152 .WillRepeatedly(Return(message_loop_.message_loop_proxy())); |
| 153 // Use a low sample rate and large buffer size when testing otherwise the | 153 // Use a low sample rate and large buffer size when testing otherwise the |
| 154 // FakeAudioOutputStream will keep the message loop busy indefinitely; i.e., | 154 // FakeAudioOutputStream will keep the message loop busy indefinitely; i.e., |
| 155 // RunUntilIdle() will never terminate. | 155 // RunUntilIdle() will never terminate. |
| 156 params_ = AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, | 156 params_ = AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, |
| 157 CHANNEL_LAYOUT_STEREO, 8000, 16, 2048); | 157 CHANNEL_LAYOUT_STEREO, 8000, 16, 2048); |
| 158 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); | 158 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 virtual void TearDown() { | 161 virtual void TearDown() { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 // Wait for all of the messages to fly and then verify stream behavior. | 743 // Wait for all of the messages to fly and then verify stream behavior. |
| 744 EXPECT_TRUE(stream1.stop_called()); | 744 EXPECT_TRUE(stream1.stop_called()); |
| 745 EXPECT_TRUE(stream1.start_called()); | 745 EXPECT_TRUE(stream1.start_called()); |
| 746 EXPECT_TRUE(stream2.stop_called()); | 746 EXPECT_TRUE(stream2.stop_called()); |
| 747 EXPECT_TRUE(stream2.start_called()); | 747 EXPECT_TRUE(stream2.start_called()); |
| 748 EXPECT_TRUE(stream3.stop_called()); | 748 EXPECT_TRUE(stream3.stop_called()); |
| 749 EXPECT_TRUE(stream3.start_called()); | 749 EXPECT_TRUE(stream3.start_called()); |
| 750 } | 750 } |
| 751 | 751 |
| 752 } // namespace media | 752 } // namespace media |
| OLD | NEW |