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

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

Issue 2175163005: Add flag to hide scrollbars completely. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ShouldHideScrollbars(). 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_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 2752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 host_impl_->active_tree()->DidBecomeActive(); 2763 host_impl_->active_tree()->DidBecomeActive();
2764 DrawFrame(); 2764 DrawFrame();
2765 } 2765 }
2766 2766
2767 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 2767 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
2768 LayerTreeSettings settings = DefaultSettings(); 2768 LayerTreeSettings settings = DefaultSettings();
2769 settings.scrollbar_animator = animator; 2769 settings.scrollbar_animator = animator;
2770 settings.scrollbar_fade_delay_ms = 20; 2770 settings.scrollbar_fade_delay_ms = 20;
2771 settings.scrollbar_fade_duration_ms = 20; 2771 settings.scrollbar_fade_duration_ms = 20;
2772 2772
2773 // If no animator is set, scrollbar won't show and no animation is expected.
2774 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR;
2775
2773 SetupLayers(settings); 2776 SetupLayers(settings);
2774 2777
2775 base::TimeTicks fake_now = base::TimeTicks::Now(); 2778 base::TimeTicks fake_now = base::TimeTicks::Now();
2776 2779
2777 // A task will be posted to fade the initial scrollbar. 2780 if (expecting_animations) {
2778 EXPECT_FALSE(did_request_next_frame_); 2781 // A task will be posted to fade the initial scrollbar.
2779 EXPECT_FALSE(did_request_redraw_); 2782 EXPECT_FALSE(did_request_next_frame_);
2780 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2783 EXPECT_FALSE(did_request_redraw_);
2781 requested_animation_delay_ = base::TimeDelta(); 2784 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2782 animation_task_ = base::Closure(); 2785 requested_animation_delay_ = base::TimeDelta();
2786 animation_task_ = base::Closure();
2787 } else {
2788 EXPECT_FALSE(did_request_next_frame_);
2789 EXPECT_FALSE(did_request_redraw_);
2790 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2791 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2792 }
2783 2793
2784 // If no scroll happened during a scroll gesture, it should have no effect. 2794 // If no scroll happened during a scroll gesture, it should have no effect.
2785 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2795 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2786 InputHandler::WHEEL); 2796 InputHandler::WHEEL);
2787 host_impl_->ScrollEnd(EndState().get()); 2797 host_impl_->ScrollEnd(EndState().get());
2788 EXPECT_FALSE(did_request_next_frame_); 2798 EXPECT_FALSE(did_request_next_frame_);
2789 EXPECT_FALSE(did_request_redraw_); 2799 EXPECT_FALSE(did_request_redraw_);
2790 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2800 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2791 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2801 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2792 2802
(...skipping 17 matching lines...) Expand all
2810 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 2820 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
2811 EXPECT_FALSE(did_request_next_frame_); 2821 EXPECT_FALSE(did_request_next_frame_);
2812 EXPECT_TRUE(did_request_redraw_); 2822 EXPECT_TRUE(did_request_redraw_);
2813 did_request_redraw_ = false; 2823 did_request_redraw_ = false;
2814 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2824 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2815 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2825 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2816 2826
2817 host_impl_->ScrollEnd(EndState().get()); 2827 host_impl_->ScrollEnd(EndState().get());
2818 EXPECT_FALSE(did_request_next_frame_); 2828 EXPECT_FALSE(did_request_next_frame_);
2819 EXPECT_FALSE(did_request_redraw_); 2829 EXPECT_FALSE(did_request_redraw_);
2820 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2830 if (expecting_animations) {
2821 requested_animation_delay_); 2831 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2822 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2832 requested_animation_delay_);
2833 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2834 } else {
2835 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2836 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2837 }
2823 2838
2824 // Before the scrollbar animation begins, we should not get redraws. 2839 if (expecting_animations) {
2825 begin_frame_args = 2840 // Before the scrollbar animation begins, we should not get redraws.
2826 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); 2841 begin_frame_args =
2827 host_impl_->WillBeginImplFrame(begin_frame_args); 2842 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now);
2828 host_impl_->Animate(); 2843 host_impl_->WillBeginImplFrame(begin_frame_args);
2829 EXPECT_FALSE(did_request_next_frame_); 2844 host_impl_->Animate();
2830 did_request_next_frame_ = false; 2845 EXPECT_FALSE(did_request_next_frame_);
2831 EXPECT_FALSE(did_request_redraw_); 2846 did_request_next_frame_ = false;
2832 did_request_redraw_ = false; 2847 EXPECT_FALSE(did_request_redraw_);
2833 host_impl_->DidFinishImplFrame(); 2848 did_request_redraw_ = false;
2849 host_impl_->DidFinishImplFrame();
2834 2850
2835 // Start the scrollbar animation. 2851 // Start the scrollbar animation.
2836 fake_now += requested_animation_delay_; 2852 fake_now += requested_animation_delay_;
2837 requested_animation_delay_ = base::TimeDelta(); 2853 requested_animation_delay_ = base::TimeDelta();
2838 animation_task_.Run(); 2854 animation_task_.Run();
2839 animation_task_ = base::Closure(); 2855 animation_task_ = base::Closure();
2840 EXPECT_TRUE(did_request_next_frame_); 2856 EXPECT_TRUE(did_request_next_frame_);
2841 did_request_next_frame_ = false; 2857 did_request_next_frame_ = false;
2842 EXPECT_FALSE(did_request_redraw_); 2858 EXPECT_FALSE(did_request_redraw_);
2843 2859
2844 // After the scrollbar animation begins, we should start getting redraws. 2860 // After the scrollbar animation begins, we should start getting redraws.
2845 begin_frame_args = 2861 begin_frame_args =
2846 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); 2862 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now);
2847 host_impl_->WillBeginImplFrame(begin_frame_args); 2863 host_impl_->WillBeginImplFrame(begin_frame_args);
2848 host_impl_->Animate(); 2864 host_impl_->Animate();
2849 EXPECT_TRUE(did_request_next_frame_); 2865 EXPECT_TRUE(did_request_next_frame_);
2850 did_request_next_frame_ = false; 2866 did_request_next_frame_ = false;
2851 EXPECT_TRUE(did_request_redraw_); 2867 EXPECT_TRUE(did_request_redraw_);
2852 did_request_redraw_ = false; 2868 did_request_redraw_ = false;
2853 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2869 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2854 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2870 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2855 host_impl_->DidFinishImplFrame(); 2871 host_impl_->DidFinishImplFrame();
2872 }
2856 2873
2857 // Setting the scroll offset outside a scroll should also cause the 2874 // Setting the scroll offset outside a scroll should also cause the
2858 // scrollbar to appear and to schedule a scrollbar animation. 2875 // scrollbar to appear and to schedule a scrollbar animation.
2859 if (host_impl_->active_tree() 2876 if (host_impl_->active_tree()
2860 ->property_trees() 2877 ->property_trees()
2861 ->scroll_tree.UpdateScrollOffsetBaseForTesting( 2878 ->scroll_tree.UpdateScrollOffsetBaseForTesting(
2862 host_impl_->InnerViewportScrollLayer()->id(), 2879 host_impl_->InnerViewportScrollLayer()->id(),
2863 gfx::ScrollOffset(5, 5))) 2880 gfx::ScrollOffset(5, 5)))
2864 host_impl_->active_tree()->DidUpdateScrollOffset( 2881 host_impl_->active_tree()->DidUpdateScrollOffset(
2865 host_impl_->InnerViewportScrollLayer()->id(), 2882 host_impl_->InnerViewportScrollLayer()->id(),
2866 host_impl_->InnerViewportScrollLayer()->transform_tree_index()); 2883 host_impl_->InnerViewportScrollLayer()->transform_tree_index());
2867 EXPECT_FALSE(did_request_next_frame_); 2884 EXPECT_FALSE(did_request_next_frame_);
2868 EXPECT_FALSE(did_request_redraw_); 2885 EXPECT_FALSE(did_request_redraw_);
2869 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2886 if (expecting_animations) {
2870 requested_animation_delay_); 2887 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2871 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2888 requested_animation_delay_);
2872 requested_animation_delay_ = base::TimeDelta(); 2889 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2873 animation_task_ = base::Closure(); 2890 requested_animation_delay_ = base::TimeDelta();
2891 animation_task_ = base::Closure();
2892 } else {
2893 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2894 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2895 }
2874 2896
2875 // Scrolling should have stopped the animation, so we should not be getting 2897 if (expecting_animations) {
2876 // redraws. 2898 // Scrolling should have stopped the animation, so we should not be
2877 begin_frame_args = 2899 // getting redraws.
2878 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); 2900 begin_frame_args =
2879 host_impl_->WillBeginImplFrame(begin_frame_args); 2901 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now);
2880 host_impl_->Animate(); 2902 host_impl_->WillBeginImplFrame(begin_frame_args);
2881 EXPECT_FALSE(did_request_next_frame_); 2903 host_impl_->Animate();
2882 did_request_next_frame_ = false; 2904 EXPECT_FALSE(did_request_next_frame_);
2883 EXPECT_FALSE(did_request_redraw_); 2905 did_request_next_frame_ = false;
2884 did_request_redraw_ = false; 2906 EXPECT_FALSE(did_request_redraw_);
2885 host_impl_->DidFinishImplFrame(); 2907 did_request_redraw_ = false;
2908 host_impl_->DidFinishImplFrame();
2909 }
2886 2910
2887 // Scrollbar animation is not triggered unnecessarily. 2911 // Scrollbar animation is not triggered unnecessarily.
2888 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2912 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2889 InputHandler::WHEEL); 2913 InputHandler::WHEEL);
2890 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); 2914 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get());
2891 EXPECT_FALSE(did_request_next_frame_); 2915 EXPECT_FALSE(did_request_next_frame_);
2892 EXPECT_TRUE(did_request_redraw_); 2916 EXPECT_TRUE(did_request_redraw_);
2893 did_request_redraw_ = false; 2917 did_request_redraw_ = false;
2894 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2918 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2895 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2919 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2896 2920
2897 host_impl_->ScrollEnd(EndState().get()); 2921 host_impl_->ScrollEnd(EndState().get());
2898 EXPECT_FALSE(did_request_next_frame_); 2922 EXPECT_FALSE(did_request_next_frame_);
2899 EXPECT_FALSE(did_request_redraw_); 2923 EXPECT_FALSE(did_request_redraw_);
2900 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2924 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2901 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2925 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2902 2926
2903 // Changing page scale triggers scrollbar animation. 2927 // Changing page scale triggers scrollbar animation.
2904 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); 2928 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f);
2905 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); 2929 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f);
2906 EXPECT_FALSE(did_request_next_frame_); 2930 EXPECT_FALSE(did_request_next_frame_);
2907 EXPECT_FALSE(did_request_redraw_); 2931 EXPECT_FALSE(did_request_redraw_);
2908 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2932 if (expecting_animations) {
2909 requested_animation_delay_); 2933 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2910 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2934 requested_animation_delay_);
2911 requested_animation_delay_ = base::TimeDelta(); 2935 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
2912 animation_task_ = base::Closure(); 2936 requested_animation_delay_ = base::TimeDelta();
2937 animation_task_ = base::Closure();
2938 } else {
2939 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2940 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2941 }
2913 } 2942 }
2914 }; 2943 };
2915 2944
2916 TEST_F(LayerTreeHostImplTestScrollbarAnimation, LinearFade) { 2945 TEST_F(LayerTreeHostImplTestScrollbarAnimation, LinearFade) {
2917 RunTest(LayerTreeSettings::LINEAR_FADE); 2946 RunTest(LayerTreeSettings::LINEAR_FADE);
2918 } 2947 }
2919 2948
2920 TEST_F(LayerTreeHostImplTestScrollbarAnimation, Thinning) { 2949 TEST_F(LayerTreeHostImplTestScrollbarAnimation, Thinning) {
2921 RunTest(LayerTreeSettings::THINNING); 2950 RunTest(LayerTreeSettings::THINNING);
2922 } 2951 }
2923 2952
2953 TEST_F(LayerTreeHostImplTestScrollbarAnimation, NoAnimator) {
2954 RunTest(LayerTreeSettings::NO_ANIMATOR);
2955 }
2956
2924 class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { 2957 class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest {
2925 protected: 2958 protected:
2926 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 2959 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
2927 LayerTreeSettings settings = DefaultSettings(); 2960 LayerTreeSettings settings = DefaultSettings();
2928 settings.scrollbar_animator = animator; 2961 settings.scrollbar_animator = animator;
2929 settings.scrollbar_fade_delay_ms = 20; 2962 settings.scrollbar_fade_delay_ms = 20;
2930 settings.scrollbar_fade_duration_ms = 20; 2963 settings.scrollbar_fade_duration_ms = 20;
2931 gfx::Size content_size(100, 100); 2964 gfx::Size content_size(100, 100);
2932 2965
2966 // If no animator is set, scrollbar won't show and no animation is expected.
2967 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR;
2968
2933 CreateHostImpl(settings, CreateOutputSurface()); 2969 CreateHostImpl(settings, CreateOutputSurface());
2934 host_impl_->CreatePendingTree(); 2970 host_impl_->CreatePendingTree();
2935 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 2971 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
2936 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2972 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2937 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 2973 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
2938 VERTICAL, 10, 0, false, true); 2974 VERTICAL, 10, 0, false, true);
2939 scrollbar->test_properties()->opacity = 0.f; 2975 scrollbar->test_properties()->opacity = 0.f;
2940 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 2976 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
2941 LayerImpl* container = 2977 LayerImpl* container =
2942 host_impl_->pending_tree()->InnerViewportContainerLayer(); 2978 host_impl_->pending_tree()->InnerViewportContainerLayer();
2943 scrollbar->SetScrollLayerId(scroll->id()); 2979 scrollbar->SetScrollLayerId(scroll->id());
2944 container->test_properties()->AddChild(std::move(scrollbar)); 2980 container->test_properties()->AddChild(std::move(scrollbar));
2945 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 2981 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
2946 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 2982 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
2947 host_impl_->ActivateSyncTree(); 2983 host_impl_->ActivateSyncTree();
2948 2984
2949 LayerImpl* active_scrollbar_layer = 2985 LayerImpl* active_scrollbar_layer =
2950 host_impl_->active_tree()->LayerById(400); 2986 host_impl_->active_tree()->LayerById(400);
2951 2987
2952 EffectNode* active_tree_node = 2988 EffectNode* active_tree_node =
2953 host_impl_->active_tree()->property_trees()->effect_tree.Node( 2989 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2954 active_scrollbar_layer->effect_tree_index()); 2990 active_scrollbar_layer->effect_tree_index());
2955 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 2991 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
2956 active_tree_node->opacity); 2992 active_tree_node->opacity);
2957 2993
2958 host_impl_->ScrollbarAnimationControllerForId(scroll->id()) 2994 if (expecting_animations) {
2959 ->DidMouseMoveNear(0); 2995 host_impl_->ScrollbarAnimationControllerForId(scroll->id())
2996 ->DidMouseMoveNear(0);
2997 } else {
2998 EXPECT_EQ(nullptr,
2999 host_impl_->ScrollbarAnimationControllerForId(scroll->id()));
3000 }
2960 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 3001 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2961 InputHandler::WHEEL); 3002 InputHandler::WHEEL);
2962 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 3003 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
2963 host_impl_->ScrollEnd(EndState().get()); 3004 host_impl_->ScrollEnd(EndState().get());
2964 host_impl_->CreatePendingTree(); 3005 host_impl_->CreatePendingTree();
2965 // To test the case where the effect tree index of scrollbar layer changes, 3006 // To test the case where the effect tree index of scrollbar layer changes,
2966 // we force the container layer to create a render surface. 3007 // we force the container layer to create a render surface.
2967 container = host_impl_->pending_tree()->InnerViewportContainerLayer(); 3008 container = host_impl_->pending_tree()->InnerViewportContainerLayer();
2968 container->test_properties()->force_render_surface = true; 3009 container->test_properties()->force_render_surface = true;
2969 container->SetBounds(gfx::Size(10, 10)); 3010 container->SetBounds(gfx::Size(10, 10));
2970 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3011 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
2971 3012
2972 LayerImpl* pending_scrollbar_layer = 3013 LayerImpl* pending_scrollbar_layer =
2973 host_impl_->pending_tree()->LayerById(400); 3014 host_impl_->pending_tree()->LayerById(400);
3015 pending_scrollbar_layer->SetNeedsPushProperties();
2974 EffectNode* pending_tree_node = 3016 EffectNode* pending_tree_node =
2975 host_impl_->pending_tree()->property_trees()->effect_tree.Node( 3017 host_impl_->pending_tree()->property_trees()->effect_tree.Node(
2976 pending_scrollbar_layer->effect_tree_index()); 3018 pending_scrollbar_layer->effect_tree_index());
2977 host_impl_->pending_tree() 3019 host_impl_->pending_tree()
2978 ->property_trees() 3020 ->property_trees()
2979 ->always_use_active_tree_opacity_effect_ids.push_back(400); 3021 ->always_use_active_tree_opacity_effect_ids.push_back(400);
2980 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity); 3022 if (expecting_animations) {
2981 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); 3023 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity);
3024 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity());
3025 } else {
3026 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity);
3027 EXPECT_FLOAT_EQ(0.f, active_scrollbar_layer->Opacity());
3028 }
2982 EXPECT_FLOAT_EQ(0.f, pending_tree_node->opacity); 3029 EXPECT_FLOAT_EQ(0.f, pending_tree_node->opacity);
2983 host_impl_->ActivateSyncTree(); 3030 host_impl_->ActivateSyncTree();
2984 active_tree_node = 3031 active_tree_node =
2985 host_impl_->active_tree()->property_trees()->effect_tree.Node( 3032 host_impl_->active_tree()->property_trees()->effect_tree.Node(
2986 active_scrollbar_layer->effect_tree_index()); 3033 active_scrollbar_layer->effect_tree_index());
2987 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity); 3034 if (expecting_animations) {
2988 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); 3035 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity);
3036 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity());
3037 } else {
3038 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity);
3039 EXPECT_FLOAT_EQ(0.f, active_scrollbar_layer->Opacity());
3040 }
2989 } 3041 }
2990 }; 3042 };
2991 3043
2992 TEST_F(LayerTreeHostImplTestScrollbarOpacity, LinearFade) { 3044 TEST_F(LayerTreeHostImplTestScrollbarOpacity, LinearFade) {
2993 RunTest(LayerTreeSettings::LINEAR_FADE); 3045 RunTest(LayerTreeSettings::LINEAR_FADE);
2994 } 3046 }
2995 3047
2996 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) { 3048 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Thinning) {
2997 RunTest(LayerTreeSettings::THINNING); 3049 RunTest(LayerTreeSettings::THINNING);
2998 } 3050 }
2999 3051
3052 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) {
3053 RunTest(LayerTreeSettings::NO_ANIMATOR);
3054 }
3055
3000 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { 3056 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) {
3001 LayerTreeSettings settings = DefaultSettings(); 3057 LayerTreeSettings settings = DefaultSettings();
3002 CreateHostImpl(settings, CreateOutputSurface()); 3058 CreateHostImpl(settings, CreateOutputSurface());
3003 3059
3004 gfx::Size inner_viewport_size(315, 200); 3060 gfx::Size inner_viewport_size(315, 200);
3005 gfx::Size outer_viewport_size(300, 200); 3061 gfx::Size outer_viewport_size(300, 200);
3006 gfx::Size content_size(1000, 1000); 3062 gfx::Size content_size(1000, 1000);
3007 3063
3008 const int horiz_id = 11; 3064 const int horiz_id = 11;
3009 const int child_clip_id = 14; 3065 const int child_clip_id = 14;
(...skipping 7837 matching lines...) Expand 10 before | Expand all | Expand 10 after
10847 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 10903 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
10848 10904
10849 // Re-initialize with a software output surface. 10905 // Re-initialize with a software output surface.
10850 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); 10906 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware();
10851 host_impl_->InitializeRenderer(output_surface_.get()); 10907 host_impl_->InitializeRenderer(output_surface_.get());
10852 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10908 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10853 } 10909 }
10854 10910
10855 } // namespace 10911 } // namespace
10856 } // namespace cc 10912 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698