Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 2789203006: Routes touch ACK events to the correct GestureProvider (Closed)
Patch Set: Added Bug specific unit test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 delegate_1->ReceivedAck();
4713
4714 EXPECT_2_EVENTS(delegate_1->events(), ui::ET_GESTURE_BEGIN,
4715 ui::ET_GESTURE_TAP_DOWN);
4716
4717 ui::TouchEvent move(
4718 ui::ET_TOUCH_MOVED, gfx::Point(530, 512), tes.Now(),
4719 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
4720
4721 DispatchEventUsingWindowDispatcher(&move);
4722
4723 // Send a second move event to scroll.
4724 ui::TouchEvent move2(
4725 ui::ET_TOUCH_MOVED, gfx::Point(550, 512), tes.Now(),
4726 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
4727 DispatchEventUsingWindowDispatcher(&move2);
tdresser 2017/04/06 20:59:52 Does the test need this second move? For that mat
malaykeshav 2017/04/07 01:07:59 Removed.
4728
4729 // Create a new consumer and Touch event delegate.
4730 std::unique_ptr<QueueTouchEventDelegate> delegate_2(
4731 new QueueTouchEventDelegate(host()->dispatcher()));
4732 std::unique_ptr<aura::Window> window_2(CreateTestWindowWithDelegate(
4733 delegate_2.get(), -2345, bounds, root_window()));
4734 delegate_2->set_window(window_2.get());
4735
4736 // Transfer event sequence from previous window to the new window.
4737 ui::GestureRecognizer::Get()->TransferEventsTo(
4738 window_1.get(), window_2.get(),
4739 ui::GestureRecognizer::ShouldCancelTouches::DontCancel);
4740
4741 delegate_1->Reset();
4742 delegate_1->ReceivedAck();
4743 // ACK for events that were dispatched before the trasnfer should go to the
tdresser 2017/04/06 20:59:52 trasnfer -> transfer
malaykeshav 2017/04/07 01:07:59 Done
4744 // original consumer. See crbug/698843 for more details.
4745 EXPECT_3_EVENTS(delegate_1->events(), ui::ET_GESTURE_TAP_CANCEL,
4746 ui::ET_GESTURE_SCROLL_BEGIN, ui::ET_GESTURE_SCROLL_UPDATE);
4747
4748 delegate_1->Reset();
4749 delegate_1->ReceivedAck();
4750 EXPECT_1_EVENT(delegate_1->events(), ui::ET_GESTURE_SCROLL_UPDATE);
4751
4752 delegate_1->Reset();
4753 ui::TouchEvent release(
4754 ui::ET_TOUCH_RELEASED, gfx::Point(550, 512), tes.LeapForward(50),
4755 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
4756 DispatchEventUsingWindowDispatcher(&release);
4757
4758 // Events dispatched after the transfer should go to the new window.
4759 EXPECT_0_EVENTS(delegate_1->events());
4760
4761 delegate_2->ReceivedAck();
4762 // The event sequence transfer should mean that the new window receives the
4763 // gesture sequence state.
4764 EXPECT_2_EVENTS(delegate_2->events(), ui::ET_GESTURE_SCROLL_END,
4765 ui::ET_GESTURE_END);
4766
4767 EXPECT_TRUE(delegate_2->scroll_end());
4768 }
4769
4693 } // namespace test 4770 } // namespace test
4694 } // namespace aura 4771 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/events/gestures/gesture_recognizer_impl.h » ('j') | ui/events/gestures/gesture_recognizer_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698