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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2278283003: Refactor client visibility handling (Closed)
Patch Set: fix compositor_unittests 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 363e8e2e204d22348fbae5554081a2b8ade4d013..5b43dab8c8b4402918712359d642c35ee917450a 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -440,27 +440,21 @@ class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
base::MakeUnique<MockContextSupport>();
mock_context_support_ptr_ = mock_worker_context_support_owned.get();
- auto mock_worker_context_provider = make_scoped_refptr(
- new MockContextProvider(std::move(mock_worker_context_support_owned)));
- mock_context_provider_ptr_ = mock_worker_context_provider.get();
+ auto test_worker_context_provider = TestContextProvider::Create(
+ TestWebGraphicsContext3D::Create(),
+ std::move(mock_worker_context_support_owned));
// Workers are bound on the main thread.
- mock_worker_context_provider->BindToCurrentThread();
-
- // Ensure that our mock calls execute in sequence.
- ::testing::InSequence s;
+ test_worker_context_provider->BindToCurrentThread();
// 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_, AnyClientsVisible())
- .WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_context_support_ptr_,
SetAggressivelyFreeResources(false));
return LayerTreeHostTest::CreateDelegatingOutputSurface(
std::move(compositor_context_provider),
- std::move(mock_worker_context_provider));
+ std::move(test_worker_context_provider));
}
void InitializeSettings(LayerTreeSettings* settings) override {
@@ -474,15 +468,8 @@ class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
// Ensure that our initialization expectations have completed.
Mock::VerifyAndClearExpectations(mock_context_support_ptr_);
- // Ensure that our mock calls execute in sequence.
- ::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));
- EXPECT_CALL(*mock_context_support_ptr_, AnyClientsVisible())
- .WillOnce(::testing::Return(false));
- EXPECT_CALL(*mock_context_provider_ptr_, DeleteCachedResources());
+ // SetAggressivelyFreeResources(true).
EXPECT_CALL(*mock_context_support_ptr_, SetAggressivelyFreeResources(true))
.WillOnce(testing::Invoke([this](bool is_visible) { EndTest(); }));
}
@@ -490,34 +477,17 @@ class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest {
void AfterTest() override {
// Ensure all expectations are satisfied.
Mock::VerifyAndClearExpectations(mock_context_support_ptr_);
- Mock::VerifyAndClearExpectations(mock_context_provider_ptr_);
}
private:
- class MockContextProvider : public TestContextProvider {
- public:
- explicit MockContextProvider(std::unique_ptr<TestContextSupport> support)
- : TestContextProvider(std::move(support),
- base::MakeUnique<TestGLES2Interface>(),
- TestWebGraphicsContext3D::Create()) {}
-
- MOCK_METHOD0(DeleteCachedResources, void());
-
- private:
- ~MockContextProvider() = default;
- };
-
class MockContextSupport : public TestContextSupport {
public:
MockContextSupport() {}
MOCK_METHOD1(SetAggressivelyFreeResources,
void(bool aggressively_free_resources));
- MOCK_METHOD2(SetClientVisible, void(int client_id, bool is_visible));
- MOCK_CONST_METHOD0(AnyClientsVisible, bool());
};
MockContextSupport* mock_context_support_ptr_;
- MockContextProvider* mock_context_provider_ptr_;
};
// Test if the LTH successfully frees resources on the worker context when

Powered by Google App Engine
This is Rietveld 408576698