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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 1626513003: Add ScrollTree builder and unit test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index f4e5b600d39424f24c1bf3ecec9224fd8942f52d..b9e421dcd6b3344a387537b0c7a593d520e5fa44 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -9793,5 +9793,164 @@ TEST_F(LayerTreeHostCommonTest, SerializeScrollAndScale) {
EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set));
}
+TEST_F(LayerTreeHostCommonTest, ScrollTreeBuilderTest) {
+ // Test the behavior of scroll tree builder
+ // Topology:
+ // +root1(1)
+ // +--parent2(2)[should_scroll_on_main_thread & scroll_blocks_on]
+ // +----child6(6)[should_scroll_on_main_thread]
+ // +------grand_child10(10)[should_scroll_on_main_thread]
+ // +--parent3(3)
+ // +----child7(7)[scrollable]
+ // +----child8(8)[scroll_parent=7]
+ // +------grand_child11(11)[scrollable]
+ // +--parent4(4)[SCROLL_BLOCKS_ON_START_TOUCH]
+ // +----child9(9)[SCROLL_BLOCKS_ON_WHEEL_EVENT]
+ // +------grand_child12(12)
+ // +--parent5(5)[contains_non_fast_scrollable_region]
+ //
+ // Expected scroll tree topology:
+ // +property_tree_root---owner:-1
+ // +--root---owner:1
+ // +----node---owner:2
+ // +------node---owner:6
+ // +----node---owner:7
+ // +------node---owner:11
+ // +----node---owner:4
+ // +------node---owner:9
+ // +----node---owner:5
+ //
+ // Extra check:
+ // grand_child12.scroll_blocks_on = SCROLL_BLOCKS_ON_START_TOUCH |
+ // SCROLL_BLOCKS_ON_WHEEL_EVENT
+ scoped_refptr<Layer> root1 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent2 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent3 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent4 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> parent5 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child6 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child7 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child8 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> child9 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child10 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child11 = Layer::Create(layer_settings());
+ scoped_refptr<Layer> grand_child12 = Layer::Create(layer_settings());
+
+ root1->AddChild(parent2);
+ root1->AddChild(parent3);
+ root1->AddChild(parent4);
+ root1->AddChild(parent5);
+ parent2->AddChild(child6);
+ parent3->AddChild(child7);
+ parent3->AddChild(child8);
+ parent4->AddChild(child9);
+ child6->AddChild(grand_child10);
+ child8->AddChild(grand_child11);
+ child9->AddChild(grand_child12);
+ host()->SetRootLayer(root1);
+
+ parent2->AddMainThreadScrollingReasons(
+ MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
+ parent2->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT);
+ child6->AddMainThreadScrollingReasons(
+ MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
+ grand_child10->AddMainThreadScrollingReasons(
+ MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
+
+ child7->SetScrollClipLayerId(root1->id());
+ child8->SetScrollParent(child7.get());
+ grand_child11->SetScrollClipLayerId(root1->id());
+
+ parent4->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH);
+ child9->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT);
+
+ parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
+
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root1.get());
+
+ // Property tree root
+ ScrollTree scroll_tree = host()->property_trees()->scroll_tree;
+ ScrollTree expected_scroll_tree;
+ ScrollNode property_tree_root = *expected_scroll_tree.Node(0);
+ property_tree_root.id = 0;
+ property_tree_root.parent_id = -1;
+ property_tree_root.owner_id = -1;
+ property_tree_root.data.scrollable = false;
+ property_tree_root.data.should_scroll_on_main_thread = false;
+ property_tree_root.data.scroll_blocks_on = SCROLL_BLOCKS_ON_NONE;
+ property_tree_root.data.contains_non_fast_scrollable_region = false;
+ property_tree_root.data.transform_id = 0;
jaydasika 2016/01/22 22:28:28 Can you change this to root->transform_tree_index(
+
+ // The node owned by root1
+ ScrollNode scroll_root1;
+ scroll_root1.id = 1;
+ scroll_root1.owner_id = root1->id();
+ scroll_root1.data.transform_id = 1;
+ expected_scroll_tree.Insert(scroll_root1, 0);
+
+ // The node owned by parent2
+ ScrollNode scroll_parent2;
+ scroll_parent2.id = 2;
+ scroll_parent2.owner_id = parent2->id();
+ scroll_parent2.data.should_scroll_on_main_thread = true;
+ scroll_parent2.data.scroll_blocks_on = SCROLL_BLOCKS_ON_SCROLL_EVENT;
+ scroll_parent2.data.transform_id = 1;
+ expected_scroll_tree.Insert(scroll_parent2, 1);
+
+ // The node owned by child6
+ ScrollNode scroll_child6;
+ scroll_child6.id = 3;
+ scroll_child6.owner_id = child6->id();
+ scroll_child6.data.should_scroll_on_main_thread = true;
+ scroll_child6.data.scroll_blocks_on = SCROLL_BLOCKS_ON_SCROLL_EVENT;
+ scroll_child6.data.transform_id = 1;
+ expected_scroll_tree.Insert(scroll_child6, 2);
+
+ // The node owned by child7, child7 also owns a transform node
+ ScrollNode scroll_child7;
+ scroll_child7.id = 4;
+ scroll_child7.owner_id = child7->id();
+ scroll_child7.data.scrollable = true;
+ scroll_child7.data.transform_id = 2;
+ expected_scroll_tree.Insert(scroll_child7, 1);
+
+ // The node owned by grand_child11, grand_child11 also owns a transform node
+ ScrollNode scroll_grand_child11;
+ scroll_grand_child11.id = 5;
+ scroll_grand_child11.owner_id = grand_child11->id();
+ scroll_grand_child11.data.scrollable = true;
+ scroll_grand_child11.data.transform_id = 3;
+ expected_scroll_tree.Insert(scroll_grand_child11, 4);
+
+ // The node owned by parent4
+ ScrollNode scroll_parent4;
+ scroll_parent4.id = 6;
+ scroll_parent4.owner_id = parent4->id();
+ scroll_parent4.data.scroll_blocks_on = SCROLL_BLOCKS_ON_START_TOUCH;
+ scroll_parent4.data.transform_id = 1;
+ expected_scroll_tree.Insert(scroll_parent4, 1);
+
+ // The node owned by child9
+ ScrollNode scroll_child9;
+ scroll_child9.id = 7;
+ scroll_child9.owner_id = child9->id();
+ scroll_child9.data.scroll_blocks_on =
+ SCROLL_BLOCKS_ON_START_TOUCH | SCROLL_BLOCKS_ON_WHEEL_EVENT;
+ scroll_child9.data.transform_id = 1;
+ expected_scroll_tree.Insert(scroll_child9, 6);
+
+ // The node owned by parent5
+ ScrollNode scroll_parent5;
+ scroll_parent5.id = 8;
+ scroll_parent5.owner_id = parent5->id();
+ scroll_parent5.data.contains_non_fast_scrollable_region = true;
+ scroll_parent5.data.transform_id = 1;
+ expected_scroll_tree.Insert(scroll_parent5, 1);
+
+ expected_scroll_tree.set_needs_update(false);
+
+ EXPECT_EQ(expected_scroll_tree, scroll_tree);
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698