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

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

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

Powered by Google App Engine
This is Rietveld 408576698