Index: content/public/test/browser_test_utils.cc |
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc |
index 60b2b0eb50b96bb19df33baca012e78cfcf91a07..fa2c79996dbd61094cd2eb298758820931e46628 100644 |
--- a/content/public/test/browser_test_utils.cc |
+++ b/content/public/test/browser_test_utils.cc |
@@ -14,7 +14,9 @@ |
#include "base/synchronization/waitable_event.h" |
#include "base/test/test_timeouts.h" |
#include "base/values.h" |
+#include "content/browser/renderer_host/render_widget_host_impl.h" |
#include "content/browser/web_contents/web_contents_view.h" |
+#include "content/common/input/synthetic_web_input_event_builders.h" |
#include "content/public/browser/browser_context.h" |
#include "content/public/browser/dom_operation_notification_details.h" |
#include "content/public/browser/notification_service.h" |
@@ -33,6 +35,7 @@ |
#include "net/url_request/url_request_context_getter.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/base/resource/resource_bundle.h" |
+#include "ui/events/gestures/gesture_configuration.h" |
#include "ui/events/keycodes/dom4/keycode_converter.h" |
namespace content { |
@@ -256,6 +259,23 @@ void SimulateMouseEvent(WebContents* web_contents, |
web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
} |
+void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { |
+ const double kTapDurationSeconds = |
+ 0.5 * (ui::GestureConfiguration:: |
+ min_touch_down_duration_in_seconds_for_click() + |
+ ui::GestureConfiguration:: |
+ max_touch_down_duration_in_seconds_for_click()); |
+ SyntheticWebTouchEvent touch; |
+ touch.timeStampSeconds = 0; |
+ touch.PressPoint(point.x(), point.y()); |
+ RenderWidgetHostImpl* widget_host = |
+ RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
+ widget_host->ForwardTouchEvent(touch); |
+ touch.timeStampSeconds = kTapDurationSeconds; |
+ touch.ReleasePoint(0); |
+ widget_host->ForwardTouchEvent(touch); |
+} |
+ |
void SimulateKeyPress(WebContents* web_contents, |
ui::KeyboardCode key_code, |
bool control, |