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

Side by Side Diff: chrome/browser/chromeos/accessibility/touch_exploration_controller_browsertest.cc

Issue 428643008: Revert of Fix Touch Exploration tests so they don't break eager gesture detection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/chromeos/touch_exploration_controller.h » ('j') | 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 "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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 ui::GestureDetector::Config gesture_detector_config_; 70 ui::GestureDetector::Config gesture_detector_config_;
71 base::SimpleTestTickClock* simulated_clock_; 71 base::SimpleTestTickClock* simulated_clock_;
72 aura::Window* root_window_; 72 aura::Window* root_window_;
73 scoped_ptr<ui::test::TestEventHandler> event_handler_; 73 scoped_ptr<ui::test::TestEventHandler> event_handler_;
74 74
75 private: 75 private:
76 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest); 76 DISALLOW_COPY_AND_ASSIGN(TouchExplorationTest);
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 on/off and confirms that events
80 // aren't modified. 80 // get rewritten when the touch exploration mode is on, and aren't affected
81 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, NoRewritingEventsWhenOff) { 81 // after the touch exploration mode is turned off.
82 SwitchTouchExplorationMode(false); 82 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) {
83 SwitchTouchExplorationMode(true);
83 ui::test::EventGenerator generator(root_window_); 84 ui::test::EventGenerator generator(root_window_);
84 85
85 base::TimeDelta initial_time = Now(); 86 base::TimeDelta initial_time = Now();
86 ui::TouchEvent initial_press( 87 ui::TouchEvent initial_press(
87 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time); 88 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
88 generator.Dispatch(&initial_press); 89 generator.Dispatch(&initial_press);
89 90
90 // Since the touch exploration controller doesn't know if the user is 91 // Since the touch exploration controller doesn't know if the user is
91 // double-tapping or not, touch exploration is only initiated if the 92 // 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 93 // 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 94 // gestures. Here, the touch move event is not important as a move, but
94 // a way to create time advancement. 95 // a way to create time advancement.
95 ui::TouchEvent touch_time_advance(ui::ET_TOUCH_MOVED, 96 ui::TouchEvent touch_time_advance(ui::ET_TOUCH_MOVED,
96 gfx::Point(100, 200), 97 gfx::Point(100, 200),
97 1, 98 1,
98 initial_time + 99 initial_time +
99 gesture_detector_config_.double_tap_timeout + 100 gesture_detector_config_.double_tap_timeout +
100 base::TimeDelta::FromMilliseconds(1)); 101 base::TimeDelta::FromMilliseconds(1));
101 generator.Dispatch(&touch_time_advance); 102 generator.Dispatch(&touch_time_advance);
102 103
103 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. 104 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED.
104 EXPECT_EQ(0, event_handler_->num_mouse_events());
105 EXPECT_EQ(2, event_handler_->num_touch_events());
106 event_handler_->Reset();
107
108 generator.MoveTouchId(gfx::Point(11, 12), 1);
109 EXPECT_EQ(0, event_handler_->num_mouse_events());
110 EXPECT_EQ(1, event_handler_->num_touch_events());
111 event_handler_->Reset();
112
113 initial_time = Now();
114 ui::TouchEvent second_initial_press(
115 ui::ET_TOUCH_PRESSED, gfx::Point(500, 600), 2, initial_time);
116 generator.Dispatch(&second_initial_press);
117 ui::TouchEvent second_touch_time_advance(
118 ui::ET_TOUCH_MOVED,
119 gfx::Point(500, 600),
120 2,
121 initial_time + gesture_detector_config_.double_tap_timeout +
122 base::TimeDelta::FromMilliseconds(1));
123 generator.Dispatch(&second_touch_time_advance);
124 EXPECT_EQ(0, event_handler_->num_mouse_events());
125 EXPECT_EQ(2, event_handler_->num_touch_events());
126 }
127
128 // This test turns the touch exploration mode on and confirms that events get
129 // rewritten.
130 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, RewritesEventsWhenOn) {
131 SwitchTouchExplorationMode(true);
132 ui::test::EventGenerator generator(root_window_);
133
134 base::TimeDelta initial_time = Now();
135 ui::TouchEvent initial_press(
136 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
137 generator.Dispatch(&initial_press);
138
139 // Since the touch exploration controller doesn't know if the user is
140 // double-tapping or not, touch exploration is only initiated if the
141 // 300 ms has elapsed and the finger does not move fast enough to begin
142 // gestures. Here, the touch move event is not important as a move, but
143 // a way to create time advancement.
144 ui::TouchEvent touch_time_advance(ui::ET_TOUCH_MOVED,
145 gfx::Point(100, 200),
146 1,
147 initial_time +
148 gesture_detector_config_.double_tap_timeout +
149 base::TimeDelta::FromMilliseconds(1));
150 generator.Dispatch(&touch_time_advance);
151
152 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED.
153 EXPECT_GT(event_handler_->num_mouse_events(), 0); 105 EXPECT_GT(event_handler_->num_mouse_events(), 0);
154 EXPECT_EQ(0, event_handler_->num_touch_events()); 106 EXPECT_EQ(0, event_handler_->num_touch_events());
155 event_handler_->Reset(); 107 event_handler_->Reset();
156 108
109 SwitchTouchExplorationMode(false);
110 generator.MoveTouchId(gfx::Point(11, 12), 1);
111 EXPECT_EQ(0, event_handler_->num_mouse_events());
112 EXPECT_EQ(1, event_handler_->num_touch_events());
113 event_handler_->Reset();
114
115 SwitchTouchExplorationMode(true);
157 initial_time = Now(); 116 initial_time = Now();
158 ui::TouchEvent second_initial_press( 117 ui::TouchEvent second_initial_press(
159 ui::ET_TOUCH_PRESSED, gfx::Point(500, 600), 2, initial_time); 118 ui::ET_TOUCH_PRESSED, gfx::Point(500, 600), 2, initial_time);
160 generator.Dispatch(&second_initial_press); 119 generator.Dispatch(&second_initial_press);
161 ui::TouchEvent second_touch_time_advance( 120 ui::TouchEvent second_touch_time_advance(
162 ui::ET_TOUCH_MOVED, 121 ui::ET_TOUCH_MOVED,
163 gfx::Point(500, 600), 122 gfx::Point(500, 600),
164 2, 123 2,
165 initial_time + gesture_detector_config_.double_tap_timeout + 124 initial_time + gesture_detector_config_.double_tap_timeout +
166 base::TimeDelta::FromMilliseconds(1)); 125 base::TimeDelta::FromMilliseconds(1));
167 generator.Dispatch(&second_touch_time_advance); 126 generator.Dispatch(&second_touch_time_advance);
168 EXPECT_GT(event_handler_->num_mouse_events(), 0); 127 EXPECT_GT(event_handler_->num_mouse_events(), 0);
169 EXPECT_EQ(1, event_handler_->num_touch_events()); 128 EXPECT_EQ(0, event_handler_->num_touch_events());
170 } 129 }
171 130
172 // This test makes sure that after the user clicks with split tap, 131 // This test makes sure that after the user clicks with split tap,
173 // they continue to touch exploration mode if the original touch exploration 132 // they continue to touch exploration mode if the original touch exploration
174 // finger is still on the screen. 133 // finger is still on the screen.
175 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) { 134 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) {
176 SwitchTouchExplorationMode(true); 135 SwitchTouchExplorationMode(true);
177 ui::test::EventGenerator generator(root_window_); 136 ui::test::EventGenerator generator(root_window_);
178 aura::client::CursorClient* cursor_client = 137 aura::client::CursorClient* cursor_client =
179 aura::client::GetCursorClient(root_window_); 138 aura::client::GetCursorClient(root_window_);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 180
222 // Continuing to move the touch exploration finger should send more mouse 181 // Continuing to move the touch exploration finger should send more mouse
223 // events. 182 // events.
224 generator.MoveTouchId(gfx::Point(509, 609), 1); 183 generator.MoveTouchId(gfx::Point(509, 609), 1);
225 EXPECT_EQ(0, event_handler_->num_touch_events()); 184 EXPECT_EQ(0, event_handler_->num_touch_events());
226 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); 185 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
227 EXPECT_FALSE(cursor_client->IsCursorVisible()); 186 EXPECT_FALSE(cursor_client->IsCursorVisible());
228 } 187 }
229 188
230 } // namespace ui 189 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/chromeos/touch_exploration_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698