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

Side by Side Diff: content/renderer/media_recorder/audio_track_recorder_unittest.cc

Issue 2800893002: Use ScopedTaskEnvironment instead of MessageLoop in content unit tests. (Closed)
Patch Set: Created 3 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 | « content/renderer/media_capture_from_element/html_audio_element_capturer_source_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/renderer/media_recorder/audio_track_recorder.h" 5 #include "content/renderer/media_recorder/audio_track_recorder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/test/scoped_task_environment.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "content/renderer/media/media_stream_audio_source.h" 18 #include "content/renderer/media/media_stream_audio_source.h"
18 #include "media/audio/simple_sources.h" 19 #include "media/audio/simple_sources.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"
21 #include "third_party/WebKit/public/platform/WebString.h" 22 #include "third_party/WebKit/public/platform/WebString.h"
22 #include "third_party/WebKit/public/web/WebHeap.h" 23 #include "third_party/WebKit/public/web/WebHeap.h"
23 #include "third_party/opus/src/include/opus.h" 24 #include "third_party/opus/src/include/opus.h"
24 25
25 using ::testing::_; 26 using ::testing::_;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // per buffer. 185 // per buffer.
185 EXPECT_EQ(kDefaultSampleRate * kOpusBufferDurationMs / 1000, 186 EXPECT_EQ(kDefaultSampleRate * kOpusBufferDurationMs / 1000,
186 opus_decode_float( 187 opus_decode_float(
187 opus_decoder_, reinterpret_cast<uint8_t*>( 188 opus_decoder_, reinterpret_cast<uint8_t*>(
188 base::string_as_array(encoded_data.get())), 189 base::string_as_array(encoded_data.get())),
189 encoded_data->size(), buffer_.get(), kFramesPerBuffer, 0)); 190 encoded_data->size(), buffer_.get(), kFramesPerBuffer, 0));
190 191
191 DoOnEncodedAudio(params, *encoded_data, timestamp); 192 DoOnEncodedAudio(params, *encoded_data, timestamp);
192 } 193 }
193 194
194 const base::MessageLoop message_loop_; 195 const base::test::ScopedTaskEnvironment scoped_task_environment_;
195 196
196 // ATR and WebMediaStreamTrack for fooling it. 197 // ATR and WebMediaStreamTrack for fooling it.
197 std::unique_ptr<AudioTrackRecorder> audio_track_recorder_; 198 std::unique_ptr<AudioTrackRecorder> audio_track_recorder_;
198 blink::WebMediaStreamTrack blink_track_; 199 blink::WebMediaStreamTrack blink_track_;
199 200
200 // Two different sets of AudioParameters for testing re-init of ATR. 201 // Two different sets of AudioParameters for testing re-init of ATR.
201 const media::AudioParameters first_params_; 202 const media::AudioParameters first_params_;
202 const media::AudioParameters second_params_; 203 const media::AudioParameters second_params_;
203 204
204 // AudioSources for creating AudioBuses. 205 // AudioSources for creating AudioBuses.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 298
298 if (GetParam().sample_rate % 100) 299 if (GetParam().sample_rate % 100)
299 audio_track_recorder_->OnData(*GetFirstSourceAudioBus(), TimeTicks::Now()); 300 audio_track_recorder_->OnData(*GetFirstSourceAudioBus(), TimeTicks::Now());
300 301
301 run_loop.Run(); 302 run_loop.Run();
302 Mock::VerifyAndClearExpectations(this); 303 Mock::VerifyAndClearExpectations(this);
303 } 304 }
304 305
305 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams)); 306 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams));
306 } // namespace content 307 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media_capture_from_element/html_audio_element_capturer_source_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698