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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_util_unittest.cc

Issue 1499873002: Fix MotionEvent conversion unit test to use valid tilt angles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Needed on Windows to get |M_PI| from <cmath>. 5 // Needed on Windows to get |M_PI| from <cmath>.
6 #ifdef _WIN32 6 #ifdef _WIN32
7 #define _USE_MATH_DEFINES 7 #define _USE_MATH_DEFINES
8 #endif 8 #endif
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 22 matching lines...) Expand all
33 const MotionEvent::ToolType tool_types[] = {MotionEvent::TOOL_TYPE_FINGER, 33 const MotionEvent::ToolType tool_types[] = {MotionEvent::TOOL_TYPE_FINGER,
34 MotionEvent::TOOL_TYPE_STYLUS, 34 MotionEvent::TOOL_TYPE_STYLUS,
35 MotionEvent::TOOL_TYPE_MOUSE}; 35 MotionEvent::TOOL_TYPE_MOUSE};
36 ui::PointerProperties pointer(5, 10, 40); 36 ui::PointerProperties pointer(5, 10, 40);
37 pointer.id = 15; 37 pointer.id = 15;
38 pointer.raw_x = 20; 38 pointer.raw_x = 20;
39 pointer.raw_y = 25; 39 pointer.raw_y = 25;
40 pointer.pressure = 30; 40 pointer.pressure = 30;
41 pointer.touch_minor = 35; 41 pointer.touch_minor = 35;
42 pointer.orientation = static_cast<float>(-M_PI / 2); 42 pointer.orientation = static_cast<float>(-M_PI / 2);
43 pointer.tilt = static_cast<float>(-M_PI / 3); 43 pointer.tilt = static_cast<float>(M_PI / 3);
44 for (MotionEvent::ToolType tool_type : tool_types) { 44 for (MotionEvent::ToolType tool_type : tool_types) {
45 pointer.tool_type = tool_type; 45 pointer.tool_type = tool_type;
46 MotionEventGeneric event( 46 MotionEventGeneric event(
47 MotionEvent::ACTION_DOWN, base::TimeTicks::Now(), pointer); 47 MotionEvent::ACTION_DOWN, base::TimeTicks::Now(), pointer);
48 event.set_flags(ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); 48 event.set_flags(ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN);
49 event.set_unique_event_id(123456U); 49 event.set_unique_event_id(123456U);
50 50
51 WebTouchEvent expected_event; 51 WebTouchEvent expected_event;
52 expected_event.type = WebInputEvent::TouchStart; 52 expected_event.type = WebInputEvent::TouchStart;
53 expected_event.touchesLength = 1; 53 expected_event.touchesLength = 1;
54 expected_event.timeStampSeconds = 54 expected_event.timeStampSeconds =
55 (event.GetEventTime() - base::TimeTicks()).InSecondsF(); 55 (event.GetEventTime() - base::TimeTicks()).InSecondsF();
56 expected_event.modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 56 expected_event.modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
57 WebTouchPoint expected_pointer; 57 WebTouchPoint expected_pointer;
58 expected_pointer.id = pointer.id; 58 expected_pointer.id = pointer.id;
59 expected_pointer.state = WebTouchPoint::StatePressed; 59 expected_pointer.state = WebTouchPoint::StatePressed;
60 expected_pointer.position = blink::WebFloatPoint(pointer.x, pointer.y); 60 expected_pointer.position = blink::WebFloatPoint(pointer.x, pointer.y);
61 expected_pointer.screenPosition = 61 expected_pointer.screenPosition =
62 blink::WebFloatPoint(pointer.raw_x, pointer.raw_y); 62 blink::WebFloatPoint(pointer.raw_x, pointer.raw_y);
63 expected_pointer.radiusX = pointer.touch_major / 2.f; 63 expected_pointer.radiusX = pointer.touch_major / 2.f;
64 expected_pointer.radiusY = pointer.touch_minor / 2.f; 64 expected_pointer.radiusY = pointer.touch_minor / 2.f;
65 expected_pointer.rotationAngle = 0.f; 65 expected_pointer.rotationAngle = 0.f;
66 expected_pointer.force = pointer.pressure; 66 expected_pointer.force = pointer.pressure;
67 if (tool_type == MotionEvent::TOOL_TYPE_STYLUS) { 67 if (tool_type == MotionEvent::TOOL_TYPE_STYLUS) {
68 expected_pointer.tiltX = -60; 68 expected_pointer.tiltX = 60;
69 expected_pointer.tiltY = 0; 69 expected_pointer.tiltY = 0;
70 } else { 70 } else {
71 expected_pointer.tiltX = 0; 71 expected_pointer.tiltX = 0;
72 expected_pointer.tiltY = 0; 72 expected_pointer.tiltY = 0;
73 } 73 }
74 expected_event.touches[0] = expected_pointer; 74 expected_event.touches[0] = expected_pointer;
75 expected_event.uniqueTouchEventId = 123456U; 75 expected_event.uniqueTouchEventId = 123456U;
76 76
77 WebTouchEvent actual_event = 77 WebTouchEvent actual_event =
78 ui::CreateWebTouchEventFromMotionEvent(event, false); 78 ui::CreateWebTouchEventFromMotionEvent(event, false);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 TEST(WebInputEventUtilTest, NoScalingWith1DSF) { 126 TEST(WebInputEventUtilTest, NoScalingWith1DSF) {
127 auto event = 127 auto event =
128 SyntheticWebMouseEventBuilder::Build(blink::WebInputEvent::MouseMove, 128 SyntheticWebMouseEventBuilder::Build(blink::WebInputEvent::MouseMove,
129 10, 10, 0); 129 10, 10, 0);
130 EXPECT_FALSE(ConvertWebInputEventToViewport(event, 1.f)); 130 EXPECT_FALSE(ConvertWebInputEventToViewport(event, 1.f));
131 EXPECT_TRUE(ConvertWebInputEventToViewport(event, 2.f)); 131 EXPECT_TRUE(ConvertWebInputEventToViewport(event, 2.f));
132 } 132 }
133 133
134 } // namespace content 134 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698