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/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "cc/resources/prioritized_resource_manager.h" | 8 #include "cc/resources/prioritized_resource_manager.h" |
9 #include "cc/resources/resource_provider.h" | 9 #include "cc/resources/resource_provider.h" |
10 #include "cc/resources/resource_update_queue.h" | 10 #include "cc/resources/resource_update_queue.h" |
11 #include "cc/resources/scoped_ui_resource.h" | 11 #include "cc/resources/scoped_ui_resource.h" |
12 #include "cc/test/fake_layer_tree_host.h" | 12 #include "cc/test/fake_layer_tree_host.h" |
13 #include "cc/test/fake_layer_tree_host_client.h" | 13 #include "cc/test/fake_layer_tree_host_client.h" |
14 #include "cc/test/fake_output_surface.h" | 14 #include "cc/test/fake_output_surface.h" |
15 #include "cc/test/fake_output_surface_client.h" | 15 #include "cc/test/fake_output_surface_client.h" |
16 #include "cc/test/geometry_test_utils.h" | 16 #include "cc/test/geometry_test_utils.h" |
| 17 #include "cc/test/test_task_graph_runner.h" |
17 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
18 #include "cc/trees/single_thread_proxy.h" | 19 #include "cc/trees/single_thread_proxy.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
22 | 23 |
23 using ::testing::Mock; | 24 using ::testing::Mock; |
24 using ::testing::_; | 25 using ::testing::_; |
25 using ::testing::AtLeast; | 26 using ::testing::AtLeast; |
26 using ::testing::AnyNumber; | 27 using ::testing::AnyNumber; |
(...skipping 21 matching lines...) Expand all Loading... |
48 } | 49 } |
49 ~TestUIResourceLayer() override {} | 50 ~TestUIResourceLayer() override {} |
50 }; | 51 }; |
51 | 52 |
52 class UIResourceLayerTest : public testing::Test { | 53 class UIResourceLayerTest : public testing::Test { |
53 public: | 54 public: |
54 UIResourceLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} | 55 UIResourceLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} |
55 | 56 |
56 protected: | 57 protected: |
57 void SetUp() override { | 58 void SetUp() override { |
58 layer_tree_host_ = FakeLayerTreeHost::Create(&fake_client_); | 59 layer_tree_host_ = |
| 60 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); |
59 layer_tree_host_->InitializeSingleThreaded( | 61 layer_tree_host_->InitializeSingleThreaded( |
60 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); | 62 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); |
61 } | 63 } |
62 | 64 |
63 void TearDown() override { | 65 void TearDown() override { |
64 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 66 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
65 } | 67 } |
66 | 68 |
67 FakeLayerTreeHostClient fake_client_; | 69 FakeLayerTreeHostClient fake_client_; |
| 70 TestTaskGraphRunner task_graph_runner_; |
68 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; | 71 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; |
69 LayerSettings layer_settings_; | 72 LayerSettings layer_settings_; |
70 }; | 73 }; |
71 | 74 |
72 TEST_F(UIResourceLayerTest, SetBitmap) { | 75 TEST_F(UIResourceLayerTest, SetBitmap) { |
73 scoped_refptr<UIResourceLayer> test_layer = | 76 scoped_refptr<UIResourceLayer> test_layer = |
74 TestUIResourceLayer::Create(layer_settings_); | 77 TestUIResourceLayer::Create(layer_settings_); |
75 ASSERT_TRUE(test_layer.get()); | 78 ASSERT_TRUE(test_layer.get()); |
76 test_layer->SetBounds(gfx::Size(100, 100)); | 79 test_layer->SetBounds(gfx::Size(100, 100)); |
77 | 80 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 146 |
144 test_layer->SetBitmap(bitmap); | 147 test_layer->SetBitmap(bitmap); |
145 ASSERT_FALSE(bitmap.pixelRef()->unique()); | 148 ASSERT_FALSE(bitmap.pixelRef()->unique()); |
146 | 149 |
147 test_layer->SetUIResourceId(0); | 150 test_layer->SetUIResourceId(0); |
148 EXPECT_TRUE(bitmap.pixelRef()->unique()); | 151 EXPECT_TRUE(bitmap.pixelRef()->unique()); |
149 } | 152 } |
150 | 153 |
151 } // namespace | 154 } // namespace |
152 } // namespace cc | 155 } // namespace cc |
OLD | NEW |