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

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

Issue 1169923009: Remove remaining use of the deprecated MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo. Created 5 years, 6 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 | « gin/v8_platform.cc ('k') | media/audio/win/audio_low_latency_output_win_unittest.cc » ('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 <vector> 5 #include <vector>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/process/process_handle.h" 10 #include "base/process/process_handle.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 MOCK_METHOD0(PauseStream, void()); 52 MOCK_METHOD0(PauseStream, void());
53 MOCK_METHOD0(CloseStream, void()); 53 MOCK_METHOD0(CloseStream, void());
54 MOCK_METHOD1(SetVolume, void(double volume)); 54 MOCK_METHOD1(SetVolume, void(double volume));
55 }; 55 };
56 56
57 ACTION_P2(SendPendingBytes, socket, pending_bytes) { 57 ACTION_P2(SendPendingBytes, socket, pending_bytes) {
58 socket->Send(&pending_bytes, sizeof(pending_bytes)); 58 socket->Send(&pending_bytes, sizeof(pending_bytes));
59 } 59 }
60 60
61 // Used to terminate a loop from a different thread than the loop belongs to. 61 // Used to terminate a loop from a different thread than the loop belongs to.
62 // |loop| should be a MessageLoopProxy. 62 // |task_runner| should be a SingleThreadTaskRunner.
63 ACTION_P(QuitLoop, loop) { 63 ACTION_P(QuitLoop, task_runner) {
64 loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); 64 task_runner->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
65 } 65 }
66 66
67 } // namespace. 67 } // namespace.
68 68
69 class AudioOutputDeviceTest 69 class AudioOutputDeviceTest
70 : public testing::Test, 70 : public testing::Test,
71 public testing::WithParamInterface<bool> { 71 public testing::WithParamInterface<bool> {
72 public: 72 public:
73 AudioOutputDeviceTest(); 73 AudioOutputDeviceTest();
74 ~AudioOutputDeviceTest(); 74 ~AudioOutputDeviceTest();
(...skipping 30 matching lines...) Expand all
105 } 105 }
106 106
107 AudioOutputDeviceTest::AudioOutputDeviceTest() { 107 AudioOutputDeviceTest::AudioOutputDeviceTest() {
108 default_audio_parameters_.Reset( 108 default_audio_parameters_.Reset(
109 AudioParameters::AUDIO_PCM_LINEAR, 109 AudioParameters::AUDIO_PCM_LINEAR,
110 CHANNEL_LAYOUT_STEREO, 2, 48000, 16, 1024); 110 CHANNEL_LAYOUT_STEREO, 2, 48000, 16, 1024);
111 111
112 audio_output_ipc_ = new MockAudioOutputIPC(); 112 audio_output_ipc_ = new MockAudioOutputIPC();
113 audio_device_ = new AudioOutputDevice( 113 audio_device_ = new AudioOutputDevice(
114 scoped_ptr<AudioOutputIPC>(audio_output_ipc_), 114 scoped_ptr<AudioOutputIPC>(audio_output_ipc_),
115 io_loop_.message_loop_proxy()); 115 io_loop_.task_runner());
116 116
117 audio_device_->Initialize(default_audio_parameters_, 117 audio_device_->Initialize(default_audio_parameters_,
118 &callback_); 118 &callback_);
119 119
120 io_loop_.RunUntilIdle(); 120 io_loop_.RunUntilIdle();
121 } 121 }
122 122
123 AudioOutputDeviceTest::~AudioOutputDeviceTest() { 123 AudioOutputDeviceTest::~AudioOutputDeviceTest() {
124 audio_device_ = NULL; 124 audio_device_ = NULL;
125 } 125 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // We expect calls to our audio renderer callback, which returns the number 170 // We expect calls to our audio renderer callback, which returns the number
171 // of frames written to the memory section. 171 // of frames written to the memory section.
172 // Here's the second place where it gets hacky: There's no way for us to 172 // Here's the second place where it gets hacky: There's no way for us to
173 // know (without using a sleep loop!) when the AudioOutputDevice has finished 173 // know (without using a sleep loop!) when the AudioOutputDevice has finished
174 // writing the interleaved audio data into the shared memory section. 174 // writing the interleaved audio data into the shared memory section.
175 // So, for the sake of this test, we consider the call to Render a sign 175 // So, for the sake of this test, we consider the call to Render a sign
176 // of success and quit the loop. 176 // of success and quit the loop.
177 const int kNumberOfFramesToProcess = 0; 177 const int kNumberOfFramesToProcess = 0;
178 EXPECT_CALL(callback_, Render(_, _)) 178 EXPECT_CALL(callback_, Render(_, _))
179 .WillOnce(DoAll( 179 .WillOnce(DoAll(
180 QuitLoop(io_loop_.message_loop_proxy()), 180 QuitLoop(io_loop_.task_runner()),
181 Return(kNumberOfFramesToProcess))); 181 Return(kNumberOfFramesToProcess)));
182 } 182 }
183 183
184 void AudioOutputDeviceTest::WaitUntilRenderCallback() { 184 void AudioOutputDeviceTest::WaitUntilRenderCallback() {
185 // Don't hang the test if we never get the Render() callback. 185 // Don't hang the test if we never get the Render() callback.
186 io_loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(), 186 io_loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(),
187 TestTimeouts::action_timeout()); 187 TestTimeouts::action_timeout());
188 io_loop_.Run(); 188 io_loop_.Run();
189 } 189 }
190 190
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 StartAudioDevice(); 235 StartAudioDevice();
236 ExpectRenderCallback(); 236 ExpectRenderCallback();
237 CreateStream(); 237 CreateStream();
238 WaitUntilRenderCallback(); 238 WaitUntilRenderCallback();
239 StopAudioDevice(); 239 StopAudioDevice();
240 } 240 }
241 241
242 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); 242 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false));
243 243
244 } // namespace media. 244 } // namespace media.
OLDNEW
« no previous file with comments | « gin/v8_platform.cc ('k') | media/audio/win/audio_low_latency_output_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698