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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 // Tap and hold at one location, and get a mouse move event in touch explore. | 775 // Tap and hold at one location, and get a mouse move event in touch explore. |
776 EnterTouchExplorationModeAtLocation(initial_touch_location); | 776 EnterTouchExplorationModeAtLocation(initial_touch_location); |
777 std::vector<ui::LocatedEvent*> events = | 777 std::vector<ui::LocatedEvent*> events = |
778 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 778 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); |
779 ASSERT_EQ(1U, events.size()); | 779 ASSERT_EQ(1U, events.size()); |
780 | 780 |
781 EXPECT_EQ(initial_touch_location, events[0]->location()); | 781 EXPECT_EQ(initial_touch_location, events[0]->location()); |
782 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 782 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
783 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 783 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
784 ClearCapturedEvents(); | 784 ClearCapturedEvents(); |
| 785 EXPECT_TRUE(IsInTouchToMouseMode()); |
785 | 786 |
786 // Now tap and release at a different location. This should result in a | 787 // Now tap and release at a different location. This should result in a |
787 // single touch and release at the location of the first (held) tap, | 788 // single touch and release at the location of the first (held) tap, |
788 // not at the location of the second tap and release. | 789 // not at the location of the second tap and release. |
789 // After the release, there is still a finger in touch explore mode. | 790 // After the release, there is still a finger in touch explore mode. |
790 ui::TouchEvent split_tap_press( | 791 ui::TouchEvent split_tap_press( |
791 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 792 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
792 generator_->Dispatch(&split_tap_press); | 793 generator_->Dispatch(&split_tap_press); |
| 794 // To simulate the behavior of the real device, we manually disable |
| 795 // mouse events. To not rely on manually setting the state, this is also |
| 796 // tested in touch_exploration_controller_browsertest. |
| 797 cursor_client()->DisableMouseEvents(); |
793 ui::TouchEvent split_tap_release( | 798 ui::TouchEvent split_tap_release( |
794 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 799 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
795 generator_->Dispatch(&split_tap_release); | 800 generator_->Dispatch(&split_tap_release); |
796 EXPECT_FALSE(IsInNoFingersDownState()); | 801 EXPECT_FALSE(IsInNoFingersDownState()); |
| 802 // Releasing the second finger should re-enable mouse events putting us |
| 803 // back into the touch exploration mode. |
| 804 EXPECT_TRUE(IsInTouchToMouseMode()); |
797 | 805 |
798 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 806 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); |
799 ASSERT_EQ(2U, captured_events.size()); | 807 ASSERT_EQ(2U, captured_events.size()); |
800 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 808 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
801 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 809 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
802 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 810 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
803 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 811 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
| 812 ClearCapturedEvents(); |
| 813 |
| 814 ui::TouchEvent touch_explore_release( |
| 815 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); |
| 816 generator_->Dispatch(&touch_explore_release); |
| 817 AdvanceSimulatedTimePastTapDelay(); |
| 818 EXPECT_TRUE(IsInNoFingersDownState()); |
804 } | 819 } |
805 | 820 |
806 // If split tap is started but the touch explore finger is released first, | 821 // If split tap is started but the touch explore finger is released first, |
807 // there should still be a touch press and release sent to the location of | 822 // there should still be a touch press and release sent to the location of |
808 // the last successful touch exploration. | 823 // the last successful touch exploration. |
809 // Both fingers should be released after the click goes through. | 824 // Both fingers should be released after the click goes through. |
810 TEST_F(TouchExplorationTest, SplitTapRelease) { | 825 TEST_F(TouchExplorationTest, SplitTapRelease) { |
811 SwitchTouchExplorationMode(true); | 826 SwitchTouchExplorationMode(true); |
812 | 827 |
813 gfx::Point initial_touch_location(11, 12); | 828 gfx::Point initial_touch_location(11, 12); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 // not at the location of the second tap and release. | 882 // not at the location of the second tap and release. |
868 // After the release, there is still a finger in touch explore mode. | 883 // After the release, there is still a finger in touch explore mode. |
869 ui::TouchEvent split_tap_press( | 884 ui::TouchEvent split_tap_press( |
870 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 885 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
871 generator_->Dispatch(&split_tap_press); | 886 generator_->Dispatch(&split_tap_press); |
872 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); | 887 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); |
873 ui::TouchEvent split_tap_release( | 888 ui::TouchEvent split_tap_release( |
874 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 889 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
875 generator_->Dispatch(&split_tap_release); | 890 generator_->Dispatch(&split_tap_release); |
876 EXPECT_FALSE(IsInNoFingersDownState()); | 891 EXPECT_FALSE(IsInNoFingersDownState()); |
| 892 // This is the added line in the test. TODO: Change the way the cursor |
| 893 // client is set up so this test will fail. |
| 894 EXPECT_TRUE(IsInTouchToMouseMode()); |
877 | 895 |
878 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 896 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); |
879 ASSERT_EQ(2U, captured_events.size()); | 897 ASSERT_EQ(2U, captured_events.size()); |
880 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 898 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
881 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 899 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
882 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 900 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
883 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 901 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
884 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 902 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
885 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 903 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
886 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 904 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 1001 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
984 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 1002 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
985 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 1003 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
986 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 1004 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
987 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 1005 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
988 released_time - pressed_time); | 1006 released_time - pressed_time); |
989 EXPECT_TRUE(IsInNoFingersDownState()); | 1007 EXPECT_TRUE(IsInNoFingersDownState()); |
990 } | 1008 } |
991 | 1009 |
992 } // namespace ui | 1010 } // namespace ui |
OLD | NEW |