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

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

Issue 78263003: Ignore TouchCancel ack dispositions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REbase Created 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/browser/renderer_host/input/input_router_unittest.h" 5 #include "content/browser/renderer_host/input/input_router_unittest.h"
6 6
7 #include "content/browser/renderer_host/input/input_router.h" 7 #include "content/browser/renderer_host/input/input_router.h"
8 #include "content/common/input_messages.h" 8 #include "content/common/input_messages.h"
9 9
10 using blink::WebGestureEvent; 10 using blink::WebGestureEvent;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 ui::LatencyInfo())); 67 ui::LatencyInfo()));
68 } 68 }
69 69
70 void InputRouterTest::SimulateWheelEventWithPhase( 70 void InputRouterTest::SimulateWheelEventWithPhase(
71 WebMouseWheelEvent::Phase phase) { 71 WebMouseWheelEvent::Phase phase) {
72 input_router_->SendWheelEvent( 72 input_router_->SendWheelEvent(
73 MouseWheelEventWithLatencyInfo( 73 MouseWheelEventWithLatencyInfo(
74 SyntheticWebMouseWheelEventBuilder::Build(phase), ui::LatencyInfo())); 74 SyntheticWebMouseWheelEventBuilder::Build(phase), ui::LatencyInfo()));
75 } 75 }
76 76
77 // Inject provided synthetic WebGestureEvent instance.
78 void InputRouterTest::SimulateGestureEvent( 77 void InputRouterTest::SimulateGestureEvent(
79 const WebGestureEvent& gesture) { 78 const WebGestureEvent& gesture) {
80 GestureEventWithLatencyInfo gesture_with_latency(gesture, ui::LatencyInfo()); 79 GestureEventWithLatencyInfo gesture_with_latency(gesture, ui::LatencyInfo());
81 input_router_->SendGestureEvent(gesture_with_latency); 80 input_router_->SendGestureEvent(gesture_with_latency);
82 } 81 }
83 82
84 // Inject simple synthetic WebGestureEvent instances.
85 void InputRouterTest::SimulateGestureEvent( 83 void InputRouterTest::SimulateGestureEvent(
86 WebInputEvent::Type type, 84 WebInputEvent::Type type,
87 WebGestureEvent::SourceDevice sourceDevice) { 85 WebGestureEvent::SourceDevice sourceDevice) {
88 SimulateGestureEvent( 86 SimulateGestureEvent(
89 SyntheticWebGestureEventBuilder::Build(type, sourceDevice)); 87 SyntheticWebGestureEventBuilder::Build(type, sourceDevice));
90 } 88 }
91 89
92 void InputRouterTest::SimulateGestureScrollUpdateEvent(float dX, 90 void InputRouterTest::SimulateGestureScrollUpdateEvent(float dX,
93 float dY, 91 float dY,
94 int modifiers) { 92 int modifiers) {
95 SimulateGestureEvent( 93 SimulateGestureEvent(
96 SyntheticWebGestureEventBuilder::BuildScrollUpdate(dX, dY, modifiers)); 94 SyntheticWebGestureEventBuilder::BuildScrollUpdate(dX, dY, modifiers));
97 } 95 }
98 96
99 void InputRouterTest::SimulateGesturePinchUpdateEvent(float scale, 97 void InputRouterTest::SimulateGesturePinchUpdateEvent(float scale,
100 float anchorX, 98 float anchorX,
101 float anchorY, 99 float anchorY,
102 int modifiers) { 100 int modifiers) {
103 SimulateGestureEvent( 101 SimulateGestureEvent(
104 SyntheticWebGestureEventBuilder::BuildPinchUpdate(scale, 102 SyntheticWebGestureEventBuilder::BuildPinchUpdate(scale,
105 anchorX, 103 anchorX,
106 anchorY, 104 anchorY,
107 modifiers)); 105 modifiers));
108 } 106 }
109 107
110 // Inject synthetic GestureFlingStart events.
111 void InputRouterTest::SimulateGestureFlingStartEvent( 108 void InputRouterTest::SimulateGestureFlingStartEvent(
112 float velocityX, 109 float velocityX,
113 float velocityY, 110 float velocityY,
114 WebGestureEvent::SourceDevice sourceDevice) { 111 WebGestureEvent::SourceDevice sourceDevice) {
115 SimulateGestureEvent( 112 SimulateGestureEvent(
116 SyntheticWebGestureEventBuilder::BuildFling(velocityX, 113 SyntheticWebGestureEventBuilder::BuildFling(velocityX,
117 velocityY, 114 velocityY,
118 sourceDevice)); 115 sourceDevice));
119 } 116 }
120 117
121 void InputRouterTest::SimulateTouchEvent(int x, int y) { 118 void InputRouterTest::SimulateTouchEvent(WebInputEvent::Type type) {
122 PressTouchPoint(x, y); 119 touch_event_.ResetPoints();
120 int index = PressTouchPoint(0, 0);
121 switch (type) {
122 case WebInputEvent::TouchStart:
123 // Already handled by |PressTouchPoint()|.
124 break;
125 case WebInputEvent::TouchMove:
126 MoveTouchPoint(index, 5, 5);
127 break;
128 case WebInputEvent::TouchEnd:
129 ReleaseTouchPoint(index);
130 break;
131 case WebInputEvent::TouchCancel:
132 CancelTouchPoint(index);
133 break;
134 default:
135 FAIL() << "Invalid touch event type.";
136 break;
137 }
123 SendTouchEvent(); 138 SendTouchEvent();
124 } 139 }
125 140
126 // Set the timestamp for the touch-event.
127 void InputRouterTest::SetTouchTimestamp(base::TimeDelta timestamp) { 141 void InputRouterTest::SetTouchTimestamp(base::TimeDelta timestamp) {
128 touch_event_.SetTimestamp(timestamp); 142 touch_event_.SetTimestamp(timestamp);
129 } 143 }
130 144
131 // Sends a touch event (irrespective of whether the page has a touch-event
132 // handler or not).
133 void InputRouterTest::SendTouchEvent() { 145 void InputRouterTest::SendTouchEvent() {
134 input_router_->SendTouchEvent( 146 input_router_->SendTouchEvent(
135 TouchEventWithLatencyInfo(touch_event_, ui::LatencyInfo())); 147 TouchEventWithLatencyInfo(touch_event_, ui::LatencyInfo()));
136 touch_event_.ResetPoints(); 148 touch_event_.ResetPoints();
137 } 149 }
138 150
139 int InputRouterTest::PressTouchPoint(int x, int y) { 151 int InputRouterTest::PressTouchPoint(int x, int y) {
140 return touch_event_.PressPoint(x, y); 152 return touch_event_.PressPoint(x, y);
141 } 153 }
142 154
143 void InputRouterTest::MoveTouchPoint(int index, int x, int y) { 155 void InputRouterTest::MoveTouchPoint(int index, int x, int y) {
144 touch_event_.MovePoint(index, x, y); 156 touch_event_.MovePoint(index, x, y);
145 } 157 }
146 158
147 void InputRouterTest::ReleaseTouchPoint(int index) { 159 void InputRouterTest::ReleaseTouchPoint(int index) {
148 touch_event_.ReleasePoint(index); 160 touch_event_.ReleasePoint(index);
149 } 161 }
150 162
163 void InputRouterTest::CancelTouchPoint(int index) {
164 touch_event_.CancelPoint(index);
165 }
166
151 } // namespace content 167 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698