OLD | NEW |
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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 RenderWidgetHostImpl* GetWidgetHost() { | 96 RenderWidgetHostImpl* GetWidgetHost() { |
97 return RenderWidgetHostImpl::From( | 97 return RenderWidgetHostImpl::From( |
98 shell()->web_contents()->GetRenderViewHost()->GetWidget()); | 98 shell()->web_contents()->GetRenderViewHost()->GetWidget()); |
99 } | 99 } |
100 | 100 |
101 scoped_refptr<InputMsgWatcher> AddFilter(blink::WebInputEvent::Type type) { | 101 scoped_refptr<InputMsgWatcher> AddFilter(blink::WebInputEvent::Type type) { |
102 return new InputMsgWatcher(GetWidgetHost(), type); | 102 return new InputMsgWatcher(GetWidgetHost(), type); |
103 } | 103 } |
104 | 104 |
105 protected: | 105 protected: |
| 106 void SendTouchEvent(SyntheticWebTouchEvent* event) { |
| 107 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(*event, |
| 108 ui::LatencyInfo()); |
| 109 event->ResetPoints(); |
| 110 } |
106 void LoadURL() { | 111 void LoadURL() { |
107 const GURL data_url(kTouchEventDataURL); | 112 const GURL data_url(kTouchEventDataURL); |
108 NavigateToURL(shell(), data_url); | 113 NavigateToURL(shell(), data_url); |
109 | 114 |
110 RenderWidgetHostImpl* host = GetWidgetHost(); | 115 RenderWidgetHostImpl* host = GetWidgetHost(); |
111 host->GetView()->SetSize(gfx::Size(400, 400)); | 116 host->GetView()->SetSize(gfx::Size(400, 400)); |
112 | 117 |
113 // The page is loaded in the renderer, wait for a new frame to arrive. | 118 // The page is loaded in the renderer, wait for a new frame to arrive. |
114 while (!host->ScheduleComposite()) | 119 while (!host->ScheduleComposite()) |
115 GiveItSomeTime(); | 120 GiveItSomeTime(); |
(...skipping 12 matching lines...) Expand all Loading... |
128 #define MAYBE_TouchNoHandler TouchNoHandler | 133 #define MAYBE_TouchNoHandler TouchNoHandler |
129 #endif | 134 #endif |
130 IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_TouchNoHandler) { | 135 IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_TouchNoHandler) { |
131 LoadURL(); | 136 LoadURL(); |
132 SyntheticWebTouchEvent touch; | 137 SyntheticWebTouchEvent touch; |
133 | 138 |
134 // A press on |first| should be acked with NO_CONSUMER_EXISTS since there is | 139 // A press on |first| should be acked with NO_CONSUMER_EXISTS since there is |
135 // no touch-handler on it. | 140 // no touch-handler on it. |
136 touch.PressPoint(25, 25); | 141 touch.PressPoint(25, 25); |
137 scoped_refptr<InputMsgWatcher> filter = AddFilter(WebInputEvent::TouchStart); | 142 scoped_refptr<InputMsgWatcher> filter = AddFilter(WebInputEvent::TouchStart); |
138 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 143 SendTouchEvent(&touch); |
139 | 144 |
140 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, filter->WaitForAck()); | 145 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, filter->WaitForAck()); |
141 | 146 |
142 // If a touch-press is acked with NO_CONSUMER_EXISTS, then subsequent | 147 // If a touch-press is acked with NO_CONSUMER_EXISTS, then subsequent |
143 // touch-points don't need to be dispatched until the touch point is released. | 148 // touch-points don't need to be dispatched until the touch point is released. |
144 touch.ReleasePoint(0); | 149 touch.ReleasePoint(0); |
145 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 150 SendTouchEvent(&touch); |
146 touch.ResetPoints(); | |
147 } | 151 } |
148 | 152 |
149 #if defined(OS_CHROMEOS) | 153 #if defined(OS_CHROMEOS) |
150 // crbug.com/514456 | 154 // crbug.com/514456 |
151 #define MAYBE_TouchHandlerNoConsume DISABLED_TouchHandlerNoConsume | 155 #define MAYBE_TouchHandlerNoConsume DISABLED_TouchHandlerNoConsume |
152 #else | 156 #else |
153 #define MAYBE_TouchHandlerNoConsume TouchHandlerNoConsume | 157 #define MAYBE_TouchHandlerNoConsume TouchHandlerNoConsume |
154 #endif | 158 #endif |
155 IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_TouchHandlerNoConsume) { | 159 IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_TouchHandlerNoConsume) { |
156 LoadURL(); | 160 LoadURL(); |
157 SyntheticWebTouchEvent touch; | 161 SyntheticWebTouchEvent touch; |
158 | 162 |
159 // Press on |second| should be acked with NOT_CONSUMED since there is a | 163 // Press on |second| should be acked with NOT_CONSUMED since there is a |
160 // touch-handler on |second|, but it doesn't consume the event. | 164 // touch-handler on |second|, but it doesn't consume the event. |
161 touch.PressPoint(125, 25); | 165 touch.PressPoint(125, 25); |
162 scoped_refptr<InputMsgWatcher> filter = AddFilter(WebInputEvent::TouchStart); | 166 scoped_refptr<InputMsgWatcher> filter = AddFilter(WebInputEvent::TouchStart); |
163 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 167 SendTouchEvent(&touch); |
164 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, filter->WaitForAck()); | 168 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, filter->WaitForAck()); |
165 | 169 |
166 filter = AddFilter(WebInputEvent::TouchEnd); | 170 filter = AddFilter(WebInputEvent::TouchEnd); |
167 touch.ReleasePoint(0); | 171 touch.ReleasePoint(0); |
168 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 172 SendTouchEvent(&touch); |
169 touch.ResetPoints(); | |
170 filter->WaitForAck(); | 173 filter->WaitForAck(); |
171 } | 174 } |
172 | 175 |
173 #if defined(OS_CHROMEOS) | 176 #if defined(OS_CHROMEOS) |
174 // crbug.com/514456 | 177 // crbug.com/514456 |
175 #define MAYBE_TouchHandlerConsume DISABLED_TouchHandlerConsume | 178 #define MAYBE_TouchHandlerConsume DISABLED_TouchHandlerConsume |
176 #else | 179 #else |
177 #define MAYBE_TouchHandlerConsume TouchHandlerConsume | 180 #define MAYBE_TouchHandlerConsume TouchHandlerConsume |
178 #endif | 181 #endif |
179 IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_TouchHandlerConsume) { | 182 IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_TouchHandlerConsume) { |
180 LoadURL(); | 183 LoadURL(); |
181 SyntheticWebTouchEvent touch; | 184 SyntheticWebTouchEvent touch; |
182 | 185 |
183 // Press on |third| should be acked with CONSUMED since the touch-handler on | 186 // Press on |third| should be acked with CONSUMED since the touch-handler on |
184 // |third| consimes the event. | 187 // |third| consimes the event. |
185 touch.PressPoint(25, 125); | 188 touch.PressPoint(25, 125); |
186 scoped_refptr<InputMsgWatcher> filter = AddFilter(WebInputEvent::TouchStart); | 189 scoped_refptr<InputMsgWatcher> filter = AddFilter(WebInputEvent::TouchStart); |
187 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 190 SendTouchEvent(&touch); |
188 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, filter->WaitForAck()); | 191 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, filter->WaitForAck()); |
189 | 192 |
190 touch.ReleasePoint(0); | 193 touch.ReleasePoint(0); |
191 filter = AddFilter(WebInputEvent::TouchEnd); | 194 filter = AddFilter(WebInputEvent::TouchEnd); |
192 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 195 SendTouchEvent(&touch); |
193 filter->WaitForAck(); | 196 filter->WaitForAck(); |
194 } | 197 } |
195 | 198 |
196 #if defined(OS_CHROMEOS) | 199 #if defined(OS_CHROMEOS) |
197 // crbug.com/514456 | 200 // crbug.com/514456 |
198 #define MAYBE_MultiPointTouchPress DISABLED_MultiPointTouchPress | 201 #define MAYBE_MultiPointTouchPress DISABLED_MultiPointTouchPress |
199 #elif defined(OS_MACOSX) | 202 #elif defined(OS_MACOSX) |
200 // TODO(ccameron): Failing on mac: crbug.com/346363 | 203 // TODO(ccameron): Failing on mac: crbug.com/346363 |
201 #define MAYBE_MultiPointTouchPress DISABLED_MultiPointTouchPress | 204 #define MAYBE_MultiPointTouchPress DISABLED_MultiPointTouchPress |
202 #else | 205 #else |
203 #define MAYBE_MultiPointTouchPress MultiPointTouchPress | 206 #define MAYBE_MultiPointTouchPress MultiPointTouchPress |
204 #endif | 207 #endif |
205 IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_MultiPointTouchPress) { | 208 IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_MultiPointTouchPress) { |
206 LoadURL(); | 209 LoadURL(); |
207 SyntheticWebTouchEvent touch; | 210 SyntheticWebTouchEvent touch; |
208 | 211 |
209 // Press on |first|, which sould be acked with NO_CONSUMER_EXISTS. Then press | 212 // Press on |first|, which sould be acked with NO_CONSUMER_EXISTS. Then press |
210 // on |third|. That point should be acked with CONSUMED. | 213 // on |third|. That point should be acked with CONSUMED. |
211 touch.PressPoint(25, 25); | 214 touch.PressPoint(25, 25); |
212 scoped_refptr<InputMsgWatcher> filter = AddFilter(WebInputEvent::TouchStart); | 215 scoped_refptr<InputMsgWatcher> filter = AddFilter(WebInputEvent::TouchStart); |
213 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 216 SendTouchEvent(&touch); |
214 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, filter->WaitForAck()); | 217 EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, filter->WaitForAck()); |
215 | 218 |
216 touch.PressPoint(25, 125); | 219 touch.PressPoint(25, 125); |
217 filter = AddFilter(WebInputEvent::TouchStart); | 220 filter = AddFilter(WebInputEvent::TouchStart); |
218 GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 221 SendTouchEvent(&touch); |
219 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, filter->WaitForAck()); | 222 EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, filter->WaitForAck()); |
220 } | 223 } |
221 | 224 |
222 } // namespace content | 225 } // namespace content |
OLD | NEW |