| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/scrollbar_animation_controller.h" | 5 #include "cc/input/scrollbar_animation_controller.h" |
| 6 | 6 |
| 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 8 #include "cc/test/fake_impl_task_runner_provider.h" | 8 #include "cc/test/fake_impl_task_runner_provider.h" |
| 9 #include "cc/test/fake_layer_tree_host_impl.h" | 9 #include "cc/test/fake_layer_tree_host_impl.h" |
| 10 #include "cc/test/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 // Move mouse over scrollbar. | 985 // Move mouse over scrollbar. |
| 986 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 986 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
| 987 | 987 |
| 988 // An show animation should have been enqueued. | 988 // An show animation should have been enqueued. |
| 989 EXPECT_FALSE(client_.start_fade().is_null()); | 989 EXPECT_FALSE(client_.start_fade().is_null()); |
| 990 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 990 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 991 EXPECT_EQ(kShowDelay, client_.delay()); | 991 EXPECT_EQ(kShowDelay, client_.delay()); |
| 992 | 992 |
| 993 // Play the delay animation. | 993 // Play the delay animation. |
| 994 client_.start_fade().Run(); | 994 client_.start_fade().Run(); |
| 995 EXPECT_TRUE(client_.start_fade().IsCancelled()); |
| 995 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); | 996 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
| 996 } | 997 } |
| 997 | 998 |
| 998 // Scrollbars should not schedule a new delay show when the mouse hovers inside | 999 // Scrollbars should not schedule a new delay show when the mouse hovers inside |
| 999 // a scrollbar already scheduled a delay show. | 1000 // a scrollbar already scheduled a delay show. |
| 1000 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1001 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1001 MouseHoverScrollbarAndMoveInside) { | 1002 MouseHoverScrollbarAndMoveInside) { |
| 1002 base::TimeTicks time; | 1003 base::TimeTicks time; |
| 1003 time += base::TimeDelta::FromSeconds(1); | 1004 time += base::TimeDelta::FromSeconds(1); |
| 1004 | 1005 |
| 1005 // Move mouse over scrollbar. | 1006 // Move mouse over scrollbar. |
| 1006 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 1007 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
| 1007 | 1008 |
| 1008 // An show animation should have been enqueued. | 1009 // An show animation should have been enqueued. |
| 1009 EXPECT_FALSE(client_.start_fade().is_null()); | 1010 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1010 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1011 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1011 EXPECT_EQ(kShowDelay, client_.delay()); | 1012 EXPECT_EQ(kShowDelay, client_.delay()); |
| 1012 | 1013 |
| 1013 base::Closure& fade = client_.start_fade(); | 1014 base::Closure& fade = client_.start_fade(); |
| 1014 // Move mouse inside scrollbar. should not post a new show. | 1015 // Move mouse inside scrollbar. should not post a new show. |
| 1015 scrollbar_controller_->DidMouseMoveNear( | 1016 scrollbar_controller_->DidMouseMoveNear( |
| 1016 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness - 1); | 1017 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness - 1); |
| 1017 | 1018 |
| 1018 EXPECT_TRUE(fade.Equals(client_.start_fade())); | 1019 EXPECT_TRUE(fade.Equals(client_.start_fade())); |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then | 1022 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then |
| 1022 // move out. | 1023 // move out of scrollbar. |
| 1023 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1024 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1024 MouseHoverThenOutShouldCancelShow) { | 1025 MouseHoverThenOutShouldCancelShow) { |
| 1025 base::TimeTicks time; | 1026 base::TimeTicks time; |
| 1026 time += base::TimeDelta::FromSeconds(1); | 1027 time += base::TimeDelta::FromSeconds(1); |
| 1027 | 1028 |
| 1028 // Move mouse over scrollbar. | 1029 // Move mouse over scrollbar. |
| 1029 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 1030 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
| 1030 | 1031 |
| 1031 // An show animation should have been enqueued. | 1032 // An show animation should have been enqueued. |
| 1032 EXPECT_FALSE(client_.start_fade().is_null()); | 1033 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1033 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1034 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1034 EXPECT_EQ(kShowDelay, client_.delay()); | 1035 EXPECT_EQ(kShowDelay, client_.delay()); |
| 1035 | 1036 |
| 1036 // Move mouse out of scrollbar,delay show should be canceled. | 1037 // Move mouse out of scrollbar,delay show should be canceled. |
| 1037 scrollbar_controller_->DidMouseMoveNear( | 1038 scrollbar_controller_->DidMouseMoveNear( |
| 1038 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness); | 1039 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness); |
| 1039 EXPECT_TRUE(client_.start_fade().is_null() || | 1040 EXPECT_TRUE(client_.start_fade().is_null() || |
| 1040 client_.start_fade().IsCancelled()); | 1041 client_.start_fade().IsCancelled()); |
| 1041 } | 1042 } |
| 1042 | 1043 |
| 1044 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then |
| 1045 // move out of window. |
| 1046 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1047 MouseHoverThenLeaveShouldCancelShow) { |
| 1048 base::TimeTicks time; |
| 1049 time += base::TimeDelta::FromSeconds(1); |
| 1050 |
| 1051 // Move mouse over scrollbar. |
| 1052 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
| 1053 |
| 1054 // An show animation should have been enqueued. |
| 1055 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1056 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1057 EXPECT_EQ(kShowDelay, client_.delay()); |
| 1058 |
| 1059 // Move mouse out of window,delay show should be canceled. |
| 1060 scrollbar_controller_->DidMouseLeave(); |
| 1061 EXPECT_TRUE(client_.start_fade().is_null() || |
| 1062 client_.start_fade().IsCancelled()); |
| 1063 } |
| 1064 |
| 1043 class ScrollbarAnimationControllerAndroidTest | 1065 class ScrollbarAnimationControllerAndroidTest |
| 1044 : public testing::Test, | 1066 : public testing::Test, |
| 1045 public ScrollbarAnimationControllerClient { | 1067 public ScrollbarAnimationControllerClient { |
| 1046 public: | 1068 public: |
| 1047 ScrollbarAnimationControllerAndroidTest() | 1069 ScrollbarAnimationControllerAndroidTest() |
| 1048 : host_impl_(&task_runner_provider_, &task_graph_runner_), | 1070 : host_impl_(&task_runner_provider_, &task_graph_runner_), |
| 1049 did_request_redraw_(false), | 1071 did_request_redraw_(false), |
| 1050 did_request_animate_(false) {} | 1072 did_request_animate_(false) {} |
| 1051 | 1073 |
| 1052 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, | 1074 void PostDelayedScrollbarAnimationTask(const base::Closure& start_fade, |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1540 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
| 1519 | 1541 |
| 1520 time += base::TimeDelta::FromSeconds(1); | 1542 time += base::TimeDelta::FromSeconds(1); |
| 1521 scrollbar_controller_->DidScrollEnd(); | 1543 scrollbar_controller_->DidScrollEnd(); |
| 1522 EXPECT_FALSE(did_request_animate_); | 1544 EXPECT_FALSE(did_request_animate_); |
| 1523 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1545 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
| 1524 } | 1546 } |
| 1525 | 1547 |
| 1526 } // namespace | 1548 } // namespace |
| 1527 } // namespace cc | 1549 } // namespace cc |
| OLD | NEW |