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

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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 // Tap and hold at one location, and get a mouse move event in touch explore. 564 // Tap and hold at one location, and get a mouse move event in touch explore.
565 EnterTouchExplorationModeAtLocation(initial_touch_location); 565 EnterTouchExplorationModeAtLocation(initial_touch_location);
566 std::vector<ui::LocatedEvent*> events = 566 std::vector<ui::LocatedEvent*> events =
567 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); 567 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
568 ASSERT_EQ(1U, events.size()); 568 ASSERT_EQ(1U, events.size());
569 569
570 EXPECT_EQ(initial_touch_location, events[0]->location()); 570 EXPECT_EQ(initial_touch_location, events[0]->location());
571 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); 571 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
572 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); 572 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
573 ClearCapturedEvents(); 573 ClearCapturedEvents();
574 EXPECT_TRUE(IsInTouchToMouseMode());
574 575
575 // Now tap and release at a different location. This should result in a 576 // Now tap and release at a different location. This should result in a
576 // single touch and release at the location of the first (held) tap, 577 // single touch and release at the location of the first (held) tap,
577 // not at the location of the second tap and release. 578 // not at the location of the second tap and release.
578 // After the release, there is still a finger in touch explore mode. 579 // After the release, there is still a finger in touch explore mode.
579 ui::TouchEvent split_tap_press( 580 ui::TouchEvent split_tap_press(
580 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 581 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
581 generator_->Dispatch(&split_tap_press); 582 generator_->Dispatch(&split_tap_press);
583 // To simulate the behavior of the real device, we manually disable
584 // mouse events. To not rely on manually setting the state, this is also
585 // tested in touch_exploration_controller_browsertest.
586 cursor_client()->DisableMouseEvents();
582 ui::TouchEvent split_tap_release( 587 ui::TouchEvent split_tap_release(
583 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 588 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
584 generator_->Dispatch(&split_tap_release); 589 generator_->Dispatch(&split_tap_release);
585 EXPECT_FALSE(IsInNoFingersDownState()); 590 EXPECT_FALSE(IsInNoFingersDownState());
591 // Releasing the second finger should re-enable mouse events putting us
592 // back into the touch exploration mode.
593 EXPECT_TRUE(IsInTouchToMouseMode());
586 594
587 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); 595 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
588 ASSERT_EQ(2U, captured_events.size()); 596 ASSERT_EQ(2U, captured_events.size());
589 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 597 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
590 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); 598 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
591 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 599 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
592 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 600 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
601 ClearCapturedEvents();
602
603 ui::TouchEvent touch_explore_release(
604 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now());
605 generator_->Dispatch(&touch_explore_release);
606 AdvanceSimulatedTimePastTapDelay();
607 EXPECT_TRUE(IsInNoFingersDownState());
593 } 608 }
594 609
595 // If split tap is started but the touch explore finger is released first, 610 // If split tap is started but the touch explore finger is released first,
596 // there should still be a touch press and release sent to the location of 611 // there should still be a touch press and release sent to the location of
597 // the last successful touch exploration. 612 // the last successful touch exploration.
598 // Both fingers should be released after the click goes through. 613 // Both fingers should be released after the click goes through.
599 TEST_F(TouchExplorationTest, SplitTapRelease) { 614 TEST_F(TouchExplorationTest, SplitTapRelease) {
600 SwitchTouchExplorationMode(true); 615 SwitchTouchExplorationMode(true);
601 616
602 gfx::Point initial_touch_location(11, 12); 617 gfx::Point initial_touch_location(11, 12);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 EnterTouchExplorationModeAtLocation(initial_touch_location); 662 EnterTouchExplorationModeAtLocation(initial_touch_location);
648 std::vector<ui::LocatedEvent*> events = 663 std::vector<ui::LocatedEvent*> events =
649 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); 664 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
650 ASSERT_EQ(1U, events.size()); 665 ASSERT_EQ(1U, events.size());
651 666
652 ClearCapturedEvents(); 667 ClearCapturedEvents();
653 668
654 // Now tap and release at a different location. This should result in a 669 // Now tap and release at a different location. This should result in a
655 // single touch and release at the location of the first (held) tap, 670 // single touch and release at the location of the first (held) tap,
656 // not at the location of the second tap and release. 671 // not at the location of the second tap and release.
657 // After the release, there is still a finger in touch explore mode. 672 // After the release, there is still a finger in touch exploration, and
673 // touches from this finger should trigger mouse events.
658 ui::TouchEvent split_tap_press( 674 ui::TouchEvent split_tap_press(
659 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 675 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
660 generator_->Dispatch(&split_tap_press); 676 generator_->Dispatch(&split_tap_press);
661 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); 677 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
662 ui::TouchEvent split_tap_release( 678 ui::TouchEvent split_tap_release(
663 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 679 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
664 generator_->Dispatch(&split_tap_release); 680 generator_->Dispatch(&split_tap_release);
665 EXPECT_FALSE(IsInNoFingersDownState()); 681 EXPECT_FALSE(IsInNoFingersDownState());
682 EXPECT_TRUE(IsInTouchToMouseMode());
666 683
667 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); 684 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
668 ASSERT_EQ(2U, captured_events.size()); 685 ASSERT_EQ(2U, captured_events.size());
669 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 686 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
670 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); 687 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
671 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); 688 base::TimeDelta pressed_time = captured_events[0]->time_stamp();
672 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 689 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
673 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 690 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
674 base::TimeDelta released_time = captured_events[1]->time_stamp(); 691 base::TimeDelta released_time = captured_events[1]->time_stamp();
675 EXPECT_EQ(gesture_detector_config_.longpress_timeout, 692 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 ClearCapturedEvents(); 959 ClearCapturedEvents();
943 960
944 ui::TouchEvent first_touch_release( 961 ui::TouchEvent first_touch_release(
945 ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now()); 962 ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now());
946 generator_->Dispatch(&first_touch_release); 963 generator_->Dispatch(&first_touch_release);
947 ASSERT_EQ(captured_events.size(), 1u); 964 ASSERT_EQ(captured_events.size(), 1u);
948 EXPECT_TRUE(IsInNoFingersDownState()); 965 EXPECT_TRUE(IsInNoFingersDownState());
949 } 966 }
950 967
951 } // namespace ui 968 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698