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

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

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for added files 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 | 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/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/client/cursor_client.h"
18 #include "ui/aura/test/event_generator.h"
19 #include "ui/aura/window_tree_host.h" 18 #include "ui/aura/window_tree_host.h"
20 #include "ui/compositor/compositor.h" 19 #include "ui/compositor/compositor.h"
21 #include "ui/compositor/test/draw_waiter_for_test.h" 20 #include "ui/compositor/test/draw_waiter_for_test.h"
22 #include "ui/events/event.h" 21 #include "ui/events/event.h"
23 #include "ui/events/event_utils.h" 22 #include "ui/events/event_utils.h"
23 #include "ui/events/test/event_generator.h"
24 #include "ui/events/test/test_event_handler.h" 24 #include "ui/events/test/test_event_handler.h"
25 25
26 namespace ui { 26 namespace ui {
27 27
28 class TouchExplorationTest : public InProcessBrowserTest { 28 class TouchExplorationTest : public InProcessBrowserTest {
29 public: 29 public:
30 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { 30 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) {
31 // Tests fail if time is ever 0. 31 // Tests fail if time is ever 0.
32 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 32 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
33 } 33 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 on/off and confirms that events 79 // This test turns the touch exploration mode on/off and confirms that events
80 // get rewritten when the touch exploration mode is on, and aren't affected 80 // get rewritten when the touch exploration mode is on, and aren't affected
81 // after the touch exploration mode is turned off. 81 // after the touch exploration mode is turned off.
82 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { 82 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) {
83 SwitchTouchExplorationMode(true); 83 SwitchTouchExplorationMode(true);
84 aura::test::EventGenerator generator(root_window_); 84 ui::test::EventGenerator generator(root_window_);
85 85
86 base::TimeDelta initial_time = Now(); 86 base::TimeDelta initial_time = Now();
87 ui::TouchEvent initial_press( 87 ui::TouchEvent initial_press(
88 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time); 88 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
89 generator.Dispatch(&initial_press); 89 generator.Dispatch(&initial_press);
90 90
91 // 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
92 // double-tapping or not, touch exploration is only initiated if the 92 // double-tapping or not, touch exploration is only initiated if the
93 // 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
94 // 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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 generator.Dispatch(&second_touch_time_advance); 126 generator.Dispatch(&second_touch_time_advance);
127 EXPECT_GT(event_handler_->num_mouse_events(), 0); 127 EXPECT_GT(event_handler_->num_mouse_events(), 0);
128 EXPECT_EQ(0, event_handler_->num_touch_events()); 128 EXPECT_EQ(0, event_handler_->num_touch_events());
129 } 129 }
130 130
131 // 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,
132 // they continue to touch exploration mode if the original touch exploration 132 // they continue to touch exploration mode if the original touch exploration
133 // finger is still on the screen. 133 // finger is still on the screen.
134 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) { 134 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) {
135 SwitchTouchExplorationMode(true); 135 SwitchTouchExplorationMode(true);
136 aura::test::EventGenerator generator(root_window_); 136 ui::test::EventGenerator generator(root_window_);
137 aura::client::CursorClient* cursor_client = 137 aura::client::CursorClient* cursor_client =
138 aura::client::GetCursorClient(root_window_); 138 aura::client::GetCursorClient(root_window_);
139 139
140 // Mouse events should show the cursor. 140 // Mouse events should show the cursor.
141 generator.MoveMouseTo(gfx::Point(30, 31)); 141 generator.MoveMouseTo(gfx::Point(30, 31));
142 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); 142 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
143 EXPECT_TRUE(cursor_client->IsCursorVisible()); 143 EXPECT_TRUE(cursor_client->IsCursorVisible());
144 144
145 // The cursor should be shown immediately after the press, and hidden 145 // The cursor should be shown immediately after the press, and hidden
146 // after the move. 146 // after the move.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 // Continuing to move the touch exploration finger should send more mouse 181 // Continuing to move the touch exploration finger should send more mouse
182 // events. 182 // events.
183 generator.MoveTouchId(gfx::Point(509, 609), 1); 183 generator.MoveTouchId(gfx::Point(509, 609), 1);
184 EXPECT_EQ(0, event_handler_->num_touch_events()); 184 EXPECT_EQ(0, event_handler_->num_touch_events());
185 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); 185 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
186 EXPECT_FALSE(cursor_client->IsCursorVisible()); 186 EXPECT_FALSE(cursor_client->IsCursorVisible());
187 } 187 }
188 188
189 } // namespace ui 189 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698