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

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

Issue 2611013002: Show Overlay Scrollbar when GestureScrollUpdate (Closed)
Patch Set: rebase & merge 2716453005 & fix tests 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
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 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2730 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 2730 host_impl_->active_tree()->BuildPropertyTreesForTesting();
2731 host_impl_->active_tree()->DidBecomeActive(); 2731 host_impl_->active_tree()->DidBecomeActive();
2732 DrawFrame(); 2732 DrawFrame();
2733 } 2733 }
2734 2734
2735 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 2735 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
2736 LayerTreeSettings settings = DefaultSettings(); 2736 LayerTreeSettings settings = DefaultSettings();
2737 settings.scrollbar_animator = animator; 2737 settings.scrollbar_animator = animator;
2738 settings.scrollbar_fade_in_delay = base::TimeDelta::FromMilliseconds(20); 2738 settings.scrollbar_fade_in_delay = base::TimeDelta::FromMilliseconds(20);
2739 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); 2739 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
2740 settings.scrollbar_fade_out_resize_delay =
2741 base::TimeDelta::FromMilliseconds(20);
2740 settings.scrollbar_fade_out_duration = 2742 settings.scrollbar_fade_out_duration =
2741 base::TimeDelta::FromMilliseconds(20); 2743 base::TimeDelta::FromMilliseconds(20);
2742 2744
2743 // If no animator is set, scrollbar won't show and no animation is expected. 2745 // If no animator is set, scrollbar won't show and no animation is expected.
2744 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; 2746 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR;
2745 2747
2746 SetupLayers(settings); 2748 SetupLayers(settings);
2747 2749
2748 base::TimeTicks fake_now = base::TimeTicks::Now(); 2750 base::TimeTicks fake_now = base::TimeTicks::Now();
2749 2751
2750 if (expecting_animations) { 2752 if (expecting_animations) {
2751 // A task will be posted to fade the initial scrollbar. 2753 // A task will be posted to fade the initial scrollbar.
2752 EXPECT_FALSE(did_request_next_frame_); 2754 EXPECT_FALSE(did_request_next_frame_);
2753 EXPECT_FALSE(did_request_redraw_); 2755 EXPECT_FALSE(did_request_redraw_);
2754 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2756 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2755 requested_animation_delay_ = base::TimeDelta(); 2757 requested_animation_delay_ = base::TimeDelta();
2756 animation_task_ = base::Closure(); 2758 animation_task_ = base::Closure();
2757 } else { 2759 } else {
2758 EXPECT_FALSE(did_request_next_frame_); 2760 EXPECT_FALSE(did_request_next_frame_);
2759 EXPECT_FALSE(did_request_redraw_); 2761 EXPECT_FALSE(did_request_redraw_);
2760 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2762 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2761 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2763 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2762 } 2764 }
2763 2765
2764 // If no scroll happened during a scroll gesture, it should have no effect. 2766 // If no scroll happened during a scroll gesture, it appears scrollbars and
bokan 2017/02/27 23:34:17 I would leave this case as is and make sure no GSU
2767 // schedules a fade out delay.
2765 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2768 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2766 InputHandler::WHEEL); 2769 InputHandler::WHEEL);
2770 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 0)).get());
2767 host_impl_->ScrollEnd(EndState().get()); 2771 host_impl_->ScrollEnd(EndState().get());
2768 EXPECT_FALSE(did_request_next_frame_); 2772 EXPECT_FALSE(did_request_next_frame_);
2769 EXPECT_FALSE(did_request_redraw_); 2773 EXPECT_FALSE(did_request_redraw_);
2770 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2774 if (expecting_animations) {
2771 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2775 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2776 requested_animation_delay_);
2777 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2778 requested_animation_delay_ = base::TimeDelta();
2779 animation_task_ = base::Closure();
2780 } else {
2781 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2782 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2783 }
2772 2784
2773 // Before the scrollbar animation exists, we should not get redraws. 2785 // Before the scrollbar animation exists, we should not get redraws.
2774 BeginFrameArgs begin_frame_args = 2786 BeginFrameArgs begin_frame_args =
2775 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); 2787 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now);
2776 host_impl_->WillBeginImplFrame(begin_frame_args); 2788 host_impl_->WillBeginImplFrame(begin_frame_args);
2777 host_impl_->Animate(); 2789 host_impl_->Animate();
2778 EXPECT_FALSE(did_request_next_frame_); 2790 EXPECT_FALSE(did_request_next_frame_);
2779 did_request_next_frame_ = false; 2791 did_request_next_frame_ = false;
2780 EXPECT_FALSE(did_request_redraw_); 2792 EXPECT_FALSE(did_request_redraw_);
2781 did_request_redraw_ = false; 2793 did_request_redraw_ = false;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2883 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); 2895 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get());
2884 EXPECT_FALSE(did_request_next_frame_); 2896 EXPECT_FALSE(did_request_next_frame_);
2885 EXPECT_TRUE(did_request_redraw_); 2897 EXPECT_TRUE(did_request_redraw_);
2886 did_request_redraw_ = false; 2898 did_request_redraw_ = false;
2887 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2899 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2888 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2900 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2889 2901
2890 host_impl_->ScrollEnd(EndState().get()); 2902 host_impl_->ScrollEnd(EndState().get());
2891 EXPECT_FALSE(did_request_next_frame_); 2903 EXPECT_FALSE(did_request_next_frame_);
2892 EXPECT_FALSE(did_request_redraw_); 2904 EXPECT_FALSE(did_request_redraw_);
2893 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2905
2894 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2906 if (expecting_animations) {
2907 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
bokan 2017/02/27 23:34:16 Is this because the layer is already scrolled to t
chaopeng 2017/02/28 01:51:12 Yes, https://cs.chromium.org/chromium/src/cc/trees
2908 requested_animation_delay_);
2909 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2910 requested_animation_delay_ = base::TimeDelta();
2911 animation_task_ = base::Closure();
2912 } else {
2913 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2914 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2915 }
2895 2916
2896 // Changing page scale triggers scrollbar animation. 2917 // Changing page scale triggers scrollbar animation.
2897 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); 2918 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f);
2898 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); 2919 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f);
2899 EXPECT_FALSE(did_request_next_frame_); 2920 EXPECT_FALSE(did_request_next_frame_);
2900 EXPECT_FALSE(did_request_redraw_); 2921 EXPECT_FALSE(did_request_redraw_);
2901 if (expecting_animations) { 2922 if (expecting_animations) {
2902 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2923 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2903 requested_animation_delay_); 2924 requested_animation_delay_);
2904 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2925 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
(...skipping 8953 matching lines...) Expand 10 before | Expand all | Expand 10 after
11858 else 11879 else
11859 EXPECT_FALSE(tile->HasRasterTask()); 11880 EXPECT_FALSE(tile->HasRasterTask());
11860 } 11881 }
11861 Region expected_invalidation( 11882 Region expected_invalidation(
11862 raster_source->GetRectForImage(checkerable_image->uniqueID())); 11883 raster_source->GetRectForImage(checkerable_image->uniqueID()));
11863 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 11884 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
11864 } 11885 }
11865 11886
11866 } // namespace 11887 } // namespace
11867 } // namespace cc 11888 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698