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 4672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4683 EXPECT_FALSE(queued_delegate2->scroll_update()); | 4683 EXPECT_FALSE(queued_delegate2->scroll_update()); |
4684 EXPECT_FALSE(queued_delegate2->scroll_end()); | 4684 EXPECT_FALSE(queued_delegate2->scroll_end()); |
4685 EXPECT_FALSE(queued_delegate2->long_press()); | 4685 EXPECT_FALSE(queued_delegate2->long_press()); |
4686 | 4686 |
4687 queued_delegate->Reset(); | 4687 queued_delegate->Reset(); |
4688 queued_delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); | 4688 queued_delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); |
4689 EXPECT_TRUE(queued_delegate->show_press()); | 4689 EXPECT_TRUE(queued_delegate->show_press()); |
4690 EXPECT_FALSE(queued_delegate->tap_down()); | 4690 EXPECT_FALSE(queued_delegate->tap_down()); |
4691 } | 4691 } |
4692 | 4692 |
| 4693 // Test for crbug/698843. Checks whether the events are routed to the correct |
| 4694 // consumer in the event of TransferEventsTo() function call. |
| 4695 TEST_F(GestureRecognizerTest, TransferEventsToRoutesAckCorrectly) { |
| 4696 std::unique_ptr<QueueTouchEventDelegate> delegate_1( |
| 4697 new QueueTouchEventDelegate(host()->dispatcher())); |
| 4698 TimedEvents tes; |
| 4699 const int kTouchId = 7; |
| 4700 gfx::Rect bounds(0, 0, 1000, 1000); |
| 4701 |
| 4702 std::unique_ptr<aura::Window> window_1(CreateTestWindowWithDelegate( |
| 4703 delegate_1.get(), -1234, bounds, root_window())); |
| 4704 |
| 4705 delegate_1->set_window(window_1.get()); |
| 4706 |
| 4707 delegate_1->Reset(); |
| 4708 ui::TouchEvent press( |
| 4709 ui::ET_TOUCH_PRESSED, gfx::Point(512, 512), tes.Now(), |
| 4710 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 4711 DispatchEventUsingWindowDispatcher(&press); |
| 4712 |
| 4713 // Create a new consumer and Touch event delegate. |
| 4714 std::unique_ptr<QueueTouchEventDelegate> delegate_2( |
| 4715 new QueueTouchEventDelegate(host()->dispatcher())); |
| 4716 std::unique_ptr<aura::Window> window_2(CreateTestWindowWithDelegate( |
| 4717 delegate_2.get(), -2345, bounds, root_window())); |
| 4718 delegate_2->set_window(window_2.get()); |
| 4719 |
| 4720 // Transfer event sequence from previous window to the new window. |
| 4721 ui::GestureRecognizer::Get()->TransferEventsTo( |
| 4722 window_1.get(), window_2.get(), |
| 4723 ui::GestureRecognizer::ShouldCancelTouches::DontCancel); |
| 4724 |
| 4725 delegate_1->Reset(); |
| 4726 delegate_1->ReceivedAck(); |
| 4727 |
| 4728 // ACK for events that were dispatched before the transfer should go to the |
| 4729 // original consumer. See crbug/698843 for more details. |
| 4730 EXPECT_2_EVENTS(delegate_1->events(), ui::ET_GESTURE_BEGIN, |
| 4731 ui::ET_GESTURE_TAP_DOWN); |
| 4732 |
| 4733 delegate_1->Reset(); |
| 4734 |
| 4735 ui::TouchEvent release( |
| 4736 ui::ET_TOUCH_RELEASED, gfx::Point(550, 512), tes.LeapForward(50), |
| 4737 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId)); |
| 4738 DispatchEventUsingWindowDispatcher(&release); |
| 4739 |
| 4740 // Events dispatched after the transfer should go to the new window. |
| 4741 EXPECT_0_EVENTS(delegate_1->events()); |
| 4742 |
| 4743 delegate_2->ReceivedAck(); |
| 4744 |
| 4745 // The event sequence transfer should mean that the new window receives the |
| 4746 // gesture sequence state. |
| 4747 EXPECT_3_EVENTS(delegate_2->events(), ui::ET_GESTURE_SHOW_PRESS, |
| 4748 ui::ET_GESTURE_TAP, ui::ET_GESTURE_END); |
| 4749 |
| 4750 EXPECT_TRUE(delegate_2->tap()); |
| 4751 } |
| 4752 |
4693 } // namespace test | 4753 } // namespace test |
4694 } // namespace aura | 4754 } // namespace aura |
OLD | NEW |