| 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/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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/test/simple_test_tick_clock.h" | 12 #include "base/test/simple_test_tick_clock.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
| 19 #include "ui/aura/client/cursor_client.h" | 19 #include "ui/aura/client/cursor_client.h" |
| 20 #include "ui/aura/test/event_generator.h" | |
| 21 #include "ui/aura/window_tree_host.h" | 20 #include "ui/aura/window_tree_host.h" |
| 22 #include "ui/compositor/compositor.h" | 21 #include "ui/compositor/compositor.h" |
| 23 #include "ui/compositor/test/draw_waiter_for_test.h" | 22 #include "ui/compositor/test/draw_waiter_for_test.h" |
| 24 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
| 25 #include "ui/events/event_utils.h" | 24 #include "ui/events/event_utils.h" |
| 25 #include "ui/events/test/event_generator.h" |
| 26 #include "ui/events/test/test_event_handler.h" | 26 #include "ui/events/test/test_event_handler.h" |
| 27 | 27 |
| 28 namespace ui { | 28 namespace ui { |
| 29 | 29 |
| 30 class TouchExplorationTest : public InProcessBrowserTest { | 30 class TouchExplorationTest : public InProcessBrowserTest { |
| 31 public: | 31 public: |
| 32 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { | 32 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { |
| 33 // Tests fail if time is ever 0. | 33 // Tests fail if time is ever 0. |
| 34 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); | 34 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); |
| 35 } | 35 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 on/off and confirms that events |
| 87 // get rewritten when the touch exploration mode is on, and aren't affected | 87 // get rewritten when the touch exploration mode is on, and aren't affected |
| 88 // after the touch exploration mode is turned off. | 88 // after the touch exploration mode is turned off. |
| 89 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { | 89 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { |
| 90 SwitchTouchExplorationMode(true); | 90 SwitchTouchExplorationMode(true); |
| 91 aura::test::EventGenerator generator(root_window_); | 91 ui::test::EventGenerator generator(root_window_); |
| 92 | 92 |
| 93 base::TimeDelta initial_time = Now(); | 93 base::TimeDelta initial_time = Now(); |
| 94 ui::TouchEvent initial_press( | 94 ui::TouchEvent initial_press( |
| 95 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time); | 95 ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time); |
| 96 generator.Dispatch(&initial_press); | 96 generator.Dispatch(&initial_press); |
| 97 | 97 |
| 98 // Since the touch exploration controller doesn't know if the user is | 98 // Since the touch exploration controller doesn't know if the user is |
| 99 // double-tapping or not, touch exploration is only initiated if the | 99 // 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 | 100 // 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 | 101 // 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 Loading... |
| 133 generator.Dispatch(&second_touch_time_advance); | 133 generator.Dispatch(&second_touch_time_advance); |
| 134 EXPECT_GT(event_handler_->num_mouse_events(), 0); | 134 EXPECT_GT(event_handler_->num_mouse_events(), 0); |
| 135 EXPECT_EQ(0, event_handler_->num_touch_events()); | 135 EXPECT_EQ(0, event_handler_->num_touch_events()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // This test makes sure that after the user clicks with split tap, | 138 // This test makes sure that after the user clicks with split tap, |
| 139 // they continue to touch exploration mode if the original touch exploration | 139 // they continue to touch exploration mode if the original touch exploration |
| 140 // finger is still on the screen. | 140 // finger is still on the screen. |
| 141 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) { | 141 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) { |
| 142 SwitchTouchExplorationMode(true); | 142 SwitchTouchExplorationMode(true); |
| 143 aura::test::EventGenerator generator(root_window_); | 143 ui::test::EventGenerator generator(root_window_); |
| 144 aura::client::CursorClient* cursor_client = | 144 aura::client::CursorClient* cursor_client = |
| 145 aura::client::GetCursorClient(root_window_); | 145 aura::client::GetCursorClient(root_window_); |
| 146 | 146 |
| 147 // Mouse events should show the cursor. | 147 // Mouse events should show the cursor. |
| 148 generator.MoveMouseTo(gfx::Point(30, 31)); | 148 generator.MoveMouseTo(gfx::Point(30, 31)); |
| 149 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | 149 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
| 150 EXPECT_TRUE(cursor_client->IsCursorVisible()); | 150 EXPECT_TRUE(cursor_client->IsCursorVisible()); |
| 151 | 151 |
| 152 // The cursor should be shown immediately after the press, and hidden | 152 // The cursor should be shown immediately after the press, and hidden |
| 153 // after the move. | 153 // after the move. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 187 |
| 188 // Continuing to move the touch exploration finger should send more mouse | 188 // Continuing to move the touch exploration finger should send more mouse |
| 189 // events. | 189 // events. |
| 190 generator.MoveTouchId(gfx::Point(509, 609), 1); | 190 generator.MoveTouchId(gfx::Point(509, 609), 1); |
| 191 EXPECT_EQ(0, event_handler_->num_touch_events()); | 191 EXPECT_EQ(0, event_handler_->num_touch_events()); |
| 192 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | 192 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); |
| 193 EXPECT_FALSE(cursor_client->IsCursorVisible()); | 193 EXPECT_FALSE(cursor_client->IsCursorVisible()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace ui | 196 } // namespace ui |
| OLD | NEW |