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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
774 | 774 |
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(); |
mfomitchev
2014/06/27 16:36:05
Add EXPECT_TRUE(IsInTouchToMouseMode())
evy
2014/06/27 18:03:00
Done.
| |
785 | 785 |
786 // Now tap and release at a different location. This should result in a | 786 // 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, | 787 // single touch and release at the location of the first (held) tap, |
788 // not at the location of the second tap and release. | 788 // not at the location of the second tap and release. |
789 // After the release, there is still a finger in touch explore mode. | 789 // After the release, there is still a finger in touch explore mode. |
790 ui::TouchEvent split_tap_press( | 790 ui::TouchEvent split_tap_press( |
791 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 791 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
792 generator_->Dispatch(&split_tap_press); | 792 generator_->Dispatch(&split_tap_press); |
793 cursor_client()->DisableMouseEvents(); | |
mfomitchev
2014/06/27 16:36:05
A comment explaining that we are simulating the be
tdanderson
2014/06/27 17:01:07
I'd also mention that you've added the browser tes
evy
2014/06/27 18:03:00
Done.
evy
2014/06/27 18:03:00
Done.
| |
794 cursor_client()->HideCursor(); | |
mfomitchev
2014/06/27 16:36:05
You can probably get rid of HideCursor() since lik
evy
2014/06/27 18:03:00
Done.
| |
793 ui::TouchEvent split_tap_release( | 795 ui::TouchEvent split_tap_release( |
794 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 796 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
795 generator_->Dispatch(&split_tap_release); | 797 generator_->Dispatch(&split_tap_release); |
796 EXPECT_FALSE(IsInNoFingersDownState()); | 798 EXPECT_FALSE(IsInNoFingersDownState()); |
799 EXPECT_TRUE(IsInTouchToMouseMode()); | |
mfomitchev
2014/06/27 16:36:05
Comment: Releasing the second finger should re-ena
evy
2014/06/27 18:03:00
Done.
| |
797 | 800 |
798 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 801 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); |
799 ASSERT_EQ(2U, captured_events.size()); | 802 ASSERT_EQ(2U, captured_events.size()); |
800 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 803 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
801 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 804 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
802 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 805 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
803 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 806 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
804 } | 807 } |
mfomitchev
2014/06/27 16:36:05
At the end of the test would be good to do the rel
evy
2014/06/27 18:03:00
Done.
| |
805 | 808 |
806 // If split tap is started but the touch explore finger is released first, | 809 // 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 | 810 // there should still be a touch press and release sent to the location of |
808 // the last successful touch exploration. | 811 // the last successful touch exploration. |
809 // Both fingers should be released after the click goes through. | 812 // Both fingers should be released after the click goes through. |
810 TEST_F(TouchExplorationTest, SplitTapRelease) { | 813 TEST_F(TouchExplorationTest, SplitTapRelease) { |
811 SwitchTouchExplorationMode(true); | 814 SwitchTouchExplorationMode(true); |
812 | 815 |
813 gfx::Point initial_touch_location(11, 12); | 816 gfx::Point initial_touch_location(11, 12); |
814 gfx::Point second_touch_location(33, 34); | 817 gfx::Point second_touch_location(33, 34); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
983 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 986 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
984 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 987 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
985 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 988 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
986 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 989 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
987 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 990 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
988 released_time - pressed_time); | 991 released_time - pressed_time); |
989 EXPECT_TRUE(IsInNoFingersDownState()); | 992 EXPECT_TRUE(IsInNoFingersDownState()); |
990 } | 993 } |
991 | 994 |
992 } // namespace ui | 995 } // namespace ui |
OLD | NEW |