Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: media/audio/audio_output_proxy_unittest.cc

Issue 1901583005: Revert of Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/audio_output_controller_unittest.cc ('k') | media/audio/cras/audio_manager_cras.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "build/build_config.h" 11 #include "build/build_config.h"
13 #include "media/audio/audio_manager.h" 12 #include "media/audio/audio_manager.h"
14 #include "media/audio/audio_manager_base.h" 13 #include "media/audio/audio_manager_base.h"
15 #include "media/audio/audio_output_dispatcher_impl.h" 14 #include "media/audio/audio_output_dispatcher_impl.h"
16 #include "media/audio/audio_output_proxy.h" 15 #include "media/audio/audio_output_proxy.h"
17 #include "media/audio/audio_output_resampler.h" 16 #include "media/audio/audio_output_resampler.h"
18 #include "media/audio/fake_audio_log_factory.h" 17 #include "media/audio/fake_audio_log_factory.h"
19 #include "media/audio/fake_audio_output_stream.h" 18 #include "media/audio/fake_audio_output_stream.h"
20 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 80
82 private: 81 private:
83 bool start_called_; 82 bool start_called_;
84 bool stop_called_; 83 bool stop_called_;
85 AudioParameters params_; 84 AudioParameters params_;
86 scoped_ptr<AudioOutputStream> fake_output_stream_; 85 scoped_ptr<AudioOutputStream> fake_output_stream_;
87 }; 86 };
88 87
89 class MockAudioManager : public AudioManagerBase { 88 class MockAudioManager : public AudioManagerBase {
90 public: 89 public:
91 MockAudioManager() 90 MockAudioManager() : AudioManagerBase(&fake_audio_log_factory_) {}
92 : AudioManagerBase(base::ThreadTaskRunnerHandle::Get(), 91 virtual ~MockAudioManager() {
93 base::ThreadTaskRunnerHandle::Get(), 92 Shutdown();
94 &fake_audio_log_factory_) {} 93 }
95 ~MockAudioManager() override { Shutdown(); }
96 94
97 MOCK_METHOD0(HasAudioOutputDevices, bool()); 95 MOCK_METHOD0(HasAudioOutputDevices, bool());
98 MOCK_METHOD0(HasAudioInputDevices, bool()); 96 MOCK_METHOD0(HasAudioInputDevices, bool());
99 MOCK_METHOD0(GetAudioInputDeviceModel, base::string16()); 97 MOCK_METHOD0(GetAudioInputDeviceModel, base::string16());
100 MOCK_METHOD2(MakeAudioOutputStream, AudioOutputStream*( 98 MOCK_METHOD2(MakeAudioOutputStream, AudioOutputStream*(
101 const AudioParameters& params, 99 const AudioParameters& params,
102 const std::string& device_id)); 100 const std::string& device_id));
103 MOCK_METHOD2(MakeAudioOutputStreamProxy, AudioOutputStream*( 101 MOCK_METHOD2(MakeAudioOutputStreamProxy, AudioOutputStream*(
104 const AudioParameters& params, 102 const AudioParameters& params,
105 const std::string& device_id)); 103 const std::string& device_id));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 MOCK_METHOD1(OnError, void(AudioOutputStream* stream)); 136 MOCK_METHOD1(OnError, void(AudioOutputStream* stream));
139 }; 137 };
140 138
141 } // namespace 139 } // namespace
142 140
143 namespace media { 141 namespace media {
144 142
145 class AudioOutputProxyTest : public testing::Test { 143 class AudioOutputProxyTest : public testing::Test {
146 protected: 144 protected:
147 void SetUp() override { 145 void SetUp() override {
146 EXPECT_CALL(manager_, GetTaskRunner())
147 .WillRepeatedly(Return(message_loop_.task_runner()));
148 EXPECT_CALL(manager_, GetWorkerTaskRunner())
149 .WillRepeatedly(Return(message_loop_.task_runner()));
148 // Use a low sample rate and large buffer size when testing otherwise the 150 // Use a low sample rate and large buffer size when testing otherwise the
149 // FakeAudioOutputStream will keep the message loop busy indefinitely; i.e., 151 // FakeAudioOutputStream will keep the message loop busy indefinitely; i.e.,
150 // RunUntilIdle() will never terminate. 152 // RunUntilIdle() will never terminate.
151 params_ = AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 153 params_ = AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
152 CHANNEL_LAYOUT_STEREO, 8000, 16, 2048); 154 CHANNEL_LAYOUT_STEREO, 8000, 16, 2048);
153 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); 155 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs));
154 } 156 }
155 157
156 void TearDown() override { 158 void TearDown() override {
157 // This is necessary to free all proxy objects that have been 159 // This is necessary to free all proxy objects that have been
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 _)).WillOnce(Return(&real_stream)); 726 _)).WillOnce(Return(&real_stream));
725 727
726 // Stream1 should be able to successfully open and start. 728 // Stream1 should be able to successfully open and start.
727 EXPECT_CALL(real_stream, Open()).WillOnce(Return(true)); 729 EXPECT_CALL(real_stream, Open()).WillOnce(Return(true));
728 proxy = new AudioOutputProxy(resampler_.get()); 730 proxy = new AudioOutputProxy(resampler_.get());
729 EXPECT_TRUE(proxy->Open()); 731 EXPECT_TRUE(proxy->Open());
730 CloseAndWaitForCloseTimer(proxy, &real_stream); 732 CloseAndWaitForCloseTimer(proxy, &real_stream);
731 } 733 }
732 734
733 } // namespace media 735 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_controller_unittest.cc ('k') | media/audio/cras/audio_manager_cras.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698