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

Side by Side Diff: content/renderer/media_capture_from_element/html_audio_element_capturer_source_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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_capture_from_element/html_audio_element_capture r_source.h"
5 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
6 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/scoped_task_environment.h"
7 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
8 #include "content/public/renderer/media_stream_audio_sink.h" 10 #include "content/public/renderer/media_stream_audio_sink.h"
9 #include "content/renderer/media/media_stream_audio_track.h" 11 #include "content/renderer/media/media_stream_audio_track.h"
10 #include "content/renderer/media_capture_from_element/html_audio_element_capture r_source.h"
11 #include "media/audio/null_audio_sink.h" 12 #include "media/audio/null_audio_sink.h"
12 #include "media/base/audio_parameters.h" 13 #include "media/base/audio_parameters.h"
13 #include "media/base/fake_audio_render_callback.h" 14 #include "media/base/fake_audio_render_callback.h"
14 #include "media/base/media_log.h" 15 #include "media/base/media_log.h"
15 #include "media/blink/webaudiosourceprovider_impl.h" 16 #include "media/blink/webaudiosourceprovider_impl.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/WebKit/public/platform/WebString.h" 19 #include "third_party/WebKit/public/platform/WebString.h"
19 #include "third_party/WebKit/public/web/WebHeap.h" 20 #include "third_party/WebKit/public/web/WebHeap.h"
20 21
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 105
105 MediaStreamAudioTrack* track() const { 106 MediaStreamAudioTrack* track() const {
106 return MediaStreamAudioTrack::From(blink_audio_track_); 107 return MediaStreamAudioTrack::From(blink_audio_track_);
107 } 108 }
108 109
109 int InjectAudio(media::AudioBus* audio_bus) { 110 int InjectAudio(media::AudioBus* audio_bus) {
110 return audio_source_->RenderForTesting(audio_bus); 111 return audio_source_->RenderForTesting(audio_bus);
111 } 112 }
112 113
113 protected: 114 protected:
114 const base::MessageLoop message_loop_; 115 const base::test::ScopedTaskEnvironment scoped_task_environment_;
115 116
116 blink::WebMediaStreamSource blink_audio_source_; 117 blink::WebMediaStreamSource blink_audio_source_;
117 blink::WebMediaStreamTrack blink_audio_track_; 118 blink::WebMediaStreamTrack blink_audio_track_;
118 119
119 media::FakeAudioRenderCallback fake_callback_; 120 media::FakeAudioRenderCallback fake_callback_;
120 scoped_refptr<media::WebAudioSourceProviderImpl> audio_source_; 121 scoped_refptr<media::WebAudioSourceProviderImpl> audio_source_;
121 }; 122 };
122 123
123 // Constructs and destructs all objects. This is a non trivial sequence. 124 // Constructs and destructs all objects. This is a non trivial sequence.
124 TEST_F(HTMLAudioElementCapturerSourceTest, ConstructAndDestruct) { 125 TEST_F(HTMLAudioElementCapturerSourceTest, ConstructAndDestruct) {
(...skipping 22 matching lines...) Expand all
147 std::unique_ptr<media::AudioBus> bus = media::AudioBus::Create( 148 std::unique_ptr<media::AudioBus> bus = media::AudioBus::Create(
148 kNumChannelsForTest, kAudioTrackSamplesPerBuffer); 149 kNumChannelsForTest, kAudioTrackSamplesPerBuffer);
149 InjectAudio(bus.get()); 150 InjectAudio(bus.get());
150 run_loop.Run(); 151 run_loop.Run();
151 152
152 track()->Stop(); 153 track()->Stop();
153 track()->RemoveSink(&sink); 154 track()->RemoveSink(&sink);
154 } 155 }
155 156
156 } // namespace content 157 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698