Chromium Code Reviews| Index: cc/surfaces/surface_manager_unittest.cc |
| diff --git a/cc/surfaces/surface_manager_unittest.cc b/cc/surfaces/surface_manager_unittest.cc |
| index 6142560acb4315e2bcfd8eddd156ce2929ff5905..53611c48fe5e02d30b0a91ee85c3931d9b251c2f 100644 |
| --- a/cc/surfaces/surface_manager_unittest.cc |
| +++ b/cc/surfaces/surface_manager_unittest.cc |
| @@ -5,30 +5,30 @@ |
| #include <stddef.h> |
| #include "cc/scheduler/begin_frame_source.h" |
| -#include "cc/surfaces/surface_factory_client.h" |
| +#include "cc/surfaces/compositor_frame_sink_support.h" |
| #include "cc/surfaces/surface_manager.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace cc { |
| -class FakeSurfaceFactoryClient : public SurfaceFactoryClient { |
| +class FakeSurfaceFactoryClient : public CompositorFrameSinkSupport { |
|
Fady Samuel
2017/04/03 22:33:25
Can we get rid of this entirely?
Alex Z.
2017/04/04 14:10:33
Done.
|
| public: |
| - explicit FakeSurfaceFactoryClient(const FrameSinkId& frame_sink_id) |
| - : source_(nullptr), manager_(nullptr), frame_sink_id_(frame_sink_id) {} |
| - |
| FakeSurfaceFactoryClient(const FrameSinkId& frame_sink_id, |
| SurfaceManager* manager) |
| - : source_(nullptr), manager_(nullptr), frame_sink_id_(frame_sink_id) { |
| + : CompositorFrameSinkSupport(nullptr, |
| + manager, |
| + frame_sink_id, |
| + false /* is_root */, |
| + false /* handles_frame_sink_id_validation */, |
| + true /* needs_sync_points */), |
| + source_(nullptr), |
| + manager_(nullptr), |
| + frame_sink_id_(frame_sink_id) { |
| DCHECK(manager); |
| Register(manager); |
| } |
| - ~FakeSurfaceFactoryClient() override { |
| - if (manager_) { |
| - Unregister(); |
| - } |
| - EXPECT_EQ(nullptr, source_); |
| - } |
| + ~FakeSurfaceFactoryClient() override {} |
| BeginFrameSource* source() { return source_; } |
| const FrameSinkId& frame_sink_id() { return frame_sink_id_; } |
| @@ -80,16 +80,12 @@ class SurfaceManagerTest : public testing::Test { |
| }; |
| TEST_F(SurfaceManagerTest, SingleClients) { |
| - FakeSurfaceFactoryClient client(FrameSinkId(1, 1)); |
| - FakeSurfaceFactoryClient other_client(FrameSinkId(2, 2)); |
| + FakeSurfaceFactoryClient client(FrameSinkId(1, 1), &manager_); |
| + FakeSurfaceFactoryClient other_client(FrameSinkId(2, 2), &manager_); |
| StubBeginFrameSource source; |
| EXPECT_EQ(nullptr, client.source()); |
| EXPECT_EQ(nullptr, other_client.source()); |
| - client.Register(&manager_); |
| - other_client.Register(&manager_); |
| - EXPECT_EQ(nullptr, client.source()); |
| - EXPECT_EQ(nullptr, other_client.source()); |
| // Test setting unsetting BFS |
| manager_.RegisterBeginFrameSource(&source, client.frame_sink_id()); |
| @@ -267,10 +263,7 @@ TEST_F(SurfaceManagerTest, |
| class SurfaceManagerOrderingTest : public SurfaceManagerTest { |
| public: |
| SurfaceManagerOrderingTest() |
| - : client_a_(FrameSinkId(1, 1)), |
| - client_b_(FrameSinkId(2, 2)), |
| - client_c_(FrameSinkId(3, 3)), |
| - hierarchy_registered_(false), |
| + : hierarchy_registered_(false), |
| clients_registered_(false), |
| bfs_registered_(false) { |
| AssertCorrectBFSState(); |
| @@ -286,44 +279,43 @@ class SurfaceManagerOrderingTest : public SurfaceManagerTest { |
| void RegisterHierarchy() { |
| DCHECK(!hierarchy_registered_); |
| hierarchy_registered_ = true; |
| - manager_.RegisterFrameSinkHierarchy(client_a_.frame_sink_id(), |
| - client_b_.frame_sink_id()); |
| - manager_.RegisterFrameSinkHierarchy(client_b_.frame_sink_id(), |
| - client_c_.frame_sink_id()); |
| + manager_.RegisterFrameSinkHierarchy(frame_sink_id_a_, frame_sink_id_b_); |
| + manager_.RegisterFrameSinkHierarchy(frame_sink_id_b_, frame_sink_id_c_); |
| AssertCorrectBFSState(); |
| } |
| void UnregisterHierarchy() { |
| DCHECK(hierarchy_registered_); |
| hierarchy_registered_ = false; |
| - manager_.UnregisterFrameSinkHierarchy(client_a_.frame_sink_id(), |
| - client_b_.frame_sink_id()); |
| - manager_.UnregisterFrameSinkHierarchy(client_b_.frame_sink_id(), |
| - client_c_.frame_sink_id()); |
| + manager_.UnregisterFrameSinkHierarchy(frame_sink_id_a_, frame_sink_id_b_); |
| + manager_.UnregisterFrameSinkHierarchy(frame_sink_id_b_, frame_sink_id_c_); |
| AssertCorrectBFSState(); |
| } |
| void RegisterClients() { |
| DCHECK(!clients_registered_); |
| clients_registered_ = true; |
| - client_a_.Register(&manager_); |
| - client_b_.Register(&manager_); |
| - client_c_.Register(&manager_); |
| + client_a_ = |
| + base::MakeUnique<FakeSurfaceFactoryClient>(frame_sink_id_a_, &manager_); |
| + client_b_ = |
| + base::MakeUnique<FakeSurfaceFactoryClient>(frame_sink_id_b_, &manager_); |
| + client_c_ = |
| + base::MakeUnique<FakeSurfaceFactoryClient>(frame_sink_id_c_, &manager_); |
| AssertCorrectBFSState(); |
| } |
| void UnregisterClients() { |
| DCHECK(clients_registered_); |
| clients_registered_ = false; |
| - client_a_.Unregister(); |
| - client_b_.Unregister(); |
| - client_c_.Unregister(); |
| + client_a_.reset(); |
| + client_b_.reset(); |
| + client_c_.reset(); |
| AssertCorrectBFSState(); |
| } |
| void RegisterBFS() { |
| DCHECK(!bfs_registered_); |
| bfs_registered_ = true; |
| - manager_.RegisterBeginFrameSource(&source_, client_a_.frame_sink_id()); |
| + manager_.RegisterBeginFrameSource(&source_, frame_sink_id_a_); |
| AssertCorrectBFSState(); |
| } |
| void UnregisterBFS() { |
| @@ -334,15 +326,15 @@ class SurfaceManagerOrderingTest : public SurfaceManagerTest { |
| } |
| void AssertEmptyBFS() { |
| - EXPECT_EQ(nullptr, client_a_.source()); |
| - EXPECT_EQ(nullptr, client_b_.source()); |
| - EXPECT_EQ(nullptr, client_c_.source()); |
| + EXPECT_TRUE(client_a_.get() == nullptr || client_a_->source() == nullptr); |
| + EXPECT_TRUE(client_b_.get() == nullptr || client_b_->source() == nullptr); |
| + EXPECT_TRUE(client_c_.get() == nullptr || client_c_->source() == nullptr); |
| } |
| void AssertAllValidBFS() { |
| - EXPECT_EQ(&source_, client_a_.source()); |
| - EXPECT_EQ(&source_, client_b_.source()); |
| - EXPECT_EQ(&source_, client_c_.source()); |
| + EXPECT_EQ(&source_, client_a_->source()); |
| + EXPECT_EQ(&source_, client_b_->source()); |
| + EXPECT_EQ(&source_, client_c_->source()); |
| } |
| protected: |
| @@ -353,9 +345,9 @@ class SurfaceManagerOrderingTest : public SurfaceManagerTest { |
| } |
| if (!hierarchy_registered_) { |
| // A valid but not attached to anything. |
| - EXPECT_EQ(&source_, client_a_.source()); |
| - EXPECT_EQ(nullptr, client_b_.source()); |
| - EXPECT_EQ(nullptr, client_c_.source()); |
| + EXPECT_EQ(&source_, client_a_->source()); |
| + EXPECT_TRUE(client_b_.get() == nullptr || client_b_->source() == nullptr); |
| + EXPECT_TRUE(client_c_.get() == nullptr || client_c_->source() == nullptr); |
| return; |
| } |
| @@ -364,9 +356,13 @@ class SurfaceManagerOrderingTest : public SurfaceManagerTest { |
| StubBeginFrameSource source_; |
| // A -> B -> C hierarchy, with A always having the BFS. |
| - FakeSurfaceFactoryClient client_a_; |
| - FakeSurfaceFactoryClient client_b_; |
| - FakeSurfaceFactoryClient client_c_; |
| + std::unique_ptr<FakeSurfaceFactoryClient> client_a_; |
| + std::unique_ptr<FakeSurfaceFactoryClient> client_b_; |
| + std::unique_ptr<FakeSurfaceFactoryClient> client_c_; |
| + |
| + const FrameSinkId frame_sink_id_a_ = FrameSinkId(1, 1); |
| + const FrameSinkId frame_sink_id_b_ = FrameSinkId(2, 2); |
| + const FrameSinkId frame_sink_id_c_ = FrameSinkId(3, 3); |
| bool hierarchy_registered_; |
| bool clients_registered_; |