| 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/events/gesture_detection/gesture_provider.h" | 5 #include "ui/events/gesture_detection/gesture_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" |
| 14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "ui/events/event_constants.h" | 19 #include "ui/events/event_constants.h" |
| 19 #include "ui/events/gesture_detection/gesture_event_data.h" | 20 #include "ui/events/gesture_detection/gesture_event_data.h" |
| 20 #include "ui/events/gesture_detection/motion_event.h" | 21 #include "ui/events/gesture_detection/motion_event.h" |
| 21 #include "ui/events/test/motion_event_test_utils.h" | 22 #include "ui/events/test/motion_event_test_utils.h" |
| 22 #include "ui/gfx/geometry/point_f.h" | 23 #include "ui/gfx/geometry/point_f.h" |
| 23 | 24 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 | 412 |
| 412 event = ObtainMotionEvent(event_time + 2 * kDeltaTimeForFlingSequences, | 413 event = ObtainMotionEvent(event_time + 2 * kDeltaTimeForFlingSequences, |
| 413 MotionEvent::ACTION_POINTER_UP, | 414 MotionEvent::ACTION_POINTER_UP, |
| 414 positions); | 415 positions); |
| 415 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 416 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 416 } | 417 } |
| 417 | 418 |
| 418 static void RunTasksAndWait(base::TimeDelta delay) { | 419 static void RunTasksAndWait(base::TimeDelta delay) { |
| 419 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 420 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 420 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); | 421 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); |
| 421 base::MessageLoop::current()->Run(); | 422 base::RunLoop().Run(); |
| 422 } | 423 } |
| 423 | 424 |
| 424 std::vector<GestureEventData> gestures_; | 425 std::vector<GestureEventData> gestures_; |
| 425 std::unique_ptr<GestureProvider> gesture_provider_; | 426 std::unique_ptr<GestureProvider> gesture_provider_; |
| 426 std::unique_ptr<GestureEventData> active_scroll_begin_event_; | 427 std::unique_ptr<GestureEventData> active_scroll_begin_event_; |
| 427 base::MessageLoopForUI message_loop_; | 428 base::MessageLoopForUI message_loop_; |
| 428 }; | 429 }; |
| 429 | 430 |
| 430 // Verify that a DOWN followed shortly by an UP will trigger a single tap. | 431 // Verify that a DOWN followed shortly by an UP will trigger a single tap. |
| 431 TEST_F(GestureProviderTest, GestureTap) { | 432 TEST_F(GestureProviderTest, GestureTap) { |
| (...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, | 2643 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, |
| 2643 kFakeCoordY + GetTouchSlop() / 2); | 2644 kFakeCoordY + GetTouchSlop() / 2); |
| 2644 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2645 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 2645 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); | 2646 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); |
| 2646 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2647 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
| 2647 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); | 2648 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); |
| 2648 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); | 2649 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); |
| 2649 } | 2650 } |
| 2650 | 2651 |
| 2651 } // namespace ui | 2652 } // namespace ui |
| OLD | NEW |