Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: cc/layers/layer_unittest.cc

Issue 2716583004: cc: Remove SetNeedsUpdate function from cc::Layer (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "cc/animation/animation_host.h" 11 #include "cc/animation/animation_host.h"
12 #include "cc/animation/animation_id_provider.h" 12 #include "cc/animation/animation_id_provider.h"
13 #include "cc/animation/keyframed_animation_curve.h" 13 #include "cc/animation/keyframed_animation_curve.h"
14 #include "cc/base/math_util.h" 14 #include "cc/base/math_util.h"
15 #include "cc/input/main_thread_scrolling_reason.h" 15 #include "cc/input/main_thread_scrolling_reason.h"
16 #include "cc/layers/layer_impl.h" 16 #include "cc/layers/layer_impl.h"
17 #include "cc/layers/solid_color_scrollbar_layer.h" 17 #include "cc/layers/solid_color_scrollbar_layer.h"
18 #include "cc/output/copy_output_request.h" 18 #include "cc/output/copy_output_request.h"
19 #include "cc/output/copy_output_result.h" 19 #include "cc/output/copy_output_result.h"
20 #include "cc/test/animation_test_common.h" 20 #include "cc/test/animation_test_common.h"
21 #include "cc/test/fake_impl_task_runner_provider.h" 21 #include "cc/test/fake_impl_task_runner_provider.h"
22 #include "cc/test/fake_layer_tree_host.h" 22 #include "cc/test/fake_layer_tree_host.h"
23 #include "cc/test/fake_layer_tree_host_client.h" 23 #include "cc/test/fake_layer_tree_host_client.h"
24 #include "cc/test/fake_layer_tree_host_impl.h" 24 #include "cc/test/fake_layer_tree_host_impl.h"
25 #include "cc/test/geometry_test_utils.h" 25 #include "cc/test/geometry_test_utils.h"
26 #include "cc/test/layer_internals_for_test.h"
27 #include "cc/test/layer_test_common.h" 26 #include "cc/test/layer_test_common.h"
28 #include "cc/test/stub_layer_tree_host_single_thread_client.h" 27 #include "cc/test/stub_layer_tree_host_single_thread_client.h"
29 #include "cc/test/test_task_graph_runner.h" 28 #include "cc/test/test_task_graph_runner.h"
30 #include "cc/trees/layer_tree_host.h" 29 #include "cc/trees/layer_tree_host.h"
31 #include "cc/trees/mutable_properties.h" 30 #include "cc/trees/mutable_properties.h"
32 #include "cc/trees/single_thread_proxy.h" 31 #include "cc/trees/single_thread_proxy.h"
33 #include "cc/trees/transform_node.h" 32 #include "cc/trees/transform_node.h"
34 #include "testing/gmock/include/gmock/gmock.h" 33 #include "testing/gmock/include/gmock/gmock.h"
35 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
36 #include "third_party/skia/include/core/SkColor.h" 35 #include "third_party/skia/include/core/SkColor.h"
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 EXPECT_EQ(0, did_receive_second_result_from_this_source); 1373 EXPECT_EQ(0, did_receive_second_result_from_this_source);
1375 1374
1376 // When the layer is destroyed, the other three requests should be aborted. 1375 // When the layer is destroyed, the other three requests should be aborted.
1377 layer = nullptr; 1376 layer = nullptr;
1378 EXPECT_EQ(1, did_receive_first_result_from_this_source); 1377 EXPECT_EQ(1, did_receive_first_result_from_this_source);
1379 EXPECT_EQ(1, did_receive_result_from_different_source); 1378 EXPECT_EQ(1, did_receive_result_from_different_source);
1380 EXPECT_EQ(1, did_receive_result_from_anonymous_source); 1379 EXPECT_EQ(1, did_receive_result_from_anonymous_source);
1381 EXPECT_EQ(1, did_receive_second_result_from_this_source); 1380 EXPECT_EQ(1, did_receive_second_result_from_this_source);
1382 } 1381 }
1383 1382
1384 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { 1383 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) {
danakj 2017/02/24 00:52:38 This doesnt look like a LayerTest anymore
1385 scoped_refptr<Layer> layer = Layer::Create(); 1384 scoped_refptr<Layer> layer = Layer::Create();
1385 layer->SetElementId(ElementId(2, 0));
1386 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer)); 1386 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer));
1387 1387 auto element_id = layer->element_id();
1388 LayerInternalsForTest layer_internals(layer.get());
1389 1388
1390 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); 1389 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1);
1391 layer_internals.OnOpacityAnimated(0.5f); 1390 layer_tree_host_->SetElementOpacityMutated(element_id,
1391 ElementListType::ACTIVE, 0.5f);
1392 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 1392 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
1393 1393
1394 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); 1394 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1);
1395 gfx::Transform transform; 1395 gfx::Transform transform;
1396 transform.Rotate(45.0); 1396 transform.Rotate(45.0);
1397 layer_internals.OnTransformAnimated(transform); 1397 layer_tree_host_->SetElementTransformMutated(
1398 element_id, ElementListType::ACTIVE, transform);
1398 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 1399 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
1399 1400
1400 // Scroll offset animation should not schedule a layer update since it is 1401 // Scroll offset animation should not schedule a layer update since it is
1401 // handled similarly to normal compositor scroll updates. 1402 // handled similarly to normal compositor scroll updates.
1402 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(0); 1403 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(0);
1403 layer_internals.OnScrollOffsetAnimated(gfx::ScrollOffset(10, 10)); 1404 layer_tree_host_->SetElementScrollOffsetMutated(
1405 element_id, ElementListType::ACTIVE, gfx::ScrollOffset(10, 10));
1404 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 1406 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
1405 } 1407 }
1406 1408
1407 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { 1409 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) {
1408 scoped_refptr<Layer> test_layer = Layer::Create(); 1410 scoped_refptr<Layer> test_layer = Layer::Create();
1409 std::unique_ptr<LayerImpl> impl_layer = 1411 std::unique_ptr<LayerImpl> impl_layer =
1410 LayerImpl::Create(host_impl_.active_tree(), 1); 1412 LayerImpl::Create(host_impl_.active_tree(), 1);
1411 1413
1412 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, 1414 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
1413 layer_tree_host_->SetRootLayer(test_layer)); 1415 layer_tree_host_->SetRootLayer(test_layer));
1414 1416
1415 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); 1417 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2);
1416 1418
1417 test_layer->SetElementId(ElementId(2, 0)); 1419 test_layer->SetElementId(ElementId(2, 0));
1418 test_layer->SetMutableProperties(MutableProperty::kTransform); 1420 test_layer->SetMutableProperties(MutableProperty::kTransform);
1419 1421
1420 EXPECT_FALSE(impl_layer->element_id()); 1422 EXPECT_FALSE(impl_layer->element_id());
1421 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 1423 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
1422 1424
1423 test_layer->PushPropertiesTo(impl_layer.get()); 1425 test_layer->PushPropertiesTo(impl_layer.get());
1424 1426
1425 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); 1427 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id());
1426 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 1428 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
1427 } 1429 }
1428 1430
1429 } // namespace 1431 } // namespace
1430 } // namespace cc 1432 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698