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

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: removed extra browser test 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 explore mode.
658 ui::TouchEvent split_tap_press( 673 ui::TouchEvent split_tap_press(
659 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); 674 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now());
660 generator_->Dispatch(&split_tap_press); 675 generator_->Dispatch(&split_tap_press);
661 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); 676 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
662 ui::TouchEvent split_tap_release( 677 ui::TouchEvent split_tap_release(
663 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); 678 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now());
664 generator_->Dispatch(&split_tap_release); 679 generator_->Dispatch(&split_tap_release);
665 EXPECT_FALSE(IsInNoFingersDownState()); 680 EXPECT_FALSE(IsInNoFingersDownState());
681 // This is the added line in the test. TODO: Change the way the cursor
682 // client is set up so this test will fail.
mfomitchev 2014/07/03 17:31:55 Need to fix the comment. Also make it so the test
evy 2014/07/07 18:53:42 Done.
mfomitchev 2014/07/09 13:26:01 Does it fail without the fix now? I thought you ne
683 EXPECT_TRUE(IsInTouchToMouseMode());
666 684
667 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); 685 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
668 ASSERT_EQ(2U, captured_events.size()); 686 ASSERT_EQ(2U, captured_events.size());
669 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); 687 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
670 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); 688 EXPECT_EQ(initial_touch_location, captured_events[0]->location());
671 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); 689 base::TimeDelta pressed_time = captured_events[0]->time_stamp();
672 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); 690 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
673 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); 691 EXPECT_EQ(initial_touch_location, captured_events[1]->location());
674 base::TimeDelta released_time = captured_events[1]->time_stamp(); 692 base::TimeDelta released_time = captured_events[1]->time_stamp();
675 EXPECT_EQ(gesture_detector_config_.longpress_timeout, 693 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 ClearCapturedEvents(); 960 ClearCapturedEvents();
943 961
944 ui::TouchEvent first_touch_release( 962 ui::TouchEvent first_touch_release(
945 ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now()); 963 ui::ET_TOUCH_RELEASED, first_touch_location, 0, Now());
946 generator_->Dispatch(&first_touch_release); 964 generator_->Dispatch(&first_touch_release);
947 ASSERT_EQ(captured_events.size(), 1u); 965 ASSERT_EQ(captured_events.size(), 1u);
948 EXPECT_TRUE(IsInNoFingersDownState()); 966 EXPECT_TRUE(IsInNoFingersDownState());
949 } 967 }
950 968
951 } // namespace ui 969 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698