OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "cc/animation/keyframed_animation_curve.h" | 8 #include "cc/animation/keyframed_animation_curve.h" |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ | 37 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ |
38 code_to_test; \ | 38 code_to_test; \ |
39 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ | 39 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ |
40 } while (false) | 40 } while (false) |
41 | 41 |
42 namespace cc { | 42 namespace cc { |
43 namespace { | 43 namespace { |
44 | 44 |
45 class MockLayerTreeHost : public LayerTreeHost { | 45 class MockLayerTreeHost : public LayerTreeHost { |
46 public: | 46 public: |
47 explicit MockLayerTreeHost(FakeLayerTreeHostClient* client) | 47 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, |
48 : LayerTreeHost(client, nullptr, nullptr, nullptr, LayerTreeSettings()) { | 48 LayerTreeHost::InitParams* params) |
49 InitializeSingleThreaded(client, base::ThreadTaskRunnerHandle::Get(), | 49 : LayerTreeHost(params) { |
50 nullptr); | 50 InitializeSingleThreaded(single_thread_client, |
| 51 base::ThreadTaskRunnerHandle::Get(), nullptr); |
51 } | 52 } |
52 | 53 |
53 MOCK_METHOD0(SetNeedsCommit, void()); | 54 MOCK_METHOD0(SetNeedsCommit, void()); |
54 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 55 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
55 MOCK_METHOD0(SetNeedsFullTreeSync, void()); | 56 MOCK_METHOD0(SetNeedsFullTreeSync, void()); |
56 }; | 57 }; |
57 | 58 |
58 class MockLayerPainter : public LayerPainter { | 59 class MockLayerPainter : public LayerPainter { |
59 public: | 60 public: |
60 void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) override {} | 61 void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) override {} |
61 }; | 62 }; |
62 | 63 |
63 class LayerTest : public testing::Test { | 64 class LayerTest : public testing::Test { |
64 public: | 65 public: |
65 LayerTest() | 66 LayerTest() |
66 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), | 67 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), |
67 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} | 68 fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} |
68 | 69 |
69 protected: | 70 protected: |
70 void SetUp() override { | 71 void SetUp() override { |
71 layer_tree_host_.reset(new StrictMock<MockLayerTreeHost>(&fake_client_)); | 72 LayerTreeHost::InitParams params; |
| 73 params.client = &fake_client_; |
| 74 layer_tree_host_.reset( |
| 75 new StrictMock<MockLayerTreeHost>(&fake_client_, ¶ms)); |
72 } | 76 } |
73 | 77 |
74 void TearDown() override { | 78 void TearDown() override { |
75 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 79 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
76 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 80 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
77 parent_ = nullptr; | 81 parent_ = nullptr; |
78 child1_ = nullptr; | 82 child1_ = nullptr; |
79 child2_ = nullptr; | 83 child2_ = nullptr; |
80 child3_ = nullptr; | 84 child3_ = nullptr; |
81 grand_child1_ = nullptr; | 85 grand_child1_ = nullptr; |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 934 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
931 } | 935 } |
932 | 936 |
933 class LayerTreeHostFactory { | 937 class LayerTreeHostFactory { |
934 public: | 938 public: |
935 LayerTreeHostFactory() | 939 LayerTreeHostFactory() |
936 : client_(FakeLayerTreeHostClient::DIRECT_3D), | 940 : client_(FakeLayerTreeHostClient::DIRECT_3D), |
937 shared_bitmap_manager_(new TestSharedBitmapManager), | 941 shared_bitmap_manager_(new TestSharedBitmapManager), |
938 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager) {} | 942 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager) {} |
939 | 943 |
940 scoped_ptr<LayerTreeHost> Create() { | 944 scoped_ptr<LayerTreeHost> Create() { return Create(LayerTreeSettings()); } |
941 return LayerTreeHost::CreateSingleThreaded( | |
942 &client_, &client_, shared_bitmap_manager_.get(), | |
943 gpu_memory_buffer_manager_.get(), nullptr, LayerTreeSettings(), | |
944 base::ThreadTaskRunnerHandle::Get(), nullptr); | |
945 } | |
946 | 945 |
947 scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { | 946 scoped_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { |
948 return LayerTreeHost::CreateSingleThreaded( | 947 LayerTreeHost::InitParams params; |
949 &client_, &client_, shared_bitmap_manager_.get(), | 948 params.client = &client_; |
950 gpu_memory_buffer_manager_.get(), nullptr, settings, | 949 params.shared_bitmap_manager = shared_bitmap_manager_.get(); |
951 base::ThreadTaskRunnerHandle::Get(), nullptr); | 950 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager_.get(); |
| 951 params.settings = &settings; |
| 952 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 953 return LayerTreeHost::CreateSingleThreaded(&client_, ¶ms); |
952 } | 954 } |
953 | 955 |
954 private: | 956 private: |
955 FakeLayerTreeHostClient client_; | 957 FakeLayerTreeHostClient client_; |
956 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; | 958 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; |
957 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 959 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
958 }; | 960 }; |
959 | 961 |
960 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { | 962 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { |
961 EXPECT_EQ(host, layer->layer_tree_host()); | 963 EXPECT_EQ(host, layer->layer_tree_host()); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 // When the layer is destroyed, the other three requests should be aborted. | 1318 // When the layer is destroyed, the other three requests should be aborted. |
1317 layer = nullptr; | 1319 layer = nullptr; |
1318 EXPECT_EQ(1, did_receive_first_result_from_this_source); | 1320 EXPECT_EQ(1, did_receive_first_result_from_this_source); |
1319 EXPECT_EQ(1, did_receive_result_from_different_source); | 1321 EXPECT_EQ(1, did_receive_result_from_different_source); |
1320 EXPECT_EQ(1, did_receive_result_from_anonymous_source); | 1322 EXPECT_EQ(1, did_receive_result_from_anonymous_source); |
1321 EXPECT_EQ(1, did_receive_second_result_from_this_source); | 1323 EXPECT_EQ(1, did_receive_second_result_from_this_source); |
1322 } | 1324 } |
1323 | 1325 |
1324 } // namespace | 1326 } // namespace |
1325 } // namespace cc | 1327 } // namespace cc |
OLD | NEW |