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

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

Issue 2813643002: Change the distance trigger scrollbar show (Closed)
Patch Set: update 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 hover the show scrollbar
1010 // region of a hidden scrollbar.
1010 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverShow) { 1011 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicMouseHoverShow) {
1011 base::TimeTicks time; 1012 base::TimeTicks time;
1012 time += base::TimeDelta::FromSeconds(1); 1013 time += base::TimeDelta::FromSeconds(1);
1013 1014
1014 // Move mouse over scrollbar. 1015 // Move mouse hover the show scrollbar region of scrollbar.
1015 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1016 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1017 kMouseMoveDistanceToTriggerShow - 1);
1016 1018
1017 // An show animation should have been enqueued. 1019 // An show animation should have been enqueued.
1018 EXPECT_FALSE(client_.start_fade().is_null()); 1020 EXPECT_FALSE(client_.start_fade().is_null());
1019 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1021 EXPECT_FALSE(client_.start_fade().IsCancelled());
1020 EXPECT_EQ(kShowDelay, client_.delay()); 1022 EXPECT_EQ(kShowDelay, client_.delay());
1021 1023
1022 // Play the delay animation. 1024 // Play the delay animation.
1023 client_.start_fade().Run(); 1025 client_.start_fade().Run();
1024 EXPECT_TRUE(client_.start_fade().IsCancelled()); 1026 EXPECT_TRUE(client_.start_fade().IsCancelled());
1025 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 1027 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden());
1026 } 1028 }
1027 1029
1028 // Scrollbars should not schedule a new delay show when the mouse hovers inside 1030 // Scrollbars should not schedule a new delay show when the mouse hovers inside
1029 // a scrollbar already scheduled a delay show. 1031 // a scrollbar already scheduled a delay show.
1030 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1032 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1031 MouseHoverScrollbarAndMoveInside) { 1033 MouseHoverScrollbarAndMoveInside) {
1032 base::TimeTicks time; 1034 base::TimeTicks time;
1033 time += base::TimeDelta::FromSeconds(1); 1035 time += base::TimeDelta::FromSeconds(1);
1034 1036
1035 // Move mouse over scrollbar. 1037 // Move mouse hover the show scrollbar region of scrollbar.
1036 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1038 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1039 kMouseMoveDistanceToTriggerShow - 1);
1037 1040
1038 // An show animation should have been enqueued. 1041 // An show animation should have been enqueued.
1039 EXPECT_FALSE(client_.start_fade().is_null()); 1042 EXPECT_FALSE(client_.start_fade().is_null());
1040 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1043 EXPECT_FALSE(client_.start_fade().IsCancelled());
1041 EXPECT_EQ(kShowDelay, client_.delay()); 1044 EXPECT_EQ(kShowDelay, client_.delay());
1042 1045
1043 base::Closure& fade = client_.start_fade(); 1046 base::Closure& fade = client_.start_fade();
1044 // Move mouse inside scrollbar. should not post a new show. 1047 // Move mouse still hover the show scrollbar region of scrollbar should not
1045 scrollbar_controller_->DidMouseMoveNear( 1048 // post a new show.
1046 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness - 1); 1049 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1050 kMouseMoveDistanceToTriggerShow - 2);
1047 1051
1048 EXPECT_TRUE(fade.Equals(client_.start_fade())); 1052 EXPECT_TRUE(fade.Equals(client_.start_fade()));
1049 } 1053 }
1050 1054
1051 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then 1055 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then
1052 // move out of scrollbar. 1056 // move far away.
1053 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1057 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1054 MouseHoverThenOutShouldCancelShow) { 1058 MouseHoverThenOutShouldCancelShow) {
1055 base::TimeTicks time; 1059 base::TimeTicks time;
1056 time += base::TimeDelta::FromSeconds(1); 1060 time += base::TimeDelta::FromSeconds(1);
1057 1061
1058 // Move mouse over scrollbar. 1062 // Move mouse hover the show scrollbar region of scrollbar.
1059 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1063 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1064 kMouseMoveDistanceToTriggerShow - 1);
1060 1065
1061 // An show animation should have been enqueued. 1066 // An show animation should have been enqueued.
1062 EXPECT_FALSE(client_.start_fade().is_null()); 1067 EXPECT_FALSE(client_.start_fade().is_null());
1063 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1068 EXPECT_FALSE(client_.start_fade().IsCancelled());
1064 EXPECT_EQ(kShowDelay, client_.delay()); 1069 EXPECT_EQ(kShowDelay, client_.delay());
1065 1070
1066 // Move mouse out of scrollbar,delay show should be canceled. 1071 // Move mouse far away,delay show should be canceled.
1067 scrollbar_controller_->DidMouseMoveNear( 1072 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1068 VERTICAL, kMouseMoveDistanceToTriggerShow - kThumbThickness); 1073 kMouseMoveDistanceToTriggerShow);
1069 EXPECT_TRUE(client_.start_fade().is_null() || 1074 EXPECT_TRUE(client_.start_fade().is_null() ||
1070 client_.start_fade().IsCancelled()); 1075 client_.start_fade().IsCancelled());
1071 } 1076 }
1072 1077
1073 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then 1078 // Scrollbars should cancel delay show when mouse hover hidden scrollbar then
1074 // move out of window. 1079 // move out of window.
1075 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, 1080 TEST_F(ScrollbarAnimationControllerAuraOverlayTest,
1076 MouseHoverThenLeaveShouldCancelShowThenEnterShouldShow) { 1081 MouseHoverThenLeaveShouldCancelShowThenEnterShouldShow) {
1077 base::TimeTicks time; 1082 base::TimeTicks time;
1078 time += base::TimeDelta::FromSeconds(1); 1083 time += base::TimeDelta::FromSeconds(1);
1079 1084
1080 // Move mouse over scrollbar. 1085 // Move mouse hover the show scrollbar region of scrollbar.
1081 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1086 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1087 kMouseMoveDistanceToTriggerShow - 1);
1082 1088
1083 // An show animation should have been enqueued. 1089 // An show animation should have been enqueued.
1084 EXPECT_FALSE(client_.start_fade().is_null()); 1090 EXPECT_FALSE(client_.start_fade().is_null());
1085 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1091 EXPECT_FALSE(client_.start_fade().IsCancelled());
1086 EXPECT_EQ(kShowDelay, client_.delay()); 1092 EXPECT_EQ(kShowDelay, client_.delay());
1087 1093
1088 // Move mouse out of window,delay show should be canceled. 1094 // Move mouse out of window,delay show should be canceled.
1089 scrollbar_controller_->DidMouseLeave(); 1095 scrollbar_controller_->DidMouseLeave();
1090 EXPECT_TRUE(client_.start_fade().is_null() || 1096 EXPECT_TRUE(client_.start_fade().is_null() ||
1091 client_.start_fade().IsCancelled()); 1097 client_.start_fade().IsCancelled());
1092 1098
1093 // Move mouse over scrollbar. 1099 // Move mouse hover the show scrollbar region of scrollbar.
1094 scrollbar_controller_->DidMouseMoveNear(VERTICAL, 0); 1100 scrollbar_controller_->DidMouseMoveNear(VERTICAL,
1101 kMouseMoveDistanceToTriggerShow - 1);
1095 1102
1096 // An show animation should have been enqueued. 1103 // An show animation should have been enqueued.
1097 EXPECT_FALSE(client_.start_fade().is_null()); 1104 EXPECT_FALSE(client_.start_fade().is_null());
1098 EXPECT_FALSE(client_.start_fade().IsCancelled()); 1105 EXPECT_FALSE(client_.start_fade().IsCancelled());
1099 EXPECT_EQ(kShowDelay, client_.delay()); 1106 EXPECT_EQ(kShowDelay, client_.delay());
1100 1107
1101 // Play the delay animation. 1108 // Play the delay animation.
1102 client_.start_fade().Run(); 1109 client_.start_fade().Run();
1103 EXPECT_TRUE(client_.start_fade().IsCancelled()); 1110 EXPECT_TRUE(client_.start_fade().IsCancelled());
1104 EXPECT_FALSE(scrollbar_controller_->ScrollbarsHidden()); 1111 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()); 1594 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1588 1595
1589 time += base::TimeDelta::FromSeconds(1); 1596 time += base::TimeDelta::FromSeconds(1);
1590 scrollbar_controller_->DidScrollEnd(); 1597 scrollbar_controller_->DidScrollEnd();
1591 EXPECT_FALSE(did_request_animate_); 1598 EXPECT_FALSE(did_request_animate_);
1592 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1599 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity());
1593 } 1600 }
1594 1601
1595 } // namespace 1602 } // namespace
1596 } // namespace cc 1603 } // 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