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

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

Issue 2748343004: Revert of Show Overlay Scrollbar when GestureScrollUpdate (Closed)
Patch Set: rebase Created 3 years, 9 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.cc » ('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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 // SetScrollLayerId will initialize the scrollbar which will cause it to 2807 // SetScrollLayerId will initialize the scrollbar which will cause it to
2808 // show and request a redraw. 2808 // show and request a redraw.
2809 did_request_redraw_ = false; 2809 did_request_redraw_ = false;
2810 } 2810 }
2811 2811
2812 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 2812 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
2813 LayerTreeSettings settings = DefaultSettings(); 2813 LayerTreeSettings settings = DefaultSettings();
2814 settings.scrollbar_animator = animator; 2814 settings.scrollbar_animator = animator;
2815 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); 2815 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
2816 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); 2816 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
2817 settings.scrollbar_fade_out_resize_delay =
2818 base::TimeDelta::FromMilliseconds(20);
2819 settings.scrollbar_fade_out_duration = 2817 settings.scrollbar_fade_out_duration =
2820 base::TimeDelta::FromMilliseconds(20); 2818 base::TimeDelta::FromMilliseconds(20);
2821 2819
2822 // If no animator is set, scrollbar won't show and no animation is expected. 2820 // If no animator is set, scrollbar won't show and no animation is expected.
2823 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; 2821 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR;
2824 2822
2825 SetupLayers(settings); 2823 SetupLayers(settings);
2826 2824
2827 base::TimeTicks fake_now = base::TimeTicks::Now(); 2825 base::TimeTicks fake_now = base::TimeTicks::Now();
2828 2826
(...skipping 13 matching lines...) Expand all
2842 2840
2843 // If no scroll happened during a scroll gesture, it should have no effect. 2841 // If no scroll happened during a scroll gesture, it should have no effect.
2844 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2842 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2845 InputHandler::WHEEL); 2843 InputHandler::WHEEL);
2846 host_impl_->ScrollEnd(EndState().get()); 2844 host_impl_->ScrollEnd(EndState().get());
2847 EXPECT_FALSE(did_request_next_frame_); 2845 EXPECT_FALSE(did_request_next_frame_);
2848 EXPECT_FALSE(did_request_redraw_); 2846 EXPECT_FALSE(did_request_redraw_);
2849 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2847 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2850 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2848 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2851 2849
2852 // For Aura Overlay Scrollbar, if no scroll happened during a scroll
2853 // gesture, shows scrollbars and schedules a delay fade out.
2854 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2855 InputHandler::WHEEL);
2856 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 0)).get());
2857 host_impl_->ScrollEnd(EndState().get());
2858 EXPECT_FALSE(did_request_next_frame_);
2859 EXPECT_FALSE(did_request_redraw_);
2860 if (animator == LayerTreeSettings::AURA_OVERLAY) {
2861 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2862 requested_animation_delay_);
2863 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2864 requested_animation_delay_ = base::TimeDelta();
2865 animation_task_ = base::Closure();
2866 } else {
2867 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2868 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2869 }
2870
2871 // Before the scrollbar animation exists, we should not get redraws. 2850 // Before the scrollbar animation exists, we should not get redraws.
2872 BeginFrameArgs begin_frame_args = 2851 BeginFrameArgs begin_frame_args =
2873 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); 2852 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now);
2874 host_impl_->WillBeginImplFrame(begin_frame_args); 2853 host_impl_->WillBeginImplFrame(begin_frame_args);
2875 host_impl_->Animate(); 2854 host_impl_->Animate();
2876 EXPECT_FALSE(did_request_next_frame_); 2855 EXPECT_FALSE(did_request_next_frame_);
2877 did_request_next_frame_ = false; 2856 did_request_next_frame_ = false;
2878 EXPECT_FALSE(did_request_redraw_); 2857 EXPECT_FALSE(did_request_redraw_);
2879 did_request_redraw_ = false; 2858 did_request_redraw_ = false;
2880 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2859 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now); 2947 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now);
2969 host_impl_->WillBeginImplFrame(begin_frame_args); 2948 host_impl_->WillBeginImplFrame(begin_frame_args);
2970 host_impl_->Animate(); 2949 host_impl_->Animate();
2971 EXPECT_FALSE(did_request_next_frame_); 2950 EXPECT_FALSE(did_request_next_frame_);
2972 did_request_next_frame_ = false; 2951 did_request_next_frame_ = false;
2973 EXPECT_FALSE(did_request_redraw_); 2952 EXPECT_FALSE(did_request_redraw_);
2974 did_request_redraw_ = false; 2953 did_request_redraw_ = false;
2975 host_impl_->DidFinishImplFrame(); 2954 host_impl_->DidFinishImplFrame();
2976 } 2955 }
2977 2956
2978 // For Andrdoid, scrollbar animation is not triggered unnecessarily. 2957 // Scrollbar animation is not triggered unnecessarily.
2979 // For Aura Overlay Scrollbar, scrollbar appears even if scroll offset did
2980 // not change.
2981 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2958 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2982 InputHandler::WHEEL); 2959 InputHandler::WHEEL);
2983 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); 2960 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get());
2984 EXPECT_FALSE(did_request_next_frame_); 2961 EXPECT_FALSE(did_request_next_frame_);
2985 EXPECT_TRUE(did_request_redraw_); 2962 EXPECT_TRUE(did_request_redraw_);
2986 did_request_redraw_ = false; 2963 did_request_redraw_ = false;
2987 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2964 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2988 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2965 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2989 2966
2990 host_impl_->ScrollEnd(EndState().get()); 2967 host_impl_->ScrollEnd(EndState().get());
2991 EXPECT_FALSE(did_request_next_frame_); 2968 EXPECT_FALSE(did_request_next_frame_);
2992 EXPECT_FALSE(did_request_redraw_); 2969 EXPECT_FALSE(did_request_redraw_);
2993 if (animator == LayerTreeSettings::AURA_OVERLAY) { 2970 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2994 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2971 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2995 requested_animation_delay_);
2996 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2997 requested_animation_delay_ = base::TimeDelta();
2998 animation_task_ = base::Closure();
2999 } else {
3000 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
3001 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
3002 }
3003 2972
3004 // Changing page scale triggers scrollbar animation. 2973 // Changing page scale triggers scrollbar animation.
3005 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); 2974 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f);
3006 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); 2975 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f);
3007 EXPECT_FALSE(did_request_next_frame_); 2976 EXPECT_FALSE(did_request_next_frame_);
3008 EXPECT_FALSE(did_request_redraw_); 2977 EXPECT_FALSE(did_request_redraw_);
3009 if (expecting_animations) { 2978 if (expecting_animations) {
3010 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2979 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
3011 requested_animation_delay_); 2980 requested_animation_delay_);
3012 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2981 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
(...skipping 9082 matching lines...) Expand 10 before | Expand all | Expand 10 after
12095 else 12064 else
12096 EXPECT_FALSE(tile->HasRasterTask()); 12065 EXPECT_FALSE(tile->HasRasterTask());
12097 } 12066 }
12098 Region expected_invalidation( 12067 Region expected_invalidation(
12099 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12068 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12100 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12069 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12101 } 12070 }
12102 12071
12103 } // namespace 12072 } // namespace
12104 } // namespace cc 12073 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698