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

Side by Side Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 2007863004: Fix the double-tap to click gesture in touch accessibility mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/chromeos/touch_exploration_controller.h" 5 #include "ui/chromeos/touch_exploration_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 float GetSlopDistanceFromEdge() const { 175 float GetSlopDistanceFromEdge() const {
176 return touch_exploration_controller_->kSlopDistanceFromEdge; 176 return touch_exploration_controller_->kSlopDistanceFromEdge;
177 } 177 }
178 178
179 void SetTickClockForTesting(base::TickClock* simulated_clock) { 179 void SetTickClockForTesting(base::TickClock* simulated_clock) {
180 touch_exploration_controller_->tick_clock_ = simulated_clock; 180 touch_exploration_controller_->tick_clock_ = simulated_clock;
181 } 181 }
182 182
183 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) {
184 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location);
185 }
186
183 private: 187 private:
184 std::unique_ptr<TouchExplorationController> touch_exploration_controller_; 188 std::unique_ptr<TouchExplorationController> touch_exploration_controller_;
185 189
186 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi); 190 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi);
187 }; 191 };
188 192
189 class TouchExplorationTest : public aura::test::AuraTestBase { 193 class TouchExplorationTest : public aura::test::AuraTestBase {
190 public: 194 public:
191 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { 195 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) {
192 // Tests fail if time is ever 0. 196 // Tests fail if time is ever 0.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 return touch_exploration_controller_->GetSlopDistanceFromEdge(); 392 return touch_exploration_controller_->GetSlopDistanceFromEdge();
389 } 393 }
390 394
391 base::TimeDelta Now() { 395 base::TimeDelta Now() {
392 // This is the same as what EventTimeForNow() does, but here we do it 396 // This is the same as what EventTimeForNow() does, but here we do it
393 // with our simulated clock. 397 // with our simulated clock.
394 return base::TimeDelta::FromInternalValue( 398 return base::TimeDelta::FromInternalValue(
395 simulated_clock_->NowTicks().ToInternalValue()); 399 simulated_clock_->NowTicks().ToInternalValue());
396 } 400 }
397 401
402 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) {
403 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location);
404 }
405
398 std::unique_ptr<test::EventGenerator> generator_; 406 std::unique_ptr<test::EventGenerator> generator_;
399 ui::GestureDetector::Config gesture_detector_config_; 407 ui::GestureDetector::Config gesture_detector_config_;
400 // Owned by |generator_|. 408 // Owned by |generator_|.
401 base::SimpleTestTickClock* simulated_clock_; 409 base::SimpleTestTickClock* simulated_clock_;
402 MockTouchExplorationControllerDelegate delegate_; 410 MockTouchExplorationControllerDelegate delegate_;
403 411
404 private: 412 private:
405 EventCapturer event_capturer_; 413 EventCapturer event_capturer_;
406 std::unique_ptr<TouchExplorationControllerTestApi> 414 std::unique_ptr<TouchExplorationControllerTestApi>
407 touch_exploration_controller_; 415 touch_exploration_controller_;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 708
701 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 709 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
702 ASSERT_EQ(2U, captured_events.size()); 710 ASSERT_EQ(2U, captured_events.size());
703 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 711 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
704 EXPECT_EQ(tap_location, captured_events[0]->location()); 712 EXPECT_EQ(tap_location, captured_events[0]->location());
705 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 713 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
706 EXPECT_EQ(tap_location, captured_events[1]->location()); 714 EXPECT_EQ(tap_location, captured_events[1]->location());
707 EXPECT_TRUE(IsInNoFingersDownState()); 715 EXPECT_TRUE(IsInNoFingersDownState());
708 } 716 }
709 717
718 // If an explicit anchor point is set during touch exploration, double-tapping
719 // should send a 'click' gesture rather than a simulated touch press and
720 // release.
721 TEST_F(TouchExplorationTest, DoubleTapWithExplicitAnchorPoint) {
722 SwitchTouchExplorationMode(true);
723
724 // Tap at one location, and get a mouse move event.
725 gfx::Point tap_location(51, 52);
726 generator_->set_current_location(tap_location);
727 generator_->PressTouchId(1);
728 generator_->ReleaseTouchId(1);
729 AdvanceSimulatedTimePastTapDelay();
730
731 SetTouchAccessibilityAnchorPoint(tap_location);
732
733 std::vector<ui::LocatedEvent*> events =
734 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
735 ASSERT_EQ(1U, events.size());
736
737 EXPECT_EQ(tap_location, events[0]->location());
738 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
739 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
740 ClearCapturedEvents();
741
742 // Now double-tap at a different location. This should result in
743 // a click gesture.
744 gfx::Point double_tap_location(33, 34);
745 generator_->set_current_location(double_tap_location);
746 generator_->PressTouch();
747 generator_->ReleaseTouch();
748 generator_->PressTouch();
749 generator_->ReleaseTouch();
750
751 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
752 ASSERT_EQ(0U, captured_events.size());
753 EXPECT_TRUE(IsInNoFingersDownState());
754 EXPECT_EQ(ui::AX_GESTURE_CLICK, delegate_.GetLastGesture());
755 }
756
710 // Double-tapping where the user holds their finger down for the second time 757 // Double-tapping where the user holds their finger down for the second time
711 // for a longer press should send a touch press and passthrough all further 758 // for a longer press should send a touch press and passthrough all further
712 // events from that finger. Other finger presses should be ignored. 759 // events from that finger. Other finger presses should be ignored.
713 TEST_F(TouchExplorationTest, DoubleTapPassthrough) { 760 TEST_F(TouchExplorationTest, DoubleTapPassthrough) {
714 SwitchTouchExplorationMode(true); 761 SwitchTouchExplorationMode(true);
715 762
716 // Tap at one location, and get a mouse move event. 763 // Tap at one location, and get a mouse move event.
717 gfx::Point tap_location(11, 12); 764 gfx::Point tap_location(11, 12);
718 generator_->set_current_location(tap_location); 765 generator_->set_current_location(tap_location);
719 generator_->PressTouch(); 766 generator_->PressTouch();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 954 }
908 955
909 // Tapping and releasing with a second finger when in touch exploration mode 956 // Tapping and releasing with a second finger when in touch exploration mode
910 // should send a touch press and released to the location of the last 957 // should send a touch press and released to the location of the last
911 // successful touch exploration and return to touch explore. 958 // successful touch exploration and return to touch explore.
912 TEST_F(TouchExplorationTest, SplitTap) { 959 TEST_F(TouchExplorationTest, SplitTap) {
913 SwitchTouchExplorationMode(true); 960 SwitchTouchExplorationMode(true);
914 gfx::Point initial_touch_location(11, 12); 961 gfx::Point initial_touch_location(11, 12);
915 gfx::Point second_touch_location(33, 34); 962 gfx::Point second_touch_location(33, 34);
916 963
964 LOG(ERROR) << "*** SplitTap initial hold ***";
oshima 2016/05/26 22:15:39 debug msg
dmazzoni 2016/05/26 22:53:48 Done.
965
917 // Tap and hold at one location, and get a mouse move event in touch explore. 966 // Tap and hold at one location, and get a mouse move event in touch explore.
918 EnterTouchExplorationModeAtLocation(initial_touch_location); 967 EnterTouchExplorationModeAtLocation(initial_touch_location);
919 std::vector<ui::LocatedEvent*> events = 968 std::vector<ui::LocatedEvent*> events =
920 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); 969 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
921 ASSERT_EQ(1U, events.size()); 970 ASSERT_EQ(1U, events.size());
922 971
923 EXPECT_EQ(initial_touch_location, events[0]->location()); 972 EXPECT_EQ(initial_touch_location, events[0]->location());
924 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); 973 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
925 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); 974 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
926 ClearCapturedEvents(); 975 ClearCapturedEvents();
927 EXPECT_TRUE(IsInTouchToMouseMode()); 976 EXPECT_TRUE(IsInTouchToMouseMode());
928 977
978 LOG(ERROR) << "*** SplitTap press ***";
oshima 2016/05/26 22:15:39 ditto
dmazzoni 2016/05/26 22:53:48 Done.
979
929 // Now tap and release at a different location. This should result in a 980 // Now tap and release at a different location. This should result in a
930 // single touch and release at the location of the first (held) tap, 981 // single touch and release at the location of the first (held) tap,
931 // not at the location of the second tap and release. 982 // not at the location of the second tap and release.
932 // After the release, there is still a finger in touch explore mode. 983 // After the release, there is still a finger in touch explore mode.
933 ui::TouchEvent split_tap_press( 984 ui::TouchEvent split_tap_press(
934 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 985 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
935 generator_->Dispatch(&split_tap_press); 986 generator_->Dispatch(&split_tap_press);
936 // To simulate the behavior of the real device, we manually disable 987 // To simulate the behavior of the real device, we manually disable
937 // mouse events. To not rely on manually setting the state, this is also 988 // mouse events. To not rely on manually setting the state, this is also
938 // tested in touch_exploration_controller_browsertest. 989 // tested in touch_exploration_controller_browsertest.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 EXPECT_TRUE(IsInNoFingersDownState()); 1049 EXPECT_TRUE(IsInNoFingersDownState());
999 1050
1000 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 1051 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1001 ASSERT_EQ(2U, captured_events.size()); 1052 ASSERT_EQ(2U, captured_events.size());
1002 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 1053 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1003 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); 1054 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
1004 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 1055 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
1005 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 1056 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
1006 } 1057 }
1007 1058
1008 // When in touch exploration mode, making a long press with a second finger
1009 // should send a touch press and released to the location of the last
1010 // successful touch exploration. There should be a delay between the
1011 // touch and release events (right click).
1012 TEST_F(TouchExplorationTest, SplitTapLongPress) {
1013 SwitchTouchExplorationMode(true);
1014 gfx::Point initial_touch_location(11, 12);
1015 gfx::Point second_touch_location(33, 34);
1016
1017 // Tap and hold at one location, and get a mouse move event in touch explore.
1018 EnterTouchExplorationModeAtLocation(initial_touch_location);
1019 std::vector<ui::LocatedEvent*> events =
1020 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
1021 ASSERT_EQ(1U, events.size());
1022
1023 ClearCapturedEvents();
1024
1025 // Now tap, hold, and release at a different location. This should result
1026 // in a single touch and release (long press) at the location of the first
1027 // (held) tap, not at the location of the second tap and release.
1028 ui::TouchEvent split_tap_press(
1029 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
1030 generator_->Dispatch(&split_tap_press);
1031 // To simulate the behavior of the real device, we manually disable
1032 // mouse events, like in the SplitTap test.
1033 cursor_client()->DisableMouseEvents();
1034 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled());
1035 EXPECT_FALSE(cursor_client()->IsCursorVisible());
1036 EXPECT_FALSE(IsInGestureInProgressState());
1037 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
1038 // After the release, there is still a finger in touch exploration, and
1039 // mouse events should be enabled again.
1040 ui::TouchEvent split_tap_release(
1041 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
1042 generator_->Dispatch(&split_tap_release);
1043 EXPECT_FALSE(IsInNoFingersDownState());
1044 EXPECT_TRUE(IsInTouchToMouseMode());
1045
1046 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1047 ASSERT_EQ(2U, captured_events.size());
1048 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1049 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
1050 base::TimeDelta pressed_time = captured_events[0]->time_stamp();
1051 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
1052 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
1053 base::TimeDelta released_time = captured_events[1]->time_stamp();
1054 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
1055 released_time - pressed_time);
1056 }
1057
1058 // If split tap is started but the touch explore finger is released first,
1059 // there should still be a touch press and release sent to the location of
1060 // the last successful touch exploration. If the remaining finger is held
1061 // as a longpress, there should be a delay between the sent touch and release
1062 // events (right click).All fingers should be released after the click
1063 // goes through.
1064 TEST_F(TouchExplorationTest, SplitTapReleaseLongPress) {
1065 SwitchTouchExplorationMode(true);
1066 gfx::Point initial_touch_location(11, 12);
1067 gfx::Point second_touch_location(33, 34);
1068
1069 // Tap and hold at one location, and get a mouse move event in touch explore.
1070 EnterTouchExplorationModeAtLocation(initial_touch_location);
1071 std::vector<ui::LocatedEvent*> events =
1072 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
1073 ASSERT_EQ(1U, events.size());
1074 ClearCapturedEvents();
1075
1076 // Now tap at a different location. Release at the first location,
1077 // then release at the second. This should result in a
1078 // single touch and release at the location of the first (held) tap,
1079 // not at the location of the second tap and release.
1080 // After the release, TouchToMouseMode should still be on.
1081 ui::TouchEvent split_tap_press(
1082 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
1083 generator_->Dispatch(&split_tap_press);
1084 ui::TouchEvent touch_explore_release(
1085 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now());
1086 generator_->Dispatch(&touch_explore_release);
1087 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
1088 ui::TouchEvent split_tap_release(
1089 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
1090 generator_->Dispatch(&split_tap_release);
1091 EXPECT_TRUE(IsInTouchToMouseMode());
1092
1093 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1094 ASSERT_EQ(2U, captured_events.size());
1095 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1096 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
1097 base::TimeDelta pressed_time = captured_events[0]->time_stamp();
1098 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
1099 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
1100 base::TimeDelta released_time = captured_events[1]->time_stamp();
1101 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
1102 released_time - pressed_time);
1103 }
1104
1105 TEST_F(TouchExplorationTest, SplitTapMultiFinger) { 1059 TEST_F(TouchExplorationTest, SplitTapMultiFinger) {
1106 SwitchTouchExplorationMode(true); 1060 SwitchTouchExplorationMode(true);
1107 gfx::Point initial_touch_location(11, 12); 1061 gfx::Point initial_touch_location(11, 12);
1108 gfx::Point second_touch_location(33, 34); 1062 gfx::Point second_touch_location(33, 34);
1109 gfx::Point third_touch_location(16, 17); 1063 gfx::Point third_touch_location(16, 17);
1110 1064
1111 // Tap and hold at one location, and get a mouse move event in touch explore. 1065 // Tap and hold at one location, and get a mouse move event in touch explore.
1112 EnterTouchExplorationModeAtLocation(initial_touch_location); 1066 EnterTouchExplorationModeAtLocation(initial_touch_location);
1113 1067
1114 std::vector<ui::LocatedEvent*> events = 1068 std::vector<ui::LocatedEvent*> events =
1115 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); 1069 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
1116 ASSERT_EQ(1U, events.size()); 1070 ASSERT_EQ(1U, events.size());
1117 1071
1118 EXPECT_EQ(initial_touch_location, events[0]->location()); 1072 EXPECT_EQ(initial_touch_location, events[0]->location());
1119 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); 1073 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
1120 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); 1074 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
1121 ClearCapturedEvents(); 1075 ClearCapturedEvents();
1122 1076
1123 // Now tap at a different location and hold for long press. 1077 // Now tap at a different location
1124 ui::TouchEvent split_tap_press( 1078 ui::TouchEvent split_tap_press(
1125 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 1079 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
1126 generator_->Dispatch(&split_tap_press); 1080 generator_->Dispatch(&split_tap_press);
1127 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); 1081 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
1128 1082
1129 // Placing a third finger on the screen should cancel the initial press and 1083 // Placing a third finger on the screen should cancel the split tap and
1130 // enter the wait state. 1084 // enter the wait state.
1131 ui::TouchEvent third_press( 1085 ui::TouchEvent third_press(
1132 ui::ET_TOUCH_PRESSED, third_touch_location, 2, Now()); 1086 ui::ET_TOUCH_PRESSED, third_touch_location, 2, Now());
1133 generator_->Dispatch(&third_press); 1087 generator_->Dispatch(&third_press);
1134 1088
1135 // When all three fingers are released, the only events captured should be a 1089 // When all three fingers are released, no events should be captured.
1136 // press and touch cancel. All fingers should then be up. 1090 // All fingers should then be up.
1137 ui::TouchEvent touch_explore_release( 1091 ui::TouchEvent touch_explore_release(
1138 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); 1092 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now());
1139 generator_->Dispatch(&touch_explore_release); 1093 generator_->Dispatch(&touch_explore_release);
1140 ui::TouchEvent split_tap_release( 1094 ui::TouchEvent split_tap_release(
1141 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 1095 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
1142 generator_->Dispatch(&split_tap_release); 1096 generator_->Dispatch(&split_tap_release);
1143 ui::TouchEvent third_tap_release( 1097 ui::TouchEvent third_tap_release(
1144 ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now()); 1098 ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now());
1145 generator_->Dispatch(&third_tap_release); 1099 generator_->Dispatch(&third_tap_release);
1146 1100
1147 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 1101 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1148 ASSERT_EQ(2U, captured_events.size()); 1102 ASSERT_EQ(0U, captured_events.size());
1149 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1150 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
1151 EXPECT_EQ(ui::ET_TOUCH_CANCELLED, captured_events[1]->type());
1152 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
1153 EXPECT_TRUE(IsInNoFingersDownState()); 1103 EXPECT_TRUE(IsInNoFingersDownState());
1154 } 1104 }
1155 1105
1156
1157 TEST_F(TouchExplorationTest, SplitTapLeaveSlop) { 1106 TEST_F(TouchExplorationTest, SplitTapLeaveSlop) {
1158 SwitchTouchExplorationMode(true); 1107 SwitchTouchExplorationMode(true);
1159 gfx::Point first_touch_location(11, 12); 1108 gfx::Point first_touch_location(11, 12);
1160 gfx::Point second_touch_location(33, 34); 1109 gfx::Point second_touch_location(33, 34);
1161 gfx::Point first_move_location( 1110 gfx::Point first_move_location(
1162 first_touch_location.x() + gesture_detector_config_.touch_slop * 3 + 1, 1111 first_touch_location.x() + gesture_detector_config_.touch_slop * 3 + 1,
1163 first_touch_location.y()); 1112 first_touch_location.y());
1164 gfx::Point second_move_location( 1113 gfx::Point second_move_location(
1165 second_touch_location.x() + gesture_detector_config_.touch_slop * 3 + 1, 1114 second_touch_location.x() + gesture_detector_config_.touch_slop * 3 + 1,
1166 second_touch_location.y()); 1115 second_touch_location.y());
1167 1116
1168 // Tap and hold at one location, and get a mouse move event in touch explore. 1117 // Tap and hold at one location, and get a mouse move event in touch explore.
1169 EnterTouchExplorationModeAtLocation(first_touch_location); 1118 EnterTouchExplorationModeAtLocation(first_touch_location);
1170 ClearCapturedEvents(); 1119 ClearCapturedEvents();
1171 1120
1172 // Now tap at a different location for split tap. 1121 // Now tap at a different location for split tap.
1173 ui::TouchEvent split_tap_press( 1122 ui::TouchEvent split_tap_press(
1174 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 1123 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
1175 generator_->Dispatch(&split_tap_press); 1124 generator_->Dispatch(&split_tap_press);
1176 1125
1177 // Move the first finger out of slop and release both fingers. The split 1126 // Move the first finger out of slop and release both fingers. The split
1178 // tap should have been cancelled, so a touch press and touch cancel event 1127 // tap should have been cancelled.
1179 // should go through at the last touch exploration location (the first press).
1180 ui::TouchEvent first_touch_move( 1128 ui::TouchEvent first_touch_move(
1181 ui::ET_TOUCH_MOVED, first_move_location, 0, Now()); 1129 ui::ET_TOUCH_MOVED, first_move_location, 0, Now());
1182 generator_->Dispatch(&first_touch_move); 1130 generator_->Dispatch(&first_touch_move);
1183 ui::TouchEvent first_touch_release( 1131 ui::TouchEvent first_touch_release(
1184 ui::ET_TOUCH_RELEASED, first_move_location, 0, Now()); 1132 ui::ET_TOUCH_RELEASED, first_move_location, 0, Now());
1185 generator_->Dispatch(&first_touch_release); 1133 generator_->Dispatch(&first_touch_release);
1134 LOG(ERROR) << "*** FINAL RELEASE ***";
1186 ui::TouchEvent second_touch_release( 1135 ui::TouchEvent second_touch_release(
1187 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 1136 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
1188 generator_->Dispatch(&second_touch_release); 1137 generator_->Dispatch(&second_touch_release);
1189 1138
1190 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 1139 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1191 ASSERT_EQ(2U, captured_events.size()); 1140 ASSERT_EQ(0U, captured_events.size());
1192 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1193 EXPECT_EQ(first_touch_location, captured_events[0]->location());
1194 EXPECT_EQ(ui::ET_TOUCH_CANCELLED, captured_events[1]->type());
1195 EXPECT_EQ(first_touch_location, captured_events[1]->location());
1196 EXPECT_TRUE(IsInNoFingersDownState()); 1141 EXPECT_TRUE(IsInNoFingersDownState());
1197 1142
1198 // Now do the same, but moving the split tap finger out of slop 1143 // Now do the same, but moving the split tap finger out of slop
1199 EnterTouchExplorationModeAtLocation(first_touch_location); 1144 EnterTouchExplorationModeAtLocation(first_touch_location);
1200 ClearCapturedEvents(); 1145 ClearCapturedEvents();
1201 ui::TouchEvent split_tap_press2( 1146 ui::TouchEvent split_tap_press2(
1202 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 1147 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
1203 generator_->Dispatch(&split_tap_press2); 1148 generator_->Dispatch(&split_tap_press2);
1204 1149
1205 // Move the second finger out of slop and release both fingers. The split 1150 // Move the second finger out of slop and release both fingers. The split
1206 // tap should have been cancelled, so a touch press and touch cancel event 1151 // tap should have been cancelled.
1207 // should go through at the last touch exploration location (the first press).
1208 ui::TouchEvent second_touch_move2( 1152 ui::TouchEvent second_touch_move2(
1209 ui::ET_TOUCH_MOVED, second_move_location, 1, Now()); 1153 ui::ET_TOUCH_MOVED, second_move_location, 1, Now());
1210 generator_->Dispatch(&second_touch_move2); 1154 generator_->Dispatch(&second_touch_move2);
1211 ui::TouchEvent first_touch_release2( 1155 ui::TouchEvent first_touch_release2(
1212 ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now()); 1156 ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now());
1213 generator_->Dispatch(&first_touch_release2); 1157 generator_->Dispatch(&first_touch_release2);
1214 ui::TouchEvent second_touch_release2( 1158 ui::TouchEvent second_touch_release2(
1215 ui::ET_TOUCH_RELEASED, second_move_location, 1, Now()); 1159 ui::ET_TOUCH_RELEASED, second_move_location, 1, Now());
1216 generator_->Dispatch(&second_touch_release2); 1160 generator_->Dispatch(&second_touch_release2);
1217 1161
1218 captured_events = GetCapturedLocatedEvents(); 1162 captured_events = GetCapturedLocatedEvents();
1219 ASSERT_EQ(2U, captured_events.size()); 1163 ASSERT_EQ(0U, captured_events.size());
1220 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1221 EXPECT_EQ(first_touch_location, captured_events[0]->location());
1222 EXPECT_EQ(ui::ET_TOUCH_CANCELLED, captured_events[1]->type());
1223 EXPECT_EQ(first_touch_location, captured_events[1]->location());
1224 EXPECT_TRUE(IsInNoFingersDownState()); 1164 EXPECT_TRUE(IsInNoFingersDownState());
1225 } 1165 }
1226 1166
1227 // Finger must have moved more than slop, faster than the minimum swipe 1167 // Finger must have moved more than slop, faster than the minimum swipe
1228 // velocity, and before the tap timer fires in order to enter 1168 // velocity, and before the tap timer fires in order to enter
1229 // GestureInProgress state. Otherwise, if the tap timer fires before the a 1169 // GestureInProgress state. Otherwise, if the tap timer fires before the a
1230 // gesture is completed, enter touch exploration. 1170 // gesture is completed, enter touch exploration.
1231 TEST_F(TouchExplorationTest, EnterGestureInProgressState) { 1171 TEST_F(TouchExplorationTest, EnterGestureInProgressState) {
1232 SwitchTouchExplorationMode(true); 1172 SwitchTouchExplorationMode(true);
1233 EXPECT_FALSE(IsInTouchToMouseMode()); 1173 EXPECT_FALSE(IsInTouchToMouseMode());
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 generator_->PressTouch(); 1830 generator_->PressTouch();
1891 generator_->MoveTouch(initial_press); 1831 generator_->MoveTouch(initial_press);
1892 generator_->MoveTouch(*point); 1832 generator_->MoveTouch(*point);
1893 generator_->ReleaseTouch(); 1833 generator_->ReleaseTouch();
1894 ASSERT_EQ(1U, delegate_.NumExitScreenSounds()); 1834 ASSERT_EQ(1U, delegate_.NumExitScreenSounds());
1895 delegate_.ResetCountersToZero(); 1835 delegate_.ResetCountersToZero();
1896 } 1836 }
1897 } 1837 }
1898 1838
1899 } // namespace ui 1839 } // namespace ui
OLDNEW
« ui/chromeos/touch_exploration_controller.cc ('K') | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698