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

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

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from patch 48 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"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "media/audio/audio_manager.h" 13 #include "media/audio/audio_manager.h"
13 #include "media/audio/audio_manager_base.h" 14 #include "media/audio/audio_manager_base.h"
14 #include "media/audio/audio_output_dispatcher_impl.h" 15 #include "media/audio/audio_output_dispatcher_impl.h"
15 #include "media/audio/audio_output_proxy.h" 16 #include "media/audio/audio_output_proxy.h"
16 #include "media/audio/audio_output_resampler.h" 17 #include "media/audio/audio_output_resampler.h"
17 #include "media/audio/fake_audio_log_factory.h" 18 #include "media/audio/fake_audio_log_factory.h"
18 #include "media/audio/fake_audio_output_stream.h" 19 #include "media/audio/fake_audio_output_stream.h"
19 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 private: 82 private:
82 bool start_called_; 83 bool start_called_;
83 bool stop_called_; 84 bool stop_called_;
84 AudioParameters params_; 85 AudioParameters params_;
85 scoped_ptr<AudioOutputStream> fake_output_stream_; 86 scoped_ptr<AudioOutputStream> fake_output_stream_;
86 }; 87 };
87 88
88 class MockAudioManager : public AudioManagerBase { 89 class MockAudioManager : public AudioManagerBase {
89 public: 90 public:
90 MockAudioManager() : AudioManagerBase(&fake_audio_log_factory_) {} 91 MockAudioManager()
91 virtual ~MockAudioManager() { 92 : AudioManagerBase(base::ThreadTaskRunnerHandle::Get(),
92 Shutdown(); 93 base::ThreadTaskRunnerHandle::Get(),
93 } 94 &fake_audio_log_factory_) {}
95 ~MockAudioManager() override { Shutdown(); }
94 96
95 MOCK_METHOD0(HasAudioOutputDevices, bool()); 97 MOCK_METHOD0(HasAudioOutputDevices, bool());
96 MOCK_METHOD0(HasAudioInputDevices, bool()); 98 MOCK_METHOD0(HasAudioInputDevices, bool());
97 MOCK_METHOD0(GetAudioInputDeviceModel, base::string16()); 99 MOCK_METHOD0(GetAudioInputDeviceModel, base::string16());
98 MOCK_METHOD2(MakeAudioOutputStream, AudioOutputStream*( 100 MOCK_METHOD2(MakeAudioOutputStream, AudioOutputStream*(
99 const AudioParameters& params, 101 const AudioParameters& params,
100 const std::string& device_id)); 102 const std::string& device_id));
101 MOCK_METHOD2(MakeAudioOutputStreamProxy, AudioOutputStream*( 103 MOCK_METHOD2(MakeAudioOutputStreamProxy, AudioOutputStream*(
102 const AudioParameters& params, 104 const AudioParameters& params,
103 const std::string& device_id)); 105 const std::string& device_id));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 MOCK_METHOD1(OnError, void(AudioOutputStream* stream)); 138 MOCK_METHOD1(OnError, void(AudioOutputStream* stream));
137 }; 139 };
138 140
139 } // namespace 141 } // namespace
140 142
141 namespace media { 143 namespace media {
142 144
143 class AudioOutputProxyTest : public testing::Test { 145 class AudioOutputProxyTest : public testing::Test {
144 protected: 146 protected:
145 void SetUp() override { 147 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()));
150 // Use a low sample rate and large buffer size when testing otherwise the 148 // Use a low sample rate and large buffer size when testing otherwise the
151 // FakeAudioOutputStream will keep the message loop busy indefinitely; i.e., 149 // FakeAudioOutputStream will keep the message loop busy indefinitely; i.e.,
152 // RunUntilIdle() will never terminate. 150 // RunUntilIdle() will never terminate.
153 params_ = AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 151 params_ = AudioParameters(AudioParameters::AUDIO_PCM_LINEAR,
154 CHANNEL_LAYOUT_STEREO, 8000, 16, 2048); 152 CHANNEL_LAYOUT_STEREO, 8000, 16, 2048);
155 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); 153 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs));
156 } 154 }
157 155
158 void TearDown() override { 156 void TearDown() override {
159 // This is necessary to free all proxy objects that have been 157 // This is necessary to free all proxy objects that have been
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 _)).WillOnce(Return(&real_stream)); 724 _)).WillOnce(Return(&real_stream));
727 725
728 // Stream1 should be able to successfully open and start. 726 // Stream1 should be able to successfully open and start.
729 EXPECT_CALL(real_stream, Open()).WillOnce(Return(true)); 727 EXPECT_CALL(real_stream, Open()).WillOnce(Return(true));
730 proxy = new AudioOutputProxy(resampler_.get()); 728 proxy = new AudioOutputProxy(resampler_.get());
731 EXPECT_TRUE(proxy->Open()); 729 EXPECT_TRUE(proxy->Open());
732 CloseAndWaitForCloseTimer(proxy, &real_stream); 730 CloseAndWaitForCloseTimer(proxy, &real_stream);
733 } 731 }
734 732
735 } // namespace media 733 } // 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