OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 blink::WebInputEvent::Type type, | 287 blink::WebInputEvent::Type type, |
288 const gfx::Point& point) { | 288 const gfx::Point& point) { |
289 blink::WebMouseEvent mouse_event; | 289 blink::WebMouseEvent mouse_event; |
290 mouse_event.type = type; | 290 mouse_event.type = type; |
291 mouse_event.x = point.x(); | 291 mouse_event.x = point.x(); |
292 mouse_event.y = point.y(); | 292 mouse_event.y = point.y(); |
293 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 293 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
294 } | 294 } |
295 | 295 |
296 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { | 296 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { |
297 const double kTapDurationSeconds = | 297 blink::WebGestureEvent tap; |
298 0.5 * (ui::GestureConfiguration:: | 298 tap.type = blink::WebGestureEvent::GestureTap; |
299 min_touch_down_duration_in_seconds_for_click() + | 299 tap.x = point.x(); |
300 ui::GestureConfiguration:: | 300 tap.y = point.y(); |
301 max_touch_down_duration_in_seconds_for_click()); | |
302 SyntheticWebTouchEvent touch; | |
303 // Set the timestamp to the base::TimeDelta representing the current time. | |
304 touch.SetTimestamp(base::TimeTicks::Now() - base::TimeTicks()); | |
305 touch.PressPoint(point.x(), point.y()); | |
306 RenderWidgetHostImpl* widget_host = | 301 RenderWidgetHostImpl* widget_host = |
307 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); | 302 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
308 widget_host->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | 303 widget_host->ForwardGestureEvent(tap); |
309 touch.timeStampSeconds += kTapDurationSeconds; | |
310 touch.ReleasePoint(0); | |
311 widget_host->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); | |
312 } | 304 } |
313 | 305 |
314 void SimulateKeyPress(WebContents* web_contents, | 306 void SimulateKeyPress(WebContents* web_contents, |
315 ui::KeyboardCode key_code, | 307 ui::KeyboardCode key_code, |
316 bool control, | 308 bool control, |
317 bool shift, | 309 bool shift, |
318 bool alt, | 310 bool alt, |
319 bool command) { | 311 bool command) { |
320 SimulateKeyPressWithCode( | 312 SimulateKeyPressWithCode( |
321 web_contents, key_code, NULL, control, shift, alt, command); | 313 web_contents, key_code, NULL, control, shift, alt, command); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 } | 719 } |
728 // The queue should not be empty, unless we were quit because of a timeout. | 720 // The queue should not be empty, unless we were quit because of a timeout. |
729 if (message_queue_.empty()) | 721 if (message_queue_.empty()) |
730 return false; | 722 return false; |
731 *message = message_queue_.front(); | 723 *message = message_queue_.front(); |
732 message_queue_.pop(); | 724 message_queue_.pop(); |
733 return true; | 725 return true; |
734 } | 726 } |
735 | 727 |
736 } // namespace content | 728 } // namespace content |
OLD | NEW |