Index: chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
diff --git a/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc b/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
index 1d0f2aaddd2731735a441e487150a683981f50e6..74cd1a0f2374d5a4925a686818e0e6163cdf53aa 100644 |
--- a/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
+++ b/chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc |
@@ -76,11 +76,10 @@ private: |
DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest); |
}; |
-// This test turns the touch exploration mode on/off and confirms that events |
-// get rewritten when the touch exploration mode is on, and aren't affected |
-// after the touch exploration mode is turned off. |
-IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { |
- SwitchTouchExplorationMode(true); |
+// This test turns the touch exploration mode off and confirms that events |
+// aren't modified. |
+IN_PROC_BROWSER_TEST_F(TouchExplorationTest, NoRewritingEventsWhenOff) { |
+ SwitchTouchExplorationMode(false); |
ui::test::EventGenerator generator(root_window_); |
base::TimeDelta initial_time = Now(); |
@@ -102,17 +101,15 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { |
generator.Dispatch(&touch_time_advance); |
// Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. |
- EXPECT_GT(event_handler_->num_mouse_events(), 0); |
- EXPECT_EQ(0, event_handler_->num_touch_events()); |
+ EXPECT_EQ(0, event_handler_->num_mouse_events()); |
+ EXPECT_EQ(2, event_handler_->num_touch_events()); |
event_handler_->Reset(); |
- SwitchTouchExplorationMode(false); |
generator.MoveTouchId(gfx::Point(11, 12), 1); |
EXPECT_EQ(0, event_handler_->num_mouse_events()); |
EXPECT_EQ(1, event_handler_->num_touch_events()); |
event_handler_->Reset(); |
- SwitchTouchExplorationMode(true); |
initial_time = Now(); |
ui::TouchEvent second_initial_press( |
ui::ET_TOUCH_PRESSED, gfx::Point(500, 600), 2, initial_time); |
@@ -124,8 +121,52 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { |
initial_time + gesture_detector_config_.double_tap_timeout + |
base::TimeDelta::FromMilliseconds(1)); |
generator.Dispatch(&second_touch_time_advance); |
+ EXPECT_EQ(0, event_handler_->num_mouse_events()); |
+ EXPECT_EQ(2, event_handler_->num_touch_events()); |
+} |
+ |
+// This test turns the touch exploration mode on and confirms that events get |
+// rewritten. |
+IN_PROC_BROWSER_TEST_F(TouchExplorationTest, RewritesEventsWhenOn) { |
+ SwitchTouchExplorationMode(true); |
+ ui::test::EventGenerator generator(root_window_); |
+ |
+ base::TimeDelta initial_time = Now(); |
+ ui::TouchEvent initial_press( |
+ ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time); |
+ generator.Dispatch(&initial_press); |
+ |
+ // Since the touch exploration controller doesn't know if the user is |
+ // double-tapping or not, touch exploration is only initiated if the |
+ // 300 ms has elapsed and the finger does not move fast enough to begin |
+ // gestures. Here, the touch move event is not important as a move, but |
+ // a way to create time advancement. |
+ ui::TouchEvent touch_time_advance(ui::ET_TOUCH_MOVED, |
+ gfx::Point(100, 200), |
+ 1, |
+ initial_time + |
+ gesture_detector_config_.double_tap_timeout + |
+ base::TimeDelta::FromMilliseconds(1)); |
+ generator.Dispatch(&touch_time_advance); |
+ |
+ // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. |
EXPECT_GT(event_handler_->num_mouse_events(), 0); |
EXPECT_EQ(0, event_handler_->num_touch_events()); |
+ event_handler_->Reset(); |
+ |
+ initial_time = Now(); |
+ ui::TouchEvent second_initial_press( |
+ ui::ET_TOUCH_PRESSED, gfx::Point(500, 600), 2, initial_time); |
+ generator.Dispatch(&second_initial_press); |
+ ui::TouchEvent second_touch_time_advance( |
+ ui::ET_TOUCH_MOVED, |
+ gfx::Point(500, 600), |
+ 2, |
+ initial_time + gesture_detector_config_.double_tap_timeout + |
+ base::TimeDelta::FromMilliseconds(1)); |
+ generator.Dispatch(&second_touch_time_advance); |
+ EXPECT_GT(event_handler_->num_mouse_events(), 0); |
+ EXPECT_EQ(1, event_handler_->num_touch_events()); |
} |
// This test makes sure that after the user clicks with split tap, |