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

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

Issue 2692243005: Merge Compositor's ScrollbarAnimationControllers into single class (Closed)
Patch Set: Created 3 years, 10 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>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "cc/animation/animation_host.h" 18 #include "cc/animation/animation_host.h"
19 #include "cc/animation/animation_id_provider.h" 19 #include "cc/animation/animation_id_provider.h"
20 #include "cc/animation/transform_operations.h" 20 #include "cc/animation/transform_operations.h"
21 #include "cc/base/math_util.h" 21 #include "cc/base/math_util.h"
22 #include "cc/input/browser_controls_offset_manager.h" 22 #include "cc/input/browser_controls_offset_manager.h"
23 #include "cc/input/main_thread_scrolling_reason.h" 23 #include "cc/input/main_thread_scrolling_reason.h"
24 #include "cc/input/page_scale_animation.h" 24 #include "cc/input/page_scale_animation.h"
25 #include "cc/input/scrollbar_animation_controller_thinning.h"
26 #include "cc/layers/append_quads_data.h" 25 #include "cc/layers/append_quads_data.h"
27 #include "cc/layers/heads_up_display_layer_impl.h" 26 #include "cc/layers/heads_up_display_layer_impl.h"
28 #include "cc/layers/layer_impl.h" 27 #include "cc/layers/layer_impl.h"
29 #include "cc/layers/painted_scrollbar_layer_impl.h" 28 #include "cc/layers/painted_scrollbar_layer_impl.h"
30 #include "cc/layers/render_surface_impl.h" 29 #include "cc/layers/render_surface_impl.h"
31 #include "cc/layers/solid_color_layer_impl.h" 30 #include "cc/layers/solid_color_layer_impl.h"
32 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 31 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
33 #include "cc/layers/texture_layer_impl.h" 32 #include "cc/layers/texture_layer_impl.h"
34 #include "cc/layers/video_layer_impl.h" 33 #include "cc/layers/video_layer_impl.h"
35 #include "cc/layers/viewport.h" 34 #include "cc/layers/viewport.h"
(...skipping 3151 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 host_impl_->active_tree() 3186 host_impl_->active_tree()
3188 ->InnerViewportContainerLayer() 3187 ->InnerViewportContainerLayer()
3189 ->test_properties() 3188 ->test_properties()
3190 ->AddChild(std::move(scrollbar)); 3189 ->AddChild(std::move(scrollbar));
3191 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 3190 host_impl_->active_tree()->BuildPropertyTreesForTesting();
3192 host_impl_->active_tree()->DidBecomeActive(); 3191 host_impl_->active_tree()->DidBecomeActive();
3193 3192
3194 DrawFrame(); 3193 DrawFrame();
3195 host_impl_->active_tree()->UpdateDrawProperties(false); 3194 host_impl_->active_tree()->UpdateDrawProperties(false);
3196 3195
3197 ScrollbarAnimationControllerThinning* scrollbar_animation_controller = 3196 ScrollbarAnimationController* scrollbar_animation_controller =
3198 static_cast<ScrollbarAnimationControllerThinning*>( 3197 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id());
3199 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
3200 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f); 3198 scrollbar_animation_controller->set_mouse_move_distance_for_test(100.f);
3201 3199
3202 host_impl_->MouseMoveAt(gfx::Point(200, 1)); 3200 host_impl_->MouseMoveAt(gfx::Point(200, 1));
3203 EXPECT_FALSE( 3201 EXPECT_FALSE(
3204 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); 3202 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3205 3203
3206 host_impl_->MouseMoveAt(gfx::Point(100, 50)); 3204 host_impl_->MouseMoveAt(gfx::Point(100, 50));
3207 EXPECT_TRUE( 3205 EXPECT_TRUE(
3208 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL)); 3206 scrollbar_animation_controller->mouse_is_near_scrollbar(VERTICAL));
3209 3207
(...skipping 8392 matching lines...) Expand 10 before | Expand all | Expand 10 after
11602 ->InnerViewportContainerLayer() 11600 ->InnerViewportContainerLayer()
11603 ->test_properties() 11601 ->test_properties()
11604 ->AddChild(std::move(scrollbar_1)); 11602 ->AddChild(std::move(scrollbar_1));
11605 11603
11606 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 11604 host_impl_->active_tree()->BuildPropertyTreesForTesting();
11607 host_impl_->active_tree()->DidBecomeActive(); 11605 host_impl_->active_tree()->DidBecomeActive();
11608 11606
11609 DrawFrame(); 11607 DrawFrame();
11610 host_impl_->active_tree()->UpdateDrawProperties(false); 11608 host_impl_->active_tree()->UpdateDrawProperties(false);
11611 11609
11612 ScrollbarAnimationControllerThinning* scrollbar_1_animation_controller = 11610 ScrollbarAnimationController* scrollbar_1_animation_controller =
11613 static_cast<ScrollbarAnimationControllerThinning*>( 11611 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id());
11614 host_impl_->ScrollbarAnimationControllerForId(root_scroll->id()));
11615 EXPECT_TRUE(scrollbar_1_animation_controller); 11612 EXPECT_TRUE(scrollbar_1_animation_controller);
11616 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f); 11613 scrollbar_1_animation_controller->set_mouse_move_distance_for_test(40.f);
11617 11614
11618 // Mouse moves close to the scrollbar, goes over the scrollbar, and 11615 // Mouse moves close to the scrollbar, goes over the scrollbar, and
11619 // moves back to where it was. 11616 // moves back to where it was.
11620 host_impl_->MouseMoveAt(gfx::Point(100, 150)); 11617 host_impl_->MouseMoveAt(gfx::Point(100, 150));
11621 EXPECT_FALSE( 11618 EXPECT_FALSE(
11622 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); 11619 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11623 EXPECT_FALSE( 11620 EXPECT_FALSE(
11624 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); 11621 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
11666 scrollbar_2->SetDrawsContent(true); 11663 scrollbar_2->SetDrawsContent(true);
11667 scrollbar_2->SetBounds(scrollbar_size_2); 11664 scrollbar_2->SetBounds(scrollbar_size_2);
11668 11665
11669 child->test_properties()->AddChild(std::move(scrollbar_2)); 11666 child->test_properties()->AddChild(std::move(scrollbar_2));
11670 child_clip->test_properties()->AddChild(std::move(child)); 11667 child_clip->test_properties()->AddChild(std::move(child));
11671 root_scroll->test_properties()->AddChild(std::move(child_clip)); 11668 root_scroll->test_properties()->AddChild(std::move(child_clip));
11672 11669
11673 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 11670 host_impl_->active_tree()->BuildPropertyTreesForTesting();
11674 host_impl_->active_tree()->DidBecomeActive(); 11671 host_impl_->active_tree()->DidBecomeActive();
11675 11672
11676 ScrollbarAnimationControllerThinning* scrollbar_2_animation_controller = 11673 ScrollbarAnimationController* scrollbar_2_animation_controller =
11677 static_cast<ScrollbarAnimationControllerThinning*>( 11674 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id);
11678 host_impl_->ScrollbarAnimationControllerForId(child_scroll_id));
11679 EXPECT_TRUE(scrollbar_2_animation_controller); 11675 EXPECT_TRUE(scrollbar_2_animation_controller);
11680 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f); 11676 scrollbar_2_animation_controller->set_mouse_move_distance_for_test(40.f);
11681 11677
11682 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to 11678 // Mouse goes over scrollbar_2, moves close to scrollbar_2, moves close to
11683 // scrollbar_1, goes over scrollbar_1. 11679 // scrollbar_1, goes over scrollbar_1.
11684 host_impl_->MouseMoveAt(gfx::Point(60, 150)); 11680 host_impl_->MouseMoveAt(gfx::Point(60, 150));
11685 EXPECT_FALSE( 11681 EXPECT_FALSE(
11686 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL)); 11682 scrollbar_1_animation_controller->mouse_is_near_scrollbar(VERTICAL));
11687 EXPECT_FALSE( 11683 EXPECT_FALSE(
11688 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL)); 11684 scrollbar_1_animation_controller->mouse_is_over_scrollbar(VERTICAL));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
11734 SetupMouseMoveAtTestScrollbarStates(true); 11730 SetupMouseMoveAtTestScrollbarStates(true);
11735 } 11731 }
11736 11732
11737 TEST_F(LayerTreeHostImplTest, 11733 TEST_F(LayerTreeHostImplTest,
11738 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) { 11734 LayerTreeHostImplTestScrollbarStatesInNotMainThreadScorlling) {
11739 SetupMouseMoveAtTestScrollbarStates(false); 11735 SetupMouseMoveAtTestScrollbarStates(false);
11740 } 11736 }
11741 11737
11742 } // namespace 11738 } // namespace
11743 } // namespace cc 11739 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698