Chromium Code Reviews| Index: cc/output/gl_renderer_unittest.cc |
| diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc |
| index 0cf7d508ae37abe27e2b7368ccdfb327a15a20d8..a06b1bf0c0fb5b8d49a8bfcf1cd84cb82f3568e2 100644 |
| --- a/cc/output/gl_renderer_unittest.cc |
| +++ b/cc/output/gl_renderer_unittest.cc |
| @@ -1495,6 +1495,7 @@ class MockOutputSurface : public OutputSurface { |
| bool has_alpha, |
| bool use_stencil)); |
| MOCK_METHOD0(BindFramebuffer, void()); |
| + MOCK_METHOD1(SetDrawRectangle, void(const gfx::Rect&)); |
| MOCK_METHOD0(GetFramebufferCopyTextureFormat, GLenum()); |
| MOCK_METHOD1(SwapBuffers_, void(OutputSurfaceFrame& frame)); // NOLINT |
| void SwapBuffers(OutputSurfaceFrame frame) override { SwapBuffers_(frame); } |
| @@ -1872,12 +1873,14 @@ class PartialSwapMockGLES2Interface : public TestGLES2Interface { |
| class GLRendererPartialSwapTest : public GLRendererTest { |
| protected: |
| - void RunTest(bool partial_swap) { |
| + void RunTest(bool partial_swap, bool set_draw_rectangle) { |
| auto gl_owned = base::MakeUnique<PartialSwapMockGLES2Interface>(); |
| auto* gl = gl_owned.get(); |
| auto provider = TestContextProvider::Create(std::move(gl_owned)); |
| provider->BindToCurrentThread(); |
| + provider->TestContext3d()->set_support_set_draw_rectangle( |
| + set_draw_rectangle); |
| FakeOutputSurfaceClient output_surface_client; |
| std::unique_ptr<FakeOutputSurface> output_surface( |
| @@ -1917,12 +1920,18 @@ class GLRendererPartialSwapTest : public GLRendererTest { |
| // Partial frame, we should use a scissor to swap only that part when |
| // partial swap is enabled. |
| root_pass->damage_rect = gfx::Rect(2, 2, 3, 3); |
| + gfx::Rect output_rectangle = |
| + partial_swap ? root_pass->damage_rect : gfx::Rect(viewport_size); |
| - if (partial_swap) { |
| + if (partial_swap || set_draw_rectangle) { |
| EXPECT_CALL(*gl, Enable(GL_SCISSOR_TEST)).InSequence(seq); |
| // The scissor is flipped, so subtract the y coord and height from the |
| // bottom of the GL viewport. |
| - EXPECT_CALL(*gl, Scissor(2, viewport_size.height() - 3 - 2, 3, 3)) |
| + EXPECT_CALL( |
| + *gl, Scissor(output_rectangle.x(), |
| + viewport_size.height() - output_rectangle.y() - |
| + output_rectangle.height(), |
| + output_rectangle.width(), output_rectangle.height())) |
| .InSequence(seq); |
| } |
| @@ -1935,16 +1944,27 @@ class GLRendererPartialSwapTest : public GLRendererTest { |
| renderer.DecideRenderPassAllocationsForFrame( |
| render_passes_in_draw_order_); |
| DrawFrame(&renderer, viewport_size); |
| + if (set_draw_rectangle) { |
| + EXPECT_EQ(output_rectangle, output_surface->last_set_draw_rectangle()); |
|
danakj
2017/02/23 23:38:51
FWIW you could mock and EXPECT the method instead
|
| + } |
| } |
| } |
| }; |
| TEST_F(GLRendererPartialSwapTest, PartialSwap) { |
| - RunTest(true); |
| + RunTest(true, false); |
| } |
| TEST_F(GLRendererPartialSwapTest, NoPartialSwap) { |
| - RunTest(false); |
| + RunTest(false, false); |
| +} |
| + |
| +TEST_F(GLRendererPartialSwapTest, SetDrawRectangle) { |
|
danakj
2017/02/23 23:38:51
nit: maybe name the two test variants a bit more e
|
| + RunTest(true, true); |
| +} |
| + |
| +TEST_F(GLRendererPartialSwapTest, SetDrawRectangleNoPartialSwap) { |
| + RunTest(false, true); |
| } |
| class GLRendererWithMockContextTest : public ::testing::Test { |