OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui_resource_layer.h" | 5 #include "cc/layers/ui_resource_layer.h" |
6 | 6 |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "cc/resources/resource_provider.h" | 8 #include "cc/resources/resource_provider.h" |
9 #include "cc/resources/scoped_ui_resource.h" | 9 #include "cc/resources/scoped_ui_resource.h" |
10 #include "cc/test/fake_layer_tree_host.h" | 10 #include "cc/test/fake_layer_tree_host.h" |
11 #include "cc/test/fake_layer_tree_host_client.h" | 11 #include "cc/test/fake_layer_tree_host_client.h" |
12 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
13 #include "cc/test/fake_output_surface_client.h" | 13 #include "cc/test/fake_output_surface_client.h" |
14 #include "cc/test/geometry_test_utils.h" | 14 #include "cc/test/geometry_test_utils.h" |
| 15 #include "cc/test/stub_layer_tree_host_single_thread_client.h" |
15 #include "cc/test/test_task_graph_runner.h" | 16 #include "cc/test/test_task_graph_runner.h" |
16 #include "cc/trees/layer_tree_host.h" | 17 #include "cc/trees/layer_tree_host.h" |
17 #include "cc/trees/single_thread_proxy.h" | 18 #include "cc/trees/single_thread_proxy.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
21 | 22 |
22 using ::testing::Mock; | 23 using ::testing::Mock; |
23 using ::testing::_; | 24 using ::testing::_; |
24 using ::testing::AtLeast; | 25 using ::testing::AtLeast; |
(...skipping 18 matching lines...) Expand all Loading... |
43 TestUIResourceLayer() : UIResourceLayer() { SetIsDrawable(true); } | 44 TestUIResourceLayer() : UIResourceLayer() { SetIsDrawable(true); } |
44 ~TestUIResourceLayer() override {} | 45 ~TestUIResourceLayer() override {} |
45 }; | 46 }; |
46 | 47 |
47 class UIResourceLayerTest : public testing::Test { | 48 class UIResourceLayerTest : public testing::Test { |
48 protected: | 49 protected: |
49 void SetUp() override { | 50 void SetUp() override { |
50 layer_tree_host_ = | 51 layer_tree_host_ = |
51 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); | 52 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); |
52 layer_tree_host_->InitializeSingleThreaded( | 53 layer_tree_host_->InitializeSingleThreaded( |
53 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); | 54 &single_thread_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); |
54 } | 55 } |
55 | 56 |
56 void TearDown() override { | 57 void TearDown() override { |
57 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 58 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
58 } | 59 } |
59 | 60 |
60 FakeLayerTreeHostClient fake_client_; | 61 FakeLayerTreeHostClient fake_client_; |
| 62 StubLayerTreeHostSingleThreadClient single_thread_client_; |
61 TestTaskGraphRunner task_graph_runner_; | 63 TestTaskGraphRunner task_graph_runner_; |
62 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; | 64 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; |
63 }; | 65 }; |
64 | 66 |
65 TEST_F(UIResourceLayerTest, SetBitmap) { | 67 TEST_F(UIResourceLayerTest, SetBitmap) { |
66 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create(); | 68 scoped_refptr<UIResourceLayer> test_layer = TestUIResourceLayer::Create(); |
67 ASSERT_TRUE(test_layer.get()); | 69 ASSERT_TRUE(test_layer.get()); |
68 test_layer->SetBounds(gfx::Size(100, 100)); | 70 test_layer->SetBounds(gfx::Size(100, 100)); |
69 | 71 |
70 layer_tree_host_->SetRootLayer(test_layer); | 72 layer_tree_host_->SetRootLayer(test_layer); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 133 |
132 test_layer->SetBitmap(bitmap); | 134 test_layer->SetBitmap(bitmap); |
133 ASSERT_FALSE(bitmap.pixelRef()->unique()); | 135 ASSERT_FALSE(bitmap.pixelRef()->unique()); |
134 | 136 |
135 test_layer->SetUIResourceId(0); | 137 test_layer->SetUIResourceId(0); |
136 EXPECT_TRUE(bitmap.pixelRef()->unique()); | 138 EXPECT_TRUE(bitmap.pixelRef()->unique()); |
137 } | 139 } |
138 | 140 |
139 } // namespace | 141 } // namespace |
140 } // namespace cc | 142 } // namespace cc |
OLD | NEW |