Chromium Code Reviews| Index: media/blink/skcanvas_video_renderer_unittest.cc |
| diff --git a/media/blink/skcanvas_video_renderer_unittest.cc b/media/blink/skcanvas_video_renderer_unittest.cc |
| index 9b8765aa4c5784eed6fc273c9a2634adb8b9e338..2da8efb7c5475af15dca7f1f98f04a3d545c7ed5 100644 |
| --- a/media/blink/skcanvas_video_renderer_unittest.cc |
| +++ b/media/blink/skcanvas_video_renderer_unittest.cc |
| @@ -3,12 +3,16 @@ |
| // found in the LICENSE file. |
| #include "base/message_loop/message_loop.h" |
| +#include "gpu/GLES2/gl2extchromium.h" |
| +#include "gpu/command_buffer/client/gles2_interface_stub.h" |
| #include "media/base/timestamp_constants.h" |
| #include "media/base/video_frame.h" |
| #include "media/base/video_util.h" |
| #include "media/blink/skcanvas_video_renderer.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "third_party/skia/include/core/SkCanvas.h" |
| +#include "third_party/skia/include/gpu/GrContext.h" |
| +#include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
| using media::VideoFrame; |
| @@ -75,7 +79,7 @@ class SkCanvasVideoRendererTest : public testing::Test { |
| // Standard canvas. |
| SkCanvas* target_canvas() { return &target_canvas_; } |
| - private: |
| + protected: |
| SkCanvasVideoRenderer renderer_; |
| scoped_refptr<VideoFrame> natural_frame_; |
| @@ -497,4 +501,36 @@ TEST_F(SkCanvasVideoRendererTest, Video_Translate_Rotation_270) { |
| EXPECT_EQ(SK_ColorBLACK, GetColorAt(&canvas, kWidth / 2, kHeight - 1)); |
| } |
| +namespace { |
| +class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub { |
| + public: |
| + void GenTextures(GLsizei n, GLuint* textures) override { |
| + DCHECK_EQ(1, n); |
| + *textures = 1; |
| + } |
| +}; |
| +void MailboxHoldersReleased(uint32 sync_point) {} |
| +} // namespace |
| + |
| +TEST_F(SkCanvasVideoRendererTest, ContextLost) { |
|
Justin Novosad
2015/09/08 19:14:17
Add a comment to say that this test passes by not
Daniele Castagna
2015/09/08 19:24:24
Done.
|
| + skia::RefPtr<const GrGLInterface> null_interface = |
| + skia::AdoptRef(GrGLCreateNullInterface()); |
| + auto gr_context = skia::AdoptRef(GrContext::Create( |
| + kOpenGL_GrBackend, |
| + reinterpret_cast<GrBackendContext>(null_interface.get()))); |
| + SkCanvas canvas(AllocBitmap(kWidth, kHeight)); |
| + gr_context->abandonContext(); |
|
Justin Novosad
2015/09/08 19:14:17
Nit: I would have put this after constructing Cont
Daniele Castagna
2015/09/08 19:24:24
Done.
|
| + |
| + TestGLES2Interface gles2; |
| + Context3D context_3d(&gles2, gr_context.get()); |
| + gfx::Size size(kWidth, kHeight); |
| + gpu::MailboxHolder mailbox(gpu::Mailbox::Generate(), GL_TEXTURE_RECTANGLE_ARB, |
| + 0); |
| + auto video_frame = VideoFrame::WrapNativeTexture( |
| + PIXEL_FORMAT_UYVY, mailbox, base::Bind(MailboxHoldersReleased), size, |
| + gfx::Rect(size), size, kNoTimestamp()); |
| + |
| + renderer_.Paint(video_frame, &canvas, kNaturalRect, 0xFF, |
| + SkXfermode::kSrcOver_Mode, VIDEO_ROTATION_90, context_3d); |
| +} |
| } // namespace media |