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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 297693002: Tests for "WebView: speed up user gesture notification for GestureTap" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Limit test to Aura Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/test/test_timeouts.h" 15 #include "base/test/test_timeouts.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "content/browser/renderer_host/render_widget_host_impl.h"
17 #include "content/browser/web_contents/web_contents_view.h" 18 #include "content/browser/web_contents/web_contents_view.h"
19 #include "content/common/input/synthetic_web_input_event_builders.h"
18 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/dom_operation_notification_details.h" 21 #include "content/public/browser/dom_operation_notification_details.h"
20 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
22 #include "content/public/browser/render_frame_host.h" 24 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_contents_observer.h" 28 #include "content/public/browser/web_contents_observer.h"
27 #include "content/public/test/test_utils.h" 29 #include "content/public/test/test_utils.h"
28 #include "grit/webui_resources.h" 30 #include "grit/webui_resources.h"
29 #include "net/base/filename_util.h" 31 #include "net/base/filename_util.h"
30 #include "net/cookies/cookie_store.h" 32 #include "net/cookies/cookie_store.h"
31 #include "net/test/python_utils.h" 33 #include "net/test/python_utils.h"
32 #include "net/url_request/url_request_context.h" 34 #include "net/url_request/url_request_context.h"
33 #include "net/url_request/url_request_context_getter.h" 35 #include "net/url_request/url_request_context_getter.h"
34 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
35 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
38 #include "ui/events/gestures/gesture_configuration.h"
36 #include "ui/events/keycodes/dom4/keycode_converter.h" 39 #include "ui/events/keycodes/dom4/keycode_converter.h"
37 40
38 namespace content { 41 namespace content {
39 namespace { 42 namespace {
40 43
41 class DOMOperationObserver : public NotificationObserver, 44 class DOMOperationObserver : public NotificationObserver,
42 public WebContentsObserver { 45 public WebContentsObserver {
43 public: 46 public:
44 explicit DOMOperationObserver(RenderViewHost* rvh) 47 explicit DOMOperationObserver(RenderViewHost* rvh)
45 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)), 48 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)),
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 void SimulateMouseEvent(WebContents* web_contents, 252 void SimulateMouseEvent(WebContents* web_contents,
250 blink::WebInputEvent::Type type, 253 blink::WebInputEvent::Type type,
251 const gfx::Point& point) { 254 const gfx::Point& point) {
252 blink::WebMouseEvent mouse_event; 255 blink::WebMouseEvent mouse_event;
253 mouse_event.type = type; 256 mouse_event.type = type;
254 mouse_event.x = point.x(); 257 mouse_event.x = point.x();
255 mouse_event.y = point.y(); 258 mouse_event.y = point.y();
256 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 259 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
257 } 260 }
258 261
262 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) {
263 const double kTapDurationSeconds =
264 0.5 * (ui::GestureConfiguration::
265 min_touch_down_duration_in_seconds_for_click() +
266 ui::GestureConfiguration::
267 max_touch_down_duration_in_seconds_for_click());
268 SyntheticWebTouchEvent touch;
269 touch.timeStampSeconds = 0;
270 touch.PressPoint(point.x(), point.y());
271 RenderWidgetHostImpl* widget_host =
272 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost());
273 widget_host->ForwardTouchEvent(touch);
274 touch.timeStampSeconds = kTapDurationSeconds;
275 touch.ReleasePoint(0);
276 widget_host->ForwardTouchEvent(touch);
277 }
278
259 void SimulateKeyPress(WebContents* web_contents, 279 void SimulateKeyPress(WebContents* web_contents,
260 ui::KeyboardCode key_code, 280 ui::KeyboardCode key_code,
261 bool control, 281 bool control,
262 bool shift, 282 bool shift,
263 bool alt, 283 bool alt,
264 bool command) { 284 bool command) {
265 SimulateKeyPressWithCode( 285 SimulateKeyPressWithCode(
266 web_contents, key_code, NULL, control, shift, alt, command); 286 web_contents, key_code, NULL, control, shift, alt, command);
267 } 287 }
268 288
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 } 692 }
673 // The queue should not be empty, unless we were quit because of a timeout. 693 // The queue should not be empty, unless we were quit because of a timeout.
674 if (message_queue_.empty()) 694 if (message_queue_.empty())
675 return false; 695 return false;
676 *message = message_queue_.front(); 696 *message = message_queue_.front();
677 message_queue_.pop(); 697 message_queue_.pop();
678 return true; 698 return true;
679 } 699 }
680 700
681 } // namespace content 701 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698