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

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

Issue 1236643003: [Android] Suppress overscroll for unscrollable axes in the browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove old test Created 5 years, 5 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
« no previous file with comments | « cc/layers/viewport.cc ('k') | cc/trees/layer_tree_settings.h » ('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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 did_request_prepare_tiles_(false), 94 did_request_prepare_tiles_(false),
95 did_complete_page_scale_animation_(false), 95 did_complete_page_scale_animation_(false),
96 reduce_memory_result_(true) { 96 reduce_memory_result_(true) {
97 media::InitializeMediaLibrary(); 97 media::InitializeMediaLibrary();
98 } 98 }
99 99
100 LayerTreeSettings DefaultSettings() { 100 LayerTreeSettings DefaultSettings() {
101 LayerTreeSettings settings; 101 LayerTreeSettings settings;
102 settings.minimum_occlusion_tracking_size = gfx::Size(); 102 settings.minimum_occlusion_tracking_size = gfx::Size();
103 settings.renderer_settings.texture_id_allocation_chunk_size = 1; 103 settings.renderer_settings.texture_id_allocation_chunk_size = 1;
104 settings.report_overscroll_only_for_scrollable_axes = true;
105 settings.gpu_rasterization_enabled = true; 104 settings.gpu_rasterization_enabled = true;
106 return settings; 105 return settings;
107 } 106 }
108 107
109 void SetUp() override { 108 void SetUp() override {
110 CreateHostImpl(DefaultSettings(), CreateOutputSurface()); 109 CreateHostImpl(DefaultSettings(), CreateOutputSurface());
111 } 110 }
112 111
113 void TearDown() override {} 112 void TearDown() override {}
114 113
(...skipping 4514 matching lines...) Expand 10 before | Expand all | Expand 10 after
4629 4628
4630 // Even though the layer can't scroll the overscroll still happens. 4629 // Even though the layer can't scroll the overscroll still happens.
4631 EXPECT_EQ(InputHandler::SCROLL_STARTED, 4630 EXPECT_EQ(InputHandler::SCROLL_STARTED,
4632 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); 4631 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL));
4633 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 4632 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
4634 EXPECT_FALSE(scroll_result.did_scroll); 4633 EXPECT_FALSE(scroll_result.did_scroll);
4635 EXPECT_TRUE(scroll_result.did_overscroll_root); 4634 EXPECT_TRUE(scroll_result.did_overscroll_root);
4636 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); 4635 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
4637 } 4636 }
4638 4637
4639 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) {
4640 InputHandlerScrollResult scroll_result;
4641 gfx::Size surface_size(980, 1439);
4642 gfx::Size content_size(980, 1438);
4643 float device_scale_factor = 1.5f;
4644 scoped_ptr<LayerImpl> root_clip =
4645 LayerImpl::Create(host_impl_->active_tree(), 3);
4646 root_clip->SetHasRenderSurface(true);
4647
4648 scoped_ptr<LayerImpl> root =
4649 CreateScrollableLayer(1, content_size, root_clip.get());
4650 root->SetIsContainerForFixedPositionLayers(true);
4651 scoped_ptr<LayerImpl> child =
4652 CreateScrollableLayer(2, content_size, root_clip.get());
4653 root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469));
4654 host_impl_->active_tree()->PushPageScaleFromMainThread(0.326531f, 0.326531f,
4655 5.f);
4656 host_impl_->SetPageScaleOnActiveTree(0.326531f);
4657 child->SetScrollClipLayer(Layer::INVALID_ID);
4658 root->AddChild(child.Pass());
4659 root_clip->AddChild(root.Pass());
4660
4661 host_impl_->SetViewportSize(surface_size);
4662 host_impl_->SetDeviceScaleFactor(device_scale_factor);
4663 host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
4664 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1,
4665 Layer::INVALID_ID);
4666 host_impl_->active_tree()->DidBecomeActive();
4667 DrawFrame();
4668 {
4669 // Horizontal & Vertical GlowEffect should not be applied when
4670 // content size is less then view port size. For Example Horizontal &
4671 // vertical GlowEffect should not be applied in about:blank page.
4672 EXPECT_EQ(InputHandler::SCROLL_STARTED,
4673 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL));
4674 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1));
4675 EXPECT_FALSE(scroll_result.did_scroll);
4676 EXPECT_FALSE(scroll_result.did_overscroll_root);
4677 EXPECT_EQ(gfx::Vector2dF().ToString(),
4678 host_impl_->accumulated_root_overscroll().ToString());
4679
4680 host_impl_->ScrollEnd();
4681 }
4682 }
4683
4684 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { 4638 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
4685 InputHandlerScrollResult scroll_result; 4639 InputHandlerScrollResult scroll_result;
4686 gfx::Size surface_size(100, 100); 4640 gfx::Size surface_size(100, 100);
4687 gfx::Size content_size(200, 200); 4641 gfx::Size content_size(200, 200);
4688 scoped_ptr<LayerImpl> root_clip = 4642 scoped_ptr<LayerImpl> root_clip =
4689 LayerImpl::Create(host_impl_->active_tree(), 3); 4643 LayerImpl::Create(host_impl_->active_tree(), 3);
4690 root_clip->SetHasRenderSurface(true); 4644 root_clip->SetHasRenderSurface(true);
4691 4645
4692 scoped_ptr<LayerImpl> root = 4646 scoped_ptr<LayerImpl> root =
4693 CreateScrollableLayer(1, content_size, root_clip.get()); 4647 CreateScrollableLayer(1, content_size, root_clip.get());
(...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after
8193 // Hold an unowned pointer to the output surface to use for mock expectations. 8147 // Hold an unowned pointer to the output surface to use for mock expectations.
8194 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); 8148 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get();
8195 8149
8196 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 8150 CreateHostImpl(DefaultSettings(), output_surface.Pass());
8197 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); 8151 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1);
8198 host_impl_->BeginCommit(); 8152 host_impl_->BeginCommit();
8199 } 8153 }
8200 8154
8201 } // namespace 8155 } // namespace
8202 } // namespace cc 8156 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/viewport.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698