| OLD | NEW |
| 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" |
| 11 #include "ui/aura/test/event_generator.h" | 11 #include "ui/aura/test/event_generator.h" |
| 12 #include "ui/aura/test/test_cursor_client.h" | 12 #include "ui/aura/test/test_cursor_client.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 15 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
| 16 #include "ui/events/gestures/gesture_provider_aura.h" |
| 16 #include "ui/gfx/geometry/point.h" | 17 #include "ui/gfx/geometry/point.h" |
| 17 #include "ui/gl/gl_implementation.h" | 18 #include "ui/gl/gl_implementation.h" |
| 18 #include "ui/gl/gl_surface.h" | 19 #include "ui/gl/gl_surface.h" |
| 19 | 20 |
| 20 namespace ui { | 21 namespace ui { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 // Records all mouse and touch events. | 24 // Records all mouse and touch events. |
| 24 class EventCapturer : public ui::EventHandler { | 25 class EventCapturer : public ui::EventHandler { |
| 25 public: | 26 public: |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 | 652 |
| 652 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 653 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); |
| 653 ASSERT_EQ(2U, captured_events.size()); | 654 ASSERT_EQ(2U, captured_events.size()); |
| 654 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 655 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
| 655 EXPECT_EQ(tap_location, captured_events[0]->location()); | 656 EXPECT_EQ(tap_location, captured_events[0]->location()); |
| 656 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 657 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
| 657 EXPECT_EQ(tap_location, captured_events[1]->location()); | 658 EXPECT_EQ(tap_location, captured_events[1]->location()); |
| 658 EXPECT_TRUE(IsInNoFingersDownState()); | 659 EXPECT_TRUE(IsInNoFingersDownState()); |
| 659 } | 660 } |
| 660 | 661 |
| 661 | |
| 662 // Double-tapping where the user holds their finger down for the second time | 662 // Double-tapping where the user holds their finger down for the second time |
| 663 // for a longer press should send a touch press and released (right click) | 663 // for a longer press should send a touch press and released (right click) |
| 664 // to the location of the last successful touch exploration. | 664 // to the location of the last successful touch exploration. |
| 665 TEST_F(TouchExplorationTest, DoubleTapLongPress) { | 665 TEST_F(TouchExplorationTest, DoubleTapLongPress) { |
| 666 SwitchTouchExplorationMode(true); | 666 SwitchTouchExplorationMode(true); |
| 667 | 667 |
| 668 // Tap at one location, and get a mouse move event. | 668 // Tap at one location, and get a mouse move event. |
| 669 gfx::Point tap_location(11, 12); | 669 gfx::Point tap_location(11, 12); |
| 670 generator_->set_current_location(tap_location); | 670 generator_->set_current_location(tap_location); |
| 671 generator_->PressTouch(); | 671 generator_->PressTouch(); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 945 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
| 946 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 946 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
| 947 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 947 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
| 948 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 948 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
| 949 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 949 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
| 950 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 950 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
| 951 released_time - pressed_time); | 951 released_time - pressed_time); |
| 952 EXPECT_TRUE(IsInNoFingersDownState()); | 952 EXPECT_TRUE(IsInNoFingersDownState()); |
| 953 } | 953 } |
| 954 | 954 |
| 955 // A swipe right gesture should trigger a Shift+Search+RightArrow |
| 956 // keyboard pressed event. |
| 957 TEST_F(TouchExplorationTest, GestureSwipeRight) { |
| 958 SwitchTouchExplorationMode(true); |
| 959 // TODO(lisayin) add gesture tests. |
| 960 } |
| 961 |
| 955 } // namespace ui | 962 } // namespace ui |
| OLD | NEW |