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

Side by Side Diff: media/cast/sender/h264_vt_encoder_unittest.cc

Issue 2053123002: Remove MessageLoop::current()->RunUntilIdle() in media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/power_monitor/power_monitor.h" 13 #include "base/power_monitor/power_monitor.h"
14 #include "base/run_loop.h"
14 #include "base/test/launcher/unit_test_launcher.h" 15 #include "base/test/launcher/unit_test_launcher.h"
15 #include "base/test/power_monitor_test_base.h" 16 #include "base/test/power_monitor_test_base.h"
16 #include "base/test/simple_test_tick_clock.h" 17 #include "base/test/simple_test_tick_clock.h"
17 #include "base/test/test_suite.h" 18 #include "base/test/test_suite.h"
18 #include "media/base/cdm_context.h" 19 #include "media/base/cdm_context.h"
19 #include "media/base/decoder_buffer.h" 20 #include "media/base/decoder_buffer.h"
20 #include "media/base/media.h" 21 #include "media/base/media.h"
21 #include "media/base/media_switches.h" 22 #include "media/base/media_switches.h"
22 #include "media/base/media_util.h" 23 #include "media/base/media_util.h"
23 #include "media/cast/common/rtp_time.h" 24 #include "media/cast/common/rtp_time.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 : public base::RefCountedThreadSafe<EndToEndFrameChecker> { 139 : public base::RefCountedThreadSafe<EndToEndFrameChecker> {
139 public: 140 public:
140 explicit EndToEndFrameChecker(const VideoDecoderConfig& config) 141 explicit EndToEndFrameChecker(const VideoDecoderConfig& config)
141 : decoder_(), count_frames_checked_(0) { 142 : decoder_(), count_frames_checked_(0) {
142 bool decoder_init_result; 143 bool decoder_init_result;
143 decoder_.Initialize( 144 decoder_.Initialize(
144 config, false, nullptr, 145 config, false, nullptr,
145 base::Bind(&SaveDecoderInitResult, &decoder_init_result), 146 base::Bind(&SaveDecoderInitResult, &decoder_init_result),
146 base::Bind(&EndToEndFrameChecker::CompareFrameWithExpected, 147 base::Bind(&EndToEndFrameChecker::CompareFrameWithExpected,
147 base::Unretained(this))); 148 base::Unretained(this)));
148 base::MessageLoop::current()->RunUntilIdle(); 149 base::RunLoop().RunUntilIdle();
149 EXPECT_TRUE(decoder_init_result); 150 EXPECT_TRUE(decoder_init_result);
150 } 151 }
151 152
152 void PushExpectation(const scoped_refptr<VideoFrame>& frame) { 153 void PushExpectation(const scoped_refptr<VideoFrame>& frame) {
153 expectations_.push(frame); 154 expectations_.push(frame);
154 } 155 }
155 156
156 void EncodeDone(std::unique_ptr<SenderEncodedFrame> encoded_frame) { 157 void EncodeDone(std::unique_ptr<SenderEncodedFrame> encoded_frame) {
157 auto buffer = DecoderBuffer::CopyFrom(encoded_frame->bytes(), 158 auto buffer = DecoderBuffer::CopyFrom(encoded_frame->bytes(),
158 encoded_frame->data.size()); 159 encoded_frame->data.size());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 CVPixelBufferUnlockBaseAddress(cv_pixel_buffer, 0); 199 CVPixelBufferUnlockBaseAddress(cv_pixel_buffer, 0);
199 } 200 }
200 201
201 void NoopFrameEncodedCallback( 202 void NoopFrameEncodedCallback(
202 std::unique_ptr<media::cast::SenderEncodedFrame> /*encoded_frame*/) {} 203 std::unique_ptr<media::cast::SenderEncodedFrame> /*encoded_frame*/) {}
203 204
204 class TestPowerSource : public base::PowerMonitorSource { 205 class TestPowerSource : public base::PowerMonitorSource {
205 public: 206 public:
206 void GenerateSuspendEvent() { 207 void GenerateSuspendEvent() {
207 ProcessPowerEvent(SUSPEND_EVENT); 208 ProcessPowerEvent(SUSPEND_EVENT);
208 base::MessageLoop::current()->RunUntilIdle(); 209 base::RunLoop().RunUntilIdle();
209 } 210 }
210 void GenerateResumeEvent() { 211 void GenerateResumeEvent() {
211 ProcessPowerEvent(RESUME_EVENT); 212 ProcessPowerEvent(RESUME_EVENT);
212 base::MessageLoop::current()->RunUntilIdle(); 213 base::RunLoop().RunUntilIdle();
213 } 214 }
214 215
215 private: 216 private:
216 bool IsOnBatteryPowerImpl() final { return false; } 217 bool IsOnBatteryPowerImpl() final { return false; }
217 }; 218 };
218 219
219 class H264VideoToolboxEncoderTest : public ::testing::Test { 220 class H264VideoToolboxEncoderTest : public ::testing::Test {
220 protected: 221 protected:
221 H264VideoToolboxEncoderTest() = default; 222 H264VideoToolboxEncoderTest() = default;
222 223
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 gfx::Size(kVideoWidth, kVideoHeight), base::TimeDelta())); 413 gfx::Size(kVideoWidth, kVideoHeight), base::TimeDelta()));
413 414
414 // After a power resume event, the factory should produce frames right away 415 // After a power resume event, the factory should produce frames right away
415 // because the encoder re-initializes on its own. 416 // because the encoder re-initializes on its own.
416 power_source_->GenerateResumeEvent(); 417 power_source_->GenerateResumeEvent();
417 CreateFrameAndMemsetPlane(video_frame_factory.get()); 418 CreateFrameAndMemsetPlane(video_frame_factory.get());
418 } 419 }
419 420
420 } // namespace cast 421 } // namespace cast
421 } // namespace media 422 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/video_capture_device_unittest.cc ('k') | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698