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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/gestures/gesture_recognizer_unittest.cc
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index 3c3e14f38d735321fca19391910e62cbe38bace9..a7e5114063e1f68396bbb16f8feab36498bd5d24 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -4690,5 +4690,82 @@ TEST_F(GestureRecognizerTest, GestureEventTwoWindowsActive) {
EXPECT_FALSE(queued_delegate->tap_down());
}
+// Test for crbug/698843. Checks whether the events are routed to the correct
+// consumer in the event of TransferEventsTo() function call.
+TEST_F(GestureRecognizerTest, TransferEventsToRoutesAckCorrectly) {
+ std::unique_ptr<QueueTouchEventDelegate> delegate_1(
+ new QueueTouchEventDelegate(host()->dispatcher()));
+ TimedEvents tes;
+ const int kTouchId = 7;
+ gfx::Rect bounds(0, 0, 1000, 1000);
+
+ std::unique_ptr<aura::Window> window_1(CreateTestWindowWithDelegate(
+ delegate_1.get(), -1234, bounds, root_window()));
+
+ delegate_1->set_window(window_1.get());
+
+ delegate_1->Reset();
+ ui::TouchEvent press(
+ ui::ET_TOUCH_PRESSED, gfx::Point(512, 512), tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ DispatchEventUsingWindowDispatcher(&press);
+ delegate_1->ReceivedAck();
+
+ EXPECT_2_EVENTS(delegate_1->events(), ui::ET_GESTURE_BEGIN,
+ ui::ET_GESTURE_TAP_DOWN);
+
+ ui::TouchEvent move(
+ ui::ET_TOUCH_MOVED, gfx::Point(530, 512), tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+
+ DispatchEventUsingWindowDispatcher(&move);
+
+ // Send a second move event to scroll.
+ ui::TouchEvent move2(
+ ui::ET_TOUCH_MOVED, gfx::Point(550, 512), tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ 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.
+
+ // Create a new consumer and Touch event delegate.
+ std::unique_ptr<QueueTouchEventDelegate> delegate_2(
+ new QueueTouchEventDelegate(host()->dispatcher()));
+ std::unique_ptr<aura::Window> window_2(CreateTestWindowWithDelegate(
+ delegate_2.get(), -2345, bounds, root_window()));
+ delegate_2->set_window(window_2.get());
+
+ // Transfer event sequence from previous window to the new window.
+ ui::GestureRecognizer::Get()->TransferEventsTo(
+ window_1.get(), window_2.get(),
+ ui::GestureRecognizer::ShouldCancelTouches::DontCancel);
+
+ delegate_1->Reset();
+ delegate_1->ReceivedAck();
+ // 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
+ // original consumer. See crbug/698843 for more details.
+ EXPECT_3_EVENTS(delegate_1->events(), ui::ET_GESTURE_TAP_CANCEL,
+ ui::ET_GESTURE_SCROLL_BEGIN, ui::ET_GESTURE_SCROLL_UPDATE);
+
+ delegate_1->Reset();
+ delegate_1->ReceivedAck();
+ EXPECT_1_EVENT(delegate_1->events(), ui::ET_GESTURE_SCROLL_UPDATE);
+
+ delegate_1->Reset();
+ ui::TouchEvent release(
+ ui::ET_TOUCH_RELEASED, gfx::Point(550, 512), tes.LeapForward(50),
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ DispatchEventUsingWindowDispatcher(&release);
+
+ // Events dispatched after the transfer should go to the new window.
+ EXPECT_0_EVENTS(delegate_1->events());
+
+ delegate_2->ReceivedAck();
+ // The event sequence transfer should mean that the new window receives the
+ // gesture sequence state.
+ EXPECT_2_EVENTS(delegate_2->events(), ui::ET_GESTURE_SCROLL_END,
+ ui::ET_GESTURE_END);
+
+ EXPECT_TRUE(delegate_2->scroll_end());
+}
+
} // namespace test
} // namespace aura
« 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