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 <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 385 } |
386 | 386 |
387 float GetMaxDistanceFromEdge() const { | 387 float GetMaxDistanceFromEdge() const { |
388 return touch_exploration_controller_->GetMaxDistanceFromEdge(); | 388 return touch_exploration_controller_->GetMaxDistanceFromEdge(); |
389 } | 389 } |
390 | 390 |
391 float GetSlopDistanceFromEdge() const { | 391 float GetSlopDistanceFromEdge() const { |
392 return touch_exploration_controller_->GetSlopDistanceFromEdge(); | 392 return touch_exploration_controller_->GetSlopDistanceFromEdge(); |
393 } | 393 } |
394 | 394 |
395 base::TimeDelta Now() { | 395 base::TimeTicks Now() { |
396 // This is the same as what EventTimeForNow() does, but here we do it | 396 // This is the same as what EventTimeForNow() does, but here we do it |
397 // with our simulated clock. | 397 // with our simulated clock. |
398 return base::TimeDelta::FromInternalValue( | 398 return simulated_clock_->NowTicks(); |
399 simulated_clock_->NowTicks().ToInternalValue()); | |
400 } | 399 } |
401 | 400 |
402 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) { | 401 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) { |
403 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location); | 402 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location); |
404 } | 403 } |
405 | 404 |
406 std::unique_ptr<test::EventGenerator> generator_; | 405 std::unique_ptr<test::EventGenerator> generator_; |
407 ui::GestureDetector::Config gesture_detector_config_; | 406 ui::GestureDetector::Config gesture_detector_config_; |
408 // Owned by |generator_|. | 407 // Owned by |generator_|. |
409 base::SimpleTestTickClock* simulated_clock_; | 408 base::SimpleTestTickClock* simulated_clock_; |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 generator_->PressTouch(); | 875 generator_->PressTouch(); |
877 // Advance to the finger passing through, and then to the longpress timeout. | 876 // Advance to the finger passing through, and then to the longpress timeout. |
878 AdvanceSimulatedTimePastTapDelay(); | 877 AdvanceSimulatedTimePastTapDelay(); |
879 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); | 878 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); |
880 generator_->ReleaseTouch(); | 879 generator_->ReleaseTouch(); |
881 | 880 |
882 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); | 881 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
883 ASSERT_EQ(2U, captured_events.size()); | 882 ASSERT_EQ(2U, captured_events.size()); |
884 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 883 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
885 EXPECT_EQ(tap_location, captured_events[0]->location()); | 884 EXPECT_EQ(tap_location, captured_events[0]->location()); |
886 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 885 base::TimeTicks pressed_time = captured_events[0]->time_stamp(); |
887 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 886 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
888 EXPECT_EQ(tap_location, captured_events[1]->location()); | 887 EXPECT_EQ(tap_location, captured_events[1]->location()); |
889 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 888 base::TimeTicks released_time = captured_events[1]->time_stamp(); |
890 EXPECT_EQ(released_time - pressed_time, | 889 EXPECT_EQ(released_time - pressed_time, |
891 gesture_detector_config_.longpress_timeout); | 890 gesture_detector_config_.longpress_timeout); |
892 } | 891 } |
893 | 892 |
894 // Single-tapping should send a touch press and release through to the location | 893 // Single-tapping should send a touch press and release through to the location |
895 // of the last successful touch exploration if the grace period has not | 894 // of the last successful touch exploration if the grace period has not |
896 // elapsed. | 895 // elapsed. |
897 TEST_F(TouchExplorationTest, SingleTap) { | 896 TEST_F(TouchExplorationTest, SingleTap) { |
898 SwitchTouchExplorationMode(true); | 897 SwitchTouchExplorationMode(true); |
899 | 898 |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 generator_->PressTouch(); | 1824 generator_->PressTouch(); |
1826 generator_->MoveTouch(initial_press); | 1825 generator_->MoveTouch(initial_press); |
1827 generator_->MoveTouch(*point); | 1826 generator_->MoveTouch(*point); |
1828 generator_->ReleaseTouch(); | 1827 generator_->ReleaseTouch(); |
1829 ASSERT_EQ(1U, delegate_.NumExitScreenSounds()); | 1828 ASSERT_EQ(1U, delegate_.NumExitScreenSounds()); |
1830 delegate_.ResetCountersToZero(); | 1829 delegate_.ResetCountersToZero(); |
1831 } | 1830 } |
1832 } | 1831 } |
1833 | 1832 |
1834 } // namespace ui | 1833 } // namespace ui |
OLD | NEW |