diff options
-rw-r--r-- | content/browser/renderer_host/input/motion_event_web.cc | 3 | ||||
-rw-r--r-- | ui/events/gestures/motion_event_aura.cc | 23 | ||||
-rw-r--r-- | ui/events/gestures/motion_event_aura_unittest.cc | 11 |
3 files changed, 25 insertions, 12 deletions
diff --git a/content/browser/renderer_host/input/motion_event_web.cc b/content/browser/renderer_host/input/motion_event_web.cc index c85d9c4..6e53773 100644 --- a/content/browser/renderer_host/input/motion_event_web.cc +++ b/content/browser/renderer_host/input/motion_event_web.cc @@ -119,7 +119,8 @@ base::TimeTicks MotionEventWeb::GetEventTime() const { ui::MotionEvent::ToolType MotionEventWeb::GetToolType( size_t pointer_index) const { - NOTIMPLEMENTED(); + // TODO(jdduke): Plumb tool type from the platform event, crbug.com/404128. + DCHECK_LT(pointer_index, GetPointerCount()); return TOOL_TYPE_UNKNOWN; } diff --git a/ui/events/gestures/motion_event_aura.cc b/ui/events/gestures/motion_event_aura.cc index 771b67f..ab20860 100644 --- a/ui/events/gestures/motion_event_aura.cc +++ b/ui/events/gestures/motion_event_aura.cc @@ -85,49 +85,50 @@ int MotionEventAura::GetActionIndex() const { DCHECK(cached_action_ == ACTION_POINTER_DOWN || cached_action_ == ACTION_POINTER_UP); DCHECK_GE(cached_action_index_, 0); - DCHECK_LE(cached_action_index_, static_cast<int>(pointer_count_)); + DCHECK_LT(cached_action_index_, static_cast<int>(pointer_count_)); return cached_action_index_; } size_t MotionEventAura::GetPointerCount() const { return pointer_count_; } int MotionEventAura::GetPointerId(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].touch_id; } float MotionEventAura::GetX(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].x; } float MotionEventAura::GetY(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].y; } float MotionEventAura::GetRawX(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].raw_x; } float MotionEventAura::GetRawY(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].raw_y; } float MotionEventAura::GetTouchMajor(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].major_radius * 2; } float MotionEventAura::GetPressure(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].pressure; } MotionEvent::ToolType MotionEventAura::GetToolType(size_t pointer_index) const { - NOTIMPLEMENTED(); + // TODO(jdduke): Plumb tool type from the platform, crbug.com/404128. + DCHECK_LT(pointer_index, pointer_count_); return MotionEvent::TOOL_TYPE_UNKNOWN; } @@ -175,7 +176,7 @@ MotionEventAura::PointData::PointData() } int MotionEventAura::GetSourceDeviceId(size_t pointer_index) const { - DCHECK_LE(pointer_index, pointer_count_); + DCHECK_LT(pointer_index, pointer_count_); return active_touches_[pointer_index].source_device_id; } @@ -212,7 +213,7 @@ void MotionEventAura::UpdateCachedAction(const TouchEvent& touch) { cached_action_ = ACTION_POINTER_UP; cached_action_index_ = static_cast<int>(GetIndexFromId(touch.touch_id())); - DCHECK_LE(cached_action_index_, static_cast<int>(pointer_count_)); + DCHECK_LT(cached_action_index_, static_cast<int>(pointer_count_)); } break; case ET_TOUCH_CANCELLED: diff --git a/ui/events/gestures/motion_event_aura_unittest.cc b/ui/events/gestures/motion_event_aura_unittest.cc index c45348e..3ef793e 100644 --- a/ui/events/gestures/motion_event_aura_unittest.cc +++ b/ui/events/gestures/motion_event_aura_unittest.cc @@ -320,4 +320,15 @@ TEST(MotionEventAuraTest, Cancel) { EXPECT_EQ(2U, static_cast<MotionEventAura*>(cancel.get())->GetPointerCount()); } +TEST(MotionEventAuraTest, ToolType) { + MotionEventAura event; + + // For now, all pointers have an unknown tool type. + // TODO(jdduke): Expand this test when ui::TouchEvent identifies the source + // touch type, crbug.com/404128. + event.OnTouch(TouchWithType(ET_TOUCH_PRESSED, 7)); + ASSERT_EQ(1U, event.GetPointerCount()); + EXPECT_EQ(MotionEvent::TOOL_TYPE_UNKNOWN, event.GetToolType(0)); +} + } // namespace ui |