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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 static_cast<FakePictureLayerImpl*>(layer); | 224 static_cast<FakePictureLayerImpl*>(layer); |
225 required_for_draw_count_ += fake_layer->CountTilesRequiredForDraw(); | 225 required_for_draw_count_ += fake_layer->CountTilesRequiredForDraw(); |
226 } | 226 } |
227 | 227 |
228 EndTest(); | 228 EndTest(); |
229 } | 229 } |
230 | 230 |
231 void AfterTest() override { | 231 void AfterTest() override { |
232 EXPECT_TRUE(did_notify_ready_to_draw_); | 232 EXPECT_TRUE(did_notify_ready_to_draw_); |
233 EXPECT_TRUE(all_tiles_required_for_draw_are_ready_to_draw_); | 233 EXPECT_TRUE(all_tiles_required_for_draw_are_ready_to_draw_); |
234 EXPECT_EQ(size_t(0), required_for_draw_count_); | 234 EXPECT_EQ(0, required_for_draw_count_); |
235 } | 235 } |
236 | 236 |
237 protected: | 237 protected: |
238 bool did_notify_ready_to_draw_; | 238 bool did_notify_ready_to_draw_; |
239 bool all_tiles_required_for_draw_are_ready_to_draw_; | 239 bool all_tiles_required_for_draw_are_ready_to_draw_; |
240 size_t required_for_draw_count_; | 240 int required_for_draw_count_; |
241 }; | 241 }; |
242 | 242 |
243 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestReadyToDrawEmpty); | 243 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestReadyToDrawEmpty); |
244 | 244 |
245 // Test if the LTHI receives ReadyToDraw notifications from the TileManager when | 245 // Test if the LTHI receives ReadyToDraw notifications from the TileManager when |
246 // some raster tasks flagged as REQUIRED_FOR_DRAW got scheduled. | 246 // some raster tasks flagged as REQUIRED_FOR_DRAW got scheduled. |
247 class LayerTreeHostTestReadyToDrawNonEmpty | 247 class LayerTreeHostTestReadyToDrawNonEmpty |
248 : public LayerTreeHostTestReadyToDrawEmpty { | 248 : public LayerTreeHostTestReadyToDrawEmpty { |
249 public: | 249 public: |
250 void SetupTree() override { | 250 void SetupTree() override { |
251 client_.set_fill_with_nonsolid_color(true); | 251 client_.set_fill_with_nonsolid_color(true); |
252 scoped_refptr<FakePictureLayer> root_layer = | 252 scoped_refptr<FakePictureLayer> root_layer = |
253 FakePictureLayer::Create(layer_settings(), &client_); | 253 FakePictureLayer::Create(layer_settings(), &client_); |
254 root_layer->SetBounds(gfx::Size(1024, 1024)); | 254 root_layer->SetBounds(gfx::Size(1024, 1024)); |
255 root_layer->SetIsDrawable(true); | 255 root_layer->SetIsDrawable(true); |
256 | 256 |
257 layer_tree_host()->SetRootLayer(root_layer); | 257 layer_tree_host()->SetRootLayer(root_layer); |
258 LayerTreeHostTest::SetupTree(); | 258 LayerTreeHostTest::SetupTree(); |
259 } | 259 } |
260 | 260 |
261 void AfterTest() override { | 261 void AfterTest() override { |
262 EXPECT_TRUE(did_notify_ready_to_draw_); | 262 EXPECT_TRUE(did_notify_ready_to_draw_); |
263 EXPECT_TRUE(all_tiles_required_for_draw_are_ready_to_draw_); | 263 EXPECT_TRUE(all_tiles_required_for_draw_are_ready_to_draw_); |
264 EXPECT_LE(size_t(1), required_for_draw_count_); | 264 EXPECT_LE(1, required_for_draw_count_); |
265 } | 265 } |
266 | 266 |
267 private: | 267 private: |
268 FakeContentLayerClient client_; | 268 FakeContentLayerClient client_; |
269 }; | 269 }; |
270 | 270 |
271 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in | 271 // Note: With this test setup, we only get tiles flagged as REQUIRED_FOR_DRAW in |
272 // single threaded mode. | 272 // single threaded mode. |
273 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty); | 273 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawNonEmpty); |
274 | 274 |
275 class LayerTreeHostTestReadyToDrawVisibility | |
brianderson
2015/07/16 22:36:14
Can you add a comment explaining what this test do
sunnyps
2015/07/16 22:51:44
Done.
| |
276 : public LayerTreeHostTestReadyToDrawNonEmpty { | |
277 public: | |
278 LayerTreeHostTestReadyToDrawVisibility() | |
279 : LayerTreeHostTestReadyToDrawNonEmpty(), did_commit_(false) {} | |
280 | |
281 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | |
282 EXPECT_FALSE(did_commit_); | |
283 did_commit_ = true; | |
284 PostSetVisibleToMainThread(false); | |
285 } | |
286 | |
287 void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, | |
288 bool visible) override { | |
289 if (!visible) { | |
290 EXPECT_TRUE(did_commit_); | |
291 PostSetVisibleToMainThread(true); | |
brianderson
2015/07/16 22:36:14
To test the test, could you:
DCHECK(!all_tiles_req
sunnyps
2015/07/16 22:51:44
Done.
| |
292 } | |
293 } | |
294 | |
295 protected: | |
296 bool did_commit_; | |
297 }; | |
298 | |
299 SINGLE_THREAD_TEST_F(LayerTreeHostTestReadyToDrawVisibility); | |
300 | |
275 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { | 301 class LayerTreeHostFreeWorkerContextResourcesTest : public LayerTreeHostTest { |
276 public: | 302 public: |
277 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 303 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
278 auto output_surface = make_scoped_ptr(new testing::StrictMock< | 304 auto output_surface = make_scoped_ptr(new testing::StrictMock< |
279 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( | 305 MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface>( |
280 delegating_renderer())); | 306 delegating_renderer())); |
281 | 307 |
282 // At init, we expect one call to set visibility to true. | 308 // At init, we expect one call to set visibility to true. |
283 testing::Expectation visibility_true = | 309 testing::Expectation visibility_true = |
284 EXPECT_CALL(*output_surface, | 310 EXPECT_CALL(*output_surface, |
(...skipping 5767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6052 void AfterTest() override {} | 6078 void AfterTest() override {} |
6053 | 6079 |
6054 std::vector<int> affected_by_page_scale_; | 6080 std::vector<int> affected_by_page_scale_; |
6055 std::vector<int> not_affected_by_page_scale_; | 6081 std::vector<int> not_affected_by_page_scale_; |
6056 }; | 6082 }; |
6057 | 6083 |
6058 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags); | 6084 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeTestPageScaleFlags); |
6059 | 6085 |
6060 } // namespace | 6086 } // namespace |
6061 } // namespace cc | 6087 } // namespace cc |
OLD | NEW |