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

Unified Diff: cc/trees/layer_tree_impl_unittest.cc

Issue 2080223010: cc: Clean up root_layer code in LTI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase++ Created 4 years, 6 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
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_impl_unittest.cc
diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc
index 66c80ac91ea39f4176cf9437eca12a119c7969f6..2e21482e20b56c67bc12d5386bf190bd9c2800fb 100644
--- a/cc/trees/layer_tree_impl_unittest.cc
+++ b/cc/trees/layer_tree_impl_unittest.cc
@@ -36,7 +36,9 @@ class LayerTreeImplTest : public LayerTreeHostCommonTest {
FakeLayerTreeHostImpl& host_impl() { return *host_impl_; }
- LayerImpl* root_layer() { return host_impl_->active_tree()->root_layer(); }
+ LayerImpl* root_layer() {
+ return host_impl_->active_tree()->root_layer_for_testing();
+ }
int HitTestSimpleTree(int root_id,
int left_child_id,
int right_child_id,
@@ -72,7 +74,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) {
root->SetDrawsContent(true);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -130,13 +132,14 @@ TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) {
root->SetDrawsContent(true);
host_impl->SetViewportSize(root->bounds());
- host_impl->active_tree()->SetRootLayer(std::move(root));
+ host_impl->active_tree()->SetRootLayerForTesting(std::move(root));
host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree();
EXPECT_EQ(
gfx::RectF(gfx::SizeF(bounds)),
host_impl->active_tree()->property_trees()->clip_tree.ViewportClip());
- EXPECT_EQ(gfx::Rect(bounds),
- host_impl->active_tree()->root_layer()->visible_layer_rect());
+ EXPECT_EQ(
+ gfx::Rect(bounds),
+ host_impl->active_tree()->root_layer_for_testing()->visible_layer_rect());
gfx::Size new_bounds(50, 50);
host_impl->SetViewportSize(new_bounds);
@@ -145,8 +148,9 @@ TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) {
EXPECT_EQ(
gfx::RectF(gfx::SizeF(new_bounds)),
host_impl->active_tree()->property_trees()->clip_tree.ViewportClip());
- EXPECT_EQ(gfx::Rect(new_bounds),
- host_impl->active_tree()->root_layer()->visible_layer_rect());
+ EXPECT_EQ(
+ gfx::Rect(new_bounds),
+ host_impl->active_tree()->root_layer_for_testing()->visible_layer_rect());
}
TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) {
@@ -173,7 +177,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) {
root->test_properties()->AddChild(std::move(hud));
host_impl().SetViewportSize(hud_bounds);
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -227,7 +231,7 @@ TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) {
root->SetDrawsContent(true);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -288,7 +292,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) {
root->SetDrawsContent(true);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -340,7 +344,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) {
root->SetDrawsContent(true);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -425,7 +429,7 @@ TEST_F(LayerTreeImplTest, HitTestingClipNodeDifferentTransformAndTargetIds) {
root->test_properties()->AddChild(std::move(render_surface));
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
gfx::PointF test_point(160.f, 160.f);
@@ -470,7 +474,7 @@ TEST_F(LayerTreeImplTest, HitTestingSiblings) {
root->test_properties()->AddChild(std::move(child2));
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
gfx::PointF test_point(50.f, 50.f);
@@ -500,7 +504,7 @@ TEST_F(LayerTreeImplTest, HitTestingPointOutsideMaxTextureSize) {
root->test_properties()->AddChild(std::move(surface));
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
gfx::PointF test_point(max_texture_size - 50, max_texture_size - 50);
@@ -538,7 +542,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) {
root->SetDrawsContent(true);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -608,7 +612,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) {
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -713,7 +717,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) {
grand_child->test_properties()->AddChild(std::move(rotated_leaf));
child->test_properties()->AddChild(std::move(grand_child));
root->test_properties()->AddChild(std::move(child));
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
ExecuteCalculateDrawProperties(root_layer);
}
@@ -807,7 +811,7 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) {
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -893,7 +897,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) {
child1->test_properties()->AddChild(std::move(grand_child1));
root->test_properties()->AddChild(std::move(child1));
root->test_properties()->AddChild(std::move(child2));
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
ExecuteCalculateDrawProperties(root_layer);
}
@@ -1016,7 +1020,7 @@ int LayerTreeImplTest::HitTestSimpleTree(int root_id,
root->test_properties()->AddChild(std::move(right_child));
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
CHECK_EQ(1u, RenderSurfaceLayerList().size());
@@ -1131,7 +1135,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) {
LayerImpl* grand_child1 = child1->test_properties()->children[0];
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -1232,7 +1236,7 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) {
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
gfx::PointF test_point(12.f, 52.f);
@@ -1294,7 +1298,7 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) {
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
gfx::PointF test_point(12.f, 52.f);
@@ -1365,7 +1369,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) {
child1->test_properties()->AddChild(std::move(grand_child1));
root->test_properties()->AddChild(std::move(child1));
root->test_properties()->AddChild(std::move(child2));
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
ExecuteCalculateDrawProperties(root_layer);
}
@@ -1459,7 +1463,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) {
root->SetDrawsContent(true);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -1474,8 +1478,10 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) {
test_point);
EXPECT_FALSE(result_layer);
- host_impl().active_tree()->root_layer()->SetTouchEventHandlerRegion(
- touch_handler_region);
+ host_impl()
+ .active_tree()
+ ->root_layer_for_testing()
+ ->SetTouchEventHandlerRegion(touch_handler_region);
// Hit checking for a point outside the layer should return a null pointer.
test_point = gfx::PointF(101.f, 101.f);
result_layer =
@@ -1544,7 +1550,7 @@ TEST_F(LayerTreeImplTest,
root->SetTouchEventHandlerRegion(touch_handler_region);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -1617,7 +1623,7 @@ TEST_F(LayerTreeImplTest,
root->SetTouchEventHandlerRegion(touch_handler_region);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -1701,7 +1707,7 @@ TEST_F(LayerTreeImplTest,
host_impl().SetViewportSize(scaled_bounds_for_root);
host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor);
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1,
Layer::INVALID_ID);
host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
@@ -1713,8 +1719,11 @@ TEST_F(LayerTreeImplTest,
// Sanity check the scenario we just created.
// The visible content rect for test_layer is actually 100x100, even though
// its layout size is 50x50, positioned at 25x25.
- LayerImpl* test_layer =
- host_impl().active_tree()->root_layer()->test_properties()->children[0];
+ LayerImpl* test_layer = host_impl()
+ .active_tree()
+ ->root_layer_for_testing()
+ ->test_properties()
+ ->children[0];
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size());
@@ -1790,7 +1799,7 @@ TEST_F(LayerTreeImplTest,
// is also the root layer.
page_scale_factor *= 1.5f;
host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
- EXPECT_EQ(host_impl().active_tree()->root_layer(),
+ EXPECT_EQ(host_impl().active_tree()->root_layer_for_testing(),
host_impl().active_tree()->PageScaleLayer());
test_point = gfx::PointF(35.f, 35.f);
@@ -1850,7 +1859,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) {
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -1951,7 +1960,7 @@ TEST_F(LayerTreeImplTest,
host_impl().SetViewportSize(scaled_bounds_for_root);
host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor);
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1,
Layer::INVALID_ID);
host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
@@ -2025,7 +2034,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) {
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -2093,11 +2102,14 @@ TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) {
root->test_properties()->AddChild(std::move(test_layer));
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
- LayerImpl* test_layer =
- host_impl().active_tree()->root_layer()->test_properties()->children[0];
+ LayerImpl* test_layer = host_impl()
+ .active_tree()
+ ->root_layer_for_testing()
+ ->test_properties()
+ ->children[0];
// As test_layer doesn't draw content, the layer list of root's render surface
// should contain only the root layer.
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
@@ -2128,8 +2140,11 @@ TEST_F(LayerTreeImplTest, HitTestingTouchHandlerRegionsForLayerThatIsNotDrawn) {
// We change the position of the test layer such that the test point is now
// inside the test_layer.
- test_layer =
- host_impl().active_tree()->root_layer()->test_properties()->children[0];
+ test_layer = host_impl()
+ .active_tree()
+ ->root_layer_for_testing()
+ ->test_properties()
+ ->children[0];
test_layer->SetPosition(gfx::PointF(10.f, 10.f));
test_layer->NoteLayerPropertyChanged();
expected_screen_space_transform.MakeIdentity();
@@ -2164,7 +2179,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) {
root->SetDrawsContent(true);
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -2268,7 +2283,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) {
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -2362,7 +2377,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) {
host_impl().active_tree()->SetDeviceScaleFactor(device_scale_factor);
host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1,
Layer::INVALID_ID);
host_impl().active_tree()->BuildLayerListAndPropertyTreesForTesting();
@@ -2448,7 +2463,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) {
}
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
LayerSelection input;
@@ -2542,7 +2557,7 @@ TEST_F(LayerTreeImplTest, HitTestingCorrectLayerWheelListener) {
root->test_properties()->AddChild(std::move(right_child));
host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().active_tree()->SetRootLayerForTesting(std::move(root));
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
CHECK_EQ(1u, RenderSurfaceLayerList().size());
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698