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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1675963002: Move MaxScrollOffset to property_trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove comment. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 600047c81a574844922f1a18491968e58273646d..cff2049bc1ed7bf4d133b53e0775e5bb92f2b634 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -413,6 +413,13 @@ class LayerTreeHostImplTest : public testing::Test,
host_impl_->DidDrawAllLayers(frame);
}
+ void DrawFrameWithoutRebuildPropertyTrees() {
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame);
+ host_impl_->DidDrawAllLayers(frame);
+ }
+
void RebuildPropertyTrees() {
host_impl_->active_tree()->property_trees()->needs_rebuild = true;
host_impl_->active_tree()->BuildPropertyTreesForTesting();
@@ -2447,6 +2454,31 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) {
host_impl_->DidFinishImplFrame();
}
+TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ host_impl_->SetViewportSize(gfx::Size(50, 50));
+ host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
+ DrawFrame();
+
+ LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer();
+ LayerImpl* inner_container = inner_scroll->scroll_clip_layer();
+ DCHECK(inner_scroll);
+ DCHECK(inner_container);
+ EXPECT_EQ(gfx::ScrollOffset(50, 50), inner_scroll->MaxScrollOffset());
+
+ inner_container->SetBoundsDelta(gfx::Vector2dF(15.f, 15.f));
+ inner_scroll->SetBoundsDelta(gfx::Vector2dF(7.f, 7.f));
+ EXPECT_EQ(gfx::ScrollOffset(42, 42), inner_scroll->MaxScrollOffset());
+
+ inner_container->SetBoundsDelta(gfx::Vector2dF());
+ inner_scroll->SetBoundsDelta(gfx::Vector2dF());
+ inner_scroll->SetBounds(gfx::Size());
+ DrawFrame();
+
+ inner_scroll->SetBoundsDelta(gfx::Vector2dF(60.f, 60.f));
+ EXPECT_EQ(gfx::ScrollOffset(10, 10), inner_scroll->MaxScrollOffset());
+}
+
class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl {
public:
LayerTreeHostImplOverridePhysicalTime(
@@ -5241,6 +5273,7 @@ TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) {
SetupScrollAndContentsLayers(gfx::Size(width, height));
host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
gfx::Size(width * scale - 1, height * scale));
+ RebuildPropertyTrees();
host_impl_->active_tree()->SetDeviceScaleFactor(scale);
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
@@ -5319,6 +5352,7 @@ TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) {
LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
LayerImpl* clip_layer = scroll_layer->parent()->parent();
clip_layer->SetBounds(gfx::Size(10, 20));
+ RebuildPropertyTrees();
host_impl_->BindToClient(&scroll_watcher);
@@ -5689,6 +5723,7 @@ TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50));
LayerImpl* clip_layer = scroll_layer->parent()->parent();
clip_layer->SetBounds(gfx::Size(50, 50));
+ RebuildPropertyTrees();
host_impl_->SetViewportSize(gfx::Size(50, 50));
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
DrawFrame();
@@ -7665,7 +7700,8 @@ TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) {
child_scroll->SetPosition(gfx::PointF(10.f, 10.f));
child_scroll->AddChild(std::move(occluder_layer));
- scroll_layer->AddChild(std::move(child_scroll));
+ child_scroll_clip->AddChild(std::move(child_scroll));
+ scroll_layer->AddChild(std::move(child_scroll_clip));
DrawFrame();
@@ -8413,7 +8449,7 @@ TEST_F(LayerTreeHostImplWithTopControlsTest,
host_impl_->SetViewportSize(gfx::Size(100, 100));
host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN,
false);
- DrawFrame();
+ DrawFrameWithoutRebuildPropertyTrees();
EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
@@ -9902,7 +9938,8 @@ TEST_F(LayerTreeHostImplTest, UpdatePageScaleFactorOnActiveTree) {
TransformNode* active_tree_node =
host_impl_->active_tree()->property_trees()->transform_tree.Node(
page_scale_layer->transform_tree_index());
- EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 1.f);
+ // SetPageScaleOnActiveTree also updates the factors in property trees.
+ EXPECT_EQ(active_tree_node->data.post_local_scale_factor, 2.f);
EXPECT_EQ(host_impl_->active_tree()->current_page_scale_factor(), 2.f);
TransformNode* pending_tree_node =
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698