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

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: Add TODO for second display 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
« no previous file with comments | « ui/chromeos/touch_exploration_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 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 EXPECT_TRUE(IsInNoFingersDownState()); 1045 EXPECT_TRUE(IsInNoFingersDownState());
999 1046
1000 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 1047 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1001 ASSERT_EQ(2U, captured_events.size()); 1048 ASSERT_EQ(2U, captured_events.size());
1002 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 1049 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1003 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); 1050 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
1004 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 1051 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
1005 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 1052 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
1006 } 1053 }
1007 1054
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) { 1055 TEST_F(TouchExplorationTest, SplitTapMultiFinger) {
1106 SwitchTouchExplorationMode(true); 1056 SwitchTouchExplorationMode(true);
1107 gfx::Point initial_touch_location(11, 12); 1057 gfx::Point initial_touch_location(11, 12);
1108 gfx::Point second_touch_location(33, 34); 1058 gfx::Point second_touch_location(33, 34);
1109 gfx::Point third_touch_location(16, 17); 1059 gfx::Point third_touch_location(16, 17);
1110 1060
1111 // Tap and hold at one location, and get a mouse move event in touch explore. 1061 // Tap and hold at one location, and get a mouse move event in touch explore.
1112 EnterTouchExplorationModeAtLocation(initial_touch_location); 1062 EnterTouchExplorationModeAtLocation(initial_touch_location);
1113 1063
1114 std::vector<ui::LocatedEvent*> events = 1064 std::vector<ui::LocatedEvent*> events =
1115 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); 1065 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
1116 ASSERT_EQ(1U, events.size()); 1066 ASSERT_EQ(1U, events.size());
1117 1067
1118 EXPECT_EQ(initial_touch_location, events[0]->location()); 1068 EXPECT_EQ(initial_touch_location, events[0]->location());
1119 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); 1069 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
1120 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); 1070 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
1121 ClearCapturedEvents(); 1071 ClearCapturedEvents();
1122 1072
1123 // Now tap at a different location and hold for long press. 1073 // Now tap at a different location
1124 ui::TouchEvent split_tap_press( 1074 ui::TouchEvent split_tap_press(
1125 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 1075 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
1126 generator_->Dispatch(&split_tap_press); 1076 generator_->Dispatch(&split_tap_press);
1127 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); 1077 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
1128 1078
1129 // Placing a third finger on the screen should cancel the initial press and 1079 // Placing a third finger on the screen should cancel the split tap and
1130 // enter the wait state. 1080 // enter the wait state.
1131 ui::TouchEvent third_press( 1081 ui::TouchEvent third_press(
1132 ui::ET_TOUCH_PRESSED, third_touch_location, 2, Now()); 1082 ui::ET_TOUCH_PRESSED, third_touch_location, 2, Now());
1133 generator_->Dispatch(&third_press); 1083 generator_->Dispatch(&third_press);
1134 1084
1135 // When all three fingers are released, the only events captured should be a 1085 // When all three fingers are released, no events should be captured.
1136 // press and touch cancel. All fingers should then be up. 1086 // All fingers should then be up.
1137 ui::TouchEvent touch_explore_release( 1087 ui::TouchEvent touch_explore_release(
1138 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); 1088 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now());
1139 generator_->Dispatch(&touch_explore_release); 1089 generator_->Dispatch(&touch_explore_release);
1140 ui::TouchEvent split_tap_release( 1090 ui::TouchEvent split_tap_release(
1141 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 1091 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
1142 generator_->Dispatch(&split_tap_release); 1092 generator_->Dispatch(&split_tap_release);
1143 ui::TouchEvent third_tap_release( 1093 ui::TouchEvent third_tap_release(
1144 ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now()); 1094 ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now());
1145 generator_->Dispatch(&third_tap_release); 1095 generator_->Dispatch(&third_tap_release);
1146 1096
1147 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 1097 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1148 ASSERT_EQ(2U, captured_events.size()); 1098 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()); 1099 EXPECT_TRUE(IsInNoFingersDownState());
1154 } 1100 }
1155 1101
1156
1157 TEST_F(TouchExplorationTest, SplitTapLeaveSlop) { 1102 TEST_F(TouchExplorationTest, SplitTapLeaveSlop) {
1158 SwitchTouchExplorationMode(true); 1103 SwitchTouchExplorationMode(true);
1159 gfx::Point first_touch_location(11, 12); 1104 gfx::Point first_touch_location(11, 12);
1160 gfx::Point second_touch_location(33, 34); 1105 gfx::Point second_touch_location(33, 34);
1161 gfx::Point first_move_location( 1106 gfx::Point first_move_location(
1162 first_touch_location.x() + gesture_detector_config_.touch_slop * 3 + 1, 1107 first_touch_location.x() + gesture_detector_config_.touch_slop * 3 + 1,
1163 first_touch_location.y()); 1108 first_touch_location.y());
1164 gfx::Point second_move_location( 1109 gfx::Point second_move_location(
1165 second_touch_location.x() + gesture_detector_config_.touch_slop * 3 + 1, 1110 second_touch_location.x() + gesture_detector_config_.touch_slop * 3 + 1,
1166 second_touch_location.y()); 1111 second_touch_location.y());
1167 1112
1168 // Tap and hold at one location, and get a mouse move event in touch explore. 1113 // Tap and hold at one location, and get a mouse move event in touch explore.
1169 EnterTouchExplorationModeAtLocation(first_touch_location); 1114 EnterTouchExplorationModeAtLocation(first_touch_location);
1170 ClearCapturedEvents(); 1115 ClearCapturedEvents();
1171 1116
1172 // Now tap at a different location for split tap. 1117 // Now tap at a different location for split tap.
1173 ui::TouchEvent split_tap_press( 1118 ui::TouchEvent split_tap_press(
1174 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 1119 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
1175 generator_->Dispatch(&split_tap_press); 1120 generator_->Dispatch(&split_tap_press);
1176 1121
1177 // Move the first finger out of slop and release both fingers. The split 1122 // 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 1123 // tap should have been cancelled.
1179 // should go through at the last touch exploration location (the first press).
1180 ui::TouchEvent first_touch_move( 1124 ui::TouchEvent first_touch_move(
1181 ui::ET_TOUCH_MOVED, first_move_location, 0, Now()); 1125 ui::ET_TOUCH_MOVED, first_move_location, 0, Now());
1182 generator_->Dispatch(&first_touch_move); 1126 generator_->Dispatch(&first_touch_move);
1183 ui::TouchEvent first_touch_release( 1127 ui::TouchEvent first_touch_release(
1184 ui::ET_TOUCH_RELEASED, first_move_location, 0, Now()); 1128 ui::ET_TOUCH_RELEASED, first_move_location, 0, Now());
1185 generator_->Dispatch(&first_touch_release); 1129 generator_->Dispatch(&first_touch_release);
1186 ui::TouchEvent second_touch_release( 1130 ui::TouchEvent second_touch_release(
1187 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 1131 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
1188 generator_->Dispatch(&second_touch_release); 1132 generator_->Dispatch(&second_touch_release);
1189 1133
1190 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 1134 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1191 ASSERT_EQ(2U, captured_events.size()); 1135 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()); 1136 EXPECT_TRUE(IsInNoFingersDownState());
1197 1137
1198 // Now do the same, but moving the split tap finger out of slop 1138 // Now do the same, but moving the split tap finger out of slop
1199 EnterTouchExplorationModeAtLocation(first_touch_location); 1139 EnterTouchExplorationModeAtLocation(first_touch_location);
1200 ClearCapturedEvents(); 1140 ClearCapturedEvents();
1201 ui::TouchEvent split_tap_press2( 1141 ui::TouchEvent split_tap_press2(
1202 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 1142 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
1203 generator_->Dispatch(&split_tap_press2); 1143 generator_->Dispatch(&split_tap_press2);
1204 1144
1205 // Move the second finger out of slop and release both fingers. The split 1145 // 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 1146 // tap should have been cancelled.
1207 // should go through at the last touch exploration location (the first press).
1208 ui::TouchEvent second_touch_move2( 1147 ui::TouchEvent second_touch_move2(
1209 ui::ET_TOUCH_MOVED, second_move_location, 1, Now()); 1148 ui::ET_TOUCH_MOVED, second_move_location, 1, Now());
1210 generator_->Dispatch(&second_touch_move2); 1149 generator_->Dispatch(&second_touch_move2);
1211 ui::TouchEvent first_touch_release2( 1150 ui::TouchEvent first_touch_release2(
1212 ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now()); 1151 ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now());
1213 generator_->Dispatch(&first_touch_release2); 1152 generator_->Dispatch(&first_touch_release2);
1214 ui::TouchEvent second_touch_release2( 1153 ui::TouchEvent second_touch_release2(
1215 ui::ET_TOUCH_RELEASED, second_move_location, 1, Now()); 1154 ui::ET_TOUCH_RELEASED, second_move_location, 1, Now());
1216 generator_->Dispatch(&second_touch_release2); 1155 generator_->Dispatch(&second_touch_release2);
1217 1156
1218 captured_events = GetCapturedLocatedEvents(); 1157 captured_events = GetCapturedLocatedEvents();
1219 ASSERT_EQ(2U, captured_events.size()); 1158 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()); 1159 EXPECT_TRUE(IsInNoFingersDownState());
1225 } 1160 }
1226 1161
1227 // Finger must have moved more than slop, faster than the minimum swipe 1162 // Finger must have moved more than slop, faster than the minimum swipe
1228 // velocity, and before the tap timer fires in order to enter 1163 // velocity, and before the tap timer fires in order to enter
1229 // GestureInProgress state. Otherwise, if the tap timer fires before the a 1164 // GestureInProgress state. Otherwise, if the tap timer fires before the a
1230 // gesture is completed, enter touch exploration. 1165 // gesture is completed, enter touch exploration.
1231 TEST_F(TouchExplorationTest, EnterGestureInProgressState) { 1166 TEST_F(TouchExplorationTest, EnterGestureInProgressState) {
1232 SwitchTouchExplorationMode(true); 1167 SwitchTouchExplorationMode(true);
1233 EXPECT_FALSE(IsInTouchToMouseMode()); 1168 EXPECT_FALSE(IsInTouchToMouseMode());
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 generator_->PressTouch(); 1825 generator_->PressTouch();
1891 generator_->MoveTouch(initial_press); 1826 generator_->MoveTouch(initial_press);
1892 generator_->MoveTouch(*point); 1827 generator_->MoveTouch(*point);
1893 generator_->ReleaseTouch(); 1828 generator_->ReleaseTouch();
1894 ASSERT_EQ(1U, delegate_.NumExitScreenSounds()); 1829 ASSERT_EQ(1U, delegate_.NumExitScreenSounds());
1895 delegate_.ResetCountersToZero(); 1830 delegate_.ResetCountersToZero();
1896 } 1831 }
1897 } 1832 }
1898 1833
1899 } // namespace ui 1834 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698