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

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

Issue 2183403002: cc: Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layer_tree_change
Patch Set: remove unused test file. Created 4 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 static ScrollTree* ScrollTreeForLayer(LayerImpl* layer_impl) { 61 static ScrollTree* ScrollTreeForLayer(LayerImpl* layer_impl) {
62 return &layer_impl->layer_tree_impl()->property_trees()->scroll_tree; 62 return &layer_impl->layer_tree_impl()->property_trees()->scroll_tree;
63 } 63 }
64 64
65 class LayerTreeHostScrollTest : public LayerTreeTest { 65 class LayerTreeHostScrollTest : public LayerTreeTest {
66 protected: 66 protected:
67 void SetupTree() override { 67 void SetupTree() override {
68 LayerTreeTest::SetupTree(); 68 LayerTreeTest::SetupTree();
69 Layer* root_layer = layer_tree_host()->root_layer(); 69 Layer* root_layer = layer_tree()->root_layer();
70 70
71 // Create an effective max_scroll_offset of (100, 100). 71 // Create an effective max_scroll_offset of (100, 100).
72 gfx::Size scroll_layer_bounds(root_layer->bounds().width() + 100, 72 gfx::Size scroll_layer_bounds(root_layer->bounds().width() + 100,
73 root_layer->bounds().height() + 100); 73 root_layer->bounds().height() + 100);
74 74
75 CreateVirtualViewportLayers(root_layer, root_layer->bounds(), 75 CreateVirtualViewportLayers(root_layer, root_layer->bounds(),
76 root_layer->bounds(), scroll_layer_bounds, 76 root_layer->bounds(), scroll_layer_bounds,
77 layer_tree_host()); 77 layer_tree_host());
78 } 78 }
79 }; 79 };
80 80
81 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest { 81 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest {
82 public: 82 public:
83 LayerTreeHostScrollTestScrollSimple() 83 LayerTreeHostScrollTestScrollSimple()
84 : initial_scroll_(10, 20), 84 : initial_scroll_(10, 20),
85 second_scroll_(40, 5), 85 second_scroll_(40, 5),
86 scroll_amount_(2, -1), 86 scroll_amount_(2, -1),
87 num_scrolls_(0) {} 87 num_scrolls_(0) {}
88 88
89 void BeginTest() override { 89 void BeginTest() override {
90 outer_viewport_container_layer_id_ = layer_tree_host() 90 outer_viewport_container_layer_id_ =
91 ->outer_viewport_scroll_layer() 91 layer_tree()->outer_viewport_scroll_layer()->scroll_clip_layer()->id();
92 ->scroll_clip_layer() 92 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset(
93 ->id();
94 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
95 initial_scroll_); 93 initial_scroll_);
96 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback( 94 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback(
97 base::Bind(&LayerTreeHostScrollTestScrollSimple::DidScrollOuterViewport, 95 base::Bind(&LayerTreeHostScrollTestScrollSimple::DidScrollOuterViewport,
98 base::Unretained(this))); 96 base::Unretained(this)));
99 PostSetNeedsCommitToMainThread(); 97 PostSetNeedsCommitToMainThread();
100 } 98 }
101 99
102 void UpdateLayerTreeHost() override { 100 void UpdateLayerTreeHost() override {
103 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer(); 101 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer();
104 if (!layer_tree_host()->source_frame_number()) { 102 if (!layer_tree_host()->source_frame_number()) {
105 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); 103 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
106 } else { 104 } else {
107 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, 105 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_,
108 scroll_amount_), 106 scroll_amount_),
109 scroll_layer->scroll_offset()); 107 scroll_layer->scroll_offset());
110 108
111 // Pretend like Javascript updated the scroll position itself. 109 // Pretend like Javascript updated the scroll position itself.
112 scroll_layer->SetScrollOffset(second_scroll_); 110 scroll_layer->SetScrollOffset(second_scroll_);
113 } 111 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 153
156 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSimple); 154 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSimple);
157 155
158 class LayerTreeHostScrollTestScrollMultipleRedraw 156 class LayerTreeHostScrollTestScrollMultipleRedraw
159 : public LayerTreeHostScrollTest { 157 : public LayerTreeHostScrollTest {
160 public: 158 public:
161 LayerTreeHostScrollTestScrollMultipleRedraw() 159 LayerTreeHostScrollTestScrollMultipleRedraw()
162 : initial_scroll_(40, 10), scroll_amount_(-3, 17), num_scrolls_(0) {} 160 : initial_scroll_(40, 10), scroll_amount_(-3, 17), num_scrolls_(0) {}
163 161
164 void BeginTest() override { 162 void BeginTest() override {
165 scroll_layer_ = layer_tree_host()->outer_viewport_scroll_layer(); 163 scroll_layer_ = layer_tree()->outer_viewport_scroll_layer();
166 scroll_layer_->SetScrollOffset(initial_scroll_); 164 scroll_layer_->SetScrollOffset(initial_scroll_);
167 scroll_layer_->set_did_scroll_callback(base::Bind( 165 scroll_layer_->set_did_scroll_callback(base::Bind(
168 &LayerTreeHostScrollTestScrollMultipleRedraw::DidScrollOuterViewport, 166 &LayerTreeHostScrollTestScrollMultipleRedraw::DidScrollOuterViewport,
169 base::Unretained(this))); 167 base::Unretained(this)));
170 PostSetNeedsCommitToMainThread(); 168 PostSetNeedsCommitToMainThread();
171 } 169 }
172 170
173 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { 171 void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
174 switch (layer_tree_host()->source_frame_number()) { 172 switch (layer_tree_host()->source_frame_number()) {
175 case 0: 173 case 0:
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 second_main_scroll_(14, -3), 244 second_main_scroll_(14, -3),
247 impl_scale_(2.f), 245 impl_scale_(2.f),
248 num_will_begin_main_frames_(0), 246 num_will_begin_main_frames_(0),
249 num_did_begin_main_frames_(0), 247 num_did_begin_main_frames_(0),
250 num_will_commits_(0), 248 num_will_commits_(0),
251 num_did_commits_(0), 249 num_did_commits_(0),
252 num_impl_commits_(0), 250 num_impl_commits_(0),
253 num_impl_scrolls_(0) {} 251 num_impl_scrolls_(0) {}
254 252
255 void BeginTest() override { 253 void BeginTest() override {
256 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset( 254 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset(
257 initial_scroll_); 255 initial_scroll_);
258 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback( 256 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback(
259 base::Bind( 257 base::Bind(
260 &LayerTreeHostScrollTestScrollAbortedCommit::DidScrollOuterViewport, 258 &LayerTreeHostScrollTestScrollAbortedCommit::DidScrollOuterViewport,
261 base::Unretained(this))); 259 base::Unretained(this)));
262 PostSetNeedsCommitToMainThread(); 260 PostSetNeedsCommitToMainThread();
263 } 261 }
264 262
265 void SetupTree() override { 263 void SetupTree() override {
266 LayerTreeHostScrollTest::SetupTree(); 264 LayerTreeHostScrollTest::SetupTree();
267 265
268 gfx::Size scroll_layer_bounds(200, 200); 266 gfx::Size scroll_layer_bounds(200, 200);
269 layer_tree_host()->outer_viewport_scroll_layer()->SetBounds( 267 layer_tree()->outer_viewport_scroll_layer()->SetBounds(scroll_layer_bounds);
270 scroll_layer_bounds); 268 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
271 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
272 } 269 }
273 270
274 void WillBeginMainFrame() override { 271 void WillBeginMainFrame() override {
275 num_will_begin_main_frames_++; 272 num_will_begin_main_frames_++;
276 Layer* root_scroll_layer = 273 Layer* root_scroll_layer = layer_tree()->outer_viewport_scroll_layer();
277 layer_tree_host()->outer_viewport_scroll_layer();
278 switch (num_will_begin_main_frames_) { 274 switch (num_will_begin_main_frames_) {
279 case 1: 275 case 1:
280 // This will not be aborted because of the initial prop changes. 276 // This will not be aborted because of the initial prop changes.
281 EXPECT_EQ(0, num_impl_scrolls_); 277 EXPECT_EQ(0, num_impl_scrolls_);
282 EXPECT_EQ(0, layer_tree_host()->source_frame_number()); 278 EXPECT_EQ(0, layer_tree_host()->source_frame_number());
283 EXPECT_VECTOR_EQ(initial_scroll_, root_scroll_layer->scroll_offset()); 279 EXPECT_VECTOR_EQ(initial_scroll_, root_scroll_layer->scroll_offset());
284 EXPECT_EQ(1.f, layer_tree_host()->page_scale_factor()); 280 EXPECT_EQ(1.f, layer_tree()->page_scale_factor());
285 break; 281 break;
286 case 2: 282 case 2:
287 // This commit will be aborted, and another commit will be 283 // This commit will be aborted, and another commit will be
288 // initiated from the redraw. 284 // initiated from the redraw.
289 EXPECT_EQ(1, num_impl_scrolls_); 285 EXPECT_EQ(1, num_impl_scrolls_);
290 EXPECT_EQ(1, layer_tree_host()->source_frame_number()); 286 EXPECT_EQ(1, layer_tree_host()->source_frame_number());
291 EXPECT_VECTOR_EQ( 287 EXPECT_VECTOR_EQ(
292 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_scroll_), 288 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_scroll_),
293 root_scroll_layer->scroll_offset()); 289 root_scroll_layer->scroll_offset());
294 EXPECT_EQ(impl_scale_, layer_tree_host()->page_scale_factor()); 290 EXPECT_EQ(impl_scale_, layer_tree()->page_scale_factor());
295 PostSetNeedsRedrawToMainThread(); 291 PostSetNeedsRedrawToMainThread();
296 break; 292 break;
297 case 3: 293 case 3:
298 // This commit will not be aborted because of the scroll change. 294 // This commit will not be aborted because of the scroll change.
299 EXPECT_EQ(2, num_impl_scrolls_); 295 EXPECT_EQ(2, num_impl_scrolls_);
300 // The source frame number still increases even with the abort. 296 // The source frame number still increases even with the abort.
301 EXPECT_EQ(2, layer_tree_host()->source_frame_number()); 297 EXPECT_EQ(2, layer_tree_host()->source_frame_number());
302 EXPECT_VECTOR_EQ( 298 EXPECT_VECTOR_EQ(
303 gfx::ScrollOffsetWithDelta(initial_scroll_, 299 gfx::ScrollOffsetWithDelta(initial_scroll_,
304 impl_scroll_ + impl_scroll_), 300 impl_scroll_ + impl_scroll_),
305 root_scroll_layer->scroll_offset()); 301 root_scroll_layer->scroll_offset());
306 EXPECT_EQ(impl_scale_ * impl_scale_, 302 EXPECT_EQ(impl_scale_ * impl_scale_, layer_tree()->page_scale_factor());
307 layer_tree_host()->page_scale_factor());
308 root_scroll_layer->SetScrollOffset(gfx::ScrollOffsetWithDelta( 303 root_scroll_layer->SetScrollOffset(gfx::ScrollOffsetWithDelta(
309 root_scroll_layer->scroll_offset(), second_main_scroll_)); 304 root_scroll_layer->scroll_offset(), second_main_scroll_));
310 break; 305 break;
311 case 4: 306 case 4:
312 // This commit will also be aborted. 307 // This commit will also be aborted.
313 EXPECT_EQ(3, num_impl_scrolls_); 308 EXPECT_EQ(3, num_impl_scrolls_);
314 EXPECT_EQ(3, layer_tree_host()->source_frame_number()); 309 EXPECT_EQ(3, layer_tree_host()->source_frame_number());
315 gfx::Vector2dF delta = 310 gfx::Vector2dF delta =
316 impl_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_; 311 impl_scroll_ + impl_scroll_ + impl_scroll_ + second_main_scroll_;
317 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, delta), 312 EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, delta),
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 }; 429 };
435 430
436 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommit); 431 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommit);
437 432
438 class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest { 433 class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest {
439 public: 434 public:
440 LayerTreeHostScrollTestFractionalScroll() : scroll_amount_(1.75, 0) {} 435 LayerTreeHostScrollTestFractionalScroll() : scroll_amount_(1.75, 0) {}
441 436
442 void SetupTree() override { 437 void SetupTree() override {
443 LayerTreeHostScrollTest::SetupTree(); 438 LayerTreeHostScrollTest::SetupTree();
444 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); 439 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
445 } 440 }
446 441
447 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 442 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
448 443
449 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 444 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
450 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 445 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
451 446
452 // Check that a fractional scroll delta is correctly accumulated over 447 // Check that a fractional scroll delta is correctly accumulated over
453 // multiple commits. 448 // multiple commits.
454 switch (impl->active_tree()->source_frame_number()) { 449 switch (impl->active_tree()->source_frame_number()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 }; 485 };
491 486
492 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll); 487 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll);
493 488
494 class LayerTreeHostScrollTestScrollSnapping : public LayerTreeHostScrollTest { 489 class LayerTreeHostScrollTestScrollSnapping : public LayerTreeHostScrollTest {
495 public: 490 public:
496 LayerTreeHostScrollTestScrollSnapping() : scroll_amount_(1.75, 0) {} 491 LayerTreeHostScrollTestScrollSnapping() : scroll_amount_(1.75, 0) {}
497 492
498 void SetupTree() override { 493 void SetupTree() override {
499 LayerTreeHostScrollTest::SetupTree(); 494 LayerTreeHostScrollTest::SetupTree();
500 layer_tree_host() 495 layer_tree()
501 ->outer_viewport_scroll_layer() 496 ->outer_viewport_scroll_layer()
502 ->scroll_clip_layer() 497 ->scroll_clip_layer()
503 ->SetForceRenderSurfaceForTesting(true); 498 ->SetForceRenderSurfaceForTesting(true);
504 gfx::Transform translate; 499 gfx::Transform translate;
505 translate.Translate(0.25f, 0.f); 500 translate.Translate(0.25f, 0.f);
506 layer_tree_host() 501 layer_tree()
507 ->outer_viewport_scroll_layer() 502 ->outer_viewport_scroll_layer()
508 ->scroll_clip_layer() 503 ->scroll_clip_layer()
509 ->SetTransform(translate); 504 ->SetTransform(translate);
510 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.1f, 100.f); 505 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.1f, 100.f);
511 } 506 }
512 507
513 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 508 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
514 509
515 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 510 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
516 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 511 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
517 gfx::Transform translate; 512 gfx::Transform translate;
518 513
519 // Check that screen space transform of the scrollable layer is correctly 514 // Check that screen space transform of the scrollable layer is correctly
520 // snapped to integers. 515 // snapped to integers.
(...skipping 29 matching lines...) Expand all
550 545
551 class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest { 546 class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
552 public: 547 public:
553 LayerTreeHostScrollTestCaseWithChild() 548 LayerTreeHostScrollTestCaseWithChild()
554 : initial_offset_(10, 20), 549 : initial_offset_(10, 20),
555 javascript_scroll_(40, 5), 550 javascript_scroll_(40, 5),
556 scroll_amount_(2, -1), 551 scroll_amount_(2, -1),
557 num_scrolls_(0) {} 552 num_scrolls_(0) {}
558 553
559 void SetupTree() override { 554 void SetupTree() override {
560 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); 555 layer_tree()->SetDeviceScaleFactor(device_scale_factor_);
561 556
562 scoped_refptr<Layer> root_layer = Layer::Create(); 557 scoped_refptr<Layer> root_layer = Layer::Create();
563 root_layer->SetBounds(gfx::Size(10, 10)); 558 root_layer->SetBounds(gfx::Size(10, 10));
564 559
565 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); 560 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
566 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); 561 root_scroll_layer_->SetBounds(gfx::Size(110, 110));
567 root_scroll_layer_->SetPosition(gfx::PointF()); 562 root_scroll_layer_->SetPosition(gfx::PointF());
568 root_scroll_layer_->SetIsDrawable(true); 563 root_scroll_layer_->SetIsDrawable(true);
569 564
570 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_, 565 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_,
(...skipping 10 matching lines...) Expand all
581 // Scrolls on the child layer will happen at 5, 5. If they are treated 576 // Scrolls on the child layer will happen at 5, 5. If they are treated
582 // like device pixels, and device scale factor is 2, then they will 577 // like device pixels, and device scale factor is 2, then they will
583 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. 578 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer.
584 child_layer_->SetPosition(gfx::PointF(5.f, 5.f)); 579 child_layer_->SetPosition(gfx::PointF(5.f, 5.f));
585 } else { 580 } else {
586 // Adjust the child layer horizontally so that scrolls will never hit it. 581 // Adjust the child layer horizontally so that scrolls will never hit it.
587 child_layer_->SetPosition(gfx::PointF(60.f, 5.f)); 582 child_layer_->SetPosition(gfx::PointF(60.f, 5.f));
588 } 583 }
589 584
590 scoped_refptr<Layer> outer_container_layer = 585 scoped_refptr<Layer> outer_container_layer =
591 layer_tree_host()->outer_viewport_scroll_layer()->parent(); 586 layer_tree()->outer_viewport_scroll_layer()->parent();
592 587
593 child_layer_->SetIsDrawable(true); 588 child_layer_->SetIsDrawable(true);
594 child_layer_->SetScrollClipLayerId(outer_container_layer->id()); 589 child_layer_->SetScrollClipLayerId(outer_container_layer->id());
595 child_layer_->SetBounds(root_scroll_layer_->bounds()); 590 child_layer_->SetBounds(root_scroll_layer_->bounds());
596 root_scroll_layer_->AddChild(child_layer_); 591 root_scroll_layer_->AddChild(child_layer_);
597 592
598 if (scroll_child_layer_) { 593 if (scroll_child_layer_) {
599 expected_scroll_layer_ = child_layer_; 594 expected_scroll_layer_ = child_layer_;
600 expected_no_scroll_layer_ = root_scroll_layer_; 595 expected_no_scroll_layer_ = root_scroll_layer_;
601 } else { 596 } else {
602 expected_scroll_layer_ = root_scroll_layer_; 597 expected_scroll_layer_ = root_scroll_layer_;
603 expected_no_scroll_layer_ = child_layer_; 598 expected_no_scroll_layer_ = child_layer_;
604 } 599 }
605 600
606 expected_scroll_layer_->SetScrollOffset(initial_offset_); 601 expected_scroll_layer_->SetScrollOffset(initial_offset_);
607 602
608 layer_tree_host()->SetRootLayer(root_layer); 603 layer_tree()->SetRootLayer(root_layer);
609 LayerTreeTest::SetupTree(); 604 LayerTreeTest::SetupTree();
610 fake_content_layer_client_.set_bounds(root_layer->bounds()); 605 fake_content_layer_client_.set_bounds(root_layer->bounds());
611 606
612 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback( 607 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback(
613 base::Bind( 608 base::Bind(
614 &LayerTreeHostScrollTestCaseWithChild::DidScrollOuterViewport, 609 &LayerTreeHostScrollTestCaseWithChild::DidScrollOuterViewport,
615 base::Unretained(this))); 610 base::Unretained(this)));
616 } 611 }
617 612
618 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 613 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
619 614
620 void WillCommit() override { 615 void WillCommit() override {
621 // Keep the test committing (otherwise the early out for no update 616 // Keep the test committing (otherwise the early out for no update
622 // will stall the test). 617 // will stall the test).
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 public: 810 public:
816 LayerTreeHostScrollTestSimple() 811 LayerTreeHostScrollTestSimple()
817 : initial_scroll_(10, 20), 812 : initial_scroll_(10, 20),
818 main_thread_scroll_(40, 5), 813 main_thread_scroll_(40, 5),
819 impl_thread_scroll1_(2, -1), 814 impl_thread_scroll1_(2, -1),
820 impl_thread_scroll2_(-3, 10), 815 impl_thread_scroll2_(-3, 10),
821 num_scrolls_(0) {} 816 num_scrolls_(0) {}
822 817
823 void SetupTree() override { 818 void SetupTree() override {
824 LayerTreeHostScrollTest::SetupTree(); 819 LayerTreeHostScrollTest::SetupTree();
825 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); 820 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
826 } 821 }
827 822
828 void BeginTest() override { 823 void BeginTest() override {
829 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset( 824 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset(
830 initial_scroll_); 825 initial_scroll_);
831 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback( 826 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback(
832 base::Bind(&LayerTreeHostScrollTestSimple::DidScrollOuterViewport, 827 base::Bind(&LayerTreeHostScrollTestSimple::DidScrollOuterViewport,
833 base::Unretained(this))); 828 base::Unretained(this)));
834 PostSetNeedsCommitToMainThread(); 829 PostSetNeedsCommitToMainThread();
835 } 830 }
836 831
837 void UpdateLayerTreeHost() override { 832 void UpdateLayerTreeHost() override {
838 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer(); 833 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer();
839 if (!layer_tree_host()->source_frame_number()) { 834 if (!layer_tree_host()->source_frame_number()) {
840 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); 835 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
841 } else { 836 } else {
842 EXPECT_VECTOR_EQ( 837 EXPECT_VECTOR_EQ(
843 scroll_layer->scroll_offset(), 838 scroll_layer->scroll_offset(),
844 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_thread_scroll1_)); 839 gfx::ScrollOffsetWithDelta(initial_scroll_, impl_thread_scroll1_));
845 840
846 // Pretend like Javascript updated the scroll position itself with a 841 // Pretend like Javascript updated the scroll position itself with a
847 // change of main_thread_scroll. 842 // change of main_thread_scroll.
848 scroll_layer->SetScrollOffset( 843 scroll_layer->SetScrollOffset(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 // beginning a commit and finishing a commit (aka scroll deltas not 932 // beginning a commit and finishing a commit (aka scroll deltas not
938 // included in sent scroll delta) still apply to layers that don't 933 // included in sent scroll delta) still apply to layers that don't
939 // push properties. 934 // push properties.
940 class LayerTreeHostScrollTestImplOnlyScroll : public LayerTreeHostScrollTest { 935 class LayerTreeHostScrollTestImplOnlyScroll : public LayerTreeHostScrollTest {
941 public: 936 public:
942 LayerTreeHostScrollTestImplOnlyScroll() 937 LayerTreeHostScrollTestImplOnlyScroll()
943 : initial_scroll_(20, 10), impl_thread_scroll_(-2, 3), impl_scale_(2.f) {} 938 : initial_scroll_(20, 10), impl_thread_scroll_(-2, 3), impl_scale_(2.f) {}
944 939
945 void SetupTree() override { 940 void SetupTree() override {
946 LayerTreeHostScrollTest::SetupTree(); 941 LayerTreeHostScrollTest::SetupTree();
947 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f); 942 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
948 } 943 }
949 944
950 void BeginTest() override { 945 void BeginTest() override {
951 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset( 946 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset(
952 initial_scroll_); 947 initial_scroll_);
953 PostSetNeedsCommitToMainThread(); 948 PostSetNeedsCommitToMainThread();
954 } 949 }
955 950
956 void WillCommit() override { 951 void WillCommit() override {
957 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer(); 952 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer();
958 switch (layer_tree_host()->source_frame_number()) { 953 switch (layer_tree_host()->source_frame_number()) {
959 case 0: 954 case 0:
960 EXPECT_TRUE( 955 EXPECT_TRUE(
961 scroll_layer->GetLayerTree()->LayerNeedsPushPropertiesForTesting( 956 scroll_layer->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
962 scroll_layer)); 957 scroll_layer));
963 break; 958 break;
964 case 1: 959 case 1:
965 // Even if this layer doesn't need push properties, it should 960 // Even if this layer doesn't need push properties, it should
966 // still pick up scrolls that happen on the active layer during 961 // still pick up scrolls that happen on the active layer during
967 // commit. 962 // commit.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1072
1078 // This tests scrolling on the impl side which is only possible with a thread. 1073 // This tests scrolling on the impl side which is only possible with a thread.
1079 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplOnlyScroll); 1074 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplOnlyScroll);
1080 1075
1081 class LayerTreeHostScrollTestScrollZeroMaxScrollOffset 1076 class LayerTreeHostScrollTestScrollZeroMaxScrollOffset
1082 : public LayerTreeHostScrollTest { 1077 : public LayerTreeHostScrollTest {
1083 public: 1078 public:
1084 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {} 1079 LayerTreeHostScrollTestScrollZeroMaxScrollOffset() {}
1085 1080
1086 void BeginTest() override { 1081 void BeginTest() override {
1087 outer_viewport_container_layer_id_ = layer_tree_host() 1082 outer_viewport_container_layer_id_ =
1088 ->outer_viewport_scroll_layer() 1083 layer_tree()->outer_viewport_scroll_layer()->scroll_clip_layer()->id();
1089 ->scroll_clip_layer()
1090 ->id();
1091 PostSetNeedsCommitToMainThread(); 1084 PostSetNeedsCommitToMainThread();
1092 } 1085 }
1093 1086
1094 void UpdateLayerTreeHost() override { 1087 void UpdateLayerTreeHost() override {
1095 Layer* root = layer_tree_host()->root_layer(); 1088 Layer* root = layer_tree()->root_layer();
1096 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer(); 1089 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer();
1097 switch (layer_tree_host()->source_frame_number()) { 1090 switch (layer_tree_host()->source_frame_number()) {
1098 case 0: 1091 case 0:
1099 scroll_layer->SetScrollClipLayerId(outer_viewport_container_layer_id_); 1092 scroll_layer->SetScrollClipLayerId(outer_viewport_container_layer_id_);
1100 // Set max_scroll_offset = (100, 100). 1093 // Set max_scroll_offset = (100, 100).
1101 scroll_layer->SetBounds(gfx::Size(root->bounds().width() + 100, 1094 scroll_layer->SetBounds(gfx::Size(root->bounds().width() + 100,
1102 root->bounds().height() + 100)); 1095 root->bounds().height() + 100));
1103 break; 1096 break;
1104 case 1: 1097 case 1:
1105 // Set max_scroll_offset = (0, 0). 1098 // Set max_scroll_offset = (0, 0).
1106 scroll_layer->SetBounds(root->bounds()); 1099 scroll_layer->SetBounds(root->bounds());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 1148
1156 class LayerTreeHostScrollTestScrollNonDrawnLayer 1149 class LayerTreeHostScrollTestScrollNonDrawnLayer
1157 : public LayerTreeHostScrollTest { 1150 : public LayerTreeHostScrollTest {
1158 public: 1151 public:
1159 LayerTreeHostScrollTestScrollNonDrawnLayer() {} 1152 LayerTreeHostScrollTestScrollNonDrawnLayer() {}
1160 1153
1161 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1154 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1162 1155
1163 void SetupTree() override { 1156 void SetupTree() override {
1164 LayerTreeHostScrollTest::SetupTree(); 1157 LayerTreeHostScrollTest::SetupTree();
1165 layer_tree_host()->outer_viewport_scroll_layer()->SetIsDrawable(false); 1158 layer_tree()->outer_viewport_scroll_layer()->SetIsDrawable(false);
1166 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset( 1159 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset(
1167 gfx::ScrollOffset(20.f, 20.f)); 1160 gfx::ScrollOffset(20.f, 20.f));
1168 layer_tree_host() 1161 layer_tree()->outer_viewport_scroll_layer()->SetNonFastScrollableRegion(
1169 ->outer_viewport_scroll_layer() 1162 gfx::Rect(20, 20, 20, 20));
1170 ->SetNonFastScrollableRegion(gfx::Rect(20, 20, 20, 20));
1171 } 1163 }
1172 1164
1173 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1165 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1174 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); 1166 LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
1175 1167
1176 ScrollTree& scroll_tree = 1168 ScrollTree& scroll_tree =
1177 impl->active_tree()->property_trees()->scroll_tree; 1169 impl->active_tree()->property_trees()->scroll_tree;
1178 ScrollNode* scroll_node = 1170 ScrollNode* scroll_node =
1179 scroll_tree.Node(scroll_layer->scroll_tree_index()); 1171 scroll_tree.Node(scroll_layer->scroll_tree_index());
1180 1172
(...skipping 24 matching lines...) Expand all
1205 1197
1206 class LayerTreeHostScrollTestImplScrollUnderMainThreadScrollingParent 1198 class LayerTreeHostScrollTestImplScrollUnderMainThreadScrollingParent
1207 : public LayerTreeHostScrollTest { 1199 : public LayerTreeHostScrollTest {
1208 public: 1200 public:
1209 LayerTreeHostScrollTestImplScrollUnderMainThreadScrollingParent() {} 1201 LayerTreeHostScrollTestImplScrollUnderMainThreadScrollingParent() {}
1210 1202
1211 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 1203 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
1212 1204
1213 void SetupTree() override { 1205 void SetupTree() override {
1214 LayerTreeHostScrollTest::SetupTree(); 1206 LayerTreeHostScrollTest::SetupTree();
1215 layer_tree_host() 1207 layer_tree()->inner_viewport_scroll_layer()->AddMainThreadScrollingReasons(
1216 ->inner_viewport_scroll_layer() 1208 MainThreadScrollingReason::kEventHandlers);
1217 ->AddMainThreadScrollingReasons(
1218 MainThreadScrollingReason::kEventHandlers);
1219 } 1209 }
1220 1210
1221 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 1211 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
1222 LayerImpl* inner_scroll_layer = impl->InnerViewportScrollLayer(); 1212 LayerImpl* inner_scroll_layer = impl->InnerViewportScrollLayer();
1223 LayerImpl* outer_scroll_layer = impl->OuterViewportScrollLayer(); 1213 LayerImpl* outer_scroll_layer = impl->OuterViewportScrollLayer();
1224 1214
1225 ScrollTree& scroll_tree = 1215 ScrollTree& scroll_tree =
1226 impl->active_tree()->property_trees()->scroll_tree; 1216 impl->active_tree()->property_trees()->scroll_tree;
1227 ScrollNode* inner_scroll_node = 1217 ScrollNode* inner_scroll_node =
1228 scroll_tree.Node(inner_scroll_layer->scroll_tree_index()); 1218 scroll_tree.Node(inner_scroll_layer->scroll_tree_index());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 } 1329 }
1340 1330
1341 class LayerTreeHostScrollTestLayerStructureChange 1331 class LayerTreeHostScrollTestLayerStructureChange
1342 : public LayerTreeHostScrollTest { 1332 : public LayerTreeHostScrollTest {
1343 public: 1333 public:
1344 LayerTreeHostScrollTestLayerStructureChange() 1334 LayerTreeHostScrollTestLayerStructureChange()
1345 : scroll_destroy_whole_tree_(false) {} 1335 : scroll_destroy_whole_tree_(false) {}
1346 1336
1347 void SetupTree() override { 1337 void SetupTree() override {
1348 LayerTreeTest::SetupTree(); 1338 LayerTreeTest::SetupTree();
1349 Layer* root_layer = layer_tree_host()->root_layer(); 1339 Layer* root_layer = layer_tree()->root_layer();
1350 root_layer->SetBounds(gfx::Size(10, 10)); 1340 root_layer->SetBounds(gfx::Size(10, 10));
1351 1341
1352 CreateVirtualViewportLayers(root_layer, root_layer->bounds(), 1342 CreateVirtualViewportLayers(root_layer, root_layer->bounds(),
1353 root_layer->bounds(), root_layer->bounds(), 1343 root_layer->bounds(), root_layer->bounds(),
1354 layer_tree_host()); 1344 layer_tree_host());
1355 1345
1356 Layer* outer_scroll_layer = 1346 Layer* outer_scroll_layer = layer_tree()->outer_viewport_scroll_layer();
1357 layer_tree_host()->outer_viewport_scroll_layer();
1358 1347
1359 Layer* root_scroll_layer = 1348 Layer* root_scroll_layer =
1360 CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_); 1349 CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_);
1361 Layer* sibling_scroll_layer = 1350 Layer* sibling_scroll_layer =
1362 CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_); 1351 CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_);
1363 Layer* child_scroll_layer = 1352 Layer* child_scroll_layer =
1364 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); 1353 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_);
1365 root_scroll_layer_id_ = root_scroll_layer->id(); 1354 root_scroll_layer_id_ = root_scroll_layer->id();
1366 sibling_scroll_layer_id_ = sibling_scroll_layer->id(); 1355 sibling_scroll_layer_id_ = sibling_scroll_layer->id();
1367 child_scroll_layer_id_ = child_scroll_layer->id(); 1356 child_scroll_layer_id_ = child_scroll_layer->id();
(...skipping 19 matching lines...) Expand all
1387 case 1: 1376 case 1:
1388 EndTest(); 1377 EndTest();
1389 break; 1378 break;
1390 } 1379 }
1391 } 1380 }
1392 1381
1393 void AfterTest() override {} 1382 void AfterTest() override {}
1394 1383
1395 virtual void DidScroll(Layer* layer) { 1384 virtual void DidScroll(Layer* layer) {
1396 if (scroll_destroy_whole_tree_) { 1385 if (scroll_destroy_whole_tree_) {
1397 layer_tree_host()->RegisterViewportLayers(NULL, NULL, NULL, NULL); 1386 layer_tree()->RegisterViewportLayers(NULL, NULL, NULL, NULL);
1398 layer_tree_host()->SetRootLayer(NULL); 1387 layer_tree()->SetRootLayer(NULL);
1399 EndTest(); 1388 EndTest();
1400 return; 1389 return;
1401 } 1390 }
1402 layer->RemoveFromParent(); 1391 layer->RemoveFromParent();
1403 } 1392 }
1404 1393
1405 protected: 1394 protected:
1406 class FakeLayerScrollClient { 1395 class FakeLayerScrollClient {
1407 public: 1396 public:
1408 void DidScroll() { 1397 void DidScroll() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 third_scroll_(20, 10), 1457 third_scroll_(20, 10),
1469 scroll_amount_(2, -1), 1458 scroll_amount_(2, -1),
1470 num_commits_(0), 1459 num_commits_(0),
1471 num_scrolls_(0) {} 1460 num_scrolls_(0) {}
1472 1461
1473 void InitializeSettings(LayerTreeSettings* settings) override { 1462 void InitializeSettings(LayerTreeSettings* settings) override {
1474 settings->main_frame_before_activation_enabled = true; 1463 settings->main_frame_before_activation_enabled = true;
1475 } 1464 }
1476 1465
1477 void BeginTest() override { 1466 void BeginTest() override {
1478 outer_viewport_container_layer_id_ = layer_tree_host() 1467 outer_viewport_container_layer_id_ =
1479 ->outer_viewport_scroll_layer() 1468 layer_tree()->outer_viewport_scroll_layer()->scroll_clip_layer()->id();
1480 ->scroll_clip_layer() 1469 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset(
1481 ->id();
1482 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset(
1483 initial_scroll_); 1470 initial_scroll_);
1484 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback( 1471 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback(
1485 base::Bind(&LayerTreeHostScrollTestScrollMFBA::DidScrollOuterViewport, 1472 base::Bind(&LayerTreeHostScrollTestScrollMFBA::DidScrollOuterViewport,
1486 base::Unretained(this))); 1473 base::Unretained(this)));
1487 PostSetNeedsCommitToMainThread(); 1474 PostSetNeedsCommitToMainThread();
1488 } 1475 }
1489 1476
1490 void ReadyToCommitOnThread(LayerTreeHostImpl* impl) override { 1477 void ReadyToCommitOnThread(LayerTreeHostImpl* impl) override {
1491 switch (num_commits_) { 1478 switch (num_commits_) {
1492 case 1: 1479 case 1:
1493 // Ask for commit here because activation (and draw) will be blocked. 1480 // Ask for commit here because activation (and draw) will be blocked.
1494 impl->SetNeedsCommit(); 1481 impl->SetNeedsCommit();
1495 // Block activation after second commit until third commit is ready. 1482 // Block activation after second commit until third commit is ready.
1496 impl->BlockNotifyReadyToActivateForTesting(true); 1483 impl->BlockNotifyReadyToActivateForTesting(true);
1497 break; 1484 break;
1498 case 2: 1485 case 2:
1499 // Unblock activation after third commit is ready. 1486 // Unblock activation after third commit is ready.
1500 impl->BlockNotifyReadyToActivateForTesting(false); 1487 impl->BlockNotifyReadyToActivateForTesting(false);
1501 break; 1488 break;
1502 } 1489 }
1503 num_commits_++; 1490 num_commits_++;
1504 } 1491 }
1505 1492
1506 void UpdateLayerTreeHost() override { 1493 void UpdateLayerTreeHost() override {
1507 Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer(); 1494 Layer* scroll_layer = layer_tree()->outer_viewport_scroll_layer();
1508 switch (layer_tree_host()->source_frame_number()) { 1495 switch (layer_tree_host()->source_frame_number()) {
1509 case 0: 1496 case 0:
1510 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset()); 1497 EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
1511 break; 1498 break;
1512 case 1: 1499 case 1:
1513 EXPECT_VECTOR_EQ( 1500 EXPECT_VECTOR_EQ(
1514 gfx::ScrollOffsetWithDelta(initial_scroll_, scroll_amount_), 1501 gfx::ScrollOffsetWithDelta(initial_scroll_, scroll_amount_),
1515 scroll_layer->scroll_offset()); 1502 scroll_layer->scroll_offset());
1516 // Pretend like Javascript updated the scroll position itself. 1503 // Pretend like Javascript updated the scroll position itself.
1517 scroll_layer->SetScrollOffset(second_scroll_); 1504 scroll_layer->SetScrollOffset(second_scroll_);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 num_impl_commits_(0), 1588 num_impl_commits_(0),
1602 num_aborted_commits_(0), 1589 num_aborted_commits_(0),
1603 num_impl_scrolls_(0), 1590 num_impl_scrolls_(0),
1604 num_draws_(0) {} 1591 num_draws_(0) {}
1605 1592
1606 void InitializeSettings(LayerTreeSettings* settings) override { 1593 void InitializeSettings(LayerTreeSettings* settings) override {
1607 settings->main_frame_before_activation_enabled = true; 1594 settings->main_frame_before_activation_enabled = true;
1608 } 1595 }
1609 1596
1610 void BeginTest() override { 1597 void BeginTest() override {
1611 layer_tree_host()->outer_viewport_scroll_layer()->SetScrollOffset( 1598 layer_tree()->outer_viewport_scroll_layer()->SetScrollOffset(
1612 initial_scroll_); 1599 initial_scroll_);
1613 layer_tree_host()->outer_viewport_scroll_layer()->set_did_scroll_callback( 1600 layer_tree()->outer_viewport_scroll_layer()->set_did_scroll_callback(
1614 base::Bind(&LayerTreeHostScrollTestScrollAbortedCommitMFBA:: 1601 base::Bind(&LayerTreeHostScrollTestScrollAbortedCommitMFBA::
1615 DidScrollOuterViewport, 1602 DidScrollOuterViewport,
1616 base::Unretained(this))); 1603 base::Unretained(this)));
1617 PostSetNeedsCommitToMainThread(); 1604 PostSetNeedsCommitToMainThread();
1618 } 1605 }
1619 1606
1620 void SetupTree() override { 1607 void SetupTree() override {
1621 LayerTreeHostScrollTest::SetupTree(); 1608 LayerTreeHostScrollTest::SetupTree();
1622 1609
1623 gfx::Size scroll_layer_bounds(200, 200); 1610 gfx::Size scroll_layer_bounds(200, 200);
1624 layer_tree_host()->outer_viewport_scroll_layer()->SetBounds( 1611 layer_tree()->outer_viewport_scroll_layer()->SetBounds(scroll_layer_bounds);
1625 scroll_layer_bounds); 1612 layer_tree()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
1626 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.01f, 100.f);
1627 } 1613 }
1628 1614
1629 void WillBeginMainFrame() override { 1615 void WillBeginMainFrame() override {
1630 num_will_begin_main_frames_++; 1616 num_will_begin_main_frames_++;
1631 Layer* root_scroll_layer = layer_tree_host()->outer_viewport_scroll_layer(); 1617 Layer* root_scroll_layer = layer_tree()->outer_viewport_scroll_layer();
1632 switch (num_will_begin_main_frames_) { 1618 switch (num_will_begin_main_frames_) {
1633 case 1: 1619 case 1:
1634 // This will not be aborted because of the initial prop changes. 1620 // This will not be aborted because of the initial prop changes.
1635 EXPECT_EQ(0, num_impl_scrolls_); 1621 EXPECT_EQ(0, num_impl_scrolls_);
1636 EXPECT_EQ(0, layer_tree_host()->source_frame_number()); 1622 EXPECT_EQ(0, layer_tree_host()->source_frame_number());
1637 EXPECT_VECTOR_EQ(initial_scroll_, root_scroll_layer->scroll_offset()); 1623 EXPECT_VECTOR_EQ(initial_scroll_, root_scroll_layer->scroll_offset());
1638 break; 1624 break;
1639 case 2: 1625 case 2:
1640 // This commit will not be aborted because of the scroll change. 1626 // This commit will not be aborted because of the scroll change.
1641 EXPECT_EQ(1, num_impl_scrolls_); 1627 EXPECT_EQ(1, num_impl_scrolls_);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 int num_impl_commits_; 1791 int num_impl_commits_;
1806 int num_aborted_commits_; 1792 int num_aborted_commits_;
1807 int num_impl_scrolls_; 1793 int num_impl_scrolls_;
1808 int num_draws_; 1794 int num_draws_;
1809 }; 1795 };
1810 1796
1811 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommitMFBA); 1797 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollAbortedCommitMFBA);
1812 1798
1813 } // namespace 1799 } // namespace
1814 } // namespace cc 1800 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698