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

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

Issue 2841943002: Overlay scrollbars expand only when mouse is near thumb (Closed)
Patch Set: add tests Created 3 years, 7 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 3153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 host_impl_->CreatePendingTree(); 3164 host_impl_->CreatePendingTree();
3165 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 3165 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
3166 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 3166 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3167 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 3167 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
3168 VERTICAL, 10, 0, false, true); 3168 VERTICAL, 10, 0, false, true);
3169 scrollbar->test_properties()->opacity = 0.f; 3169 scrollbar->test_properties()->opacity = 0.f;
3170 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 3170 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
3171 LayerImpl* container = 3171 LayerImpl* container =
3172 host_impl_->pending_tree()->InnerViewportContainerLayer(); 3172 host_impl_->pending_tree()->InnerViewportContainerLayer();
3173 scrollbar->SetScrollElementId(scroll->element_id()); 3173 scrollbar->SetScrollElementId(scroll->element_id());
3174 scrollbar->SetBounds(gfx::Size(10, 100));
3175 scrollbar->SetPosition(gfx::PointF(90, 0));
3174 container->test_properties()->AddChild(std::move(scrollbar)); 3176 container->test_properties()->AddChild(std::move(scrollbar));
3175 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3177 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3176 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3178 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3177 host_impl_->ActivateSyncTree(); 3179 host_impl_->ActivateSyncTree();
3178 3180
3179 LayerImpl* active_scrollbar_layer = 3181 LayerImpl* active_scrollbar_layer =
3180 host_impl_->active_tree()->LayerById(400); 3182 host_impl_->active_tree()->LayerById(400);
3181 3183
3182 EffectNode* active_tree_node = 3184 EffectNode* active_tree_node =
3183 host_impl_->active_tree()->property_trees()->effect_tree.Node( 3185 host_impl_->active_tree()->property_trees()->effect_tree.Node(
3184 active_scrollbar_layer->effect_tree_index()); 3186 active_scrollbar_layer->effect_tree_index());
3185 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 3187 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(),
3186 active_tree_node->opacity); 3188 active_tree_node->opacity);
3187 3189
3188 if (expecting_animations) { 3190 if (expecting_animations) {
3189 host_impl_->ScrollbarAnimationControllerForElementId(scroll->element_id()) 3191 host_impl_->ScrollbarAnimationControllerForElementId(scroll->element_id())
3190 ->DidMouseMoveNear(VERTICAL, 0); 3192 ->DidMouseMove(gfx::PointF(0, 90));
3191 } else { 3193 } else {
3192 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3194 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3193 scroll->element_id())); 3195 scroll->element_id()));
3194 } 3196 }
3195 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 3197 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
3196 InputHandler::WHEEL); 3198 InputHandler::WHEEL);
3197 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 3199 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
3198 host_impl_->ScrollEnd(EndState().get()); 3200 host_impl_->ScrollEnd(EndState().get());
3199 host_impl_->CreatePendingTree(); 3201 host_impl_->CreatePendingTree();
3200 // To test the case where the effect tree index of scrollbar layer changes, 3202 // To test the case where the effect tree index of scrollbar layer changes,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 host_impl_->CreatePendingTree(); 3260 host_impl_->CreatePendingTree();
3259 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); 3261 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size);
3260 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 3262 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3261 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, 3263 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400,
3262 VERTICAL, 10, 0, false, true); 3264 VERTICAL, 10, 0, false, true);
3263 scrollbar->test_properties()->opacity = 0.f; 3265 scrollbar->test_properties()->opacity = 0.f;
3264 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); 3266 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer();
3265 LayerImpl* container = 3267 LayerImpl* container =
3266 host_impl_->pending_tree()->InnerViewportContainerLayer(); 3268 host_impl_->pending_tree()->InnerViewportContainerLayer();
3267 scrollbar->SetScrollElementId(scroll->element_id()); 3269 scrollbar->SetScrollElementId(scroll->element_id());
3270 scrollbar->SetBounds(gfx::Size(10, 100));
3271 scrollbar->SetPosition(gfx::PointF(90, 0));
3268 container->test_properties()->AddChild(std::move(scrollbar)); 3272 container->test_properties()->AddChild(std::move(scrollbar));
3269 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3273 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3270 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3274 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3271 host_impl_->ActivateSyncTree(); 3275 host_impl_->ActivateSyncTree();
3272 3276
3273 ScrollbarAnimationController* scrollbar_controller = 3277 ScrollbarAnimationController* scrollbar_controller =
3274 host_impl_->ScrollbarAnimationControllerForElementId( 3278 host_impl_->ScrollbarAnimationControllerForElementId(
3275 scroll->element_id()); 3279 scroll->element_id());
3276 3280
3277 // Scrollbars will flash shown but we should have a fade out animation 3281 // Scrollbars will flash shown but we should have a fade out animation
3278 // queued. Run it and fade out the scrollbars. 3282 // queued. Run it and fade out the scrollbars.
3279 { 3283 {
3280 ASSERT_FALSE(animation_task_.Equals(base::Closure())); 3284 ASSERT_FALSE(animation_task_.Equals(base::Closure()));
3281 ASSERT_FALSE(animation_task_.IsCancelled()); 3285 ASSERT_FALSE(animation_task_.IsCancelled());
3282 animation_task_.Run(); 3286 animation_task_.Run();
3283 3287
3284 base::TimeTicks fake_now = base::TimeTicks::Now(); 3288 base::TimeTicks fake_now = base::TimeTicks::Now();
3285 scrollbar_controller->Animate(fake_now); 3289 scrollbar_controller->Animate(fake_now);
3286 fake_now += settings.scrollbar_fade_delay; 3290 fake_now += settings.scrollbar_fade_delay;
3287 scrollbar_controller->Animate(fake_now); 3291 scrollbar_controller->Animate(fake_now);
3288 3292
3289 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); 3293 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden());
3290 } 3294 }
3291 3295
3292 // Move the mouse over the scrollbar region. This should post a delayed fade 3296 // Move the mouse over the scrollbar region. This should post a delayed fade
3293 // in task. Execute it to show the scrollbars. 3297 // in task. Execute it to fade in the scrollbars.
3294 { 3298 {
3295 animation_task_ = base::Closure(); 3299 animation_task_ = base::Closure();
3296 scrollbar_controller->DidMouseMoveNear(VERTICAL, 0); 3300 scrollbar_controller->DidMouseMove(gfx::PointF(90, 0));
3297 ASSERT_FALSE(animation_task_.Equals(base::Closure())); 3301 ASSERT_FALSE(animation_task_.Equals(base::Closure()));
3298 ASSERT_FALSE(animation_task_.IsCancelled()); 3302 ASSERT_FALSE(animation_task_.IsCancelled());
3299 } 3303 }
3300 3304
3301 // The fade in task should cause the scrollbars to show. Ensure that we 3305 // The fade in task should cause the scrollbars to show. Ensure that we
3302 // requested a redraw and a commit. 3306 // requested a redraw and a commit.
3303 { 3307 {
3304 did_request_redraw_ = false; 3308 did_request_redraw_ = false;
3305 did_request_commit_ = false; 3309 did_request_commit_ = false;
3306 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); 3310 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden());
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3497 host_impl_->SetViewportSize(device_viewport_size); 3501 host_impl_->SetViewportSize(device_viewport_size);
3498 3502
3499 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); 3503 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size);
3500 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( 3504 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
3501 viewport_size); 3505 viewport_size);
3502 LayerImpl* root_scroll = 3506 LayerImpl* root_scroll =
3503 host_impl_->active_tree()->OuterViewportScrollLayer(); 3507 host_impl_->active_tree()->OuterViewportScrollLayer();
3504 // The scrollbar is on the left side. 3508 // The scrollbar is on the left side.
3505 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = 3509 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar =
3506 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6, 3510 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 6,
3507 VERTICAL, 5, 5, true, true); 3511 VERTICAL, 15, 0, true, true);
3508 scrollbar->SetScrollElementId(root_scroll->element_id()); 3512 scrollbar->SetScrollElementId(root_scroll->element_id());
3509 scrollbar->SetDrawsContent(true); 3513 scrollbar->SetDrawsContent(true);
3510 scrollbar->SetBounds(scrollbar_size); 3514 scrollbar->SetBounds(scrollbar_size);
3511 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size)); 3515 scrollbar->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size));
3512 host_impl_->active_tree() 3516 host_impl_->active_tree()
3513 ->InnerViewportContainerLayer() 3517 ->InnerViewportContainerLayer()
3514 ->test_properties() 3518 ->test_properties()
3515 ->AddChild(std::move(scrollbar)); 3519 ->AddChild(std::move(scrollbar));
3516 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3520 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3517 host_impl_->active_tree()->DidBecomeActive(); 3521 host_impl_->active_tree()->DidBecomeActive();
3518 3522
3519 DrawFrame(); 3523 DrawFrame();
3520 host_impl_->active_tree()->UpdateDrawProperties(false); 3524 host_impl_->active_tree()->UpdateDrawProperties(false);
3521 3525
3522 ScrollbarAnimationController* scrollbar_animation_controller = 3526 ScrollbarAnimationController* scrollbar_animation_controller =
3523 host_impl_->ScrollbarAnimationControllerForElementId( 3527 host_impl_->ScrollbarAnimationControllerForElementId(
3524 root_scroll->element_id()); 3528 root_scroll->element_id());
3525 3529
3526 const float kMouseDistanceToTriggerAnimation = 3530 const float kMouseMoveDistanceToTriggerFadeIn =
3531 ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn;
3532
3533 const float kMouseMoveDistanceToTriggerExpand =
3527 SingleScrollbarAnimationControllerThinning:: 3534 SingleScrollbarAnimationControllerThinning::
3528 kDefaultMouseMoveDistanceToTriggerAnimation; 3535 kMouseMoveDistanceToTriggerExpand;
3529 3536
3530 host_impl_->MouseMoveAt( 3537 host_impl_->MouseMoveAt(
3531 gfx::Point(15 + kMouseDistanceToTriggerAnimation * 2, 1)); 3538 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 1));
3532 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); 3539 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));
3540 EXPECT_FALSE(
3541 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
3533 3542
3534 host_impl_->MouseMoveAt( 3543 host_impl_->MouseMoveAt(
3535 gfx::Point(15 + kMouseDistanceToTriggerAnimation - 1, 50)); 3544 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand - 1, 10));
3536 EXPECT_TRUE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); 3545 EXPECT_TRUE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));
3546 EXPECT_TRUE(
3547 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
3537 3548
3538 host_impl_->MouseMoveAt( 3549 host_impl_->MouseMoveAt(
3539 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 100)); 3550 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 100));
3540 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL)); 3551 EXPECT_FALSE(scrollbar_animation_controller->MouseIsNearScrollbar(VERTICAL));
3552 EXPECT_FALSE(
3553 scrollbar_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
3541 3554
3542 did_request_redraw_ = false; 3555 did_request_redraw_ = false;
3543 EXPECT_FALSE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); 3556 EXPECT_FALSE(
3544 host_impl_->MouseMoveAt(gfx::Point(10, 100)); 3557 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
3545 EXPECT_TRUE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); 3558 host_impl_->MouseMoveAt(gfx::Point(10, 10));
3546 host_impl_->MouseMoveAt(gfx::Point(10, 120)); 3559 EXPECT_TRUE(
3547 EXPECT_TRUE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); 3560 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
3561 host_impl_->MouseMoveAt(gfx::Point(10, 0));
3562 EXPECT_TRUE(
3563 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
3548 host_impl_->MouseMoveAt(gfx::Point(150, 120)); 3564 host_impl_->MouseMoveAt(gfx::Point(150, 120));
3549 EXPECT_FALSE(scrollbar_animation_controller->MouseIsOverScrollbar(VERTICAL)); 3565 EXPECT_FALSE(
3566 scrollbar_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
3550 } 3567 }
3551 3568
3552 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) { 3569 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf1) {
3553 SetupMouseMoveAtWithDeviceScale(1.f); 3570 SetupMouseMoveAtWithDeviceScale(1.f);
3554 } 3571 }
3555 3572
3556 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) { 3573 TEST_F(LayerTreeHostImplTest, MouseMoveAtWithDeviceScaleOf2) {
3557 SetupMouseMoveAtWithDeviceScale(2.f); 3574 SetupMouseMoveAtWithDeviceScale(2.f);
3558 } 3575 }
3559 3576
(...skipping 8575 matching lines...) Expand 10 before | Expand all | Expand 10 after
12135 host_impl_->active_tree()->OuterViewportScrollLayer(); 12152 host_impl_->active_tree()->OuterViewportScrollLayer();
12136 12153
12137 if (main_thread_scrolling) { 12154 if (main_thread_scrolling) {
12138 root_scroll->set_main_thread_scrolling_reasons( 12155 root_scroll->set_main_thread_scrolling_reasons(
12139 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 12156 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
12140 } 12157 }
12141 12158
12142 // scrollbar_1 on root scroll. 12159 // scrollbar_1 on root scroll.
12143 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 = 12160 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_1 =
12144 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 12161 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
12145 scrollbar_1_id, VERTICAL, 5, 5, true, 12162 scrollbar_1_id, VERTICAL, 15, 0,
12146 true); 12163 true, true);
12147 scrollbar_1->SetScrollElementId(root_scroll->element_id()); 12164 scrollbar_1->SetScrollElementId(root_scroll->element_id());
12148 scrollbar_1->SetDrawsContent(true); 12165 scrollbar_1->SetDrawsContent(true);
12149 scrollbar_1->SetBounds(scrollbar_size_1); 12166 scrollbar_1->SetBounds(scrollbar_size_1);
12150 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1)); 12167 scrollbar_1->SetTouchEventHandlerRegion(gfx::Rect(scrollbar_size_1));
12168 scrollbar_1->SetCurrentPos(0);
12169 scrollbar_1->SetPosition(gfx::PointF(0, 0));
12151 host_impl_->active_tree() 12170 host_impl_->active_tree()
12152 ->InnerViewportContainerLayer() 12171 ->InnerViewportContainerLayer()
12153 ->test_properties() 12172 ->test_properties()
12154 ->AddChild(std::move(scrollbar_1)); 12173 ->AddChild(std::move(scrollbar_1));
12155 12174
12156 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 12175 host_impl_->active_tree()->BuildPropertyTreesForTesting();
12157 host_impl_->active_tree()->DidBecomeActive(); 12176 host_impl_->active_tree()->DidBecomeActive();
12158 12177
12159 DrawFrame(); 12178 DrawFrame();
12160 host_impl_->active_tree()->UpdateDrawProperties(false); 12179 host_impl_->active_tree()->UpdateDrawProperties(false);
12161 12180
12162 ScrollbarAnimationController* scrollbar_1_animation_controller = 12181 ScrollbarAnimationController* scrollbar_1_animation_controller =
12163 host_impl_->ScrollbarAnimationControllerForElementId( 12182 host_impl_->ScrollbarAnimationControllerForElementId(
12164 root_scroll->element_id()); 12183 root_scroll->element_id());
12165 EXPECT_TRUE(scrollbar_1_animation_controller); 12184 EXPECT_TRUE(scrollbar_1_animation_controller);
12166 12185
12167 const float kMouseDistanceToTriggerAnimation = 12186 const float kMouseMoveDistanceToTriggerFadeIn =
12187 ScrollbarAnimationController::kMouseMoveDistanceToTriggerFadeIn;
12188
12189 const float kMouseMoveDistanceToTriggerExpand =
12168 SingleScrollbarAnimationControllerThinning:: 12190 SingleScrollbarAnimationControllerThinning::
12169 kDefaultMouseMoveDistanceToTriggerAnimation; 12191 kMouseMoveDistanceToTriggerExpand;
12170 12192
12171 // Mouse moves close to the scrollbar, goes over the scrollbar, and 12193 // Mouse moves close to the scrollbar, goes over the scrollbar, and
12172 // moves back to where it was. 12194 // moves back to where it was.
12173 host_impl_->MouseMoveAt( 12195 host_impl_->MouseMoveAt(
12174 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150)); 12196 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 0));
12175 EXPECT_FALSE( 12197 EXPECT_FALSE(
12176 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12198 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12177 EXPECT_FALSE( 12199 EXPECT_FALSE(
12178 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12200 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12201 EXPECT_FALSE(
12202 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12203
12179 host_impl_->MouseMoveAt( 12204 host_impl_->MouseMoveAt(
12180 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); 12205 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand, 0));
12181 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12206 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12182 EXPECT_FALSE( 12207 EXPECT_FALSE(
12183 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12208 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12184 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 12209 EXPECT_FALSE(
12210 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12211
12212 host_impl_->MouseMoveAt(
12213 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0));
12185 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12214 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12186 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12215 EXPECT_TRUE(
12216 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12217 EXPECT_FALSE(
12218 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12219
12220 host_impl_->MouseMoveAt(gfx::Point(10, 0));
12221 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12222 EXPECT_TRUE(
12223 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12224 EXPECT_TRUE(
12225 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12226
12187 host_impl_->MouseMoveAt( 12227 host_impl_->MouseMoveAt(
12188 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); 12228 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0));
12229 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12230 EXPECT_TRUE(
12231 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12232 EXPECT_FALSE(
12233 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12234
12235 host_impl_->MouseMoveAt(
12236 gfx::Point(15 + kMouseMoveDistanceToTriggerExpand, 0));
12189 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12237 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12190 EXPECT_FALSE( 12238 EXPECT_FALSE(
12191 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12239 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12240 EXPECT_FALSE(
12241 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12242
12192 host_impl_->MouseMoveAt( 12243 host_impl_->MouseMoveAt(
12193 gfx::Point(15 + kMouseDistanceToTriggerAnimation, 150)); 12244 gfx::Point(15 + kMouseMoveDistanceToTriggerFadeIn, 0));
12194 EXPECT_FALSE( 12245 EXPECT_FALSE(
12195 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12246 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12196 EXPECT_FALSE( 12247 EXPECT_FALSE(
12197 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12248 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12249 EXPECT_FALSE(
12250 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12198 12251
12199 // scrollbar_2 on child. 12252 // scrollbar_2 on child.
12200 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 = 12253 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar_2 =
12201 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 12254 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(),
12202 scrollbar_2_id, VERTICAL, 5, 5, true, 12255 scrollbar_2_id, VERTICAL, 15, 0,
12203 true); 12256 true, true);
12204 std::unique_ptr<LayerImpl> child_clip = 12257 std::unique_ptr<LayerImpl> child_clip =
12205 LayerImpl::Create(host_impl_->active_tree(), child_clip_id); 12258 LayerImpl::Create(host_impl_->active_tree(), child_clip_id);
12206 std::unique_ptr<LayerImpl> child = 12259 std::unique_ptr<LayerImpl> child =
12207 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id); 12260 LayerImpl::Create(host_impl_->active_tree(), child_scroll_id);
12208 child->SetPosition(gfx::PointF(50, 50)); 12261 child->SetPosition(gfx::PointF(50, 50));
12209 child->SetBounds(child_layer_size); 12262 child->SetBounds(child_layer_size);
12210 child->SetDrawsContent(true); 12263 child->SetDrawsContent(true);
12211 child->SetScrollClipLayer(child_clip_id); 12264 child->SetScrollClipLayer(child_clip_id);
12212 child->SetElementId(LayerIdToElementIdForTesting(child->id())); 12265 child->SetElementId(LayerIdToElementIdForTesting(child->id()));
12213 ElementId child_element_id = child->element_id(); 12266 ElementId child_element_id = child->element_id();
12214 12267
12215 if (main_thread_scrolling) { 12268 if (main_thread_scrolling) {
12216 child->set_main_thread_scrolling_reasons( 12269 child->set_main_thread_scrolling_reasons(
12217 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); 12270 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
12218 } 12271 }
12219 12272
12220 scrollbar_2->SetScrollElementId(child_element_id); 12273 scrollbar_2->SetScrollElementId(child_element_id);
12221 scrollbar_2->SetDrawsContent(true); 12274 scrollbar_2->SetDrawsContent(true);
12222 scrollbar_2->SetBounds(scrollbar_size_2); 12275 scrollbar_2->SetBounds(scrollbar_size_2);
12276 scrollbar_2->SetCurrentPos(0);
12277 scrollbar_2->SetPosition(gfx::PointF(0, 0));
12223 12278
12224 child->test_properties()->AddChild(std::move(scrollbar_2)); 12279 child->test_properties()->AddChild(std::move(scrollbar_2));
12225 child_clip->test_properties()->AddChild(std::move(child)); 12280 child_clip->test_properties()->AddChild(std::move(child));
12226 root_scroll->test_properties()->AddChild(std::move(child_clip)); 12281 root_scroll->test_properties()->AddChild(std::move(child_clip));
12227 12282
12228 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 12283 host_impl_->active_tree()->BuildPropertyTreesForTesting();
12229 host_impl_->active_tree()->DidBecomeActive(); 12284 host_impl_->active_tree()->DidBecomeActive();
12230 12285
12231 ScrollbarAnimationController* scrollbar_2_animation_controller = 12286 ScrollbarAnimationController* scrollbar_2_animation_controller =
12232 host_impl_->ScrollbarAnimationControllerForElementId(child_element_id); 12287 host_impl_->ScrollbarAnimationControllerForElementId(child_element_id);
12233 EXPECT_TRUE(scrollbar_2_animation_controller); 12288 EXPECT_TRUE(scrollbar_2_animation_controller);
12234 12289
12235 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to 12290 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to
12236 // scrollbar_1, goes over scrollbar_1. 12291 // scrollbar_1, goes over scrollbar_1.
12237 host_impl_->MouseMoveAt(gfx::Point(60, 150)); 12292 host_impl_->MouseMoveAt(gfx::Point(60, 60));
12238 EXPECT_FALSE( 12293 EXPECT_FALSE(
12239 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12294 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12240 EXPECT_FALSE( 12295 EXPECT_FALSE(
12241 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12296 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12297 EXPECT_FALSE(
12298 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12242 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12299 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
12243 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12300 EXPECT_TRUE(
12301 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12302 EXPECT_TRUE(
12303 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12304
12244 host_impl_->MouseMoveAt( 12305 host_impl_->MouseMoveAt(
12245 gfx::Point(64 + kMouseDistanceToTriggerAnimation, 150)); 12306 gfx::Point(64 + kMouseMoveDistanceToTriggerExpand, 50));
12246 EXPECT_FALSE( 12307 EXPECT_FALSE(
12247 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12308 scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12248 EXPECT_FALSE( 12309 EXPECT_FALSE(
12249 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12310 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12311 EXPECT_FALSE(
12312 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12250 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12313 EXPECT_TRUE(scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
12314 EXPECT_TRUE(
12315 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12251 EXPECT_FALSE( 12316 EXPECT_FALSE(
12252 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12317 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12253 host_impl_->MouseMoveAt( 12318 host_impl_->MouseMoveAt(
12254 gfx::Point(14 + kMouseDistanceToTriggerAnimation, 150)); 12319 gfx::Point(14 + kMouseMoveDistanceToTriggerExpand, 0));
12255 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12320 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12321 EXPECT_TRUE(
12322 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12256 EXPECT_FALSE( 12323 EXPECT_FALSE(
12257 scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12324 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12258 EXPECT_FALSE( 12325 EXPECT_FALSE(
12259 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12326 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
12260 EXPECT_FALSE( 12327 EXPECT_FALSE(
12261 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12328 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12262 host_impl_->MouseMoveAt(gfx::Point(10, 150)); 12329 EXPECT_FALSE(
12330 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12331 host_impl_->MouseMoveAt(gfx::Point(10, 0));
12263 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12332 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsNearScrollbar(VERTICAL));
12264 EXPECT_TRUE(scrollbar_1_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12333 EXPECT_TRUE(
12334 scrollbar_1_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12335 EXPECT_TRUE(
12336 scrollbar_1_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12265 EXPECT_FALSE( 12337 EXPECT_FALSE(
12266 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL)); 12338 scrollbar_2_animation_controller->MouseIsNearScrollbar(VERTICAL));
12267 EXPECT_FALSE( 12339 EXPECT_FALSE(
12268 scrollbar_2_animation_controller->MouseIsOverScrollbar(VERTICAL)); 12340 scrollbar_2_animation_controller->MouseIsNearScrollbarThumb(VERTICAL));
12341 EXPECT_FALSE(
12342 scrollbar_2_animation_controller->MouseIsOverScrollbarThumb(VERTICAL));
12269 12343
12270 // Capture scrollbar_1, then move mouse to scrollbar_2's layer, should post an 12344 // Capture scrollbar_1, then move mouse to scrollbar_2's layer, should post an
12271 // event to fade out scrollbar_1. 12345 // event to fade out scrollbar_1.
12272 animation_task_ = base::Closure(); 12346 animation_task_ = base::Closure();
12273 12347
12274 host_impl_->MouseDown(); 12348 host_impl_->MouseDown();
12275 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 12349 host_impl_->MouseMoveAt(gfx::Point(60, 50));
12276 host_impl_->MouseUp(); 12350 host_impl_->MouseUp();
12277 12351
12278 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 12352 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
12279 12353
12280 // Near scrollbar_1, then mouse down and up, should not post an event to fade 12354 // Near scrollbar_1, then mouse down and up, should not post an event to fade
12281 // out scrollbar_1. 12355 // out scrollbar_1.
12282 host_impl_->MouseMoveAt(gfx::Point(40, 150)); 12356 host_impl_->MouseMoveAt(gfx::Point(40, 150));
12283 animation_task_ = base::Closure(); 12357 animation_task_ = base::Closure();
12284 12358
12285 host_impl_->MouseDown(); 12359 host_impl_->MouseDown();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
12375 else 12449 else
12376 EXPECT_FALSE(tile->HasRasterTask()); 12450 EXPECT_FALSE(tile->HasRasterTask());
12377 } 12451 }
12378 Region expected_invalidation( 12452 Region expected_invalidation(
12379 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12453 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12380 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12454 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12381 } 12455 }
12382 12456
12383 } // namespace 12457 } // namespace
12384 } // namespace cc 12458 } // namespace cc
OLDNEW
« cc/input/scrollbar_animation_controller.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