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

Side by Side Diff: cc/input/scrollbar_animation_controller_unittest.cc

Issue 2813643002: Change the distance trigger scrollbar show (Closed)
Patch Set: change tests and comments Created 3 years, 8 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
« no previous file with comments | « cc/input/scrollbar_animation_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 client_.start_fade().IsCancelled()); 999 client_.start_fade().IsCancelled());
1000 1000
1001 // Mouse leave. 1001 // Mouse leave.
1002 scrollbar_controller_->DidMouseLeave(); 1002 scrollbar_controller_->DidMouseLeave();
1003 1003
1004 // An fade out animation should have been enqueued. 1004 // An fade out animation should have been enqueued.
1005 EXPECT_FALSE(client_.start_fade().is_null()); 1005 EXPECT_FALSE(client_.start_fade().is_null());
1006 EXPECT_EQ(kFadeOutDelay, client_.delay()); 1006 EXPECT_EQ(kFadeOutDelay, client_.delay());
1007 } 1007 }
1008 1008
1009 // Scrollbars should schedule a delay show when mouse hover hidden scrollbar. 1009 // Scrollbars should schedule a delay show when mouse near a hidden scrollbar.
1010 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverShow) { 1010 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverShow) {
chaopeng 2017/04/10 14:56:11 Here we are not hover anymore. what should we name
bokan 2017/04/10 18:14:16 We are hovering over the "show scrollbar region" r
1011 base::TimeTicks time; 1011 base::TimeTicks time;
1012 time += base::TimeDelta::FromSeconds(1); 1012 time += base::TimeDelta::FromSeconds(1);
1013 1013
1014 // Move mouse over scrollbar. 1014 // Move mouse near scrollbar within kMouseMoveDistanceToTriggerShow.
1015 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1015 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1016 kMouseMoveDistanceToTriggerShow - 1);
1016 1017
1017 // An show animation should have been enqueued. 1018 // An show animation should have been enqueued.
1018 EXPECT_FALSE(client_.start_fade().is_null()); 1019 EXPECT_FALSE(client_.start_fade().is_null());
1019 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1020 EXPECT_FALSE(client_.start_fade().IsCancelled());
1020 EXPECT_EQ(kShowDelay, client_.delay()); 1021 EXPECT_EQ(kShowDelay, client_.delay());
1021 1022
1022 // Play the delay animation. 1023 // Play the delay animation.
1023 client_.start_fade().Run(); 1024 client_.start_fade().Run();
1024 EXPECT_TRUE(client_.start_fade().IsCancelled()); 1025 EXPECT_TRUE(client_.start_fade().IsCancelled());
1025 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 1026 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
1026 } 1027 }
1027 1028
1028 // Scrollbars should not schedule a new delay show when the mouse hovers inside 1029 // Scrollbars should not schedule a new delay show when the mouse hovers inside
1029 // a scrollbar already scheduled a delay show. 1030 // a scrollbar already scheduled a delay show.
1030 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1031 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1031 MouseHoverScrollbarAndMoveInside) { 1032 MouseHoverScrollbarAndMoveInside) {
1032 base::TimeTicks time; 1033 base::TimeTicks time;
1033 time += base::TimeDelta::FromSeconds(1); 1034 time += base::TimeDelta::FromSeconds(1);
1034 1035
1035 // Move mouse over scrollbar. 1036 // Move mouse near scrollbar within kMouseMoveDistanceToTriggerShow.
1036 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1037 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1038 kMouseMoveDistanceToTriggerShow - 1);
1037 1039
1038 // An show animation should have been enqueued. 1040 // An show animation should have been enqueued.
1039 EXPECT_FALSE(client_.start_fade().is_null()); 1041 EXPECT_FALSE(client_.start_fade().is_null());
1040 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1042 EXPECT_FALSE(client_.start_fade().IsCancelled());
1041 EXPECT_EQ(kShowDelay, client_.delay()); 1043 EXPECT_EQ(kShowDelay, client_.delay());
1042 1044
1043 base::Closure& fade = client_.start_fade(); 1045 base::Closure& fade = client_.start_fade();
1044 // Move mouse inside scrollbar. should not post a new show. 1046 // Move mouse near scrollbar still within kMouseMoveDistanceToTriggerShow.
1045 scrollbar_controller_->DidMouseMoveNear( 1047 // should not post a new show.
1046 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness - 1); 1048 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1049 kMouseMoveDistanceToTriggerShow - 2);
1047 1050
1048 EXPECT_TRUE(fade.Equals(client_.start_fade())); 1051 EXPECT_TRUE(fade.Equals(client_.start_fade()));
1049 } 1052 }
1050 1053
1051 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then 1054 // Scrollbars should cancel delay show when mouse near hidden scrollbar then
1052 // move out of scrollbar. 1055 // move far away.
1053 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1056 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1054 MouseHoverThenOutShouldCancelShow) { 1057 MouseHoverThenOutShouldCancelShow) {
1055 base::TimeTicks time; 1058 base::TimeTicks time;
1056 time += base::TimeDelta::FromSeconds(1); 1059 time += base::TimeDelta::FromSeconds(1);
1057 1060
1058 // Move mouse over scrollbar. 1061 // Move mouse near scrollbar within kMouseMoveDistanceToTriggerShow.
1059 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1062 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1063 kMouseMoveDistanceToTriggerShow - 1);
1060 1064
1061 // An show animation should have been enqueued. 1065 // An show animation should have been enqueued.
1062 EXPECT_FALSE(client_.start_fade().is_null()); 1066 EXPECT_FALSE(client_.start_fade().is_null());
1063 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1067 EXPECT_FALSE(client_.start_fade().IsCancelled());
1064 EXPECT_EQ(kShowDelay, client_.delay()); 1068 EXPECT_EQ(kShowDelay, client_.delay());
1065 1069
1066 // Move mouse out of scrollbar,delay show should be canceled. 1070 // Move mouse far away,delay show should be canceled.
1067 scrollbar_controller_->DidMouseMoveNear( 1071 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1068 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness); 1072 kMouseMoveDistanceToTriggerShow);
1069 EXPECT_TRUE(client_.start_fade().is_null() || 1073 EXPECT_TRUE(client_.start_fade().is_null() ||
1070 client_.start_fade().IsCancelled()); 1074 client_.start_fade().IsCancelled());
1071 } 1075 }
1072 1076
1073 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then 1077 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then
1074 // move out of window. 1078 // move out of window.
1075 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1079 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1076 MouseHoverThenLeaveShouldCancelShowThenEnterShouldShow) { 1080 MouseHoverThenLeaveShouldCancelShowThenEnterShouldShow) {
1077 base::TimeTicks time; 1081 base::TimeTicks time;
1078 time += base::TimeDelta::FromSeconds(1); 1082 time += base::TimeDelta::FromSeconds(1);
1079 1083
1080 // Move mouse over scrollbar. 1084 // Move mouse near scrollbar within kMouseMoveDistanceToTriggerShow.
1081 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1085 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1086 kMouseMoveDistanceToTriggerShow - 1);
1082 1087
1083 // An show animation should have been enqueued. 1088 // An show animation should have been enqueued.
1084 EXPECT_FALSE(client_.start_fade().is_null()); 1089 EXPECT_FALSE(client_.start_fade().is_null());
1085 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1090 EXPECT_FALSE(client_.start_fade().IsCancelled());
1086 EXPECT_EQ(kShowDelay, client_.delay()); 1091 EXPECT_EQ(kShowDelay, client_.delay());
1087 1092
1088 // Move mouse out of window,delay show should be canceled. 1093 // Move mouse out of window,delay show should be canceled.
1089 scrollbar_controller_->DidMouseLeave(); 1094 scrollbar_controller_->DidMouseLeave();
1090 EXPECT_TRUE(client_.start_fade().is_null() || 1095 EXPECT_TRUE(client_.start_fade().is_null() ||
1091 client_.start_fade().IsCancelled()); 1096 client_.start_fade().IsCancelled());
1092 1097
1093 // Move mouse over scrollbar. 1098 // Move mouse near scrollbar within kMouseMoveDistanceToTriggerShow.
1094 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1099 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1100 kMouseMoveDistanceToTriggerShow - 1);
1095 1101
1096 // An show animation should have been enqueued. 1102 // An show animation should have been enqueued.
1097 EXPECT_FALSE(client_.start_fade().is_null()); 1103 EXPECT_FALSE(client_.start_fade().is_null());
1098 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1104 EXPECT_FALSE(client_.start_fade().IsCancelled());
1099 EXPECT_EQ(kShowDelay, client_.delay()); 1105 EXPECT_EQ(kShowDelay, client_.delay());
1100 1106
1101 // Play the delay animation. 1107 // Play the delay animation.
1102 client_.start_fade().Run(); 1108 client_.start_fade().Run();
1103 EXPECT_TRUE(client_.start_fade().IsCancelled()); 1109 EXPECT_TRUE(client_.start_fade().IsCancelled());
1104 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 1110 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1593 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1588 1594
1589 time += base::TimeDelta::FromSeconds(1); 1595 time += base::TimeDelta::FromSeconds(1);
1590 scrollbar_controller_->DidScrollEnd(); 1596 scrollbar_controller_->DidScrollEnd();
1591 EXPECT_FALSE(did_request_animate_); 1597 EXPECT_FALSE(did_request_animate_);
1592 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1598 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1593 } 1599 }
1594 1600
1595 } // namespace 1601 } // namespace
1596 } // namespace cc 1602 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/scrollbar_animation_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698