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

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: Flattened nested ifs, fixed a special case Created 5 years, 1 month 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..439e2c1893a36eec4d1703bd0e1da86bec71cddd 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
@@ -28,6 +28,10 @@ using ui::MotionEventGeneric;
namespace content {
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 +39,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) {
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.cc ('k') | content/common/input/synthetic_web_input_event_builders.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698