OLD | NEW |
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 "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 }; | 77 }; |
78 | 78 |
79 // This test turns the touch exploration mode off and confirms that events | 79 // This test turns the touch exploration mode off and confirms that events |
80 // aren't modified. | 80 // aren't modified. |
81 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, NoRewritingEventsWhenOff) { | 81 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, NoRewritingEventsWhenOff) { |
82 SwitchTouchExplorationMode(false); | 82 SwitchTouchExplorationMode(false); |
83 ui::test::EventGenerator generator(root_window_); | 83 ui::test::EventGenerator generator(root_window_); |
84 | 84 |
85 base::TimeDelta initial_time = Now(); | 85 base::TimeDelta initial_time = Now(); |
86 ui::TouchEvent initial_press( | 86 ui::TouchEvent initial_press( |
87 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time); | 87 ui::ET_TOUCH_PRESSED, gfx::Point(99, 200), 1, initial_time); |
88 generator.Dispatch(&initial_press); | 88 generator.Dispatch(&initial_press); |
89 | 89 |
90 // Since the touch exploration controller doesn't know if the user is | 90 // Since the touch exploration controller doesn't know if the user is |
91 // double-tapping or not, touch exploration is only initiated if the | 91 // double-tapping or not, touch exploration is only initiated if the |
92 // 300 ms has elapsed and the finger does not move fast enough to begin | 92 // 300 ms has elapsed and the finger does not move fast enough to begin |
93 // gestures. Here, the touch move event is not important as a move, but | 93 // gestures. Here, the touch move event is not important as a move, but |
94 // a way to create time advancement. | 94 // a way to create time advancement. |
95 ui::TouchEvent touch_time_advance(ui::ET_TOUCH_MOVED, | 95 ui::TouchEvent touch_time_advance(ui::ET_TOUCH_MOVED, |
96 gfx::Point(100, 200), | 96 gfx::Point(100, 200), |
97 1, | 97 1, |
98 initial_time + | 98 initial_time + |
99 gesture_detector_config_.double_tap_timeout + | 99 gesture_detector_config_.double_tap_timeout + |
100 base::TimeDelta::FromMilliseconds(1)); | 100 base::TimeDelta::FromMilliseconds(1)); |
101 generator.Dispatch(&touch_time_advance); | 101 generator.Dispatch(&touch_time_advance); |
102 | 102 |
103 EXPECT_EQ(0, event_handler_->num_mouse_events()); | 103 EXPECT_EQ(0, event_handler_->num_mouse_events()); |
104 EXPECT_EQ(2, event_handler_->num_touch_events()); | 104 EXPECT_EQ(2, event_handler_->num_touch_events()); |
105 event_handler_->Reset(); | 105 event_handler_->Reset(); |
106 | 106 |
107 generator.MoveTouchId(gfx::Point(11, 12), 1); | 107 generator.MoveTouchId(gfx::Point(11, 12), 1); |
108 EXPECT_EQ(0, event_handler_->num_mouse_events()); | 108 EXPECT_EQ(0, event_handler_->num_mouse_events()); |
109 EXPECT_EQ(1, event_handler_->num_touch_events()); | 109 EXPECT_EQ(1, event_handler_->num_touch_events()); |
110 event_handler_->Reset(); | 110 event_handler_->Reset(); |
111 | 111 |
112 initial_time = Now(); | 112 initial_time = Now(); |
113 ui::TouchEvent second_initial_press( | 113 ui::TouchEvent second_initial_press( |
114 ui::ET_TOUCH_PRESSED, gfx::Point(500, 600), 2, initial_time); | 114 ui::ET_TOUCH_PRESSED, gfx::Point(499, 600), 2, initial_time); |
115 generator.Dispatch(&second_initial_press); | 115 generator.Dispatch(&second_initial_press); |
116 ui::TouchEvent second_touch_time_advance( | 116 ui::TouchEvent second_touch_time_advance( |
117 ui::ET_TOUCH_MOVED, | 117 ui::ET_TOUCH_MOVED, |
118 gfx::Point(500, 600), | 118 gfx::Point(500, 600), |
119 2, | 119 2, |
120 initial_time + gesture_detector_config_.double_tap_timeout + | 120 initial_time + gesture_detector_config_.double_tap_timeout + |
121 base::TimeDelta::FromMilliseconds(1)); | 121 base::TimeDelta::FromMilliseconds(1)); |
122 generator.Dispatch(&second_touch_time_advance); | 122 generator.Dispatch(&second_touch_time_advance); |
123 EXPECT_EQ(0, event_handler_->num_mouse_events()); | 123 EXPECT_EQ(0, event_handler_->num_mouse_events()); |
124 EXPECT_EQ(2, event_handler_->num_touch_events()); | 124 EXPECT_EQ(2, event_handler_->num_touch_events()); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 // Continuing to move the touch exploration finger should send more mouse | 236 // Continuing to move the touch exploration finger should send more mouse |
237 // events. | 237 // events. |
238 generator.MoveTouchId(gfx::Point(509, 609), 1); | 238 generator.MoveTouchId(gfx::Point(509, 609), 1); |
239 EXPECT_EQ(0, event_handler_->num_touch_events()); | 239 EXPECT_EQ(0, event_handler_->num_touch_events()); |
240 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | 240 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
241 EXPECT_FALSE(cursor_client->IsCursorVisible()); | 241 EXPECT_FALSE(cursor_client->IsCursorVisible()); |
242 } | 242 } |
243 | 243 |
244 } // namespace ui | 244 } // namespace ui |
OLD | NEW |