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 "base/test/simple_test_tick_clock.h" | 7 #include "base/test/simple_test_tick_clock.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 touch_exploration_controller_->OnTapTimerFired(); | 105 touch_exploration_controller_->OnTapTimerFired(); |
106 } | 106 } |
107 | 107 |
108 void CallTapTimerNowIfRunningForTesting() { | 108 void CallTapTimerNowIfRunningForTesting() { |
109 if (touch_exploration_controller_->tap_timer_.IsRunning()) { | 109 if (touch_exploration_controller_->tap_timer_.IsRunning()) { |
110 touch_exploration_controller_->tap_timer_.Stop(); | 110 touch_exploration_controller_->tap_timer_.Stop(); |
111 touch_exploration_controller_->OnTapTimerFired(); | 111 touch_exploration_controller_->OnTapTimerFired(); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
| 115 void SetEventHandlerForTesting( |
| 116 ui::EventHandler* event_handler_for_testing) { |
| 117 touch_exploration_controller_->event_handler_for_testing_ = |
| 118 event_handler_for_testing; |
| 119 } |
| 120 |
115 bool IsInNoFingersDownStateForTesting() const { | 121 bool IsInNoFingersDownStateForTesting() const { |
116 return touch_exploration_controller_->state_ == | 122 return touch_exploration_controller_->state_ == |
117 touch_exploration_controller_->NO_FINGERS_DOWN; | 123 touch_exploration_controller_->NO_FINGERS_DOWN; |
118 } | 124 } |
119 | 125 |
120 bool IsInGestureInProgressStateForTesting() const { | 126 bool IsInGestureInProgressStateForTesting() const { |
121 return touch_exploration_controller_->state_ == | 127 return touch_exploration_controller_->state_ == |
122 touch_exploration_controller_->GESTURE_IN_PROGRESS; | 128 touch_exploration_controller_->GESTURE_IN_PROGRESS; |
123 } | 129 } |
124 | 130 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 static_cast<base::TickClock*>(simulated_clock_)); | 253 static_cast<base::TickClock*>(simulated_clock_)); |
248 } | 254 } |
249 | 255 |
250 void SwitchTouchExplorationMode(bool on) { | 256 void SwitchTouchExplorationMode(bool on) { |
251 if (!on && touch_exploration_controller_.get()) { | 257 if (!on && touch_exploration_controller_.get()) { |
252 touch_exploration_controller_.reset(); | 258 touch_exploration_controller_.reset(); |
253 } else if (on && !touch_exploration_controller_.get()) { | 259 } else if (on && !touch_exploration_controller_.get()) { |
254 touch_exploration_controller_.reset( | 260 touch_exploration_controller_.reset( |
255 new ui::TouchExplorationControllerTestApi( | 261 new ui::TouchExplorationControllerTestApi( |
256 new TouchExplorationController(root_window(), &delegate_))); | 262 new TouchExplorationController(root_window(), &delegate_))); |
| 263 touch_exploration_controller_->SetEventHandlerForTesting( |
| 264 &event_capturer_); |
257 cursor_client()->ShowCursor(); | 265 cursor_client()->ShowCursor(); |
258 cursor_client()->DisableMouseEvents(); | 266 cursor_client()->DisableMouseEvents(); |
259 } | 267 } |
260 } | 268 } |
261 | 269 |
262 void EnterTouchExplorationModeAtLocation(gfx::Point tap_location) { | 270 void EnterTouchExplorationModeAtLocation(gfx::Point tap_location) { |
263 ui::TouchEvent touch_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now()); | 271 ui::TouchEvent touch_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now()); |
264 generator_->Dispatch(&touch_press); | 272 generator_->Dispatch(&touch_press); |
265 AdvanceSimulatedTimePastTapDelay(); | 273 AdvanceSimulatedTimePastTapDelay(); |
266 EXPECT_TRUE(IsInTouchToMouseMode()); | 274 EXPECT_TRUE(IsInTouchToMouseMode()); |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1521 EXPECT_FALSE(IsInSlideGestureState()); | 1529 EXPECT_FALSE(IsInSlideGestureState()); |
1522 EXPECT_FALSE(IsInTouchToMouseMode()); | 1530 EXPECT_FALSE(IsInTouchToMouseMode()); |
1523 | 1531 |
1524 AdvanceSimulatedTimePastTapDelay(); | 1532 AdvanceSimulatedTimePastTapDelay(); |
1525 EXPECT_FALSE(IsInGestureInProgressState()); | 1533 EXPECT_FALSE(IsInGestureInProgressState()); |
1526 EXPECT_FALSE(IsInSlideGestureState()); | 1534 EXPECT_FALSE(IsInSlideGestureState()); |
1527 EXPECT_TRUE(IsInTouchToMouseMode()); | 1535 EXPECT_TRUE(IsInTouchToMouseMode()); |
1528 } | 1536 } |
1529 | 1537 |
1530 } // namespace ui | 1538 } // namespace ui |
OLD | NEW |