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

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

Issue 2716453005: Aura Overlay Scrollbars appear when mouse hovers over scroller edge (Closed)
Patch Set: rename fade in to show 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/layers/solid_color_scrollbar_layer_impl.h ('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 2717 matching lines...) Expand 10 before | Expand all | Expand 10 after
2728 scrollbar->SetScrollLayerId(scroll->id()); 2728 scrollbar->SetScrollLayerId(scroll->id());
2729 root->test_properties()->AddChild(std::move(scrollbar)); 2729 root->test_properties()->AddChild(std::move(scrollbar));
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_delay = base::TimeDelta::FromMilliseconds(20); 2738 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
2739 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); 2739 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
2740 settings.scrollbar_fade_out_duration =
2741 base::TimeDelta::FromMilliseconds(20);
2740 2742
2741 // If no animator is set, scrollbar won't show and no animation is expected. 2743 // If no animator is set, scrollbar won't show and no animation is expected.
2742 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; 2744 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR;
2743 2745
2744 SetupLayers(settings); 2746 SetupLayers(settings);
2745 2747
2746 base::TimeTicks fake_now = base::TimeTicks::Now(); 2748 base::TimeTicks fake_now = base::TimeTicks::Now();
2747 2749
2748 if (expecting_animations) { 2750 if (expecting_animations) {
2749 // A task will be posted to fade the initial scrollbar. 2751 // A task will be posted to fade the initial scrollbar.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 2921
2920 TEST_F(LayerTreeHostImplTestScrollbarAnimation, NoAnimator) { 2922 TEST_F(LayerTreeHostImplTestScrollbarAnimation, NoAnimator) {
2921 RunTest(LayerTreeSettings::NO_ANIMATOR); 2923 RunTest(LayerTreeSettings::NO_ANIMATOR);
2922 } 2924 }
2923 2925
2924 class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { 2926 class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest {
2925 protected: 2927 protected:
2926 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { 2928 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) {
2927 LayerTreeSettings settings = DefaultSettings(); 2929 LayerTreeSettings settings = DefaultSettings();
2928 settings.scrollbar_animator = animator; 2930 settings.scrollbar_animator = animator;
2929 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); 2931 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
2930 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); 2932 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
2933 settings.scrollbar_fade_out_duration =
2934 base::TimeDelta::FromMilliseconds(20);
2931 gfx::Size content_size(100, 100); 2935 gfx::Size content_size(100, 100);
2932 2936
2933 // If no animator is set, scrollbar won't show and no animation is expected. 2937 // If no animator is set, scrollbar won't show and no animation is expected.
2934 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; 2938 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR;
2935 2939
2936 CreateHostImpl(settings, CreateCompositorFrameSink()); 2940 CreateHostImpl(settings, CreateCompositorFrameSink());
2937 host_impl_->CreatePendingTree(); 2941 host_impl_->CreatePendingTree();
2938 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 2942 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
2939 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 2943 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
2940 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 2944 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 child->SetBounds(inner_viewport_size); 3054 child->SetBounds(inner_viewport_size);
3051 3055
3052 horiz_scrollbar->SetScrollLayerId(root_scroll->id()); 3056 horiz_scrollbar->SetScrollLayerId(root_scroll->id());
3053 3057
3054 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length()); 3058 EXPECT_EQ(300, horiz_scrollbar->clip_layer_length());
3055 } 3059 }
3056 3060
3057 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) { 3061 TEST_F(LayerTreeHostImplTest, ScrollbarRegistration) {
3058 LayerTreeSettings settings = DefaultSettings(); 3062 LayerTreeSettings settings = DefaultSettings();
3059 settings.scrollbar_animator = LayerTreeSettings::ANDROID_OVERLAY; 3063 settings.scrollbar_animator = LayerTreeSettings::ANDROID_OVERLAY;
3060 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); 3064 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20);
3061 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); 3065 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20);
3066 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(20);
3062 CreateHostImpl(settings, CreateCompositorFrameSink()); 3067 CreateHostImpl(settings, CreateCompositorFrameSink());
3063 3068
3064 gfx::Size viewport_size(300, 200); 3069 gfx::Size viewport_size(300, 200);
3065 gfx::Size content_size(1000, 1000); 3070 gfx::Size content_size(1000, 1000);
3066 3071
3067 const int vert_1_id = 10; 3072 const int vert_1_id = 10;
3068 const int horiz_1_id = 11; 3073 const int horiz_1_id = 11;
3069 const int vert_2_id = 12; 3074 const int vert_2_id = 12;
3070 const int horiz_2_id = 13; 3075 const int horiz_2_id = 13;
3071 const int child_clip_id = 14; 3076 const int child_clip_id = 14;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset( 3175 host_impl_->active_tree()->InnerViewportScrollLayer()->SetCurrentScrollOffset(
3171 gfx::ScrollOffset(20, 20)); 3176 gfx::ScrollOffset(20, 20));
3172 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 3177 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
3173 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20)); 3178 child_ptr->SetCurrentScrollOffset(gfx::ScrollOffset(20, 20));
3174 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 3179 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
3175 } 3180 }
3176 3181
3177 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( 3182 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale(
3178 float device_scale_factor) { 3183 float device_scale_factor) {
3179 LayerTreeSettings settings = DefaultSettings(); 3184 LayerTreeSettings settings = DefaultSettings();
3180 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); 3185 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(500);
3181 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); 3186 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(500);
3187 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(300);
3182 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY; 3188 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY;
3183 3189
3184 gfx::Size viewport_size(300, 200); 3190 gfx::Size viewport_size(300, 200);
3185 gfx::Size device_viewport_size = 3191 gfx::Size device_viewport_size =
3186 gfx::ScaleToFlooredSize(viewport_size, device_scale_factor); 3192 gfx::ScaleToFlooredSize(viewport_size, device_scale_factor);
3187 gfx::Size content_size(1000, 1000); 3193 gfx::Size content_size(1000, 1000);
3188 gfx::Size scrollbar_size(gfx::Size(15, viewport_size.height())); 3194 gfx::Size scrollbar_size(gfx::Size(15, viewport_size.height()));
3189 3195
3190 CreateHostImpl(settings, CreateCompositorFrameSink()); 3196 CreateHostImpl(settings, CreateCompositorFrameSink());
3191 host_impl_->active_tree()->SetDeviceScaleFactor(device_scale_factor); 3197 host_impl_->active_tree()->SetDeviceScaleFactor(device_scale_factor);
(...skipping 8389 matching lines...) Expand 10 before | Expand all | Expand 10 after
11581 11587
11582 // Re-initialize with a software output surface. 11588 // Re-initialize with a software output surface.
11583 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); 11589 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware();
11584 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); 11590 host_impl_->InitializeRenderer(compositor_frame_sink_.get());
11585 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11591 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
11586 } 11592 }
11587 11593
11588 void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates( 11594 void LayerTreeHostImplTest::SetupMouseMoveAtTestScrollbarStates(
11589 bool main_thread_scrolling) { 11595 bool main_thread_scrolling) {
11590 LayerTreeSettings settings = DefaultSettings(); 11596 LayerTreeSettings settings = DefaultSettings();
11591 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(500); 11597 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(500);
11592 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); 11598 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(500);
11599 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(300);
11593 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY; 11600 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY;
11594 11601
11595 gfx::Size viewport_size(300, 200); 11602 gfx::Size viewport_size(300, 200);
11596 gfx::Size content_size(1000, 1000); 11603 gfx::Size content_size(1000, 1000);
11597 gfx::Size child_layer_size(250, 150); 11604 gfx::Size child_layer_size(250, 150);
11598 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height())); 11605 gfx::Size scrollbar_size_1(gfx::Size(15, viewport_size.height()));
11599 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height())); 11606 gfx::Size scrollbar_size_2(gfx::Size(15, child_layer_size.height()));
11600 11607
11601 const int scrollbar_1_id = 10; 11608 const int scrollbar_1_id = 10;
11602 const int scrollbar_2_id = 11; 11609 const int scrollbar_2_id = 11;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
11851 else 11858 else
11852 EXPECT_FALSE(tile->HasRasterTask()); 11859 EXPECT_FALSE(tile->HasRasterTask());
11853 } 11860 }
11854 Region expected_invalidation( 11861 Region expected_invalidation(
11855 raster_source->GetRectForImage(checkerable_image->uniqueID())); 11862 raster_source->GetRectForImage(checkerable_image->uniqueID()));
11856 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 11863 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
11857 } 11864 }
11858 11865
11859 } // namespace 11866 } // namespace
11860 } // namespace cc 11867 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/solid_color_scrollbar_layer_impl.h ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698