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

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

Issue 476113004: Replace overdraw_bottom_height with top_controls_layout_height. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ScrollViewportRounding test Created 6 years, 4 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') | cc/trees/layer_tree_impl.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 <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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); 984 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
985 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 985 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
986 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); 986 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass());
987 host_impl_->ScrollEnd(); 987 host_impl_->ScrollEnd();
988 988
989 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); 989 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
990 EXPECT_EQ(1u, scroll_info->swap_promises.size()); 990 EXPECT_EQ(1u, scroll_info->swap_promises.size());
991 EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId()); 991 EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId());
992 } 992 }
993 993
994 TEST_F(LayerTreeHostImplTest, MasksToBoundsDoesntClobberInnerContainerSize) {
995 SetupScrollAndContentsLayers(gfx::Size(100, 100));
996 host_impl_->SetViewportSize(gfx::Size(50, 50));
997 DrawFrame();
998
999 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
1000 LayerImpl* container_layer = scroll_layer->scroll_clip_layer();
1001 DCHECK(scroll_layer);
1002
1003 float min_page_scale = 1.f;
1004 float max_page_scale = 4.f;
1005 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1006 min_page_scale,
1007 max_page_scale);
1008
1009 // If the container's masks_to_bounds is false, the viewport size should
1010 // overwrite the inner viewport container layer's size.
1011 {
1012 EXPECT_EQ(gfx::Size(50, 50),
1013 container_layer->bounds());
1014 container_layer->SetMasksToBounds(false);
1015
1016 container_layer->SetBounds(gfx::Size(30, 25));
1017 EXPECT_EQ(gfx::Size(30, 25),
1018 container_layer->bounds());
1019
1020 // This should cause a reset of the inner viewport container layer's bounds.
1021 host_impl_->DidChangeTopControlsPosition();
1022
1023 EXPECT_EQ(gfx::Size(50, 50),
1024 container_layer->bounds());
1025 }
1026
1027 host_impl_->SetViewportSize(gfx::Size(50, 50));
1028 container_layer->SetBounds(gfx::Size(50, 50));
1029
1030 // If the container's masks_to_bounds is true, the viewport size should
1031 // *NOT* overwrite the inner viewport container layer's size.
1032 {
1033 EXPECT_EQ(gfx::Size(50, 50),
1034 container_layer->bounds());
1035 container_layer->SetMasksToBounds(true);
1036
1037 container_layer->SetBounds(gfx::Size(30, 25));
1038 EXPECT_EQ(gfx::Size(30, 25),
1039 container_layer->bounds());
1040
1041 // This should cause a reset of the inner viewport container layer's bounds.
1042 host_impl_->DidChangeTopControlsPosition();
1043
1044 EXPECT_EQ(gfx::Size(30, 25),
1045 container_layer->bounds());
1046 }
1047 }
1048
1049 TEST_F(LayerTreeHostImplTest, PinchGesture) { 994 TEST_F(LayerTreeHostImplTest, PinchGesture) {
1050 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 995 SetupScrollAndContentsLayers(gfx::Size(100, 100));
1051 host_impl_->SetViewportSize(gfx::Size(50, 50)); 996 host_impl_->SetViewportSize(gfx::Size(50, 50));
1052 DrawFrame(); 997 DrawFrame();
1053 998
1054 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 999 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
1055 DCHECK(scroll_layer); 1000 DCHECK(scroll_layer);
1056 1001
1057 float min_page_scale = 1.f; 1002 float min_page_scale = 1.f;
1058 float max_page_scale = 4.f; 1003 float max_page_scale = 4.f;
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 root->SetIsContainerForFixedPositionLayers(true); 2118 root->SetIsContainerForFixedPositionLayers(true);
2174 int inner_viewport_scroll_layer_id = root->id(); 2119 int inner_viewport_scroll_layer_id = root->id();
2175 int page_scale_layer_id = root_clip->id(); 2120 int page_scale_layer_id = root_clip->id();
2176 root_clip->AddChild(root.Pass()); 2121 root_clip->AddChild(root.Pass());
2177 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); 2122 host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
2178 host_impl_->active_tree()->SetViewportLayersFromIds( 2123 host_impl_->active_tree()->SetViewportLayersFromIds(
2179 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID); 2124 page_scale_layer_id, inner_viewport_scroll_layer_id, Layer::INVALID_ID);
2180 // Set a viewport size that is large enough to contain both the top controls 2125 // Set a viewport size that is large enough to contain both the top controls
2181 // and some content. 2126 // and some content.
2182 host_impl_->SetViewportSize(viewport_size_); 2127 host_impl_->SetViewportSize(viewport_size_);
2128 host_impl_->SetTopControlsLayoutHeight(settings_.top_controls_height);
2183 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); 2129 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer();
2184 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); 2130 EXPECT_EQ(clip_size_, root_clip_ptr->bounds());
2185 } 2131 }
2186 2132
2187 protected: 2133 protected:
2188 gfx::Size layer_size_; 2134 gfx::Size layer_size_;
2189 gfx::Size clip_size_; 2135 gfx::Size clip_size_;
2190 gfx::Size viewport_size_; 2136 gfx::Size viewport_size_;
2191 2137
2192 LayerTreeSettings settings_; 2138 LayerTreeSettings settings_;
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 ExpectContains(*scroll_info.get(), 2985 ExpectContains(*scroll_info.get(),
3040 scroll_layer->id(), 2986 scroll_layer->id(),
3041 wheel_scroll_delta); 2987 wheel_scroll_delta);
3042 } 2988 }
3043 2989
3044 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { 2990 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) {
3045 int width = 332; 2991 int width = 332;
3046 int height = 20; 2992 int height = 20;
3047 int scale = 3; 2993 int scale = 3;
3048 SetupScrollAndContentsLayers(gfx::Size(width, height)); 2994 SetupScrollAndContentsLayers(gfx::Size(width, height));
3049 host_impl_->SetViewportSize(gfx::Size(width * scale - 1, height * scale)); 2995 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
2996 gfx::Size(width * scale - 1, height * scale));
3050 host_impl_->SetDeviceScaleFactor(scale); 2997 host_impl_->SetDeviceScaleFactor(scale);
3051 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); 2998 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
3052 2999
3053 LayerImpl* inner_viewport_scroll_layer = 3000 LayerImpl* inner_viewport_scroll_layer =
3054 host_impl_->active_tree()->InnerViewportScrollLayer(); 3001 host_impl_->active_tree()->InnerViewportScrollLayer();
3055 EXPECT_EQ(gfx::Vector2d(0, 0), 3002 EXPECT_EQ(gfx::Vector2d(0, 0),
3056 inner_viewport_scroll_layer->MaxScrollOffset()); 3003 inner_viewport_scroll_layer->MaxScrollOffset());
3057 } 3004 }
3058 3005
3059 class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate { 3006 class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
(...skipping 3810 matching lines...) Expand 10 before | Expand all | Expand 10 after
6870 external_clip, 6817 external_clip,
6871 external_viewport, 6818 external_viewport,
6872 external_transform, 6819 external_transform,
6873 resourceless_software_draw); 6820 resourceless_software_draw);
6874 DrawFrame(); 6821 DrawFrame();
6875 EXPECT_TRANSFORMATION_MATRIX_EQ( 6822 EXPECT_TRANSFORMATION_MATRIX_EQ(
6876 external_transform, layer->draw_properties().target_space_transform); 6823 external_transform, layer->draw_properties().target_space_transform);
6877 } 6824 }
6878 6825
6879 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { 6826 TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
6880 SetupScrollAndContentsLayers(gfx::Size(100, 150)); 6827 SetupScrollAndContentsLayers(gfx::Size(100, 200));
6881 host_impl_->SetViewportSize(gfx::Size(50, 50));
6882 DrawFrame(); 6828 DrawFrame();
6883 6829
6884 base::TimeTicks start_time = 6830 base::TimeTicks start_time =
6885 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); 6831 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
6886 6832
6887 EXPECT_EQ(InputHandler::ScrollStarted, 6833 EXPECT_EQ(InputHandler::ScrollStarted,
6888 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); 6834 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
6889 6835
6890 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 6836 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
6891 6837
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
7040 host_impl_->DidLoseOutputSurface(); 6986 host_impl_->DidLoseOutputSurface();
7041 EXPECT_TRUE(host_impl_->IsContextLost()); 6987 EXPECT_TRUE(host_impl_->IsContextLost());
7042 EXPECT_EQ(1, num_lost_surfaces_); 6988 EXPECT_EQ(1, num_lost_surfaces_);
7043 host_impl_->DidLoseOutputSurface(); 6989 host_impl_->DidLoseOutputSurface();
7044 EXPECT_TRUE(host_impl_->IsContextLost()); 6990 EXPECT_TRUE(host_impl_->IsContextLost());
7045 EXPECT_EQ(1, num_lost_surfaces_); 6991 EXPECT_EQ(1, num_lost_surfaces_);
7046 } 6992 }
7047 6993
7048 } // namespace 6994 } // namespace
7049 } // namespace cc 6995 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698