OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2569 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN); | 2569 delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN); |
2570 | 2570 |
2571 delegate->Reset(); | 2571 delegate->Reset(); |
2572 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), | 2572 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), |
2573 kTouchId2, tes.Now()); | 2573 kTouchId2, tes.Now()); |
2574 DispatchEventUsingWindowDispatcher(&press2); | 2574 DispatchEventUsingWindowDispatcher(&press2); |
2575 EXPECT_2_EVENTS( | 2575 EXPECT_2_EVENTS( |
2576 delegate->events(), ui::ET_GESTURE_TAP_CANCEL, ui::ET_GESTURE_BEGIN); | 2576 delegate->events(), ui::ET_GESTURE_TAP_CANCEL, ui::ET_GESTURE_BEGIN); |
2577 | 2577 |
2578 // Little bit of touch move should not affect our state. | 2578 // Little bit of touch move should not affect our state. |
2579 // Moving within slop region doesn't cause scrolling. | |
2579 delegate->Reset(); | 2580 delegate->Reset(); |
2580 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202), | 2581 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(102, 202), |
2581 kTouchId1, tes.Now()); | 2582 kTouchId1, tes.Now()); |
2582 DispatchEventUsingWindowDispatcher(&move1); | 2583 DispatchEventUsingWindowDispatcher(&move1); |
2583 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202), | 2584 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(131, 202), |
2584 kTouchId2, tes.Now()); | 2585 kTouchId2, tes.Now()); |
2585 DispatchEventUsingWindowDispatcher(&move2); | 2586 DispatchEventUsingWindowDispatcher(&move2); |
2586 EXPECT_3_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_BEGIN, | |
2587 ui::ET_GESTURE_SCROLL_UPDATE, ui::ET_GESTURE_SCROLL_UPDATE); | |
tdresser
2016/07/01 14:29:15
Can we expect some number of events here?
sahel
2016/07/05 20:36:34
Done.
| |
2588 | 2587 |
2589 // Make sure there is enough delay before the touch is released so that it is | 2588 // Make sure there is enough delay before the touch is released so that it is |
2590 // recognized as a tap. | 2589 // recognized as a tap. |
2591 delegate->Reset(); | 2590 delegate->Reset(); |
2592 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), | 2591 ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), |
2593 kTouchId1, tes.LeapForward(50)); | 2592 kTouchId1, tes.LeapForward(50)); |
2594 | 2593 |
2595 DispatchEventUsingWindowDispatcher(&release1); | 2594 DispatchEventUsingWindowDispatcher(&release1); |
2596 EXPECT_2_EVENTS( | 2595 EXPECT_2_EVENTS( |
2597 delegate->events(), ui::ET_GESTURE_TWO_FINGER_TAP, ui::ET_GESTURE_END); | 2596 delegate->events(), ui::ET_GESTURE_TWO_FINGER_TAP, ui::ET_GESTURE_END); |
2598 | 2597 |
2599 // Lift second finger. | 2598 // Lift second finger. |
2600 // Make sure there is enough delay before the touch is released so that it is | 2599 // Two fingers have been down at some point during the current touch, |
2601 // recognized as a tap. | 2600 // single tap doesn't happen while releasing the second finger. |
2602 delegate->Reset(); | 2601 delegate->Reset(); |
2603 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), | 2602 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), |
2604 kTouchId2, tes.LeapForward(50)); | 2603 kTouchId2, tes.LeapForward(50)); |
2605 | 2604 |
2606 DispatchEventUsingWindowDispatcher(&release2); | 2605 DispatchEventUsingWindowDispatcher(&release2); |
2607 EXPECT_2_EVENTS( | 2606 EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_END); |
2608 delegate->events(), ui::ET_GESTURE_SCROLL_END, ui::ET_GESTURE_END); | |
2609 } | 2607 } |
2610 | 2608 |
2611 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { | 2609 TEST_F(GestureRecognizerTest, TwoFingerTapExpired) { |
2612 std::unique_ptr<GestureEventConsumeDelegate> delegate( | 2610 std::unique_ptr<GestureEventConsumeDelegate> delegate( |
2613 new GestureEventConsumeDelegate()); | 2611 new GestureEventConsumeDelegate()); |
2614 const int kWindowWidth = 123; | 2612 const int kWindowWidth = 123; |
2615 const int kWindowHeight = 45; | 2613 const int kWindowHeight = 45; |
2616 const int kTouchId1 = 2; | 2614 const int kTouchId1 = 2; |
2617 const int kTouchId2 = 3; | 2615 const int kTouchId2 = 3; |
2618 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 2616 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4442 EXPECT_FALSE(queued_delegate2->long_press()); | 4440 EXPECT_FALSE(queued_delegate2->long_press()); |
4443 | 4441 |
4444 queued_delegate->Reset(); | 4442 queued_delegate->Reset(); |
4445 queued_delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); | 4443 queued_delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); |
4446 EXPECT_TRUE(queued_delegate->show_press()); | 4444 EXPECT_TRUE(queued_delegate->show_press()); |
4447 EXPECT_FALSE(queued_delegate->tap_down()); | 4445 EXPECT_FALSE(queued_delegate->tap_down()); |
4448 } | 4446 } |
4449 | 4447 |
4450 } // namespace test | 4448 } // namespace test |
4451 } // namespace aura | 4449 } // namespace aura |
OLD | NEW |