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

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: rebased 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
« 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 // Tap and hold at one location, and get a mouse move event in touch explore. 663 // Tap and hold at one location, and get a mouse move event in touch explore.
664 EnterTouchExplorationModeAtLocation(initial_touch_location); 664 EnterTouchExplorationModeAtLocation(initial_touch_location);
665 std::vector<ui::LocatedEvent*> events = 665 std::vector<ui::LocatedEvent*> events =
666 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); 666 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
667 ASSERT_EQ(1U, events.size()); 667 ASSERT_EQ(1U, events.size());
668 668
669 EXPECT_EQ(initial_touch_location, events[0]->location()); 669 EXPECT_EQ(initial_touch_location, events[0]->location());
670 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); 670 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
671 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); 671 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
672 ClearCapturedEvents(); 672 ClearCapturedEvents();
673 EXPECT_TRUE(IsInTouchToMouseMode());
673 674
674 // Now tap and release at a different location. This should result in a 675 // Now tap and release at a different location. This should result in a
675 // single touch and release at the location of the first (held) tap, 676 // single touch and release at the location of the first (held) tap,
676 // not at the location of the second tap and release. 677 // not at the location of the second tap and release.
677 // After the release, there is still a finger in touch explore mode. 678 // After the release, there is still a finger in touch explore mode.
678 ui::TouchEvent split_tap_press( 679 ui::TouchEvent split_tap_press(
679 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 680 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
680 generator_->Dispatch(&split_tap_press); 681 generator_->Dispatch(&split_tap_press);
682 // To simulate the behavior of the real device, we manually disable
683 // mouse events. To not rely on manually setting the state, this is also
684 // tested in touch_exploration_controller_browsertest.
685 cursor_client()->DisableMouseEvents();
686 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled());
687 EXPECT_FALSE(cursor_client()->IsCursorVisible());
681 EXPECT_FALSE(IsInGestureInProgressState()); 688 EXPECT_FALSE(IsInGestureInProgressState());
682 ui::TouchEvent split_tap_release( 689 ui::TouchEvent split_tap_release(
683 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 690 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
684 generator_->Dispatch(&split_tap_release); 691 generator_->Dispatch(&split_tap_release);
692 // Releasing the second finger should re-enable mouse events putting us
693 // back into the touch exploration mode.
694 EXPECT_TRUE(IsInTouchToMouseMode());
685 EXPECT_FALSE(IsInNoFingersDownState()); 695 EXPECT_FALSE(IsInNoFingersDownState());
686 696
687 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 697 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
688 ASSERT_EQ(2U, captured_events.size()); 698 ASSERT_EQ(2U, captured_events.size());
689 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 699 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
690 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); 700 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
691 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 701 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
692 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 702 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
703 ClearCapturedEvents();
704
705 ui::TouchEvent touch_explore_release(
706 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now());
707 generator_->Dispatch(&touch_explore_release);
708 AdvanceSimulatedTimePastTapDelay();
709 EXPECT_TRUE(IsInNoFingersDownState());
693 } 710 }
694 711
695 // If split tap is started but the touch explore finger is released first, 712 // If split tap is started but the touch explore finger is released first,
696 // there should still be a touch press and release sent to the location of 713 // there should still be a touch press and release sent to the location of
697 // the last successful touch exploration. 714 // the last successful touch exploration.
698 // Both fingers should be released after the click goes through. 715 // Both fingers should be released after the click goes through.
699 TEST_F(TouchExplorationTest, SplitTapRelease) { 716 TEST_F(TouchExplorationTest, SplitTapRelease) {
700 SwitchTouchExplorationMode(true); 717 SwitchTouchExplorationMode(true);
701 718
702 gfx::Point initial_touch_location(11, 12); 719 gfx::Point initial_touch_location(11, 12);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 gfx::Point second_touch_location(33, 34); 761 gfx::Point second_touch_location(33, 34);
745 762
746 // Tap and hold at one location, and get a mouse move event in touch explore. 763 // Tap and hold at one location, and get a mouse move event in touch explore.
747 EnterTouchExplorationModeAtLocation(initial_touch_location); 764 EnterTouchExplorationModeAtLocation(initial_touch_location);
748 std::vector<ui::LocatedEvent*> events = 765 std::vector<ui::LocatedEvent*> events =
749 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); 766 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED);
750 ASSERT_EQ(1U, events.size()); 767 ASSERT_EQ(1U, events.size());
751 768
752 ClearCapturedEvents(); 769 ClearCapturedEvents();
753 770
754 // Now tap and release at a different location. This should result in a 771 // Now tap, hold, and release at a different location. This should result
755 // single touch and release at the location of the first (held) tap, 772 // in a single touch and release (long press) at the location of the first
756 // not at the location of the second tap and release. 773 // (held) tap, not at the location of the second tap and release.
757 // After the release, there is still a finger in touch explore mode.
758 ui::TouchEvent split_tap_press( 774 ui::TouchEvent split_tap_press(
759 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 775 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
760 generator_->Dispatch(&split_tap_press); 776 generator_->Dispatch(&split_tap_press);
777 // To simulate the behavior of the real device, we manually disable
778 // mouse events, like in the SplitTap test.
779 cursor_client()->DisableMouseEvents();
780 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled());
781 EXPECT_FALSE(cursor_client()->IsCursorVisible());
782 EXPECT_FALSE(IsInGestureInProgressState());
761 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); 783 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
784 // After the release, there is still a finger in touch exploration, and
785 // mouse events should be enabled again.
762 ui::TouchEvent split_tap_release( 786 ui::TouchEvent split_tap_release(
763 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 787 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
764 generator_->Dispatch(&split_tap_release); 788 generator_->Dispatch(&split_tap_release);
765 EXPECT_FALSE(IsInNoFingersDownState()); 789 EXPECT_FALSE(IsInNoFingersDownState());
790 EXPECT_TRUE(IsInTouchToMouseMode());
766 791
767 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 792 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
768 ASSERT_EQ(2U, captured_events.size()); 793 ASSERT_EQ(2U, captured_events.size());
769 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 794 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
770 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); 795 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
771 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); 796 base::TimeDelta pressed_time = captured_events[0]->time_stamp();
772 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 797 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
773 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 798 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
774 base::TimeDelta released_time = captured_events[1]->time_stamp(); 799 base::TimeDelta released_time = captured_events[1]->time_stamp();
775 EXPECT_EQ(gesture_detector_config_.longpress_timeout, 800 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 // The rest of the events should occur in passthrough. 1332 // The rest of the events should occur in passthrough.
1308 generator_->ReleaseTouchId(0); 1333 generator_->ReleaseTouchId(0);
1309 ASSERT_EQ(1U, captured_events.size()); 1334 ASSERT_EQ(1U, captured_events.size());
1310 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type()); 1335 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type());
1311 ClearCapturedEvents(); 1336 ClearCapturedEvents();
1312 generator_->ReleaseTouchId(1); 1337 generator_->ReleaseTouchId(1);
1313 ASSERT_EQ(0U, captured_events.size()); 1338 ASSERT_EQ(0U, captured_events.size());
1314 } 1339 }
1315 1340
1316 } // namespace ui 1341 } // 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