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

Side by Side Diff: cc/layers/layer_impl_unittest.cc

Issue 698003006: Fix double subtraction of sent_delta on sync tree activation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment Created 6 years, 1 month 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/layer_impl.cc ('k') | no next file » | 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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "cc/layers/painted_scrollbar_layer_impl.h" 7 #include "cc/layers/painted_scrollbar_layer_impl.h"
8 #include "cc/output/filter_operation.h" 8 #include "cc/output/filter_operation.h"
9 #include "cc/output/filter_operations.h" 9 #include "cc/output/filter_operations.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // offset plus 1 in each direction. 427 // offset plus 1 in each direction.
428 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1)); 428 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1));
429 gfx::Vector2d max_scroll_offset(51, 81); 429 gfx::Vector2d max_scroll_offset(51, 81);
430 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y())); 430 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y()));
431 } 431 }
432 432
433 LayerImpl* layer() { 433 LayerImpl* layer() {
434 return host_impl_.active_tree()->root_layer()->children()[0]; 434 return host_impl_.active_tree()->root_layer()->children()[0];
435 } 435 }
436 436
437 LayerTreeHostImpl& host_impl() { return host_impl_; }
438
437 LayerTreeImpl* tree() { return host_impl_.active_tree(); } 439 LayerTreeImpl* tree() { return host_impl_.active_tree(); }
438 440
439 LayerTreeSettings settings() { 441 LayerTreeSettings settings() {
440 LayerTreeSettings settings; 442 LayerTreeSettings settings;
441 settings.use_pinch_virtual_viewport = true; 443 settings.use_pinch_virtual_viewport = true;
442 return settings; 444 return settings;
443 } 445 }
444 446
445 private: 447 private:
446 FakeImplProxy proxy_; 448 FakeImplProxy proxy_;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 gfx::Vector2dF scroll_delta(20.5f, 8.5f); 670 gfx::Vector2dF scroll_delta(20.5f, 8.5f);
669 671
670 layer()->set_user_scrollable_vertical(false); 672 layer()->set_user_scrollable_vertical(false);
671 layer()->SetScrollOffset(scroll_offset); 673 layer()->SetScrollOffset(scroll_offset);
672 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); 674 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta);
673 675
674 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled); 676 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled);
675 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset()); 677 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset());
676 } 678 }
677 679
680 TEST_F(LayerImplScrollTest, PushPropertiesToMirrorsTotalScrollOffset) {
681 gfx::ScrollOffset scroll_offset(10, 5);
682 gfx::Vector2dF scroll_delta(12, 18);
683
684 host_impl().CreatePendingTree();
685
686 layer()->SetScrollOffset(scroll_offset);
687 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta);
688
689 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), unscrolled);
690 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->TotalScrollOffset());
691
692 layer()->SetSentScrollDelta(scroll_delta);
693
694 scoped_ptr<LayerImpl> pending_layer =
695 LayerImpl::Create(host_impl().sync_tree(), layer()->id());
696 pending_layer->SetScrollOffset(layer()->TotalScrollOffset());
697
698 pending_layer->PushPropertiesTo(layer());
699
700 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->TotalScrollOffset());
701 EXPECT_VECTOR_EQ(layer()->TotalScrollOffset(),
702 pending_layer->TotalScrollOffset());
703 }
704
678 TEST_F(LayerImplScrollTest, SetNewScrollbarParameters) { 705 TEST_F(LayerImplScrollTest, SetNewScrollbarParameters) {
679 gfx::ScrollOffset scroll_offset(10, 5); 706 gfx::ScrollOffset scroll_offset(10, 5);
680 layer()->SetScrollOffset(scroll_offset); 707 layer()->SetScrollOffset(scroll_offset);
681 708
682 scoped_ptr<PaintedScrollbarLayerImpl> vertical_scrollbar( 709 scoped_ptr<PaintedScrollbarLayerImpl> vertical_scrollbar(
683 PaintedScrollbarLayerImpl::Create(tree(), 100, VERTICAL)); 710 PaintedScrollbarLayerImpl::Create(tree(), 100, VERTICAL));
684 vertical_scrollbar->SetScrollLayerAndClipLayerByIds( 711 vertical_scrollbar->SetScrollLayerAndClipLayerByIds(
685 layer()->id(), tree()->root_layer()->id()); 712 layer()->id(), tree()->root_layer()->id());
686 713
687 int expected_vertical_maximum = 714 int expected_vertical_maximum =
688 layer()->bounds().height() - tree()->root_layer()->bounds().height(); 715 layer()->bounds().height() - tree()->root_layer()->bounds().height();
689 EXPECT_EQ(expected_vertical_maximum, vertical_scrollbar->maximum()); 716 EXPECT_EQ(expected_vertical_maximum, vertical_scrollbar->maximum());
690 EXPECT_EQ(scroll_offset.y(), vertical_scrollbar->current_pos()); 717 EXPECT_EQ(scroll_offset.y(), vertical_scrollbar->current_pos());
691 718
692 scoped_ptr<PaintedScrollbarLayerImpl> horizontal_scrollbar( 719 scoped_ptr<PaintedScrollbarLayerImpl> horizontal_scrollbar(
693 PaintedScrollbarLayerImpl::Create(tree(), 101, HORIZONTAL)); 720 PaintedScrollbarLayerImpl::Create(tree(), 101, HORIZONTAL));
694 horizontal_scrollbar->SetScrollLayerAndClipLayerByIds( 721 horizontal_scrollbar->SetScrollLayerAndClipLayerByIds(
695 layer()->id(), tree()->root_layer()->id()); 722 layer()->id(), tree()->root_layer()->id());
696 723
697 int expected_horizontal_maximum = 724 int expected_horizontal_maximum =
698 layer()->bounds().width() - tree()->root_layer()->bounds().width(); 725 layer()->bounds().width() - tree()->root_layer()->bounds().width();
699 EXPECT_EQ(expected_horizontal_maximum, horizontal_scrollbar->maximum()); 726 EXPECT_EQ(expected_horizontal_maximum, horizontal_scrollbar->maximum());
700 EXPECT_EQ(scroll_offset.x(), horizontal_scrollbar->current_pos()); 727 EXPECT_EQ(scroll_offset.x(), horizontal_scrollbar->current_pos());
701 } 728 }
702 729
703 } // namespace 730 } // namespace
704 } // namespace cc 731 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698