| 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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 generator_->PressTouch(); | 829 generator_->PressTouch(); |
| 830 // Advance to the finger passing through, and then to the longpress timeout. | 830 // Advance to the finger passing through, and then to the longpress timeout. |
| 831 AdvanceSimulatedTimePastTapDelay(); | 831 AdvanceSimulatedTimePastTapDelay(); |
| 832 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); | 832 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); |
| 833 generator_->ReleaseTouch(); | 833 generator_->ReleaseTouch(); |
| 834 | 834 |
| 835 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); | 835 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
| 836 ASSERT_EQ(2U, captured_events.size()); | 836 ASSERT_EQ(2U, captured_events.size()); |
| 837 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 837 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
| 838 EXPECT_EQ(tap_location, captured_events[0]->location()); | 838 EXPECT_EQ(tap_location, captured_events[0]->location()); |
| 839 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 839 base::TimeTicks pressed_time = captured_events[0]->time_stamp(); |
| 840 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 840 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
| 841 EXPECT_EQ(tap_location, captured_events[1]->location()); | 841 EXPECT_EQ(tap_location, captured_events[1]->location()); |
| 842 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 842 base::TimeTicks released_time = captured_events[1]->time_stamp(); |
| 843 EXPECT_EQ(released_time - pressed_time, | 843 EXPECT_EQ(released_time - pressed_time, |
| 844 gesture_detector_config_.longpress_timeout); | 844 gesture_detector_config_.longpress_timeout); |
| 845 } | 845 } |
| 846 | 846 |
| 847 // Single-tapping should send a touch press and release through to the location | 847 // Single-tapping should send a touch press and release through to the location |
| 848 // of the last successful touch exploration if the grace period has not | 848 // of the last successful touch exploration if the grace period has not |
| 849 // elapsed. | 849 // elapsed. |
| 850 TEST_F(TouchExplorationTest, SingleTap) { | 850 TEST_F(TouchExplorationTest, SingleTap) { |
| 851 SwitchTouchExplorationMode(true); | 851 SwitchTouchExplorationMode(true); |
| 852 | 852 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 ui::TouchEvent split_tap_release( | 1040 ui::TouchEvent split_tap_release( |
| 1041 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 1041 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
| 1042 generator_->Dispatch(&split_tap_release); | 1042 generator_->Dispatch(&split_tap_release); |
| 1043 EXPECT_FALSE(IsInNoFingersDownState()); | 1043 EXPECT_FALSE(IsInNoFingersDownState()); |
| 1044 EXPECT_TRUE(IsInTouchToMouseMode()); | 1044 EXPECT_TRUE(IsInTouchToMouseMode()); |
| 1045 | 1045 |
| 1046 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); | 1046 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
| 1047 ASSERT_EQ(2U, captured_events.size()); | 1047 ASSERT_EQ(2U, captured_events.size()); |
| 1048 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 1048 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
| 1049 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 1049 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
| 1050 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 1050 base::TimeTicks pressed_time = captured_events[0]->time_stamp(); |
| 1051 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 1051 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
| 1052 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 1052 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
| 1053 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 1053 base::TimeTicks released_time = captured_events[1]->time_stamp(); |
| 1054 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 1054 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
| 1055 released_time - pressed_time); | 1055 released_time - pressed_time); |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 // If split tap is started but the touch explore finger is released first, | 1058 // If split tap is started but the touch explore finger is released first, |
| 1059 // there should still be a touch press and release sent to the location of | 1059 // there should still be a touch press and release sent to the location of |
| 1060 // the last successful touch exploration. If the remaining finger is held | 1060 // the last successful touch exploration. If the remaining finger is held |
| 1061 // as a longpress, there should be a delay between the sent touch and release | 1061 // as a longpress, there should be a delay between the sent touch and release |
| 1062 // events (right click).All fingers should be released after the click | 1062 // events (right click).All fingers should be released after the click |
| 1063 // goes through. | 1063 // goes through. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1087 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); | 1087 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); |
| 1088 ui::TouchEvent split_tap_release( | 1088 ui::TouchEvent split_tap_release( |
| 1089 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 1089 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
| 1090 generator_->Dispatch(&split_tap_release); | 1090 generator_->Dispatch(&split_tap_release); |
| 1091 EXPECT_TRUE(IsInTouchToMouseMode()); | 1091 EXPECT_TRUE(IsInTouchToMouseMode()); |
| 1092 | 1092 |
| 1093 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); | 1093 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
| 1094 ASSERT_EQ(2U, captured_events.size()); | 1094 ASSERT_EQ(2U, captured_events.size()); |
| 1095 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 1095 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
| 1096 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 1096 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
| 1097 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 1097 base::TimeTicks pressed_time = captured_events[0]->time_stamp(); |
| 1098 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 1098 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
| 1099 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 1099 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
| 1100 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 1100 base::TimeTicks released_time = captured_events[1]->time_stamp(); |
| 1101 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 1101 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
| 1102 released_time - pressed_time); | 1102 released_time - pressed_time); |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 TEST_F(TouchExplorationTest, SplitTapMultiFinger) { | 1105 TEST_F(TouchExplorationTest, SplitTapMultiFinger) { |
| 1106 SwitchTouchExplorationMode(true); | 1106 SwitchTouchExplorationMode(true); |
| 1107 gfx::Point initial_touch_location(11, 12); | 1107 gfx::Point initial_touch_location(11, 12); |
| 1108 gfx::Point second_touch_location(33, 34); | 1108 gfx::Point second_touch_location(33, 34); |
| 1109 gfx::Point third_touch_location(16, 17); | 1109 gfx::Point third_touch_location(16, 17); |
| 1110 | 1110 |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 generator_->PressTouch(); | 1890 generator_->PressTouch(); |
| 1891 generator_->MoveTouch(initial_press); | 1891 generator_->MoveTouch(initial_press); |
| 1892 generator_->MoveTouch(*point); | 1892 generator_->MoveTouch(*point); |
| 1893 generator_->ReleaseTouch(); | 1893 generator_->ReleaseTouch(); |
| 1894 ASSERT_EQ(1U, delegate_.NumExitScreenSounds()); | 1894 ASSERT_EQ(1U, delegate_.NumExitScreenSounds()); |
| 1895 delegate_.ResetCountersToZero(); | 1895 delegate_.ResetCountersToZero(); |
| 1896 } | 1896 } |
| 1897 } | 1897 } |
| 1898 | 1898 |
| 1899 } // namespace ui | 1899 } // namespace ui |
| OLD | NEW |