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

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

Issue 2740493003: Call setNeedsRedraw when scrollbar opacity changes. (Closed)
Patch Set: 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 3073 matching lines...) Expand 10 before | Expand all | Expand 10 after
3084 } 3084 }
3085 3085
3086 TEST_F(LayerTreeHostImplTestScrollbarOpacity, AuraOverlay) { 3086 TEST_F(LayerTreeHostImplTestScrollbarOpacity, AuraOverlay) {
3087 RunTest(LayerTreeSettings::AURA_OVERLAY); 3087 RunTest(LayerTreeSettings::AURA_OVERLAY);
3088 } 3088 }
3089 3089
3090 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) { 3090 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) {
3091 RunTest(LayerTreeSettings::NO_ANIMATOR); 3091 RunTest(LayerTreeSettings::NO_ANIMATOR);
3092 } 3092 }
3093 3093
3094 TEST_F(LayerTreeHostImplTest, ScrollbarVisibilityChangeCausesRedrawAndCommit) {
3095 LayerTreeSettings settings = DefaultSettings();
3096 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY;
3097 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
3098 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
3099 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(20);
3100 gfx::Size content_size(100, 100);
3101
3102 CreateHostImpl(settings, CreateCompositorFrameSink());
3103 host_impl_->CreatePendingTree();
3104 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
3105 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3106 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
3107 VERTICAL, 10, 0, false, true);
3108 scrollbar->test_properties()->opacity = 0.f;
3109 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
3110 LayerImpl* container =
3111 host_impl_->pending_tree()->InnerViewportContainerLayer();
3112 scrollbar->SetScrollLayerId(scroll->id());
3113 container->test_properties()->AddChild(std::move(scrollbar));
3114 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3115 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3116 host_impl_->ActivateSyncTree();
3117
3118 ScrollbarAnimationController* scrollbar_controller =
3119 host_impl_->ScrollbarAnimationControllerForId(scroll->id());
3120
3121 // Scrollbars will flash shown but we should have a fade out animation
3122 // queued. Run it and fade out the scrollbars.
3123 {
3124 ASSERT_FALSE(animation_task_.Equals(base::Closure()));
3125 ASSERT_FALSE(animation_task_.IsCancelled());
3126 animation_task_.Run();
3127
3128 base::TimeTicks fake_now = base::TimeTicks::Now();
3129 scrollbar_controller->Animate(fake_now);
3130 fake_now += settings.scrollbar_fade_out_delay;
3131 scrollbar_controller->Animate(fake_now);
3132
3133 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden());
3134 }
3135
3136 // Move the mouse over the scrollbar region. This should post a delayed show
3137 // task. Execute it to show the scrollbars.
3138 {
3139 animation_task_ = base::Closure();
3140 scrollbar_controller->DidMouseMoveNear(VERTICAL, 0);
3141 ASSERT_FALSE(animation_task_.Equals(base::Closure()));
3142 ASSERT_FALSE(animation_task_.IsCancelled());
3143 }
3144
3145 // The show task should cause the scrollbars to show. Ensure that we
3146 // requested a redraw and a commit.
3147 {
3148 did_request_redraw_ = false;
3149 did_request_commit_ = false;
3150 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden());
3151 animation_task_.Run();
3152 ASSERT_FALSE(scrollbar_controller->ScrollbarsHidden());
3153 EXPECT_TRUE(did_request_redraw_);
3154 EXPECT_TRUE(did_request_commit_);
3155 }
3156 }
3157
3094 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { 3158 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) {
3095 LayerTreeSettings settings = DefaultSettings(); 3159 LayerTreeSettings settings = DefaultSettings();
3096 CreateHostImpl(settings, CreateCompositorFrameSink()); 3160 CreateHostImpl(settings, CreateCompositorFrameSink());
3097 3161
3098 gfx::Size inner_viewport_size(315, 200); 3162 gfx::Size inner_viewport_size(315, 200);
3099 gfx::Size outer_viewport_size(300, 200); 3163 gfx::Size outer_viewport_size(300, 200);
3100 gfx::Size content_size(1000, 1000); 3164 gfx::Size content_size(1000, 1000);
3101 3165
3102 const int horiz_id = 11; 3166 const int horiz_id = 11;
3103 const int child_clip_id = 14; 3167 const int child_clip_id = 14;
(...skipping 8884 matching lines...) Expand 10 before | Expand all | Expand 10 after
11988 else 12052 else
11989 EXPECT_FALSE(tile->HasRasterTask()); 12053 EXPECT_FALSE(tile->HasRasterTask());
11990 } 12054 }
11991 Region expected_invalidation( 12055 Region expected_invalidation(
11992 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12056 raster_source->GetRectForImage(checkerable_image->uniqueID()));
11993 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12057 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
11994 } 12058 }
11995 12059
11996 } // namespace 12060 } // namespace
11997 } // namespace cc 12061 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698