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

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

Issue 465543003: Modified state flow for touch explore released in touch_exploration_controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); 811 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
812 ASSERT_EQ(4U, captured_events.size()); 812 ASSERT_EQ(4U, captured_events.size());
813 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type()); 813 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type());
814 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type()); 814 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type());
815 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type()); 815 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type());
816 EXPECT_EQ(tap_location, captured_events[2]->location()); 816 EXPECT_EQ(tap_location, captured_events[2]->location());
817 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[3]->type()); 817 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[3]->type());
818 EXPECT_EQ(tap_location, captured_events[3]->location()); 818 EXPECT_EQ(tap_location, captured_events[3]->location());
819 } 819 }
820 820
821 // Single-tapping and holding should send a touch press and release through to
822 // the location of the last successful touch exploration. There should be a
823 // delay between the touch and release events (right click). The user should
824 // not enter passthrough mode - touch moves should be discarded.
825 TEST_F(TouchExplorationTest, SingleTapLongPress) {
826 SwitchTouchExplorationMode(true);
827
828 // Tap once to simulate a mouse moved event.
829 gfx::Point initial_location(11, 12);
830 generator_->set_current_location(initial_location);
831 generator_->PressTouch();
832 AdvanceSimulatedTimePastTapDelay();
833 ClearCapturedEvents();
834
835 // Move to another location for single tap
836 gfx::Point tap_location(22, 23);
837 generator_->MoveTouch(tap_location);
838 generator_->ReleaseTouch();
839
840 // Tap again for a long press single tap.
841 gfx::Point final_location(33, 34);
842 generator_->set_current_location(final_location);
843 generator_->PressTouch();
844 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
845
846 // Touch moves should not send any events through, since the user should be
aboxhall 2014/08/13 20:34:32 Assert that no events are sent through?
evy 2014/08/13 22:16:58 Done.
847 // in a wait for release state.
848 gfx::Point move_location(44, 45);
849 generator_->MoveTouch(move_location);
850
851 generator_->ReleaseTouch();
852
853 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
854 ASSERT_EQ(4U, captured_events.size());
855 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type());
aboxhall 2014/08/13 20:34:33 Would it be possible to assert these events are ca
evy 2014/08/13 22:16:57 Done.
856 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type());
857 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type());
858 EXPECT_EQ(tap_location, captured_events[2]->location());
859 base::TimeDelta pressed_time = captured_events[2]->time_stamp();
860 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[3]->type());
861 EXPECT_EQ(tap_location, captured_events[3]->location());
862 base::TimeDelta released_time = captured_events[3]->time_stamp();
863 EXPECT_EQ(gesture_detector_config_.longpress_timeout,
864 released_time - pressed_time);
865 }
866
821 // Double-tapping without coming from touch exploration (no previous touch 867 // Double-tapping without coming from touch exploration (no previous touch
822 // exploration event) should not generate any events. 868 // exploration event) should not generate any events.
823 TEST_F(TouchExplorationTest, DoubleTapNoTouchExplore) { 869 TEST_F(TouchExplorationTest, DoubleTapNoTouchExplore) {
824 SwitchTouchExplorationMode(true); 870 SwitchTouchExplorationMode(true);
825 871
826 // Double-tap without any previous touch. 872 // Double-tap without any previous touch.
827 // Touch exploration mode has not been entered, so there is no previous 873 // Touch exploration mode has not been entered, so there is no previous
828 // touch exploration event. The double-tap should be discarded, and no events 874 // touch exploration event. The double-tap should be discarded, and no events
829 // should be generated at all. 875 // should be generated at all.
830 gfx::Point double_tap_location(33, 34); 876 gfx::Point double_tap_location(33, 34);
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 EXPECT_FALSE(IsInSlideGestureState()); 1567 EXPECT_FALSE(IsInSlideGestureState());
1522 EXPECT_FALSE(IsInTouchToMouseMode()); 1568 EXPECT_FALSE(IsInTouchToMouseMode());
1523 1569
1524 AdvanceSimulatedTimePastTapDelay(); 1570 AdvanceSimulatedTimePastTapDelay();
1525 EXPECT_FALSE(IsInGestureInProgressState()); 1571 EXPECT_FALSE(IsInGestureInProgressState());
1526 EXPECT_FALSE(IsInSlideGestureState()); 1572 EXPECT_FALSE(IsInSlideGestureState());
1527 EXPECT_TRUE(IsInTouchToMouseMode()); 1573 EXPECT_TRUE(IsInTouchToMouseMode());
1528 } 1574 }
1529 1575
1530 } // namespace ui 1576 } // 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