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

Side by Side Diff: media/blink/webaudiosourceprovider_impl_unittest.cc

Issue 1904253002: Convert //media/blink from scoped_ptr to std::unique_ptr (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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
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"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 return true; 85 return true;
86 } 86 }
87 87
88 // blink::WebAudioSourceProviderClient implementation. 88 // blink::WebAudioSourceProviderClient implementation.
89 MOCK_METHOD2(setFormat, void(size_t numberOfChannels, float sampleRate)); 89 MOCK_METHOD2(setFormat, void(size_t numberOfChannels, float sampleRate));
90 90
91 // CopyAudioCB. Added forwarder method due to GMock troubles with scoped_ptr. 91 // CopyAudioCB. Added forwarder method due to GMock troubles with scoped_ptr.
92 MOCK_METHOD3(DoCopyAudioCB, 92 MOCK_METHOD3(DoCopyAudioCB,
93 void(AudioBus*, uint32_t delay_milliseconds, int sample_rate)); 93 void(AudioBus*, uint32_t delay_milliseconds, int sample_rate));
94 void OnAudioBus(scoped_ptr<AudioBus> bus, 94 void OnAudioBus(std::unique_ptr<AudioBus> bus,
95 uint32_t delay_milliseconds, 95 uint32_t delay_milliseconds,
96 int sample_rate) { 96 int sample_rate) {
97 DoCopyAudioCB(bus.get(), delay_milliseconds, sample_rate); 97 DoCopyAudioCB(bus.get(), delay_milliseconds, sample_rate);
98 } 98 }
99 99
100 int Render(AudioBus* audio_bus) { 100 int Render(AudioBus* audio_bus) {
101 return wasp_impl_->RenderForTesting(audio_bus); 101 return wasp_impl_->RenderForTesting(audio_bus);
102 } 102 }
103 103
104 protected: 104 protected:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 wasp_impl_->SetVolume(kTestVolume); 167 wasp_impl_->SetVolume(kTestVolume);
168 168
169 EXPECT_CALL(*mock_sink_.get(), SetVolume(kTestVolume)); 169 EXPECT_CALL(*mock_sink_.get(), SetVolume(kTestVolume));
170 EXPECT_CALL(*mock_sink_.get(), Start()); 170 EXPECT_CALL(*mock_sink_.get(), Start());
171 EXPECT_CALL(*mock_sink_.get(), Play()); 171 EXPECT_CALL(*mock_sink_.get(), Play());
172 SetClient(NULL); 172 SetClient(NULL);
173 } 173 }
174 174
175 // Test the AudioRendererSink state machine and its effects on provideInput(). 175 // Test the AudioRendererSink state machine and its effects on provideInput().
176 TEST_F(WebAudioSourceProviderImplTest, ProvideInput) { 176 TEST_F(WebAudioSourceProviderImplTest, ProvideInput) {
177 scoped_ptr<AudioBus> bus1 = AudioBus::Create(params_); 177 std::unique_ptr<AudioBus> bus1 = AudioBus::Create(params_);
178 scoped_ptr<AudioBus> bus2 = AudioBus::Create(params_); 178 std::unique_ptr<AudioBus> bus2 = AudioBus::Create(params_);
179 179
180 // Point the WebVector into memory owned by |bus1|. 180 // Point the WebVector into memory owned by |bus1|.
181 blink::WebVector<float*> audio_data(static_cast<size_t>(bus1->channels())); 181 blink::WebVector<float*> audio_data(static_cast<size_t>(bus1->channels()));
182 for (size_t i = 0; i < audio_data.size(); ++i) 182 for (size_t i = 0; i < audio_data.size(); ++i)
183 audio_data[i] = bus1->channel(static_cast<int>(i)); 183 audio_data[i] = bus1->channel(static_cast<int>(i));
184 184
185 // Verify provideInput() works before Initialize() and returns silence. 185 // Verify provideInput() works before Initialize() and returns silence.
186 bus1->channel(0)[0] = 1; 186 bus1->channel(0)[0] = 1;
187 bus2->Zero(); 187 bus2->Zero();
188 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); 188 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); 255 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get()));
256 } 256 }
257 257
258 // Verify CopyAudioCB is called if registered. 258 // Verify CopyAudioCB is called if registered.
259 TEST_F(WebAudioSourceProviderImplTest, CopyAudioCB) { 259 TEST_F(WebAudioSourceProviderImplTest, CopyAudioCB) {
260 testing::InSequence s; 260 testing::InSequence s;
261 wasp_impl_->Initialize(params_, &fake_callback_); 261 wasp_impl_->Initialize(params_, &fake_callback_);
262 wasp_impl_->SetCopyAudioCallback(base::Bind( 262 wasp_impl_->SetCopyAudioCallback(base::Bind(
263 &WebAudioSourceProviderImplTest::OnAudioBus, base::Unretained(this))); 263 &WebAudioSourceProviderImplTest::OnAudioBus, base::Unretained(this)));
264 264
265 const scoped_ptr<AudioBus> bus1 = AudioBus::Create(params_); 265 const std::unique_ptr<AudioBus> bus1 = AudioBus::Create(params_);
266 EXPECT_CALL(*this, DoCopyAudioCB(_, 0, params_.sample_rate())).Times(1); 266 EXPECT_CALL(*this, DoCopyAudioCB(_, 0, params_.sample_rate())).Times(1);
267 Render(bus1.get()); 267 Render(bus1.get());
268 268
269 wasp_impl_->ClearCopyAudioCallback(); 269 wasp_impl_->ClearCopyAudioCallback();
270 EXPECT_CALL(*this, DoCopyAudioCB(_, _, _)).Times(0); 270 EXPECT_CALL(*this, DoCopyAudioCB(_, _, _)).Times(0);
271 Render(bus1.get()); 271 Render(bus1.get());
272 272
273 testing::Mock::VerifyAndClear(mock_sink_.get()); 273 testing::Mock::VerifyAndClear(mock_sink_.get());
274 } 274 }
275 275
276 } // namespace media 276 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webaudiosourceprovider_impl.cc ('k') | media/blink/webcontentdecryptionmodule_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698