| 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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 // Move mouse out of scrollbar,delay show should be canceled. | 1037 // Move mouse out of scrollbar,delay show should be canceled. |
| 1038 scrollbar_controller_->DidMouseMoveNear( | 1038 scrollbar_controller_->DidMouseMoveNear( |
| 1039 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness); | 1039 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness); |
| 1040 EXPECT_TRUE(client_.start_fade().is_null() || | 1040 EXPECT_TRUE(client_.start_fade().is_null() || |
| 1041 client_.start_fade().IsCancelled()); | 1041 client_.start_fade().IsCancelled()); |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then | 1044 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then |
| 1045 // move out of window. | 1045 // move out of window. |
| 1046 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1046 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1047 MouseHoverThenLeaveShouldCancelShow) { | 1047 MouseHoverThenLeaveShouldCancelShowThenEnterShouldShow) { |
| 1048 base::TimeTicks time; | 1048 base::TimeTicks time; |
| 1049 time += base::TimeDelta::FromSeconds(1); | 1049 time += base::TimeDelta::FromSeconds(1); |
| 1050 | 1050 |
| 1051 // Move mouse over scrollbar. | 1051 // Move mouse over scrollbar. |
| 1052 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 1052 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
| 1053 | 1053 |
| 1054 // An show animation should have been enqueued. | 1054 // An show animation should have been enqueued. |
| 1055 EXPECT_FALSE(client_.start_fade().is_null()); | 1055 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1056 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1056 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1057 EXPECT_EQ(kShowDelay, client_.delay()); | 1057 EXPECT_EQ(kShowDelay, client_.delay()); |
| 1058 | 1058 |
| 1059 // Move mouse out of window,delay show should be canceled. | 1059 // Move mouse out of window,delay show should be canceled. |
| 1060 scrollbar_controller_->DidMouseLeave(); | 1060 scrollbar_controller_->DidMouseLeave(); |
| 1061 EXPECT_TRUE(client_.start_fade().is_null() || | 1061 EXPECT_TRUE(client_.start_fade().is_null() || |
| 1062 client_.start_fade().IsCancelled()); | 1062 client_.start_fade().IsCancelled()); |
| 1063 |
| 1064 // Move mouse over scrollbar. |
| 1065 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
| 1066 |
| 1067 // An show animation should have been enqueued. |
| 1068 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1069 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1070 EXPECT_EQ(kShowDelay, client_.delay()); |
| 1071 |
| 1072 // Play the delay animation. |
| 1073 client_.start_fade().Run(); |
| 1074 EXPECT_TRUE(client_.start_fade().IsCancelled()); |
| 1075 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); |
| 1063 } | 1076 } |
| 1064 | 1077 |
| 1065 class ScrollbarAnimationControllerAndroidTest | 1078 class ScrollbarAnimationControllerAndroidTest |
| 1066 : public testing::Test, | 1079 : public testing::Test, |
| 1067 public ScrollbarAnimationControllerClient { | 1080 public ScrollbarAnimationControllerClient { |
| 1068 public: | 1081 public: |
| 1069 ScrollbarAnimationControllerAndroidTest() | 1082 ScrollbarAnimationControllerAndroidTest() |
| 1070 : host_impl_(&task_runner_provider_, &task_graph_runner_), | 1083 : host_impl_(&task_runner_provider_, &task_graph_runner_), |
| 1071 did_request_redraw_(false), | 1084 did_request_redraw_(false), |
| 1072 did_request_animate_(false) {} | 1085 did_request_animate_(false) {} |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1553 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
| 1541 | 1554 |
| 1542 time += base::TimeDelta::FromSeconds(1); | 1555 time += base::TimeDelta::FromSeconds(1); |
| 1543 scrollbar_controller_->DidScrollEnd(); | 1556 scrollbar_controller_->DidScrollEnd(); |
| 1544 EXPECT_FALSE(did_request_animate_); | 1557 EXPECT_FALSE(did_request_animate_); |
| 1545 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1558 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
| 1546 } | 1559 } |
| 1547 | 1560 |
| 1548 } // namespace | 1561 } // namespace |
| 1549 } // namespace cc | 1562 } // namespace cc |
| OLD | NEW |