Index: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
index aba2b57322ef07d0fe0960cff38befe6ac9c07b5..bde1bd447f236fb0919924b4bfd40402586c3714 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
@@ -303,6 +303,8 @@ class FakeRenderWidgetHostViewAura : public RenderWidgetHostViewAura { |
touch_event_.reset( |
new blink::WebTouchEvent(ui::CreateWebTouchEventFromMotionEvent( |
pointer_state(), event->may_cause_scrolling()))); |
+ MarkUnchangedTouchPointsAsStationary(touch_event_.get(), |
+ event->touch_id()); |
} else { |
// Never create a WebTouchEvent with 0 touch points. |
touch_event_.reset(); |
@@ -1124,6 +1126,89 @@ TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { |
EXPECT_EQ(nullptr, view_->touch_event_); |
} |
+// Checks that touch-event state is maintained correctly for multiple touch |
+// points. |
+TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { |
jdduke (slow)
2015/05/08 15:28:56
I guess I'm wondering why we can't validate the re
tdresser
2015/05/08 15:34:26
That would be an improvement.
lanwei
2015/05/08 20:47:05
Thanks for the good suggestion, it is better to us
|
+ view_->InitAsChild(NULL); |
+ view_->Show(); |
+ GetSentMessageCountAndResetSink(); |
+ |
+ ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, |
+ ui::EventTimeForNow()); |
+ |
+ view_->OnTouchEvent(&press0); |
+ EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); |
+ EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
+ EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
+ view_->touch_event_->touches[0].state); |
+ |
+ ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
+ ui::EventTimeForNow()); |
+ |
+ view_->OnTouchEvent(&move0); |
+ EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
+ EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
+ EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
+ view_->touch_event_->touches[0].state); |
+ |
+ // For the second touchstart, only the state of the second touch point is |
+ // StatePressed, the state of the first touch point is StateStationary. |
+ ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, |
+ ui::EventTimeForNow()); |
+ |
+ view_->OnTouchEvent(&press1); |
+ EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); |
+ EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
+ EXPECT_EQ(blink::WebTouchPoint::StateStationary, |
+ view_->touch_event_->touches[0].state); |
+ EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
+ view_->touch_event_->touches[1].state); |
+ |
+ // For the touchmove of second point, the state of the second touch point is |
+ // StateMoved, the state of the first touch point is StateStationary. |
+ ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, |
+ ui::EventTimeForNow()); |
+ |
+ view_->OnTouchEvent(&move1); |
+ EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
+ EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
+ EXPECT_EQ(blink::WebTouchPoint::StateStationary, |
+ view_->touch_event_->touches[0].state); |
+ EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
+ view_->touch_event_->touches[1].state); |
+ |
+ // For the touchmove of first point, the state of the first touch point is |
+ // StateMoved, the state of the second touch point is StateStationary. |
+ ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, |
+ ui::EventTimeForNow()); |
+ |
+ view_->OnTouchEvent(&move2); |
+ EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
+ EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
+ EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
+ view_->touch_event_->touches[0].state); |
+ EXPECT_EQ(blink::WebTouchPoint::StateStationary, |
+ view_->touch_event_->touches[1].state); |
+ |
+ ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 10), 0, |
+ ui::EventTimeForNow()); |
+ |
+ // For the touchcancel, only the state of the current touch point is |
+ // StateCancelled, the state of the other touch point is StateStationary. |
+ view_->OnTouchEvent(&cancel0); |
+ EXPECT_EQ(blink::WebInputEvent::TouchCancel, view_->touch_event_->type); |
+ EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
+ EXPECT_EQ(blink::WebTouchPoint::StateStationary, |
+ view_->touch_event_->touches[0].state); |
+ EXPECT_EQ(1, view_->touch_event_->touches[0].id); |
+ |
+ ui::TouchEvent cancel1(ui::ET_TOUCH_CANCELLED, gfx::Point(30, 30), 1, |
+ ui::EventTimeForNow()); |
+ |
+ view_->OnTouchEvent(&cancel1); |
+ EXPECT_EQ(nullptr, view_->touch_event_); |
+} |
+ |
// Checks that touch-events are queued properly when there is a touch-event |
// handler on the page. |
TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |