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

Unified Diff: content/browser/renderer_host/input/web_input_event_util_unittest.cc

Issue 1417803002: Pass MotionEvent tilt angles to Blink on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug reference Created 5 years, 2 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: content/browser/renderer_host/input/web_input_event_util_unittest.cc
diff --git a/content/browser/renderer_host/input/web_input_event_util_unittest.cc b/content/browser/renderer_host/input/web_input_event_util_unittest.cc
index 862d6c1486393143eb4d4026236233bc7be69290..b2751a1b7cfd70642c614e9383a877cf945e9988 100644
--- a/content/browser/renderer_host/input/web_input_event_util_unittest.cc
+++ b/content/browser/renderer_host/input/web_input_event_util_unittest.cc
@@ -26,8 +26,11 @@ using ui::MotionEvent;
using ui::MotionEventGeneric;
namespace content {
tdresser 2015/11/02 14:44:07 Leave space after namespace.
e_hakkinen 2015/11/02 16:27:16 Done.
-
TEST(WebInputEventUtilTest, MotionEventConversion) {
+
+ const MotionEvent::ToolType tool_types[] = {MotionEvent::TOOL_TYPE_FINGER,
+ MotionEvent::TOOL_TYPE_STYLUS,
+ MotionEvent::TOOL_TYPE_MOUSE};
ui::PointerProperties pointer(5, 10, 40);
pointer.id = 15;
pointer.raw_x = 20;
@@ -35,34 +38,45 @@ TEST(WebInputEventUtilTest, MotionEventConversion) {
pointer.pressure = 30;
pointer.touch_minor = 35;
pointer.orientation = static_cast<float>(-M_PI / 2);
- MotionEventGeneric event(
- MotionEvent::ACTION_DOWN, base::TimeTicks::Now(), pointer);
- event.set_flags(ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN);
- event.set_unique_event_id(123456U);
+ pointer.tilt = static_cast<float>(-M_PI / 3);
+ for (MotionEvent::ToolType tool_type : tool_types) {
+ pointer.tool_type = tool_type;
+ MotionEventGeneric event(
+ MotionEvent::ACTION_DOWN, base::TimeTicks::Now(), pointer);
+ event.set_flags(ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN);
+ event.set_unique_event_id(123456U);
- WebTouchEvent expected_event;
- expected_event.type = WebInputEvent::TouchStart;
- expected_event.touchesLength = 1;
- expected_event.timeStampSeconds =
- (event.GetEventTime() - base::TimeTicks()).InSecondsF();
- expected_event.modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
- WebTouchPoint expected_pointer;
- expected_pointer.id = pointer.id;
- expected_pointer.state = WebTouchPoint::StatePressed;
- expected_pointer.position = blink::WebFloatPoint(pointer.x, pointer.y);
- expected_pointer.screenPosition =
- blink::WebFloatPoint(pointer.raw_x, pointer.raw_y);
- expected_pointer.radiusX = pointer.touch_major / 2.f;
- expected_pointer.radiusY = pointer.touch_minor / 2.f;
- expected_pointer.rotationAngle = 0.f;
- expected_pointer.force = pointer.pressure;
- expected_event.touches[0] = expected_pointer;
- expected_event.uniqueTouchEventId = 123456U;
+ WebTouchEvent expected_event;
+ expected_event.type = WebInputEvent::TouchStart;
+ expected_event.touchesLength = 1;
+ expected_event.timeStampSeconds =
+ (event.GetEventTime() - base::TimeTicks()).InSecondsF();
+ expected_event.modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
+ WebTouchPoint expected_pointer;
+ expected_pointer.id = pointer.id;
+ expected_pointer.state = WebTouchPoint::StatePressed;
+ expected_pointer.position = blink::WebFloatPoint(pointer.x, pointer.y);
+ expected_pointer.screenPosition =
+ blink::WebFloatPoint(pointer.raw_x, pointer.raw_y);
+ expected_pointer.radiusX = pointer.touch_major / 2.f;
+ expected_pointer.radiusY = pointer.touch_minor / 2.f;
+ expected_pointer.rotationAngle = 0.f;
+ expected_pointer.force = pointer.pressure;
+ if (tool_type == MotionEvent::TOOL_TYPE_STYLUS) {
+ expected_pointer.tiltX = -60;
+ expected_pointer.tiltY = 0;
+ } else {
+ expected_pointer.tiltX = 0;
+ expected_pointer.tiltY = 0;
+ }
+ expected_event.touches[0] = expected_pointer;
+ expected_event.uniqueTouchEventId = 123456U;
- WebTouchEvent actual_event =
- ui::CreateWebTouchEventFromMotionEvent(event, false);
- EXPECT_EQ(WebInputEventTraits::ToString(expected_event),
- WebInputEventTraits::ToString(actual_event));
+ WebTouchEvent actual_event =
+ ui::CreateWebTouchEventFromMotionEvent(event, false);
+ EXPECT_EQ(WebInputEventTraits::ToString(expected_event),
+ WebInputEventTraits::ToString(actual_event));
+ }
}
TEST(WebInputEventUtilTest, ScrollUpdateConversion) {

Powered by Google App Engine
This is Rietveld 408576698