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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 256303006: Make LayerScrollOffsetDelegate updates consistent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
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 60445095340630fb75ca712d3d2670730d01d540..30ee09f16bc392315a6f04bffecd90394be27a5c 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -3030,13 +3030,9 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
virtual ~TestScrollOffsetDelegate() {}
- virtual void SetMaxScrollOffset(
- const gfx::Vector2dF& max_scroll_offset) OVERRIDE {
- max_scroll_offset_ = max_scroll_offset;
- }
-
virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_value) OVERRIDE {
last_set_scroll_offset_ = new_value;
+ CheckScrollOffsetWithinBounds();
}
virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE {
@@ -3045,17 +3041,19 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
virtual bool IsExternalFlingActive() const OVERRIDE { return false; }
- virtual void SetTotalPageScaleFactorAndLimits(
- float page_scale_factor,
- float min_page_scale_factor,
- float max_page_scale_factor) OVERRIDE {
+ virtual void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset,
+ const gfx::Vector2dF& max_scroll_offset,
+ const gfx::SizeF& scrollable_size,
+ float page_scale_factor,
+ float min_page_scale_factor,
+ float max_page_scale_factor) OVERRIDE {
+ last_set_scroll_offset_ = total_scroll_offset;
+ max_scroll_offset_ = max_scroll_offset;
+ scrollable_size_ = scrollable_size;
page_scale_factor_ = page_scale_factor;
min_page_scale_factor_ = min_page_scale_factor;
max_page_scale_factor_ = max_page_scale_factor;
- }
-
- virtual void SetScrollableSize(const gfx::SizeF& scrollable_size) OVERRIDE {
- scrollable_size_ = scrollable_size;
+ CheckScrollOffsetWithinBounds();
}
gfx::Vector2dF last_set_scroll_offset() {
@@ -3087,6 +3085,11 @@ class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
}
private:
+ void CheckScrollOffsetWithinBounds() {
+ DCHECK(last_set_scroll_offset_.x() <= max_scroll_offset_.x());
+ DCHECK(last_set_scroll_offset_.y() <= max_scroll_offset_.y());
+ }
+
gfx::Vector2dF last_set_scroll_offset_;
gfx::Vector2dF getter_return_value_;
gfx::Vector2dF max_scroll_offset_;
@@ -3134,6 +3137,16 @@ TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) {
EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor());
EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor());
+ // The pinch gesture doesn't put the delegate into a state where the scroll
+ // offset is outside of the scroll range. (this is verified by DCHECKs in the
+ // delegate).
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture);
+ host_impl_->PinchGestureBegin();
+ host_impl_->PinchGestureUpdate(2.f, gfx::Point());
+ host_impl_->PinchGestureUpdate(.5f, gfx::Point());
+ host_impl_->PinchGestureEnd();
+ host_impl_->ScrollEnd();
+
// Scrolling should be relative to the offset as returned by the delegate.
gfx::Vector2dF scroll_delta(0.f, 10.f);
gfx::Vector2dF current_offset(7.f, 8.f);
@@ -3152,6 +3165,7 @@ TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) {
EXPECT_EQ(current_offset + scroll_delta,
scroll_delegate.last_set_scroll_offset());
host_impl_->ScrollEnd();
+ scroll_delegate.set_getter_return_value(gfx::Vector2dF());
// Forces a full tree synchronization and ensures that the scroll delegate
// sees the correct size of the new tree.

Powered by Google App Engine
This is Rietveld 408576698