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

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

Issue 1063853005: Unify Android Webview and Chrome's fling (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Created 5 years, 7 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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 3860 matching lines...) Expand 10 before | Expand all | Expand 10 after
3871 host_impl_->active_tree()->InnerViewportScrollLayer(); 3871 host_impl_->active_tree()->InnerViewportScrollLayer();
3872 EXPECT_EQ(gfx::ScrollOffset(0, 0), 3872 EXPECT_EQ(gfx::ScrollOffset(0, 0),
3873 inner_viewport_scroll_layer->MaxScrollOffset()); 3873 inner_viewport_scroll_layer->MaxScrollOffset());
3874 } 3874 }
3875 3875
3876 class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate { 3876 class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
3877 public: 3877 public:
3878 TestScrollOffsetDelegate() 3878 TestScrollOffsetDelegate()
3879 : page_scale_factor_(0.f), 3879 : page_scale_factor_(0.f),
3880 min_page_scale_factor_(-1.f), 3880 min_page_scale_factor_(-1.f),
3881 max_page_scale_factor_(-1.f) {} 3881 max_page_scale_factor_(-1.f),
3882 needs_animate_(false) {}
3882 3883
3883 ~TestScrollOffsetDelegate() override {} 3884 ~TestScrollOffsetDelegate() override {}
3884 3885
3885 gfx::ScrollOffset GetTotalScrollOffset() override { 3886 gfx::ScrollOffset GetTotalScrollOffset() override {
3886 return getter_return_value_; 3887 return getter_return_value_;
3887 } 3888 }
3888 3889
3889 bool IsExternalFlingActive() const override { return false; } 3890 bool IsExternalScrollActive() const override { return false; }
3891
3892 void SetNeedsAnimate(const AnimationCallback&) override {
3893 needs_animate_ = true;
3894 }
3890 3895
3891 void UpdateRootLayerState(const gfx::ScrollOffset& total_scroll_offset, 3896 void UpdateRootLayerState(const gfx::ScrollOffset& total_scroll_offset,
3892 const gfx::ScrollOffset& max_scroll_offset, 3897 const gfx::ScrollOffset& max_scroll_offset,
3893 const gfx::SizeF& scrollable_size, 3898 const gfx::SizeF& scrollable_size,
3894 float page_scale_factor, 3899 float page_scale_factor,
3895 float min_page_scale_factor, 3900 float min_page_scale_factor,
3896 float max_page_scale_factor) override { 3901 float max_page_scale_factor) override {
3897 DCHECK(total_scroll_offset.x() <= max_scroll_offset.x()); 3902 DCHECK(total_scroll_offset.x() <= max_scroll_offset.x());
3898 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); 3903 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y());
3899 last_set_scroll_offset_ = total_scroll_offset; 3904 last_set_scroll_offset_ = total_scroll_offset;
3900 max_scroll_offset_ = max_scroll_offset; 3905 max_scroll_offset_ = max_scroll_offset;
3901 scrollable_size_ = scrollable_size; 3906 scrollable_size_ = scrollable_size;
3902 page_scale_factor_ = page_scale_factor; 3907 page_scale_factor_ = page_scale_factor;
3903 min_page_scale_factor_ = min_page_scale_factor; 3908 min_page_scale_factor_ = min_page_scale_factor;
3904 max_page_scale_factor_ = max_page_scale_factor; 3909 max_page_scale_factor_ = max_page_scale_factor;
3905 3910
3906 set_getter_return_value(last_set_scroll_offset_); 3911 set_getter_return_value(last_set_scroll_offset_);
3907 } 3912 }
3908 3913
3914 bool GetAndResetNeedsAnimate() {
3915 bool needs_animate = needs_animate_;
3916 needs_animate_ = false;
3917 return needs_animate;
3918 }
3919
3909 gfx::ScrollOffset last_set_scroll_offset() { 3920 gfx::ScrollOffset last_set_scroll_offset() {
3910 return last_set_scroll_offset_; 3921 return last_set_scroll_offset_;
3911 } 3922 }
3912 3923
3913 void set_getter_return_value(const gfx::ScrollOffset& value) { 3924 void set_getter_return_value(const gfx::ScrollOffset& value) {
3914 getter_return_value_ = value; 3925 getter_return_value_ = value;
3915 } 3926 }
3916 3927
3917 gfx::ScrollOffset max_scroll_offset() const { 3928 gfx::ScrollOffset max_scroll_offset() const {
3918 return max_scroll_offset_; 3929 return max_scroll_offset_;
(...skipping 16 matching lines...) Expand all
3935 } 3946 }
3936 3947
3937 private: 3948 private:
3938 gfx::ScrollOffset last_set_scroll_offset_; 3949 gfx::ScrollOffset last_set_scroll_offset_;
3939 gfx::ScrollOffset getter_return_value_; 3950 gfx::ScrollOffset getter_return_value_;
3940 gfx::ScrollOffset max_scroll_offset_; 3951 gfx::ScrollOffset max_scroll_offset_;
3941 gfx::SizeF scrollable_size_; 3952 gfx::SizeF scrollable_size_;
3942 float page_scale_factor_; 3953 float page_scale_factor_;
3943 float min_page_scale_factor_; 3954 float min_page_scale_factor_;
3944 float max_page_scale_factor_; 3955 float max_page_scale_factor_;
3956 bool needs_animate_;
3945 }; 3957 };
3946 3958
3959 // TODO(jdduke): Test root fling animation.
3947 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { 3960 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) {
3948 TestScrollOffsetDelegate scroll_delegate; 3961 TestScrollOffsetDelegate scroll_delegate;
3949 host_impl_->SetViewportSize(gfx::Size(10, 20)); 3962 host_impl_->SetViewportSize(gfx::Size(10, 20));
3950 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 3963 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
3951 LayerImpl* clip_layer = scroll_layer->parent()->parent(); 3964 LayerImpl* clip_layer = scroll_layer->parent()->parent();
3952 clip_layer->SetBounds(gfx::Size(10, 20)); 3965 clip_layer->SetBounds(gfx::Size(10, 20));
3953 3966
3954 // Setting the delegate results in the current scroll offset being set. 3967 // Setting the delegate results in the current scroll offset being set.
3955 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); 3968 gfx::Vector2dF initial_scroll_delta(10.f, 10.f);
3956 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); 3969 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset());
(...skipping 3823 matching lines...) Expand 10 before | Expand all | Expand 10 after
7780 host_impl_->set_has_gpu_rasterization_trigger(false); 7793 host_impl_->set_has_gpu_rasterization_trigger(false);
7781 host_impl_->set_content_is_suitable_for_gpu_rasterization(false); 7794 host_impl_->set_content_is_suitable_for_gpu_rasterization(false);
7782 host_impl_->UpdateGpuRasterizationStatus(); 7795 host_impl_->UpdateGpuRasterizationStatus();
7783 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, 7796 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED,
7784 host_impl_->gpu_rasterization_status()); 7797 host_impl_->gpu_rasterization_status());
7785 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 7798 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
7786 } 7799 }
7787 7800
7788 } // namespace 7801 } // namespace
7789 } // namespace cc 7802 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698