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

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

Issue 359453003: Added accurate TouchToMouseMode testing to SplitTap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 5 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
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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
17 #include "ui/aura/client/cursor_client.h"
17 #include "ui/aura/test/event_generator.h" 18 #include "ui/aura/test/event_generator.h"
18 #include "ui/aura/window_tree_host.h" 19 #include "ui/aura/window_tree_host.h"
19 #include "ui/compositor/compositor.h" 20 #include "ui/compositor/compositor.h"
20 #include "ui/compositor/test/draw_waiter_for_test.h" 21 #include "ui/compositor/test/draw_waiter_for_test.h"
21 #include "ui/events/event.h" 22 #include "ui/events/event.h"
22 #include "ui/events/event_utils.h" 23 #include "ui/events/event_utils.h"
23 #include "ui/events/test/test_event_handler.h" 24 #include "ui/events/test/test_event_handler.h"
24 25
25 namespace ui { 26 namespace ui {
26 27
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); 69 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow();
69 scoped_ptr<ui::test::TestEventHandler> 70 scoped_ptr<ui::test::TestEventHandler>
70 event_handler(new ui::test::TestEventHandler()); 71 event_handler(new ui::test::TestEventHandler());
71 root_window->AddPreTargetHandler(event_handler.get()); 72 root_window->AddPreTargetHandler(event_handler.get());
72 SwitchTouchExplorationMode(true); 73 SwitchTouchExplorationMode(true);
73 aura::test::EventGenerator generator(root_window); 74 aura::test::EventGenerator generator(root_window);
74 75
75 base::TimeDelta initial_time = Now(); 76 base::TimeDelta initial_time = Now();
76 ui::TouchEvent initial_press( 77 ui::TouchEvent initial_press(
77 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time); 78 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
79 generator.Dispatch(&initial_press);
80
81 // Since the touch exploration controller doesn't know if the user is
82 // double-tapping or not, touch exploration is only initiated if the
83 // user moves more than 8 pixels away from the initial location (the "slop"),
84 // or after 300 ms has elapsed if the finger does not move fast enough.
78 float delta_time = 85 float delta_time =
79 (initial_press.location() - gfx::Point(109,209)).Length() / 86 (initial_press.location() - gfx::Point(109, 209)).Length() /
80 gesture_detector_config_.minimum_swipe_velocity; 87 gesture_detector_config_.minimum_swipe_velocity;
81 ui::TouchEvent touch_move( 88 ui::TouchEvent touch_move(
82 ui::ET_TOUCH_MOVED, 89 ui::ET_TOUCH_MOVED,
83 gfx::Point(109, 209), 90 gfx::Point(109, 209),
84 1, 91 1,
85 initial_time + base::TimeDelta::FromSecondsD(delta_time)); 92 initial_time + base::TimeDelta::FromSecondsD(delta_time));
86
87 generator.Dispatch(&initial_press);
88
89 // Since the touch exploration controller doesn't know if the user is
90 // double-tapping or not, touch exploration is only initiated if the
91 // user moves more than 8 pixels away from the initial location (the "slop"),
92 // or after 300 ms has elapsed if the finger does not move fast enough.
93 generator.Dispatch(&touch_move); 93 generator.Dispatch(&touch_move);
94 94
95 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. 95 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED.
96 EXPECT_GT(event_handler->num_mouse_events(), 0); 96 EXPECT_GT(event_handler->num_mouse_events(), 0);
97 EXPECT_EQ(0, event_handler->num_touch_events()); 97 EXPECT_EQ(0, event_handler->num_touch_events());
98 event_handler->Reset(); 98 event_handler->Reset();
99 99
100 SwitchTouchExplorationMode(false); 100 SwitchTouchExplorationMode(false);
101 generator.MoveTouchId(gfx::Point(11, 12), 1); 101 generator.MoveTouchId(gfx::Point(11, 12), 1);
102 EXPECT_EQ(0, event_handler->num_mouse_events()); 102 EXPECT_EQ(0, event_handler->num_mouse_events());
(...skipping 15 matching lines...) Expand all
118 118
119 generator.Dispatch(&second_initial_press); 119 generator.Dispatch(&second_initial_press);
120 generator.Dispatch(&second_move); 120 generator.Dispatch(&second_move);
121 EXPECT_GT(event_handler->num_mouse_events(), 0); 121 EXPECT_GT(event_handler->num_mouse_events(), 0);
122 EXPECT_EQ(0, event_handler->num_touch_events()); 122 EXPECT_EQ(0, event_handler->num_touch_events());
123 123
124 SwitchTouchExplorationMode(false); 124 SwitchTouchExplorationMode(false);
125 root_window->RemovePreTargetHandler(event_handler.get()); 125 root_window->RemovePreTargetHandler(event_handler.get());
126 } 126 }
127 127
128 // This test makes sure that after the user clicks with split tap,
129 // they continue to touch exploration mode if the original touch exploration
130 // finger is still on the screen.
131 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) {
132 content::WebContents* web_contents =
133 browser()->tab_strip_model()->GetActiveWebContents();
134 content::WaitForResizeComplete(web_contents);
mfomitchev 2014/07/09 13:26:01 Can you please put this setup logic into SetupOnMa
evy 2014/07/09 18:20:19 Done.
135 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow();
136 scoped_ptr<ui::test::TestEventHandler>
137 event_handler(new ui::test::TestEventHandler());
138 root_window->AddPreTargetHandler(event_handler.get());
139 SwitchTouchExplorationMode(true);
140 aura::test::EventGenerator generator(root_window);
141 aura::client::CursorClient* cursor_client =
142 aura::client::GetCursorClient(root_window);
143
144 // Mouse events should show the cursor.
145 generator.MoveMouseTo(gfx::Point(30, 31));
146 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
147 EXPECT_TRUE(cursor_client->IsCursorVisible());
148
149 // After a press the cursor should be shown after immediately after press,
mfomitchev 2014/07/09 13:26:02 This comment needs fixing
evy 2014/07/09 18:20:19 Done.
150 // hidden after move.
151 base::TimeDelta initial_time = Now();
152 ui::TouchEvent initial_press(
153 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
154 generator.Dispatch(&initial_press);
155 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
156 EXPECT_TRUE(cursor_client->IsCursorVisible());
157
158 // Initiate touch explore by moving out of the slop slowly.
159 float delta_time =
160 (initial_press.location() - gfx::Point(109, 209)).Length() /
mfomitchev 2014/07/09 13:26:01 If you want to move slower that min swipe velocity
evy 2014/07/09 18:20:19 I changed this to wait for the timeout instead. I
161 gesture_detector_config_.minimum_swipe_velocity;
162 ui::TouchEvent touch_move(
163 ui::ET_TOUCH_MOVED,
164 gfx::Point(109, 209),
165 1,
166 initial_time + base::TimeDelta::FromSecondsD(delta_time));
167 generator.Dispatch(&touch_move);
168 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
169 EXPECT_FALSE(cursor_client->IsCursorVisible());
170 event_handler->Reset();
171
172 // Press and release with a second finger for split tap. This should send
173 // touch press and release events which should send a click press and release.
174 // Once the press is passed through, mouse events should be disabled.
175 // Mouse events are reenabled after the release.
176 generator.set_current_location(gfx::Point(102, 202));
177 generator.PressTouchId(2);
178 EXPECT_FALSE(cursor_client->IsMouseEventsEnabled());
179 EXPECT_FALSE(cursor_client->IsCursorVisible());
180 generator.ReleaseTouchId(2);
181 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
182 EXPECT_FALSE(cursor_client->IsCursorVisible());
183 EXPECT_EQ(2, event_handler->num_touch_events());
184 event_handler->Reset();
185
186 // Continuing to move the touch exploration finger should send more mouse
187 // events.
188 generator.MoveTouchId(gfx::Point(509, 609), 1);
189 EXPECT_EQ(0, event_handler->num_touch_events());
190 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
191 EXPECT_FALSE(cursor_client->IsCursorVisible());
192
193 SwitchTouchExplorationMode(false);
194 root_window->RemovePreTargetHandler(event_handler.get());
195 }
196
128 } // namespace ui 197 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/chromeos/touch_exploration_controller.cc » ('j') | ui/chromeos/touch_exploration_controller_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698