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/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 "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // get rewritten when the touch exploration mode is on, and aren't affected | 48 // get rewritten when the touch exploration mode is on, and aren't affected |
49 // after the touch exploration mode is turned off. | 49 // after the touch exploration mode is turned off. |
50 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { | 50 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, ToggleOnOff) { |
51 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | 51 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
52 scoped_ptr<ui::test::TestEventHandler> | 52 scoped_ptr<ui::test::TestEventHandler> |
53 event_handler(new ui::test::TestEventHandler()); | 53 event_handler(new ui::test::TestEventHandler()); |
54 root_window->AddPreTargetHandler(event_handler.get()); | 54 root_window->AddPreTargetHandler(event_handler.get()); |
55 SwitchTouchExplorationMode(true); | 55 SwitchTouchExplorationMode(true); |
56 aura::test::EventGenerator generator(root_window); | 56 aura::test::EventGenerator generator(root_window); |
57 | 57 |
| 58 generator.set_current_location(gfx::Point(100, 200)); |
58 generator.PressTouchId(1); | 59 generator.PressTouchId(1); |
| 60 // Since the touch exploration controller doesn't know if the user is |
| 61 // double-tapping or not, touch exploration is only initiated if the |
| 62 // user moves more than 8 pixels away from the initial location (the "slop"), |
| 63 // or after 300 ms has elapsed. |
| 64 generator.MoveTouchId(gfx::Point(109, 209), 1); |
59 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. | 65 // Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED. |
60 EXPECT_GT(event_handler->num_mouse_events(), 0); | 66 EXPECT_GT(event_handler->num_mouse_events(), 0); |
61 EXPECT_EQ(0, event_handler->num_touch_events()); | 67 EXPECT_EQ(0, event_handler->num_touch_events()); |
62 event_handler->Reset(); | 68 event_handler->Reset(); |
63 | 69 |
64 SwitchTouchExplorationMode(false); | 70 SwitchTouchExplorationMode(false); |
65 generator.MoveTouchId(gfx::Point(11, 12), 1); | 71 generator.MoveTouchId(gfx::Point(11, 12), 1); |
66 EXPECT_EQ(0, event_handler->num_mouse_events()); | 72 EXPECT_EQ(0, event_handler->num_mouse_events()); |
67 EXPECT_EQ(1, event_handler->num_touch_events()); | 73 EXPECT_EQ(1, event_handler->num_touch_events()); |
68 event_handler->Reset(); | 74 event_handler->Reset(); |
69 | 75 |
70 SwitchTouchExplorationMode(true); | 76 SwitchTouchExplorationMode(true); |
| 77 generator.set_current_location(gfx::Point(500, 600)); |
71 generator.PressTouchId(2); | 78 generator.PressTouchId(2); |
| 79 generator.MoveTouchId(gfx::Point(509, 609), 2); |
72 EXPECT_GT(event_handler->num_mouse_events(), 0); | 80 EXPECT_GT(event_handler->num_mouse_events(), 0); |
73 EXPECT_EQ(0, event_handler->num_touch_events()); | 81 EXPECT_EQ(0, event_handler->num_touch_events()); |
74 | 82 |
75 SwitchTouchExplorationMode(false); | 83 SwitchTouchExplorationMode(false); |
76 root_window->RemovePreTargetHandler(event_handler.get()); | 84 root_window->RemovePreTargetHandler(event_handler.get()); |
77 } | 85 } |
78 | 86 |
79 } // namespace ui | 87 } // namespace ui |
OLD | NEW |