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

Unified Diff: content/browser/media/capture/web_contents_video_capture_device_unittest.cc

Issue 2702093002: Consistent CopyFromSurface() API, consolidated to RWHV (Closed)
Patch Set: REBASE Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/capture/web_contents_video_capture_device_unittest.cc
diff --git a/content/browser/media/capture/web_contents_video_capture_device_unittest.cc b/content/browser/media/capture/web_contents_video_capture_device_unittest.cc
index 1c1f656c16cbcc67e337b5c453d002f86277dac7..d86758ce86f5705166c53c246fb12b203b3576d3 100644
--- a/content/browser/media/capture/web_contents_video_capture_device_unittest.cc
+++ b/content/browser/media/capture/web_contents_video_capture_device_unittest.cc
@@ -99,9 +99,9 @@ media::VideoCaptureParams DefaultCaptureParams() {
}
// A stub implementation which fills solid-colors into VideoFrames in calls to
-// CopyFromCompositingSurfaceToVideoFrame(). The colors are changed by tests
-// in-between draw events to confirm that the right frames have the right
-// content and in the right sequence.
+// CopyFromSurfaceToVideoFrame(). The colors are changed by tests in-between
+// draw events to confirm that the right frames have the right content and in
+// the right sequence.
class CaptureTestView : public TestRenderWidgetHostView {
public:
explicit CaptureTestView(RenderWidgetHostImpl* rwh)
@@ -124,12 +124,21 @@ class CaptureTestView : public TestRenderWidgetHostView {
fake_bounds_ = rect;
}
- bool CanCopyToVideoFrame() const override { return true; }
+ bool IsSurfaceAvailableForCopy() const override { return true; }
- void CopyFromCompositingSurfaceToVideoFrame(
+ void CopyFromSurface(const gfx::Rect& src_rect,
+ const gfx::Size& output_size,
+ const ReadbackRequestCallback& callback,
+ const SkColorType color_type) override {
+ // WebContentsVideoCaptureDevice implementation does not use this.
+ NOTREACHED();
+ }
+
+ void CopyFromSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
- const scoped_refptr<media::VideoFrame>& target,
+ scoped_refptr<media::VideoFrame> target,
const base::Callback<void(const gfx::Rect&, bool)>& callback) override {
+ ASSERT_TRUE(src_subrect.IsEmpty());
media::FillYUV(target.get(), SkColorGetR(yuv_color_),
SkColorGetG(yuv_color_), SkColorGetB(yuv_color_));
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
@@ -155,8 +164,8 @@ class CaptureTestView : public TestRenderWidgetHostView {
scoped_refptr<media::VideoFrame> target;
if (subscriber_ && subscriber_->ShouldCaptureFrame(
gfx::Rect(), present_time, &target, &callback)) {
- CopyFromCompositingSurfaceToVideoFrame(
- gfx::Rect(), target, base::Bind(callback, present_time));
+ CopyFromSurfaceToVideoFrame(gfx::Rect(), target,
+ base::Bind(callback, present_time));
}
}
@@ -451,11 +460,11 @@ class WebContentsVideoCaptureDeviceTest : public testing::Test {
// TODO(nick): Sadness and woe! Much "mock-the-world" boilerplate could be
// eliminated here, if only we could use RenderViewHostTestHarness. The
// catch is that we need to inject our CaptureTestView::
- // CopyFromCompositingSurfaceToVideoFrame() mock. To accomplish that,
- // either RenderViewHostTestHarness would have to support installing a
- // custom RenderViewHostFactory, or else we implant some kind of delegated
- // CopyFromCompositingSurfaceToVideoFrame functionality into
- // TestRenderViewHostView itself.
+ // CopyFromSurfaceToVideoFrame() mock. To accomplish that, either
+ // RenderViewHostTestHarness would have to support installing a custom
+ // RenderViewHostFactory, or else we implant some kind of delegated
+ // CopyFromSurfaceToVideoFrame functionality into TestRenderWidgetHostView
+ // itself.
render_process_host_factory_.reset(new MockRenderProcessHostFactory());
// Create our (self-registering) RVH factory, so that when we create a

Powered by Google App Engine
This is Rietveld 408576698