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

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

Issue 712133003: Track whether a scroll sequence has been partially prevented (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Filter swipe explicitly Created 6 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 unified diff | Download patch
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>
11 11
12 #include "content/browser/renderer_host/input/web_input_event_util.h" 12 #include "content/browser/renderer_host/input/web_input_event_util.h"
13 #include "content/common/input/web_input_event_traits.h" 13 #include "content/common/input/web_input_event_traits.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/events/event_constants.h" 15 #include "ui/events/event_constants.h"
16 #include "ui/events/gesture_detection/gesture_event_data.h"
16 #include "ui/events/gesture_detection/motion_event_generic.h" 17 #include "ui/events/gesture_detection/motion_event_generic.h"
18 #include "ui/events/gesture_event_details.h"
17 19
18 using blink::WebInputEvent; 20 using blink::WebInputEvent;
19 using blink::WebTouchEvent; 21 using blink::WebTouchEvent;
20 using blink::WebTouchPoint; 22 using blink::WebTouchPoint;
21 using ui::MotionEvent; 23 using ui::MotionEvent;
22 using ui::MotionEventGeneric; 24 using ui::MotionEventGeneric;
23 25
24 namespace content { 26 namespace content {
25 27
26 TEST(WebInputEventUtilTest, MotionEventConversion) { 28 TEST(WebInputEventUtilTest, MotionEventConversion) {
(...skipping 24 matching lines...) Expand all
51 expected_pointer.radiusY = pointer.touch_minor / 2.f; 53 expected_pointer.radiusY = pointer.touch_minor / 2.f;
52 expected_pointer.rotationAngle = 0.f; 54 expected_pointer.rotationAngle = 0.f;
53 expected_pointer.force = pointer.pressure; 55 expected_pointer.force = pointer.pressure;
54 expected_event.touches[0] = expected_pointer; 56 expected_event.touches[0] = expected_pointer;
55 57
56 WebTouchEvent actual_event = CreateWebTouchEventFromMotionEvent(event); 58 WebTouchEvent actual_event = CreateWebTouchEventFromMotionEvent(event);
57 EXPECT_EQ(WebInputEventTraits::ToString(expected_event), 59 EXPECT_EQ(WebInputEventTraits::ToString(expected_event),
58 WebInputEventTraits::ToString(actual_event)); 60 WebInputEventTraits::ToString(actual_event));
59 } 61 }
60 62
63 TEST(WebInputEventUtilTest, ScrollUpdateConversion) {
64 int motion_event_id = 0;
65 MotionEvent::ToolType tool_type = MotionEvent::TOOL_TYPE_UNKNOWN;
66 base::TimeTicks timestamp = base::TimeTicks::Now();
67 gfx::Vector2dF delta(-5.f, 10.f);
68 gfx::PointF pos(1.f, 2.f);
69 gfx::PointF raw_pos(11.f, 12.f);
70 size_t touch_points = 1;
71 gfx::RectF rect(pos, gfx::SizeF());
72 int flags = 0;
73 ui::GestureEventDetails details(ui::ET_GESTURE_SCROLL_UPDATE,
74 delta.x(),
75 delta.y());
76 details.mark_previous_scroll_update_in_sequence_prevented();
77 ui::GestureEventData event(details,
78 motion_event_id,
79 tool_type,
80 timestamp,
81 pos.x(),
82 pos.y(),
83 raw_pos.x(),
84 raw_pos.y(),
85 touch_points,
86 rect,
87 flags);
88
89 blink::WebGestureEvent web_event =
90 CreateWebGestureEventFromGestureEventData(event);
91 EXPECT_EQ(WebInputEvent::GestureScrollUpdate, web_event.type);
92 EXPECT_EQ(0, web_event.modifiers);
93 EXPECT_EQ((timestamp - base::TimeTicks()).InSecondsF(),
94 web_event.timeStampSeconds);
95 EXPECT_EQ(static_cast<int>(pos.x()), web_event.x);
96 EXPECT_EQ(static_cast<int>(pos.y()), web_event.y);
97 EXPECT_EQ(static_cast<int>(raw_pos.x()), web_event.globalX);
98 EXPECT_EQ(static_cast<int>(raw_pos.y()), web_event.globalY);
99 EXPECT_EQ(blink::WebGestureDeviceTouchscreen, web_event.sourceDevice);
100 EXPECT_EQ(delta.x(), web_event.data.scrollUpdate.deltaX);
101 EXPECT_EQ(delta.y(), web_event.data.scrollUpdate.deltaY);
102 EXPECT_TRUE(web_event.data.scrollUpdate.previousUpdateInSequencePrevented);
103 }
104
61 } // namespace content 105 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698