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

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

Issue 2816923002: change overlay scrollbar hover show to hover fade in (Closed)
Patch Set: Created 3 years, 8 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 2856 matching lines...) Expand 10 before | Expand all | Expand 10 after
2867 did_request_redraw_ = false; 2867 did_request_redraw_ = false;
2868 } 2868 }
2869 2869
2870 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 2870 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
2871 LayerTreeSettings settings = DefaultSettings(); 2871 LayerTreeSettings settings = DefaultSettings();
2872 settings.scrollbar_animator = animator; 2872 settings.scrollbar_animator = animator;
2873 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); 2873 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
2874 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); 2874 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
2875 settings.scrollbar_fade_out_resize_delay = 2875 settings.scrollbar_fade_out_resize_delay =
2876 base::TimeDelta::FromMilliseconds(20); 2876 base::TimeDelta::FromMilliseconds(20);
2877 settings.scrollbar_fade_in_duration = base::TimeDelta::FromMilliseconds(20);
2877 settings.scrollbar_fade_out_duration = 2878 settings.scrollbar_fade_out_duration =
2878 base::TimeDelta::FromMilliseconds(20); 2879 base::TimeDelta::FromMilliseconds(20);
2879 2880
2880 // If no animator is set, scrollbar won't show and no animation is expected. 2881 // If no animator is set, scrollbar won't show and no animation is expected.
2881 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; 2882 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR;
2882 2883
2883 SetupLayers(settings); 2884 SetupLayers(settings);
2884 2885
2885 base::TimeTicks fake_now = base::TimeTicks::Now(); 2886 base::TimeTicks fake_now = base::TimeTicks::Now();
2886 2887
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 RunTest(LayerTreeSettings::NO_ANIMATOR); 3090 RunTest(LayerTreeSettings::NO_ANIMATOR);
3090 } 3091 }
3091 3092
3092 class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { 3093 class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest {
3093 protected: 3094 protected:
3094 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 3095 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
3095 LayerTreeSettings settings = DefaultSettings(); 3096 LayerTreeSettings settings = DefaultSettings();
3096 settings.scrollbar_animator = animator; 3097 settings.scrollbar_animator = animator;
3097 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); 3098 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
3098 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); 3099 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
3100 settings.scrollbar_fade_in_duration = base::TimeDelta::FromMilliseconds(20);
3099 settings.scrollbar_fade_out_duration = 3101 settings.scrollbar_fade_out_duration =
3100 base::TimeDelta::FromMilliseconds(20); 3102 base::TimeDelta::FromMilliseconds(20);
3101 gfx::Size content_size(100, 100); 3103 gfx::Size content_size(100, 100);
3102 3104
3103 // If no animator is set, scrollbar won't show and no animation is expected. 3105 // If no animator is set, scrollbar won't show and no animation is expected.
3104 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; 3106 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR;
3105 3107
3106 CreateHostImpl(settings, CreateCompositorFrameSink()); 3108 CreateHostImpl(settings, CreateCompositorFrameSink());
3107 host_impl_->CreatePendingTree(); 3109 host_impl_->CreatePendingTree();
3108 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 3110 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 3190
3189 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) { 3191 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) {
3190 RunTest(LayerTreeSettings::NO_ANIMATOR); 3192 RunTest(LayerTreeSettings::NO_ANIMATOR);
3191 } 3193 }
3192 3194
3193 TEST_F(LayerTreeHostImplTest, ScrollbarVisibilityChangeCausesRedrawAndCommit) { 3195 TEST_F(LayerTreeHostImplTest, ScrollbarVisibilityChangeCausesRedrawAndCommit) {
3194 LayerTreeSettings settings = DefaultSettings(); 3196 LayerTreeSettings settings = DefaultSettings();
3195 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY; 3197 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY;
3196 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); 3198 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
3197 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); 3199 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
3200 settings.scrollbar_fade_in_duration = base::TimeDelta::FromMilliseconds(20);
3198 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(20); 3201 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(20);
3199 gfx::Size content_size(100, 100); 3202 gfx::Size content_size(100, 100);
3200 3203
3201 CreateHostImpl(settings, CreateCompositorFrameSink()); 3204 CreateHostImpl(settings, CreateCompositorFrameSink());
3202 host_impl_->CreatePendingTree(); 3205 host_impl_->CreatePendingTree();
3203 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 3206 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
3204 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 3207 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3205 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 3208 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
3206 VERTICAL, 10, 0, false, true); 3209 VERTICAL, 10, 0, false, true);
3207 scrollbar->test_properties()->opacity = 0.f; 3210 scrollbar->test_properties()->opacity = 0.f;
(...skipping 27 matching lines...) Expand all
3235 // Move the mouse over the scrollbar region. This should post a delayed show 3238 // Move the mouse over the scrollbar region. This should post a delayed show
3236 // task. Execute it to show the scrollbars. 3239 // task. Execute it to show the scrollbars.
3237 { 3240 {
3238 animation_task_ = base::Closure(); 3241 animation_task_ = base::Closure();
3239 scrollbar_controller->DidMouseMoveNear(VERTICAL, 0); 3242 scrollbar_controller->DidMouseMoveNear(VERTICAL, 0);
3240 ASSERT_FALSE(animation_task_.Equals(base::Closure())); 3243 ASSERT_FALSE(animation_task_.Equals(base::Closure()));
3241 ASSERT_FALSE(animation_task_.IsCancelled()); 3244 ASSERT_FALSE(animation_task_.IsCancelled());
3242 } 3245 }
3243 3246
3244 // The show task should cause the scrollbars to show. Ensure that we 3247 // The show task should cause the scrollbars to show. Ensure that we
3245 // requested a redraw and a commit. 3248 // requested a redraw and a commit.
bokan 2017/04/13 14:38:14 This assumes the fade in is instant, you'll need t
chaopeng 2017/04/13 15:15:37 Done.
3246 { 3249 {
3247 did_request_redraw_ = false; 3250 did_request_redraw_ = false;
3248 did_request_commit_ = false; 3251 did_request_commit_ = false;
3249 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); 3252 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden());
3250 animation_task_.Run(); 3253 animation_task_.Run();
3251 ASSERT_FALSE(scrollbar_controller->ScrollbarsHidden()); 3254 ASSERT_FALSE(scrollbar_controller->ScrollbarsHidden());
3252 EXPECT_TRUE(did_request_redraw_); 3255 EXPECT_TRUE(did_request_redraw_);
3253 EXPECT_TRUE(did_request_commit_); 3256 EXPECT_TRUE(did_request_commit_);
3254 } 3257 }
3255 } 3258 }
(...skipping 30 matching lines...) Expand all
3286 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); 3289 horiz_scrollbar->SetScrollLayerId(root_scroll->id());
3287 3290
3288 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); 3291 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length());
3289 } 3292 }
3290 3293
3291 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { 3294 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) {
3292 LayerTreeSettings settings = DefaultSettings(); 3295 LayerTreeSettings settings = DefaultSettings();
3293 settings.scrollbar_animator = LayerTreeSettings::ANDROID_OVERLAY; 3296 settings.scrollbar_animator = LayerTreeSettings::ANDROID_OVERLAY;
3294 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); 3297 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
3295 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); 3298 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
3299 settings.scrollbar_fade_in_duration = base::TimeDelta::FromMilliseconds(20);
3296 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(20); 3300 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(20);
3297 CreateHostImpl(settings, CreateCompositorFrameSink()); 3301 CreateHostImpl(settings, CreateCompositorFrameSink());
3298 3302
3299 gfx::Size viewport_size(300, 200); 3303 gfx::Size viewport_size(300, 200);
3300 gfx::Size content_size(1000, 1000); 3304 gfx::Size content_size(1000, 1000);
3301 3305
3302 const int vert_1_id = 10; 3306 const int vert_1_id = 10;
3303 const int horiz_1_id = 11; 3307 const int horiz_1_id = 11;
3304 const int vert_2_id = 12; 3308 const int vert_2_id = 12;
3305 const int horiz_2_id = 13; 3309 const int horiz_2_id = 13;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3408 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 3412 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
3409 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20)); 3413 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20));
3410 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 3414 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
3411 } 3415 }
3412 3416
3413 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( 3417 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale(
3414 float device_scale_factor) { 3418 float device_scale_factor) {
3415 LayerTreeSettings settings = DefaultSettings(); 3419 LayerTreeSettings settings = DefaultSettings();
3416 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(500); 3420 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(500);
3417 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(500); 3421 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(500);
3422 settings.scrollbar_fade_in_duration = base::TimeDelta::FromMilliseconds(500);
3418 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(300); 3423 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(300);
3419 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY; 3424 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY;
3420 3425
3421 gfx::Size viewport_size(300, 200); 3426 gfx::Size viewport_size(300, 200);
3422 gfx::Size device_viewport_size = 3427 gfx::Size device_viewport_size =
3423 gfx::ScaleToFlooredSize(viewport_size, device_scale_factor); 3428 gfx::ScaleToFlooredSize(viewport_size, device_scale_factor);
3424 gfx::Size content_size(1000, 1000); 3429 gfx::Size content_size(1000, 1000);
3425 gfx::Size scrollbar_size(gfx::Size(15, viewport_size.height())); 3430 gfx::Size scrollbar_size(gfx::Size(15, viewport_size.height()));
3426 3431
3427 CreateHostImpl(settings, CreateCompositorFrameSink()); 3432 CreateHostImpl(settings, CreateCompositorFrameSink());
(...skipping 8599 matching lines...) Expand 10 before | Expand all | Expand 10 after
12027 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); 12032 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware();
12028 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); 12033 host_impl_->InitializeRenderer(compositor_frame_sink_.get());
12029 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 12034 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
12030 } 12035 }
12031 12036
12032 void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates( 12037 void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates(
12033 bool main_thread_scrolling) { 12038 bool main_thread_scrolling) {
12034 LayerTreeSettings settings = DefaultSettings(); 12039 LayerTreeSettings settings = DefaultSettings();
12035 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(500); 12040 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(500);
12036 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(500); 12041 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(500);
12042 settings.scrollbar_fade_in_duration = base::TimeDelta::FromMilliseconds(500);
12037 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(300); 12043 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(300);
12038 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY; 12044 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY;
12039 12045
12040 gfx::Size viewport_size(300, 200); 12046 gfx::Size viewport_size(300, 200);
12041 gfx::Size content_size(1000, 1000); 12047 gfx::Size content_size(1000, 1000);
12042 gfx::Size child_layer_size(250, 150); 12048 gfx::Size child_layer_size(250, 150);
12043 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height())); 12049 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height()));
12044 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height())); 12050 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height()));
12045 12051
12046 const int scrollbar_1_id = 10; 12052 const int scrollbar_1_id = 10;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
12296 else 12302 else
12297 EXPECT_FALSE(tile->HasRasterTask()); 12303 EXPECT_FALSE(tile->HasRasterTask());
12298 } 12304 }
12299 Region expected_invalidation( 12305 Region expected_invalidation(
12300 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12306 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12301 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12307 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12302 } 12308 }
12303 12309
12304 } // namespace 12310 } // namespace
12305 } // namespace cc 12311 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698