| 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" |
| 11 #include "ui/aura/test/event_generator.h" |
| 11 #include "ui/aura/test/test_cursor_client.h" | 12 #include "ui/aura/test/test_cursor_client.h" |
| 12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 13 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 14 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
| 15 #include "ui/events/gestures/gesture_provider_aura.h" | 16 #include "ui/events/gestures/gesture_provider_aura.h" |
| 16 #include "ui/events/test/event_generator.h" | |
| 17 #include "ui/events/test/events_test_utils.h" | 17 #include "ui/events/test/events_test_utils.h" |
| 18 #include "ui/gfx/geometry/point.h" | 18 #include "ui/gfx/geometry/point.h" |
| 19 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
| 20 #include "ui/gl/gl_surface.h" | 20 #include "ui/gl/gl_surface.h" |
| 21 | 21 |
| 22 namespace ui { | 22 namespace ui { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Records all mouse, touch, gesture, and key events. | 26 // Records all mouse, touch, gesture, and key events. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); | 164 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); |
| 165 } | 165 } |
| 166 virtual ~TouchExplorationTest() {} | 166 virtual ~TouchExplorationTest() {} |
| 167 | 167 |
| 168 virtual void SetUp() OVERRIDE { | 168 virtual void SetUp() OVERRIDE { |
| 169 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone) | 169 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone) |
| 170 gfx::GLSurface::InitializeOneOffForTests(); | 170 gfx::GLSurface::InitializeOneOffForTests(); |
| 171 aura::test::AuraTestBase::SetUp(); | 171 aura::test::AuraTestBase::SetUp(); |
| 172 cursor_client_.reset(new aura::test::TestCursorClient(root_window())); | 172 cursor_client_.reset(new aura::test::TestCursorClient(root_window())); |
| 173 root_window()->AddPreTargetHandler(&event_capturer_); | 173 root_window()->AddPreTargetHandler(&event_capturer_); |
| 174 generator_.reset(new test::EventGenerator(root_window())); | 174 generator_.reset(new aura::test::EventGenerator(root_window())); |
| 175 // The generator takes ownership of the clock. | 175 // The generator takes ownership of the clock. |
| 176 generator_->SetTickClock(scoped_ptr<base::TickClock>(simulated_clock_)); | 176 generator_->SetTickClock(scoped_ptr<base::TickClock>(simulated_clock_)); |
| 177 cursor_client()->ShowCursor(); | 177 cursor_client()->ShowCursor(); |
| 178 cursor_client()->DisableMouseEvents(); | 178 cursor_client()->DisableMouseEvents(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 virtual void TearDown() OVERRIDE { | 181 virtual void TearDown() OVERRIDE { |
| 182 root_window()->RemovePreTargetHandler(&event_capturer_); | 182 root_window()->RemovePreTargetHandler(&event_capturer_); |
| 183 SwitchTouchExplorationMode(false); | 183 SwitchTouchExplorationMode(false); |
| 184 cursor_client_.reset(); | 184 cursor_client_.reset(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 return touch_exploration_controller_->GetSlopDistanceFromEdge(); | 308 return touch_exploration_controller_->GetSlopDistanceFromEdge(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 base::TimeDelta Now() { | 311 base::TimeDelta Now() { |
| 312 // This is the same as what EventTimeForNow() does, but here we do it | 312 // This is the same as what EventTimeForNow() does, but here we do it |
| 313 // with our simulated clock. | 313 // with our simulated clock. |
| 314 return base::TimeDelta::FromInternalValue( | 314 return base::TimeDelta::FromInternalValue( |
| 315 simulated_clock_->NowTicks().ToInternalValue()); | 315 simulated_clock_->NowTicks().ToInternalValue()); |
| 316 } | 316 } |
| 317 | 317 |
| 318 scoped_ptr<test::EventGenerator> generator_; | 318 scoped_ptr<aura::test::EventGenerator> generator_; |
| 319 ui::GestureDetector::Config gesture_detector_config_; | 319 ui::GestureDetector::Config gesture_detector_config_; |
| 320 // Owned by |generator_|. | 320 // Owned by |generator_|. |
| 321 base::SimpleTestTickClock* simulated_clock_; | 321 base::SimpleTestTickClock* simulated_clock_; |
| 322 MockTouchExplorationControllerDelegate delegate_; | 322 MockTouchExplorationControllerDelegate delegate_; |
| 323 | 323 |
| 324 private: | 324 private: |
| 325 EventCapturer event_capturer_; | 325 EventCapturer event_capturer_; |
| 326 scoped_ptr<TouchExplorationControllerTestApi> | 326 scoped_ptr<TouchExplorationControllerTestApi> |
| 327 touch_exploration_controller_; | 327 touch_exploration_controller_; |
| 328 scoped_ptr<aura::test::TestCursorClient> cursor_client_; | 328 scoped_ptr<aura::test::TestCursorClient> cursor_client_; |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 EXPECT_FALSE(IsInSlideGestureState()); | 1628 EXPECT_FALSE(IsInSlideGestureState()); |
| 1629 EXPECT_FALSE(IsInTouchToMouseMode()); | 1629 EXPECT_FALSE(IsInTouchToMouseMode()); |
| 1630 | 1630 |
| 1631 AdvanceSimulatedTimePastTapDelay(); | 1631 AdvanceSimulatedTimePastTapDelay(); |
| 1632 EXPECT_FALSE(IsInGestureInProgressState()); | 1632 EXPECT_FALSE(IsInGestureInProgressState()); |
| 1633 EXPECT_FALSE(IsInSlideGestureState()); | 1633 EXPECT_FALSE(IsInSlideGestureState()); |
| 1634 EXPECT_TRUE(IsInTouchToMouseMode()); | 1634 EXPECT_TRUE(IsInTouchToMouseMode()); |
| 1635 } | 1635 } |
| 1636 | 1636 |
| 1637 } // namespace ui | 1637 } // namespace ui |
| OLD | NEW |