Chromium Code Reviews| 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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 // Scrollbars should not schedule a new delay show when the mouse hovers inside | 1028 // Scrollbars should not schedule a new delay show when the mouse hovers inside |
| 1029 // a scrollbar already scheduled a delay show. | 1029 // a scrollbar already scheduled a delay show. |
| 1030 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1030 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1031 MouseHoverScrollbarAndMoveInside) { | 1031 MouseHoverScrollbarAndMoveInside) { |
| 1032 base::TimeTicks time; | 1032 base::TimeTicks time; |
| 1033 time += base::TimeDelta::FromSeconds(1); | 1033 time += base::TimeDelta::FromSeconds(1); |
| 1034 | 1034 |
| 1035 // Move mouse over scrollbar. | 1035 // Move mouse over scrollbar. |
| 1036 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 1036 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
|
bokan
2017/04/10 14:30:17
This should be kMouseMoveDistanceToTriggerShow - 1
| |
| 1037 | 1037 |
| 1038 // An show animation should have been enqueued. | 1038 // An show animation should have been enqueued. |
| 1039 EXPECT_FALSE(client_.start_fade().is_null()); | 1039 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1040 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1040 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1041 EXPECT_EQ(kShowDelay, client_.delay()); | 1041 EXPECT_EQ(kShowDelay, client_.delay()); |
| 1042 | 1042 |
| 1043 base::Closure& fade = client_.start_fade(); | 1043 base::Closure& fade = client_.start_fade(); |
| 1044 // Move mouse inside scrollbar. should not post a new show. | 1044 // Move mouse inside scrollbar. should not post a new show. |
| 1045 scrollbar_controller_->DidMouseMoveNear( | 1045 scrollbar_controller_->DidMouseMoveNear(VERTICAL, |
| 1046 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness - 1); | 1046 kMouseMoveDistanceToTriggerShow - 1); |
| 1047 | 1047 |
| 1048 EXPECT_TRUE(fade.Equals(client_.start_fade())); | 1048 EXPECT_TRUE(fade.Equals(client_.start_fade())); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then | 1051 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then |
| 1052 // move out of scrollbar. | 1052 // move out of scrollbar. |
| 1053 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1053 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1054 MouseHoverThenOutShouldCancelShow) { | 1054 MouseHoverThenOutShouldCancelShow) { |
| 1055 base::TimeTicks time; | 1055 base::TimeTicks time; |
| 1056 time += base::TimeDelta::FromSeconds(1); | 1056 time += base::TimeDelta::FromSeconds(1); |
| 1057 | 1057 |
| 1058 // Move mouse over scrollbar. | 1058 // Move mouse over scrollbar. |
| 1059 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); | 1059 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); |
| 1060 | 1060 |
| 1061 // An show animation should have been enqueued. | 1061 // An show animation should have been enqueued. |
| 1062 EXPECT_FALSE(client_.start_fade().is_null()); | 1062 EXPECT_FALSE(client_.start_fade().is_null()); |
| 1063 EXPECT_FALSE(client_.start_fade().IsCancelled()); | 1063 EXPECT_FALSE(client_.start_fade().IsCancelled()); |
| 1064 EXPECT_EQ(kShowDelay, client_.delay()); | 1064 EXPECT_EQ(kShowDelay, client_.delay()); |
| 1065 | 1065 |
| 1066 // Move mouse out of scrollbar,delay show should be canceled. | 1066 // Move mouse out of scrollbar,delay show should be canceled. |
| 1067 scrollbar_controller_->DidMouseMoveNear( | 1067 scrollbar_controller_->DidMouseMoveNear(VERTICAL, |
| 1068 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness); | 1068 kMouseMoveDistanceToTriggerShow); |
| 1069 EXPECT_TRUE(client_.start_fade().is_null() || | 1069 EXPECT_TRUE(client_.start_fade().is_null() || |
| 1070 client_.start_fade().IsCancelled()); | 1070 client_.start_fade().IsCancelled()); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then | 1073 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then |
| 1074 // move out of window. | 1074 // move out of window. |
| 1075 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, | 1075 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, |
| 1076 MouseHoverThenLeaveShouldCancelShowThenEnterShouldShow) { | 1076 MouseHoverThenLeaveShouldCancelShowThenEnterShouldShow) { |
| 1077 base::TimeTicks time; | 1077 base::TimeTicks time; |
| 1078 time += base::TimeDelta::FromSeconds(1); | 1078 time += base::TimeDelta::FromSeconds(1); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1587 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1587 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
| 1588 | 1588 |
| 1589 time += base::TimeDelta::FromSeconds(1); | 1589 time += base::TimeDelta::FromSeconds(1); |
| 1590 scrollbar_controller_->DidScrollEnd(); | 1590 scrollbar_controller_->DidScrollEnd(); |
| 1591 EXPECT_FALSE(did_request_animate_); | 1591 EXPECT_FALSE(did_request_animate_); |
| 1592 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); | 1592 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); |
| 1593 } | 1593 } |
| 1594 | 1594 |
| 1595 } // namespace | 1595 } // namespace |
| 1596 } // namespace cc | 1596 } // namespace cc |
| OLD | NEW |