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/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
15 #include "ui/aura/client/cursor_client.h" | |
15 #include "ui/aura/test/event_generator.h" | 16 #include "ui/aura/test/event_generator.h" |
16 #include "ui/aura/window_tree_host.h" | 17 #include "ui/aura/window_tree_host.h" |
17 #include "ui/compositor/compositor.h" | 18 #include "ui/compositor/compositor.h" |
18 #include "ui/compositor/test/draw_waiter_for_test.h" | 19 #include "ui/compositor/test/draw_waiter_for_test.h" |
19 #include "ui/events/test/test_event_handler.h" | 20 #include "ui/events/test/test_event_handler.h" |
20 | 21 |
21 namespace ui { | 22 namespace ui { |
22 | 23 |
23 class TouchExplorationTest : public InProcessBrowserTest { | 24 class TouchExplorationTest : public InProcessBrowserTest { |
24 public: | 25 public: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 generator.set_current_location(gfx::Point(500, 600)); | 80 generator.set_current_location(gfx::Point(500, 600)); |
80 generator.PressTouchId(2); | 81 generator.PressTouchId(2); |
81 generator.MoveTouchId(gfx::Point(509, 609), 2); | 82 generator.MoveTouchId(gfx::Point(509, 609), 2); |
82 EXPECT_GT(event_handler->num_mouse_events(), 0); | 83 EXPECT_GT(event_handler->num_mouse_events(), 0); |
83 EXPECT_EQ(0, event_handler->num_touch_events()); | 84 EXPECT_EQ(0, event_handler->num_touch_events()); |
84 | 85 |
85 SwitchTouchExplorationMode(false); | 86 SwitchTouchExplorationMode(false); |
86 root_window->RemovePreTargetHandler(event_handler.get()); | 87 root_window->RemovePreTargetHandler(event_handler.get()); |
87 } | 88 } |
88 | 89 |
90 // This test makes sure that after the user clicks with split tap, | |
91 // they continue to touch exploration mode if the original touch exploration | |
92 // finger is still on the screen. | |
93 IN_PROC_BROWSER_TEST_F(TouchExplorationTest, SplitTapExplore) { | |
94 content::WebContents* web_contents = | |
95 browser()->tab_strip_model()->GetActiveWebContents(); | |
96 content::WaitForResizeComplete(web_contents); | |
97 aura::Window* root_window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | |
98 scoped_ptr<ui::test::TestEventHandler> | |
99 event_handler(new ui::test::TestEventHandler()); | |
100 root_window->AddPreTargetHandler(event_handler.get()); | |
101 SwitchTouchExplorationMode(true); | |
102 aura::test::EventGenerator generator(root_window); | |
103 aura::client::CursorClient* cursor_client = | |
104 aura::client::GetCursorClient(root_window); | |
105 | |
106 // Mouse events should show the cursor. | |
107 generator.MoveMouseTo(gfx::Point(30, 31)); | |
108 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | |
109 EXPECT_TRUE(cursor_client->IsCursorVisible()); | |
110 | |
111 // After a press the cursor should be shown after immediately after press, | |
112 // hidden after move. | |
113 generator.set_current_location(gfx::Point(100, 200)); | |
114 generator.PressTouchId(1); | |
115 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | |
116 EXPECT_TRUE(cursor_client->IsCursorVisible()); | |
117 // Initiate touch explore by moving out of the slop. | |
118 generator.MoveTouchId(gfx::Point(109, 209), 1); | |
aboxhall
2014/07/08 21:07:49
These magic numbers make me nervous; could this be
evy
2014/07/09 18:20:19
I'm doing this a different way now, with no distan
| |
119 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | |
120 EXPECT_FALSE(cursor_client->IsCursorVisible()); | |
121 event_handler->Reset(); | |
122 | |
123 // Press and release with a second finger for split tap. This should send | |
124 // touch press and release events which should send a click press and release. | |
125 // Once the press is passed through, mouse events should be disabled. | |
126 // Mouse events are reenabled after the release. | |
127 generator.set_current_location(gfx::Point(102, 202)); | |
128 generator.PressTouchId(2); | |
129 EXPECT_FALSE(cursor_client->IsMouseEventsEnabled()); | |
130 EXPECT_FALSE(cursor_client->IsCursorVisible()); | |
131 generator.ReleaseTouchId(2); | |
132 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | |
133 EXPECT_FALSE(cursor_client->IsCursorVisible()); | |
134 EXPECT_EQ(2, event_handler->num_touch_events()); | |
135 event_handler->Reset(); | |
136 | |
137 // Continuing to move the touch exploration finger should send more mouse | |
138 // events. | |
139 generator.MoveTouchId(gfx::Point(509, 609), 1); | |
140 EXPECT_EQ(0, event_handler->num_touch_events()); | |
141 EXPECT_TRUE(cursor_client->IsMouseEventsEnabled()); | |
142 EXPECT_FALSE(cursor_client->IsCursorVisible()); | |
143 | |
144 SwitchTouchExplorationMode(false); | |
145 root_window->RemovePreTargetHandler(event_handler.get()); | |
146 } | |
147 | |
89 } // namespace ui | 148 } // namespace ui |
OLD | NEW |