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

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

Issue 359453003: Added accurate TouchToMouseMode testing to SplitTap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
mfomitchev 2014/06/27 19:15:46 Hmm.. why do we advance the time? Doesn't seems li
evy 2014/06/30 23:28:47 We added single tap, which means that when you lif
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); 998 base::TimeDelta pressed_time = captured_events[0]->time_stamp();
984 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 999 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
985 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 1000 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
986 base::TimeDelta released_time = captured_events[1]->time_stamp(); 1001 base::TimeDelta released_time = captured_events[1]->time_stamp();
987 EXPECT_EQ(gesture_detector_config_.longpress_timeout, 1002 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
988 released_time - pressed_time); 1003 released_time - pressed_time);
989 EXPECT_TRUE(IsInNoFingersDownState()); 1004 EXPECT_TRUE(IsInNoFingersDownState());
990 } 1005 }
991 1006
992 } // namespace ui 1007 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698