Chromium Code Reviews| 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 // Tap and hold at one location, and get a mouse move event in touch explore. | 645 // Tap and hold at one location, and get a mouse move event in touch explore. |
| 646 EnterTouchExplorationModeAtLocation(initial_touch_location); | 646 EnterTouchExplorationModeAtLocation(initial_touch_location); |
| 647 std::vector<ui::LocatedEvent*> events = | 647 std::vector<ui::LocatedEvent*> events = |
| 648 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); | 648 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
| 649 ASSERT_EQ(1U, events.size()); | 649 ASSERT_EQ(1U, events.size()); |
| 650 | 650 |
| 651 EXPECT_EQ(initial_touch_location, events[0]->location()); | 651 EXPECT_EQ(initial_touch_location, events[0]->location()); |
| 652 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 652 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
| 653 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 653 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
| 654 ClearCapturedEvents(); | 654 ClearCapturedEvents(); |
| 655 EXPECT_TRUE(IsInTouchToMouseMode()); | |
| 655 | 656 |
| 656 // Now tap and release at a different location. This should result in a | 657 // Now tap and release at a different location. This should result in a |
| 657 // single touch and release at the location of the first (held) tap, | 658 // single touch and release at the location of the first (held) tap, |
| 658 // not at the location of the second tap and release. | 659 // not at the location of the second tap and release. |
| 659 // After the release, there is still a finger in touch explore mode. | 660 // After the release, there is still a finger in touch explore mode. |
| 660 ui::TouchEvent split_tap_press( | 661 ui::TouchEvent split_tap_press( |
| 661 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 662 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
| 662 generator_->Dispatch(&split_tap_press); | 663 generator_->Dispatch(&split_tap_press); |
| 664 // To simulate the behavior of the real device, we manually disable | |
| 665 // mouse events. To not rely on manually setting the state, this is also | |
| 666 // tested in touch_exploration_controller_browsertest. | |
| 667 cursor_client()->DisableMouseEvents(); | |
| 663 EXPECT_FALSE(IsInGestureInProgressState()); | 668 EXPECT_FALSE(IsInGestureInProgressState()); |
| 664 ui::TouchEvent split_tap_release( | 669 ui::TouchEvent split_tap_release( |
| 665 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 670 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
| 666 generator_->Dispatch(&split_tap_release); | 671 generator_->Dispatch(&split_tap_release); |
| 667 EXPECT_FALSE(IsInNoFingersDownState()); | 672 EXPECT_FALSE(IsInNoFingersDownState()); |
| 668 | 673 // Releasing the second finger should re-enable mouse events putting us |
| 674 // back into the touch exploration mode. | |
| 675 EXPECT_TRUE(IsInTouchToMouseMode()); | |
| 669 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); | 676 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
| 670 ASSERT_EQ(2U, captured_events.size()); | 677 ASSERT_EQ(2U, captured_events.size()); |
| 671 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 678 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
| 672 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 679 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
| 673 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 680 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
| 674 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 681 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
| 682 ClearCapturedEvents(); | |
| 683 | |
| 684 ui::TouchEvent touch_explore_release( | |
| 685 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); | |
| 686 generator_->Dispatch(&touch_explore_release); | |
| 687 AdvanceSimulatedTimePastTapDelay(); | |
| 688 EXPECT_TRUE(IsInNoFingersDownState()); | |
| 675 } | 689 } |
| 676 | 690 |
| 677 // If split tap is started but the touch explore finger is released first, | 691 // If split tap is started but the touch explore finger is released first, |
| 678 // there should still be a touch press and release sent to the location of | 692 // there should still be a touch press and release sent to the location of |
| 679 // the last successful touch exploration. | 693 // the last successful touch exploration. |
| 680 // Both fingers should be released after the click goes through. | 694 // Both fingers should be released after the click goes through. |
| 681 TEST_F(TouchExplorationTest, SplitTapRelease) { | 695 TEST_F(TouchExplorationTest, SplitTapRelease) { |
| 682 SwitchTouchExplorationMode(true); | 696 SwitchTouchExplorationMode(true); |
| 683 | 697 |
| 684 gfx::Point initial_touch_location(11, 12); | 698 gfx::Point initial_touch_location(11, 12); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 gfx::Point second_touch_location(33, 34); | 740 gfx::Point second_touch_location(33, 34); |
| 727 | 741 |
| 728 // Tap and hold at one location, and get a mouse move event in touch explore. | 742 // Tap and hold at one location, and get a mouse move event in touch explore. |
| 729 EnterTouchExplorationModeAtLocation(initial_touch_location); | 743 EnterTouchExplorationModeAtLocation(initial_touch_location); |
| 730 std::vector<ui::LocatedEvent*> events = | 744 std::vector<ui::LocatedEvent*> events = |
| 731 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); | 745 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
| 732 ASSERT_EQ(1U, events.size()); | 746 ASSERT_EQ(1U, events.size()); |
| 733 | 747 |
| 734 ClearCapturedEvents(); | 748 ClearCapturedEvents(); |
| 735 | 749 |
| 736 // Now tap and release at a different location. This should result in a | 750 // Now tap and release at a different location. This should result in a |
|
mfomitchev
2014/07/09 13:26:02
Would be nice to clarify we are doing a long press
evy
2014/07/09 18:20:19
Done.
| |
| 737 // single touch and release at the location of the first (held) tap, | 751 // single touch and release at the location of the first (held) tap, |
| 738 // not at the location of the second tap and release. | 752 // not at the location of the second tap and release. |
| 739 // After the release, there is still a finger in touch explore mode. | 753 // After the release, there is still a finger in touch exploration, and |
| 754 // touches from this finger should trigger mouse events. | |
|
mfomitchev
2014/07/09 13:26:02
Nit: It doesn't seem we are testing that "touches
evy
2014/07/09 18:20:19
Done.
| |
| 740 ui::TouchEvent split_tap_press( | 755 ui::TouchEvent split_tap_press( |
| 741 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 756 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
| 742 generator_->Dispatch(&split_tap_press); | 757 generator_->Dispatch(&split_tap_press); |
| 743 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); | 758 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); |
| 744 ui::TouchEvent split_tap_release( | 759 ui::TouchEvent split_tap_release( |
| 745 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 760 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
| 746 generator_->Dispatch(&split_tap_release); | 761 generator_->Dispatch(&split_tap_release); |
| 747 EXPECT_FALSE(IsInNoFingersDownState()); | 762 EXPECT_FALSE(IsInNoFingersDownState()); |
| 763 EXPECT_TRUE(IsInTouchToMouseMode()); | |
| 748 | 764 |
| 749 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); | 765 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
| 750 ASSERT_EQ(2U, captured_events.size()); | 766 ASSERT_EQ(2U, captured_events.size()); |
| 751 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 767 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
| 752 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 768 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
| 753 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 769 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
| 754 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 770 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
| 755 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 771 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
| 756 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 772 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
| 757 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 773 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1172 // The rest of the events should occur in passthrough. | 1188 // The rest of the events should occur in passthrough. |
| 1173 generator_->ReleaseTouchId(0); | 1189 generator_->ReleaseTouchId(0); |
| 1174 ASSERT_EQ(1U, captured_events.size()); | 1190 ASSERT_EQ(1U, captured_events.size()); |
| 1175 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type()); | 1191 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type()); |
| 1176 ClearCapturedEvents(); | 1192 ClearCapturedEvents(); |
| 1177 generator_->ReleaseTouchId(1); | 1193 generator_->ReleaseTouchId(1); |
| 1178 ASSERT_EQ(0U, captured_events.size()); | 1194 ASSERT_EQ(0U, captured_events.size()); |
| 1179 } | 1195 } |
| 1180 | 1196 |
| 1181 } // namespace ui | 1197 } // namespace ui |
| OLD | NEW |