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" |
| 6 |
5 #include <stddef.h> | 7 #include <stddef.h> |
6 | 8 |
| 9 #include <memory> |
| 10 |
7 #include "base/logging.h" | 11 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
10 #include "base/time/time.h" | 13 #include "base/time/time.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
13 #include "ui/events/gesture_detection/gesture_event_data.h" | 16 #include "ui/events/gesture_detection/gesture_event_data.h" |
14 #include "ui/events/gesture_detection/gesture_provider.h" | |
15 #include "ui/events/gesture_detection/motion_event.h" | 17 #include "ui/events/gesture_detection/motion_event.h" |
16 #include "ui/events/test/motion_event_test_utils.h" | 18 #include "ui/events/test/motion_event_test_utils.h" |
17 #include "ui/gfx/geometry/point_f.h" | 19 #include "ui/gfx/geometry/point_f.h" |
18 | 20 |
19 using base::TimeDelta; | 21 using base::TimeDelta; |
20 using base::TimeTicks; | 22 using base::TimeTicks; |
21 using ui::test::MockMotionEvent; | 23 using ui::test::MockMotionEvent; |
22 | 24 |
23 namespace ui { | 25 namespace ui { |
24 namespace { | 26 namespace { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 410 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
409 } | 411 } |
410 | 412 |
411 static void RunTasksAndWait(base::TimeDelta delay) { | 413 static void RunTasksAndWait(base::TimeDelta delay) { |
412 base::MessageLoop::current()->PostDelayedTask( | 414 base::MessageLoop::current()->PostDelayedTask( |
413 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); | 415 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), delay); |
414 base::MessageLoop::current()->Run(); | 416 base::MessageLoop::current()->Run(); |
415 } | 417 } |
416 | 418 |
417 std::vector<GestureEventData> gestures_; | 419 std::vector<GestureEventData> gestures_; |
418 scoped_ptr<GestureProvider> gesture_provider_; | 420 std::unique_ptr<GestureProvider> gesture_provider_; |
419 scoped_ptr<GestureEventData> active_scroll_begin_event_; | 421 std::unique_ptr<GestureEventData> active_scroll_begin_event_; |
420 base::MessageLoopForUI message_loop_; | 422 base::MessageLoopForUI message_loop_; |
421 }; | 423 }; |
422 | 424 |
423 // Verify that a DOWN followed shortly by an UP will trigger a single tap. | 425 // Verify that a DOWN followed shortly by an UP will trigger a single tap. |
424 TEST_F(GestureProviderTest, GestureTap) { | 426 TEST_F(GestureProviderTest, GestureTap) { |
425 base::TimeTicks event_time = base::TimeTicks::Now(); | 427 base::TimeTicks event_time = base::TimeTicks::Now(); |
426 int motion_event_id = 6; | 428 int motion_event_id = 6; |
427 int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN; | 429 int motion_event_flags = EF_CONTROL_DOWN | EF_ALT_DOWN; |
428 | 430 |
429 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false); | 431 gesture_provider_->SetDoubleTapSupportForPlatformEnabled(false); |
(...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, | 2637 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_DOWN, kFakeCoordX, |
2636 kFakeCoordY + GetTouchSlop() / 2); | 2638 kFakeCoordY + GetTouchSlop() / 2); |
2637 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2639 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
2638 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); | 2640 event = ObtainMotionEvent(event_time, MotionEvent::ACTION_UP); |
2639 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2641 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
2640 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); | 2642 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); |
2641 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); | 2643 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); |
2642 } | 2644 } |
2643 | 2645 |
2644 } // namespace ui | 2646 } // namespace ui |
OLD | NEW |