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

Unified Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 2252163003: Update Context Client Visibility to use Scoped Pattern (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix webview Created 4 years, 4 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: 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"
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | ui/compositor/test/in_process_context_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698