| Index: gpu/command_buffer/client/gles2_implementation_unittest.cc | 
| diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc | 
| index 8e532dc4c430be8cc75fd9513fae23302e99ed41..a18d4b7b0a3da90a8cef5aa0c5ea49dc4cddfb39 100644 | 
| --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc | 
| +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc | 
| @@ -17,6 +17,7 @@ | 
| #include <memory> | 
|  | 
| #include "base/compiler_specific.h" | 
| +#include "base/memory/ptr_util.h" | 
| #include "gpu/command_buffer/client/client_test_helper.h" | 
| #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 
| #include "gpu/command_buffer/client/program_info_manager.h" | 
| @@ -269,7 +270,6 @@ int MockTransferBuffer::GetResultOffset() { | 
| } | 
|  | 
| void MockTransferBuffer::Free() { | 
| -  NOTREACHED(); | 
| } | 
|  | 
| bool MockTransferBuffer::HaveBuffer() const { | 
| @@ -4609,17 +4609,46 @@ TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { | 
|  | 
| TEST_F(GLES2ImplementationTest, ClientVisibility) { | 
| EXPECT_FALSE(gl_->AnyClientsVisible()); | 
| -  gl_->SetClientVisible(0, true); | 
| -  EXPECT_TRUE(gl_->AnyClientsVisible()); | 
| -  gl_->SetClientVisible(0, false); | 
| -  EXPECT_FALSE(gl_->AnyClientsVisible()); | 
| -  gl_->SetClientVisible(0, true); | 
| -  gl_->SetClientVisible(1, true); | 
| -  EXPECT_TRUE(gl_->AnyClientsVisible()); | 
| -  gl_->SetClientVisible(0, false); | 
| -  EXPECT_TRUE(gl_->AnyClientsVisible()); | 
| -  gl_->SetClientVisible(1, false); | 
| +  { | 
| +    auto visibility_0 = gl_->ClientBecameVisible(); | 
| +    EXPECT_TRUE(gl_->AnyClientsVisible()); | 
| +    gl_->ClientBecameNotVisible(std::move(visibility_0)); | 
| +    EXPECT_FALSE(gl_->AnyClientsVisible()); | 
| +  } | 
| +  { | 
| +    auto visibility_0 = gl_->ClientBecameVisible(); | 
| +    auto visibility_1 = gl_->ClientBecameVisible(); | 
| +    EXPECT_TRUE(gl_->AnyClientsVisible()); | 
| +    gl_->ClientBecameNotVisible(std::move(visibility_0)); | 
| +    EXPECT_TRUE(gl_->AnyClientsVisible()); | 
| +    gl_->ClientBecameNotVisible(std::move(visibility_1)); | 
| +    EXPECT_FALSE(gl_->AnyClientsVisible()); | 
| +  } | 
| +} | 
| + | 
| +TEST_F(GLES2ImplementationTest, TrimResources) { | 
| EXPECT_FALSE(gl_->AnyClientsVisible()); | 
| + | 
| +  // TrimResources while no clients vivisble, this should persist | 
| +  // aggressively_free_resources_, causing further flushes to trim. | 
| +  EXPECT_CALL(*command_buffer(), OnFlush()).Times(2); | 
| +  EXPECT_CALL(*command_buffer(), DestroyTransferBuffer(_)).Times(2); | 
| +  gl_->TrimResources(); | 
| +  gl_->Flush(); | 
| +  Mock::VerifyAndClearExpectations(command_buffer()); | 
| + | 
| +  { | 
| +    // TrimResources while visible, this should not persisit | 
| +    // aggressively_free_resources_, and further flushes should not trim. | 
| +    auto visibility_0 = gl_->ClientBecameVisible(); | 
| +    EXPECT_TRUE(gl_->AnyClientsVisible()); | 
| +    EXPECT_CALL(*command_buffer(), OnFlush()).Times(2); | 
| +    EXPECT_CALL(*command_buffer(), DestroyTransferBuffer(_)).Times(1); | 
| +    gl_->Flush(); | 
| +    gl_->TrimResources(); | 
| +    gl_->Flush(); | 
| +    Mock::VerifyAndClearExpectations(command_buffer()); | 
| +  } | 
| } | 
|  | 
| #include "base/macros.h" | 
|  |