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

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

Issue 661643004: [android] Remove unused scroll delta in TopControls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unittest Added Created 6 years, 2 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 <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 7180 matching lines...) Expand 10 before | Expand all | Expand 10 after
7191 host_impl_->top_controls_manager()->ControlsTopOffset(); 7191 host_impl_->top_controls_manager()->ControlsTopOffset();
7192 7192
7193 if (new_offset != old_offset) { 7193 if (new_offset != old_offset) {
7194 EXPECT_TRUE(did_request_redraw_); 7194 EXPECT_TRUE(did_request_redraw_);
7195 EXPECT_TRUE(did_request_commit_); 7195 EXPECT_TRUE(did_request_commit_);
7196 } 7196 }
7197 } 7197 }
7198 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); 7198 EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
7199 } 7199 }
7200 7200
7201 TEST_F(LayerTreeHostImplWithTopControlsTest,
7202 TopControlsScrollDeltaInOverScroll) {
7203 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
7204 host_impl_->SetViewportSize(gfx::Size(100, 100));
7205 host_impl_->top_controls_manager()->UpdateTopControlsState(
7206 BOTH, SHOWN, false);
7207 DrawFrame();
7208
7209 EXPECT_EQ(InputHandler::ScrollStarted,
7210 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
7211 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
7212
7213 float offset = 50;
7214 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
7215 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset());
7216 EXPECT_EQ(gfx::Vector2dF().ToString(),
7217 scroll_layer->TotalScrollOffset().ToString());
7218
7219 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
7220 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(),
7221 scroll_layer->TotalScrollOffset().ToString());
7222
7223 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
7224 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(),
7225 scroll_layer->TotalScrollOffset().ToString());
7226
7227 float overscrollamount = 10;
7228 EXPECT_FALSE(
7229 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount)));
7230 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(),
7231 scroll_layer->TotalScrollOffset().ToString());
7232 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(),
7233 host_impl_->accumulated_root_overscroll().ToString());
7234
7235 EXPECT_TRUE(
7236 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset)));
7237 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(),
7238 scroll_layer->TotalScrollOffset().ToString());
7239 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset());
7240
7241 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset)));
7242 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(),
7243 scroll_layer->TotalScrollOffset().ToString());
7244 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
7245
7246 host_impl_->ScrollEnd();
7247 }
7248
7201 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { 7249 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest {
7202 public: 7250 public:
7203 void SetupVirtualViewportLayers(const gfx::Size& content_size, 7251 void SetupVirtualViewportLayers(const gfx::Size& content_size,
7204 const gfx::Size& outer_viewport, 7252 const gfx::Size& outer_viewport,
7205 const gfx::Size& inner_viewport) { 7253 const gfx::Size& inner_viewport) {
7206 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); 7254 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree();
7207 const int kOuterViewportClipLayerId = 6; 7255 const int kOuterViewportClipLayerId = 6;
7208 const int kOuterViewportScrollLayerId = 7; 7256 const int kOuterViewportScrollLayerId = 7;
7209 const int kInnerViewportScrollLayerId = 2; 7257 const int kInnerViewportScrollLayerId = 2;
7210 const int kInnerViewportClipLayerId = 4; 7258 const int kInnerViewportClipLayerId = 4;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
7516 // surface. 7564 // surface.
7517 EXPECT_EQ(0, num_lost_surfaces_); 7565 EXPECT_EQ(0, num_lost_surfaces_);
7518 host_impl_->DidLoseOutputSurface(); 7566 host_impl_->DidLoseOutputSurface();
7519 EXPECT_EQ(1, num_lost_surfaces_); 7567 EXPECT_EQ(1, num_lost_surfaces_);
7520 host_impl_->DidLoseOutputSurface(); 7568 host_impl_->DidLoseOutputSurface();
7521 EXPECT_LE(1, num_lost_surfaces_); 7569 EXPECT_LE(1, num_lost_surfaces_);
7522 } 7570 }
7523 7571
7524 } // namespace 7572 } // namespace
7525 } // namespace cc 7573 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698