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

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

Issue 183013010: Don't send touchcancel on touch scroll start (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win compile warning Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5958 matching lines...) Expand 10 before | Expand all | Expand 10 after
5969 EXPECT_EQ(0, set_needs_commit_count); 5969 EXPECT_EQ(0, set_needs_commit_count);
5970 EXPECT_EQ(2, set_needs_redraw_count); 5970 EXPECT_EQ(2, set_needs_redraw_count);
5971 } 5971 }
5972 } 5972 }
5973 5973
5974 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { 5974 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest {
5975 public: 5975 public:
5976 virtual void SetUp() OVERRIDE { 5976 virtual void SetUp() OVERRIDE {
5977 LayerTreeSettings settings = DefaultSettings(); 5977 LayerTreeSettings settings = DefaultSettings();
5978 settings.calculate_top_controls_position = true; 5978 settings.calculate_top_controls_position = true;
5979 settings.top_controls_height = top_controls_height_;
5979 CreateHostImpl(settings, CreateOutputSurface()); 5980 CreateHostImpl(settings, CreateOutputSurface());
5980 } 5981 }
5982
5983 protected:
5984 static const int top_controls_height_;
5981 }; 5985 };
5982 5986
5987 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50;
5988
5983 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { 5989 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
5984 SetupScrollAndContentsLayers(gfx::Size(100, 100)) 5990 SetupScrollAndContentsLayers(gfx::Size(100, 100))
5985 ->SetScrollOffset(gfx::Vector2d(0, 10)); 5991 ->SetScrollOffset(gfx::Vector2d(0, 10));
5986 host_impl_->Animate(base::TimeTicks(), base::Time()); 5992 host_impl_->Animate(base::TimeTicks(), base::Time());
5987 EXPECT_FALSE(did_request_redraw_); 5993 EXPECT_FALSE(did_request_redraw_);
5988 } 5994 }
5989 5995
5996 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
5997 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
5998 host_impl_->SetViewportSize(gfx::Size(100, 100));
5999 DrawFrame();
6000
6001 EXPECT_EQ(InputHandler::ScrollStarted,
6002 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
6003 EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset());
6004 EXPECT_EQ(gfx::Vector2dF().ToString(),
6005 scroll_layer->TotalScrollOffset().ToString());
6006
6007 // Scroll just the top controls and verify that the scroll succeeds.
6008 const float residue = 10;
6009 float offset = top_controls_height_ - residue;
6010 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
6011 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->controls_top_offset());
6012 EXPECT_EQ(gfx::Vector2dF().ToString(),
6013 scroll_layer->TotalScrollOffset().ToString());
6014
6015 // Scroll across the boundary
6016 const float content_scroll = 20;
6017 offset = residue + content_scroll;
6018 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
6019 EXPECT_EQ(-top_controls_height_,
6020 host_impl_->top_controls_manager()->controls_top_offset());
6021 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(),
6022 scroll_layer->TotalScrollOffset().ToString());
6023
6024 // Now scroll back to the top of the content
6025 offset = -content_scroll;
6026 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
6027 EXPECT_EQ(-top_controls_height_,
6028 host_impl_->top_controls_manager()->controls_top_offset());
6029 EXPECT_EQ(gfx::Vector2dF().ToString(),
6030 scroll_layer->TotalScrollOffset().ToString());
6031
6032 // And scroll the top controls completely into view
6033 offset = -top_controls_height_;
6034 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
6035 EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset());
6036 EXPECT_EQ(gfx::Vector2dF().ToString(),
6037 scroll_layer->TotalScrollOffset().ToString());
6038
6039 // And attempt to scroll past the end
6040 EXPECT_FALSE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
6041 EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset());
6042 EXPECT_EQ(gfx::Vector2dF().ToString(),
6043 scroll_layer->TotalScrollOffset().ToString());
6044
6045 host_impl_->ScrollEnd();
6046 }
6047
5990 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { 6048 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest {
5991 public: 6049 public:
5992 void SetupVirtualViewportLayers(const gfx::Size& content_size, 6050 void SetupVirtualViewportLayers(const gfx::Size& content_size,
5993 const gfx::Size& outer_viewport, 6051 const gfx::Size& outer_viewport,
5994 const gfx::Size& inner_viewport) { 6052 const gfx::Size& inner_viewport) {
5995 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); 6053 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree();
5996 const int kOuterViewportClipLayerId = 6; 6054 const int kOuterViewportClipLayerId = 6;
5997 const int kOuterViewportScrollLayerId = 7; 6055 const int kOuterViewportScrollLayerId = 7;
5998 const int kInnerViewportScrollLayerId = 2; 6056 const int kInnerViewportScrollLayerId = 2;
5999 const int kInnerViewportClipLayerId = 4; 6057 const int kInnerViewportClipLayerId = 4;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
6121 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, 6179 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes,
6122 300u * 1024u * 1024u); 6180 300u * 1024u * 1024u);
6123 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, 6181 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes,
6124 150u * 1024u * 1024u); 6182 150u * 1024u * 1024u);
6125 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, 6183 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes,
6126 75u * 1024u * 1024u); 6184 75u * 1024u * 1024u);
6127 } 6185 }
6128 6186
6129 } // namespace 6187 } // namespace
6130 } // namespace cc 6188 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698