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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1038173002: Refactor delegated scrolling in LayerImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove "scrollOffsetDelegate" Created 5 years, 8 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 3954 matching lines...) Expand 10 before | Expand all | Expand 10 after
3965 host_impl_->PinchGestureEnd(); 3965 host_impl_->PinchGestureEnd();
3966 host_impl_->ScrollEnd(); 3966 host_impl_->ScrollEnd();
3967 3967
3968 // Scrolling should be relative to the offset as returned by the delegate. 3968 // Scrolling should be relative to the offset as returned by the delegate.
3969 gfx::Vector2dF scroll_delta(0.f, 10.f); 3969 gfx::Vector2dF scroll_delta(0.f, 10.f);
3970 gfx::ScrollOffset current_offset(7.f, 8.f); 3970 gfx::ScrollOffset current_offset(7.f, 8.f);
3971 3971
3972 scroll_delegate.set_getter_return_value(current_offset); 3972 scroll_delegate.set_getter_return_value(current_offset);
3973 EXPECT_EQ(InputHandler::SCROLL_STARTED, 3973 EXPECT_EQ(InputHandler::SCROLL_STARTED,
3974 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); 3974 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE));
3975 host_impl_->OnRootLayerDelegatedScrollOffsetChanged();
3975 3976
3976 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 3977 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
3977 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta), 3978 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta),
3978 scroll_delegate.last_set_scroll_offset()); 3979 scroll_delegate.last_set_scroll_offset());
3979 3980
3980 current_offset = gfx::ScrollOffset(42.f, 41.f); 3981 current_offset = gfx::ScrollOffset(42.f, 41.f);
3981 scroll_delegate.set_getter_return_value(current_offset); 3982 scroll_delegate.set_getter_return_value(current_offset);
3983 host_impl_->OnRootLayerDelegatedScrollOffsetChanged();
3982 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 3984 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
3983 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta), 3985 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta),
3984 scroll_delegate.last_set_scroll_offset()); 3986 scroll_delegate.last_set_scroll_offset());
3985 host_impl_->ScrollEnd(); 3987 host_impl_->ScrollEnd();
3986 scroll_delegate.set_getter_return_value(gfx::ScrollOffset()); 3988 scroll_delegate.set_getter_return_value(gfx::ScrollOffset());
3989 host_impl_->OnRootLayerDelegatedScrollOffsetChanged();
3987 3990
3988 // Forces a full tree synchronization and ensures that the scroll delegate 3991 // Forces a full tree synchronization and ensures that the scroll delegate
3989 // sees the correct size of the new tree. 3992 // sees the correct size of the new tree.
3990 gfx::Size new_size(42, 24); 3993 gfx::Size new_size(42, 24);
3991 host_impl_->CreatePendingTree(); 3994 host_impl_->CreatePendingTree();
3992 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); 3995 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size);
3993 host_impl_->ActivateSyncTree(); 3996 host_impl_->ActivateSyncTree();
3994 EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); 3997 EXPECT_EQ(new_size, scroll_delegate.scrollable_size());
3995 3998
3996 // Un-setting the delegate should propagate the delegate's current offset to 3999 // Un-setting the delegate should propagate the delegate's current offset to
3997 // the root scrollable layer. 4000 // the root scrollable layer.
3998 current_offset = gfx::ScrollOffset(13.f, 12.f); 4001 current_offset = gfx::ScrollOffset(13.f, 12.f);
3999 scroll_delegate.set_getter_return_value(current_offset); 4002 scroll_delegate.set_getter_return_value(current_offset);
4003 host_impl_->OnRootLayerDelegatedScrollOffsetChanged();
4000 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); 4004 host_impl_->SetRootLayerScrollOffsetDelegate(NULL);
4001 4005
4002 EXPECT_EQ(current_offset.ToString(), 4006 EXPECT_EQ(current_offset.ToString(),
4003 scroll_layer->CurrentScrollOffset().ToString()); 4007 scroll_layer->CurrentScrollOffset().ToString());
4004 } 4008 }
4005 4009
4006 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { 4010 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) {
4007 const gfx::Transform target_space_transform = 4011 const gfx::Transform target_space_transform =
4008 layer->draw_properties().target_space_transform; 4012 layer->draw_properties().target_space_transform;
4009 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); 4013 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation());
(...skipping 4455 matching lines...) Expand 10 before | Expand all | Expand 10 after
8465 // surface. 8469 // surface.
8466 EXPECT_EQ(0, num_lost_surfaces_); 8470 EXPECT_EQ(0, num_lost_surfaces_);
8467 host_impl_->DidLoseOutputSurface(); 8471 host_impl_->DidLoseOutputSurface();
8468 EXPECT_EQ(1, num_lost_surfaces_); 8472 EXPECT_EQ(1, num_lost_surfaces_);
8469 host_impl_->DidLoseOutputSurface(); 8473 host_impl_->DidLoseOutputSurface();
8470 EXPECT_LE(1, num_lost_surfaces_); 8474 EXPECT_LE(1, num_lost_surfaces_);
8471 } 8475 }
8472 8476
8473 } // namespace 8477 } // namespace
8474 } // namespace cc 8478 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698