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

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

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync changes from patches 2111203004 + 2118773002. Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 6252 matching lines...) Expand 10 before | Expand all | Expand 10 after
6263 scroll_result = host_impl_->ScrollBy( 6263 scroll_result = host_impl_->ScrollBy(
6264 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get()); 6264 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get());
6265 EXPECT_FALSE(scroll_result.did_scroll); 6265 EXPECT_FALSE(scroll_result.did_scroll);
6266 EXPECT_FALSE(scroll_result.did_overscroll_root); 6266 EXPECT_FALSE(scroll_result.did_overscroll_root);
6267 EXPECT_EQ(gfx::Vector2dF().ToString(), 6267 EXPECT_EQ(gfx::Vector2dF().ToString(),
6268 host_impl_->accumulated_root_overscroll().ToString()); 6268 host_impl_->accumulated_root_overscroll().ToString());
6269 host_impl_->ScrollEnd(EndState().get()); 6269 host_impl_->ScrollEnd(EndState().get());
6270 } 6270 }
6271 } 6271 }
6272 6272
6273 TEST_F(LayerTreeHostImplTest, OverscrollOnMainThread) {
6274 InputHandlerScrollResult scroll_result;
6275 LayerTreeSettings settings = DefaultSettings();
6276 CreateHostImpl(settings, CreateOutputSurface());
6277
6278 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50));
6279 scroll_layer->set_main_thread_scrolling_reasons(
6280 MainThreadScrollingReason::kThreadedScrollingDisabled);
6281
6282 LayerImpl* clip_layer =
6283 scroll_layer->test_properties()->parent->test_properties()->parent;
6284 clip_layer->SetBounds(gfx::Size(50, 50));
6285 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6286 host_impl_->SetViewportSize(gfx::Size(50, 50));
6287 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
6288 DrawFrame();
6289
6290 // Overscroll initiated outside layers will be handled by the main thread.
6291 EXPECT_EQ(nullptr, host_impl_->active_tree()->FindLayerThatIsHitByPoint(
6292 gfx::PointF(0, 60)));
6293 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD,
6294 host_impl_
6295 ->ScrollBegin(BeginState(gfx::Point(0, 60)).get(),
6296 InputHandler::WHEEL)
6297 .thread);
6298
6299 // Overscroll initiated inside layers will be handled by the main thread.
6300 EXPECT_NE(nullptr, host_impl_->active_tree()->FindLayerThatIsHitByPoint(
6301 gfx::PointF(0, 0)));
6302 EXPECT_EQ(
6303 InputHandler::SCROLL_ON_MAIN_THREAD,
6304 host_impl_
6305 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), InputHandler::WHEEL)
6306 .thread);
6307 }
6308
6273 class BlendStateCheckLayer : public LayerImpl { 6309 class BlendStateCheckLayer : public LayerImpl {
6274 public: 6310 public:
6275 static std::unique_ptr<LayerImpl> Create( 6311 static std::unique_ptr<LayerImpl> Create(
6276 LayerTreeImpl* tree_impl, 6312 LayerTreeImpl* tree_impl,
6277 int id, 6313 int id,
6278 ResourceProvider* resource_provider) { 6314 ResourceProvider* resource_provider) {
6279 return base::WrapUnique( 6315 return base::WrapUnique(
6280 new BlendStateCheckLayer(tree_impl, id, resource_provider)); 6316 new BlendStateCheckLayer(tree_impl, id, resource_provider));
6281 } 6317 }
6282 6318
(...skipping 4669 matching lines...) Expand 10 before | Expand all | Expand 10 after
10952 10988
10953 // Re-initialize with a software output surface. 10989 // Re-initialize with a software output surface.
10954 output_surface_ = FakeOutputSurface::CreateSoftware( 10990 output_surface_ = FakeOutputSurface::CreateSoftware(
10955 base::WrapUnique(new SoftwareOutputDevice)); 10991 base::WrapUnique(new SoftwareOutputDevice));
10956 host_impl_->InitializeRenderer(output_surface_.get()); 10992 host_impl_->InitializeRenderer(output_surface_.get());
10957 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10993 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10958 } 10994 }
10959 10995
10960 } // namespace 10996 } // namespace
10961 } // namespace cc 10997 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698