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

Unified Diff: cc/trees/layer_tree_host_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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | content/common/gpu/client/context_provider_command_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 4efbb6872ae2a022a31671e0b71ae87a8d660eab..5f212536f20798faa8c3b0b2c0eb6bd074dd9a84 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -450,13 +450,13 @@ class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
// Ensure that our mock calls execute in sequence.
::testing::InSequence s;
- // At init, visibility is set to true and we will call
- // SetAggressivelyFreeResources(false).
- EXPECT_CALL(*mock_context_support_ptr_, SetClientVisible(0, true));
+ // At init, visibility is set to true.
+ EXPECT_CALL(*mock_context_support_ptr_, ClientBecameVisible())
+ .WillOnce(
+ ::testing::Invoke(mock_context_support_ptr_,
+ &MockContextSupport::SuperClientBecameVisible));
EXPECT_CALL(*mock_context_support_ptr_, AnyClientsVisible())
.WillOnce(::testing::Return(true));
- EXPECT_CALL(*mock_context_support_ptr_,
- SetAggressivelyFreeResources(false));
return LayerTreeHostTest::CreateDelegatingOutputSurface(
std::move(compositor_context_provider),
@@ -478,13 +478,15 @@ class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
::testing::InSequence s;
// While running, visibility is set to false, and we will call
- // DeleteCachedResources and SetAggressivelyFreeResources(true).
- EXPECT_CALL(*mock_context_support_ptr_, SetClientVisible(0, false));
+ // DeleteCachedResources.
+ EXPECT_CALL(*mock_context_support_ptr_, ClientBecameNotVisible_(_))
+ .WillOnce(::testing::Invoke(
+ mock_context_support_ptr_,
+ &MockContextSupport::SuperClientBecameNotVisible));
EXPECT_CALL(*mock_context_support_ptr_, AnyClientsVisible())
.WillOnce(::testing::Return(false));
- EXPECT_CALL(*mock_context_provider_ptr_, DeleteCachedResources());
- EXPECT_CALL(*mock_context_support_ptr_, SetAggressivelyFreeResources(true))
- .WillOnce(testing::Invoke([this](bool is_visible) { EndTest(); }));
+ EXPECT_CALL(*mock_context_provider_ptr_, DeleteCachedResources())
+ .WillOnce(testing::Invoke([this]() { EndTest(); }));
}
void AfterTest() override {
@@ -509,11 +511,25 @@ class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
class MockContextSupport : public TestContextSupport {
public:
+ using VisibilityToken = std::unique_ptr<ScopedVisibility>;
MockContextSupport() {}
- MOCK_METHOD1(SetAggressivelyFreeResources,
- void(bool aggressively_free_resources));
- MOCK_METHOD2(SetClientVisible, void(int client_id, bool is_visible));
+ MOCK_METHOD0(ClientBecameVisible, VisibilityToken());
+ MOCK_METHOD1(ClientBecameNotVisible_,
+ void(VisibilityToken& visibility)); // NOLINT
MOCK_CONST_METHOD0(AnyClientsVisible, bool());
+
+ // Wrapper to allow mocking w/ move-only type.
+ void ClientBecameNotVisible(VisibilityToken visibility) override {
+ ClientBecameNotVisible_(visibility);
+ }
+
+ // Wrappers to allow forwarding to super class implementation.
+ void SuperClientBecameNotVisible(VisibilityToken& visibility) { // NOLINT
+ TestContextSupport::ClientBecameNotVisible(std::move(visibility));
+ }
+ VisibilityToken SuperClientBecameVisible() {
+ return TestContextSupport::ClientBecameVisible();
+ }
};
MockContextSupport* mock_context_support_ptr_;
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | content/common/gpu/client/context_provider_command_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698