Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 334223007: Fix multi-finger click no entry bug in TouchExplorationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_tap
Patch Set: formatting fixes Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // should send a touch press and released to the location of the last 812 // should send a touch press and released to the location of the last
813 // successful touch exploration. There should be a delay between the 813 // successful touch exploration. There should be a delay between the
814 // touch and release events (right click). 814 // touch and release events (right click).
815 TEST_F(TouchExplorationTest, SplitTapLongPress) { 815 TEST_F(TouchExplorationTest, SplitTapLongPress) {
816 SwitchTouchExplorationMode(true); 816 SwitchTouchExplorationMode(true);
817 gfx::Point initial_touch_location(11, 12); 817 gfx::Point initial_touch_location(11, 12);
818 gfx::Point second_touch_location(33, 34); 818 gfx::Point second_touch_location(33, 34);
819 819
820 // Tap and hold at one location, and get a mouse move event in touch explore. 820 // Tap and hold at one location, and get a mouse move event in touch explore.
821 EnterTouchExplorationModeAtLocation(initial_touch_location); 821 EnterTouchExplorationModeAtLocation(initial_touch_location);
822
823 std::vector<ui::LocatedEvent*> events = 822 std::vector<ui::LocatedEvent*> events =
824 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); 823 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
825 ASSERT_EQ(1U, events.size()); 824 ASSERT_EQ(1U, events.size());
826 825
827 ClearCapturedEvents(); 826 ClearCapturedEvents();
828 827
829 // Now tap and release at a different location. This should result in a 828 // Now tap and release at a different location. This should result in a
830 // single touch and release at the location of the first (held) tap, 829 // single touch and release at the location of the first (held) tap,
831 // not at the location of the second tap and release. 830 // not at the location of the second tap and release.
832 // After the release, there is still a finger in touch explore mode. 831 // After the release, there is still a finger in touch explore mode.
(...skipping 24 matching lines...) Expand all
857 // as a longpress, there should be a delay between the sent touch and release 856 // as a longpress, there should be a delay between the sent touch and release
858 // events (right click).All fingers should be released after the click 857 // events (right click).All fingers should be released after the click
859 // goes through. 858 // goes through.
860 TEST_F(TouchExplorationTest, SplitTapReleaseLongPress) { 859 TEST_F(TouchExplorationTest, SplitTapReleaseLongPress) {
861 SwitchTouchExplorationMode(true); 860 SwitchTouchExplorationMode(true);
862 gfx::Point initial_touch_location(11, 12); 861 gfx::Point initial_touch_location(11, 12);
863 gfx::Point second_touch_location(33, 34); 862 gfx::Point second_touch_location(33, 34);
864 863
865 // Tap and hold at one location, and get a mouse move event in touch explore. 864 // Tap and hold at one location, and get a mouse move event in touch explore.
866 EnterTouchExplorationModeAtLocation(initial_touch_location); 865 EnterTouchExplorationModeAtLocation(initial_touch_location);
867
868 std::vector<ui::LocatedEvent*> events = 866 std::vector<ui::LocatedEvent*> events =
869 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); 867 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
870 ASSERT_EQ(1U, events.size()); 868 ASSERT_EQ(1U, events.size());
871 ClearCapturedEvents(); 869 ClearCapturedEvents();
872 870
873 // Now tap at a different location. Release at the first location, 871 // Now tap at a different location. Release at the first location,
874 // then release at the second. This should result in a 872 // then release at the second. This should result in a
875 // single touch and release at the location of the first (held) tap, 873 // single touch and release at the location of the first (held) tap,
876 // not at the location of the second tap and release. 874 // not at the location of the second tap and release.
877 // After the release, TouchToMouseMode should still be on. 875 // After the release, TouchToMouseMode should still be on.
(...skipping 14 matching lines...) Expand all
892 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 890 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
893 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); 891 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
894 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); 892 base::TimeDelta pressed_time = captured_events[0]->time_stamp();
895 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 893 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
896 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 894 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
897 base::TimeDelta released_time = captured_events[1]->time_stamp(); 895 base::TimeDelta released_time = captured_events[1]->time_stamp();
898 EXPECT_EQ(gesture_detector_config_.longpress_timeout, 896 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
899 released_time - pressed_time); 897 released_time - pressed_time);
900 } 898 }
901 899
900 TEST_F(TouchExplorationTest, SplitTapLongPressMultiFinger) {
901 SwitchTouchExplorationMode(true);
902 gfx::Point initial_touch_location(11, 12);
903 gfx::Point second_touch_location(33, 34);
904 gfx::Point third_touch_location(16, 17);
905
906 // Tap and hold at one location, and get a mouse move event in touch explore.
907 EnterTouchExplorationModeAtLocation(initial_touch_location);
908
909 std::vector<ui::LocatedEvent*> events =
910 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
911 ASSERT_EQ(1U, events.size());
912
913 EXPECT_EQ(initial_touch_location, events[0]->location());
914 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
915 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
916 ClearCapturedEvents();
917
918 // Now tap at a different location and hold for long press.
919 ui::TouchEvent split_tap_press(
920 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
921 generator_->Dispatch(&split_tap_press);
922 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
923
924 // Placing a third finger on the screen should be discarded and not affect
925 // the events passed through.
926 ui::TouchEvent third_press(
927 ui::ET_TOUCH_PRESSED, third_touch_location, 2, Now());
928 generator_->Dispatch(&third_press);
929
930 // When all three fingers are released, there should be only two captured
931 // events: touch press and touch release. All fingers should then be up.
932 ui::TouchEvent touch_explore_release(
933 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now());
934 generator_->Dispatch(&touch_explore_release);
935 ui::TouchEvent split_tap_release(
936 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
937 generator_->Dispatch(&split_tap_release);
938 ui::TouchEvent third_tap_release(
939 ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now());
940 generator_->Dispatch(&third_tap_release);
941
942 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
943 ASSERT_EQ(2U, captured_events.size());
944 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
945 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
946 base::TimeDelta pressed_time = captured_events[0]->time_stamp();
947 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
948 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
949 base::TimeDelta released_time = captured_events[1]->time_stamp();
950 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
951 released_time - pressed_time);
952 EXPECT_TRUE(IsInNoFingersDownState());
953 }
902 954
903 } // namespace ui 955 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698