OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
9 #include "cc/resources/ui_resource_bitmap.h" | 9 #include "cc/resources/ui_resource_bitmap.h" |
10 #include "cc/test/fake_layer_tree_host_client.h" | 10 #include "cc/test/stub_layer_tree_host_client.h" |
11 #include "cc/test/test_task_graph_runner.h" | 11 #include "cc/test/test_task_graph_runner.h" |
12 #include "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
17 #include "ui/android/resources/resource_manager_impl.h" | 17 #include "ui/android/resources/resource_manager_impl.h" |
18 #include "ui/android/resources/system_ui_resource_type.h" | 18 #include "ui/android/resources/system_ui_resource_type.h" |
19 #include "ui/android/window_android.h" | 19 #include "ui/android/window_android.h" |
20 #include "ui/gfx/android/java_bitmap.h" | 20 #include "ui/gfx/android/java_bitmap.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 } // namespace | 87 } // namespace |
88 | 88 |
89 class ResourceManagerTest : public testing::Test { | 89 class ResourceManagerTest : public testing::Test { |
90 public: | 90 public: |
91 ResourceManagerTest() | 91 ResourceManagerTest() |
92 : window_android_(WindowAndroid::createForTesting()), | 92 : window_android_(WindowAndroid::createForTesting()), |
93 resource_manager_(window_android_) { | 93 resource_manager_(window_android_) { |
94 cc::LayerTreeHost::InitParams params; | 94 cc::LayerTreeHost::InitParams params; |
95 cc::LayerTreeSettings settings; | 95 cc::LayerTreeSettings settings; |
96 params.client = &fake_client_; | 96 params.client = &stub_client_; |
97 params.settings = &settings; | 97 params.settings = &settings; |
98 params.task_graph_runner = &task_graph_runner_; | 98 params.task_graph_runner = &task_graph_runner_; |
99 params.animation_host = | 99 params.animation_host = |
100 cc::AnimationHost::CreateForTesting(cc::ThreadInstance::MAIN); | 100 cc::AnimationHost::CreateForTesting(cc::ThreadInstance::MAIN); |
101 host_.reset(new MockLayerTreeHost(¶ms, | 101 host_.reset(new MockLayerTreeHost(¶ms, |
102 cc::CompositorMode::SINGLE_THREADED)); | 102 cc::CompositorMode::SINGLE_THREADED)); |
103 resource_manager_.Init(host_.get()); | 103 resource_manager_.Init(host_.get()); |
104 } | 104 } |
105 | 105 |
106 ~ResourceManagerTest() override { window_android_->Destroy(NULL, NULL); } | 106 ~ResourceManagerTest() override { window_android_->Destroy(NULL, NULL); } |
(...skipping 12 matching lines...) Expand all Loading... |
119 type); | 119 type); |
120 } | 120 } |
121 | 121 |
122 private: | 122 private: |
123 WindowAndroid* window_android_; | 123 WindowAndroid* window_android_; |
124 | 124 |
125 protected: | 125 protected: |
126 std::unique_ptr<MockLayerTreeHost> host_; | 126 std::unique_ptr<MockLayerTreeHost> host_; |
127 TestResourceManagerImpl resource_manager_; | 127 TestResourceManagerImpl resource_manager_; |
128 cc::TestTaskGraphRunner task_graph_runner_; | 128 cc::TestTaskGraphRunner task_graph_runner_; |
129 cc::FakeLayerTreeHostClient fake_client_; | 129 cc::StubLayerTreeHostClient stub_client_; |
130 }; | 130 }; |
131 | 131 |
132 TEST_F(ResourceManagerTest, GetResource) { | 132 TEST_F(ResourceManagerTest, GetResource) { |
133 const cc::UIResourceId kResourceId = 99; | 133 const cc::UIResourceId kResourceId = 99; |
134 EXPECT_CALL(*host_.get(), CreateUIResource(_)) | 134 EXPECT_CALL(*host_.get(), CreateUIResource(_)) |
135 .WillOnce(Return(kResourceId)) | 135 .WillOnce(Return(kResourceId)) |
136 .RetiresOnSaturation(); | 136 .RetiresOnSaturation(); |
137 EXPECT_EQ(kResourceId, GetUIResourceId(kTestResourceType)); | 137 EXPECT_EQ(kResourceId, GetUIResourceId(kTestResourceType)); |
138 } | 138 } |
139 | 139 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 EXPECT_EQ(kNumFrames, actual_rects.size()); | 180 EXPECT_EQ(kNumFrames, actual_rects.size()); |
181 for (size_t i = 0; i < kNumFrames; i++) { | 181 for (size_t i = 0; i < kNumFrames; i++) { |
182 EXPECT_EQ(expected_rects[i].size(), actual_rects[i].size()); | 182 EXPECT_EQ(expected_rects[i].size(), actual_rects[i].size()); |
183 for (size_t j = 0; j < actual_rects[i].size(); j++) { | 183 for (size_t j = 0; j < actual_rects[i].size(); j++) { |
184 EXPECT_EQ(expected_rects[i][j], actual_rects[i][j]); | 184 EXPECT_EQ(expected_rects[i][j], actual_rects[i][j]); |
185 } | 185 } |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 } // namespace ui | 189 } // namespace ui |
OLD | NEW |