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

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

Issue 1648293003: Fix smooth scroll jump when switching scroll handling between MT and CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: skip irrelevant test on mac Created 4 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
« no previous file with comments | « cc/layers/layer_impl.h ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 1540 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
1541 1541
1542 // Case 4: SetNeedsDisplay() with a non-drawable layer 1542 // Case 4: SetNeedsDisplay() with a non-drawable layer
1543 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); 1543 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false));
1544 test_layer->ResetNeedsDisplayForTesting(); 1544 test_layer->ResetNeedsDisplayForTesting();
1545 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); 1545 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
1546 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty1)); 1546 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty1));
1547 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); 1547 EXPECT_TRUE(test_layer->NeedsDisplayForTesting());
1548 } 1548 }
1549 1549
1550 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) {
1551 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_);
1552 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
1553 layer_tree_host_->SetRootLayer(test_layer));
1554 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
1555
1556 // sanity check of initial test condition
1557 EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
1558
1559 uint32_t reasons = 0, reasons_to_clear = 0, reasons_after_clearing = 0;
1560 reasons |= MainThreadScrollingReason::kEventHandlers;
1561 reasons |= MainThreadScrollingReason::kContinuingMainThreadScroll;
1562 reasons |= MainThreadScrollingReason::kScrollbarScrolling;
1563
1564 reasons_to_clear |= MainThreadScrollingReason::kContinuingMainThreadScroll;
1565 reasons_to_clear |= MainThreadScrollingReason::kThreadedScrollingDisabled;
1566
1567 reasons_after_clearing |= MainThreadScrollingReason::kEventHandlers;
1568 reasons_after_clearing |= MainThreadScrollingReason::kScrollbarScrolling;
1569
1570 // Check that the reasons are added correctly.
1571 EXPECT_SET_NEEDS_COMMIT(1, test_layer->AddMainThreadScrollingReasons(
1572 MainThreadScrollingReason::kEventHandlers));
1573 EXPECT_SET_NEEDS_COMMIT(
1574 1, test_layer->AddMainThreadScrollingReasons(
1575 MainThreadScrollingReason::kContinuingMainThreadScroll));
1576 EXPECT_SET_NEEDS_COMMIT(1,
1577 test_layer->AddMainThreadScrollingReasons(
1578 MainThreadScrollingReason::kScrollbarScrolling));
1579 EXPECT_EQ(reasons, test_layer->main_thread_scrolling_reasons());
1580
1581 // Check that the reasons can be selectively cleared.
1582 EXPECT_SET_NEEDS_COMMIT(
1583 1, test_layer->ClearMainThreadScrollingReasons(reasons_to_clear));
1584 EXPECT_EQ(reasons_after_clearing,
1585 test_layer->main_thread_scrolling_reasons());
1586
1587 // Check that clearing non-set reasons doesn't set needs commit.
1588 reasons_to_clear = 0;
1589 reasons_to_clear |= MainThreadScrollingReason::kThreadedScrollingDisabled;
1590 reasons_to_clear |= MainThreadScrollingReason::kNoScrollingLayer;
1591 EXPECT_SET_NEEDS_COMMIT(
1592 0, test_layer->ClearMainThreadScrollingReasons(reasons_to_clear));
1593 EXPECT_EQ(reasons_after_clearing,
1594 test_layer->main_thread_scrolling_reasons());
1595
1596 // Check that adding an existing condition doesn't set needs commit.
1597 EXPECT_SET_NEEDS_COMMIT(0, test_layer->AddMainThreadScrollingReasons(
1598 MainThreadScrollingReason::kEventHandlers));
1599 }
1600
1550 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { 1601 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {
1551 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); 1602 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_);
1552 EXPECT_SET_NEEDS_FULL_TREE_SYNC( 1603 EXPECT_SET_NEEDS_FULL_TREE_SYNC(
1553 1, layer_tree_host_->SetRootLayer(test_layer)); 1604 1, layer_tree_host_->SetRootLayer(test_layer));
1554 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); 1605 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
1555 1606
1556 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_); 1607 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_);
1557 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_); 1608 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_);
1558 1609
1559 // sanity check of initial test condition 1610 // sanity check of initial test condition
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 2780 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
2730 2781
2731 test_layer->PushPropertiesTo(impl_layer.get()); 2782 test_layer->PushPropertiesTo(impl_layer.get());
2732 2783
2733 EXPECT_EQ(2lu, impl_layer->element_id()); 2784 EXPECT_EQ(2lu, impl_layer->element_id());
2734 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 2785 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
2735 } 2786 }
2736 2787
2737 } // namespace 2788 } // namespace
2738 } // namespace cc 2789 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698