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

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: feedback 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: 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 129aeca9bf265c698e797cdc0d685f236ed4aa78..d4212e48285edea76899dbe5826bc1dbf0b41852 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -452,7 +452,10 @@ class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
// At init, visibility is set to true and we will call
// SetAggressivelyFreeResources(false).
- EXPECT_CALL(*mock_context_support_ptr_, SetClientVisible(0, 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_,
@@ -479,7 +482,10 @@ class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
// While running, visibility is set to false, and we will call
// DeleteCachedResources and SetAggressivelyFreeResources(true).
- EXPECT_CALL(*mock_context_support_ptr_, SetClientVisible(0, false));
+ 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());
@@ -509,11 +515,27 @@ 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_;

Powered by Google App Engine
This is Rietveld 408576698