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/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "net/test/embedded_test_server/http_response.h" | 40 #include "net/test/embedded_test_server/http_response.h" |
41 #include "net/test/python_utils.h" | 41 #include "net/test/python_utils.h" |
42 #include "net/url_request/url_request_context.h" | 42 #include "net/url_request/url_request_context.h" |
43 #include "net/url_request/url_request_context_getter.h" | 43 #include "net/url_request/url_request_context_getter.h" |
44 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
45 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
46 #include "ui/compositor/test/draw_waiter_for_test.h" | 46 #include "ui/compositor/test/draw_waiter_for_test.h" |
47 #include "ui/events/gesture_detection/gesture_configuration.h" | 47 #include "ui/events/gesture_detection/gesture_configuration.h" |
48 #include "ui/events/keycodes/dom/dom_code.h" | 48 #include "ui/events/keycodes/dom/dom_code.h" |
49 #include "ui/events/keycodes/dom/keycode_converter.h" | 49 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 50 #include "ui/events/latency_info.h" |
50 #include "ui/resources/grit/webui_resources.h" | 51 #include "ui/resources/grit/webui_resources.h" |
51 | 52 |
52 #if defined(USE_AURA) | 53 #if defined(USE_AURA) |
53 #include "ui/aura/test/window_event_dispatcher_test_api.h" | 54 #include "ui/aura/test/window_event_dispatcher_test_api.h" |
54 #include "ui/aura/window.h" | 55 #include "ui/aura/window.h" |
55 #include "ui/aura/window_event_dispatcher.h" | 56 #include "ui/aura/window_event_dispatcher.h" |
56 #include "ui/aura/window_tree_host.h" | 57 #include "ui/aura/window_tree_host.h" |
57 #endif // USE_AURA | 58 #endif // USE_AURA |
58 | 59 |
59 namespace content { | 60 namespace content { |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 blink::WebGestureEvent tap; | 425 blink::WebGestureEvent tap; |
425 tap.type = blink::WebGestureEvent::GestureTap; | 426 tap.type = blink::WebGestureEvent::GestureTap; |
426 tap.x = point.x(); | 427 tap.x = point.x(); |
427 tap.y = point.y(); | 428 tap.y = point.y(); |
428 tap.modifiers = modifiers; | 429 tap.modifiers = modifiers; |
429 RenderWidgetHostImpl* widget_host = | 430 RenderWidgetHostImpl* widget_host = |
430 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); | 431 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
431 widget_host->ForwardGestureEvent(tap); | 432 widget_host->ForwardGestureEvent(tap); |
432 } | 433 } |
433 | 434 |
| 435 void SimulateTouchPressAt(WebContents* web_contents, const gfx::Point& point) { |
| 436 SyntheticWebTouchEvent touch; |
| 437 touch.PressPoint(point.x(), point.y()); |
| 438 RenderWidgetHostImpl* widget_host = |
| 439 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
| 440 widget_host->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); |
| 441 } |
| 442 |
434 void SimulateKeyPress(WebContents* web_contents, | 443 void SimulateKeyPress(WebContents* web_contents, |
435 ui::KeyboardCode key_code, | 444 ui::KeyboardCode key_code, |
436 bool control, | 445 bool control, |
437 bool shift, | 446 bool shift, |
438 bool alt, | 447 bool alt, |
439 bool command) { | 448 bool command) { |
440 SimulateKeyPressWithCode( | 449 SimulateKeyPressWithCode( |
441 web_contents, key_code, NULL, control, shift, alt, command); | 450 web_contents, key_code, NULL, control, shift, alt, command); |
442 } | 451 } |
443 | 452 |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 } | 963 } |
955 | 964 |
956 bool WebContentsAddedObserver::RenderViewCreatedCalled() { | 965 bool WebContentsAddedObserver::RenderViewCreatedCalled() { |
957 if (child_observer_) { | 966 if (child_observer_) { |
958 return child_observer_->render_view_created_called_ && | 967 return child_observer_->render_view_created_called_ && |
959 child_observer_->main_frame_created_called_; | 968 child_observer_->main_frame_created_called_; |
960 } | 969 } |
961 return false; | 970 return false; |
962 } | 971 } |
963 | 972 |
| 973 bool RequestFrame(WebContents* web_contents) { |
| 974 DCHECK(web_contents); |
| 975 return RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()) |
| 976 ->ScheduleComposite(); |
| 977 } |
| 978 |
964 FrameWatcher::FrameWatcher() | 979 FrameWatcher::FrameWatcher() |
965 : BrowserMessageFilter(ViewMsgStart), frames_to_wait_(0) { | 980 : BrowserMessageFilter(ViewMsgStart), frames_to_wait_(0) { |
966 } | 981 } |
967 | 982 |
968 FrameWatcher::~FrameWatcher() { | 983 FrameWatcher::~FrameWatcher() { |
969 } | 984 } |
970 | 985 |
971 void FrameWatcher::ReceivedFrameSwap() { | 986 void FrameWatcher::ReceivedFrameSwap() { |
972 --frames_to_wait_; | 987 --frames_to_wait_; |
973 if (frames_to_wait_ == 0) | 988 if (frames_to_wait_ == 0) |
974 quit_.Run(); | 989 quit_.Run(); |
975 } | 990 } |
976 | 991 |
977 bool FrameWatcher::OnMessageReceived(const IPC::Message& message) { | 992 bool FrameWatcher::OnMessageReceived(const IPC::Message& message) { |
978 if (message.type() == ViewHostMsg_SwapCompositorFrame::ID) { | 993 if (message.type() == ViewHostMsg_SwapCompositorFrame::ID) { |
979 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 994 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
980 base::Bind(&FrameWatcher::ReceivedFrameSwap, this)); | 995 base::Bind(&FrameWatcher::ReceivedFrameSwap, this)); |
981 } | 996 } |
982 return false; | 997 return false; |
983 } | 998 } |
984 | 999 |
| 1000 void FrameWatcher::AttachTo(WebContents* web_contents) { |
| 1001 DCHECK(web_contents); |
| 1002 RenderWidgetHostImpl* widget_host = |
| 1003 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
| 1004 widget_host->GetProcess()->AddFilter(this); |
| 1005 } |
| 1006 |
985 void FrameWatcher::WaitFrames(int frames_to_wait) { | 1007 void FrameWatcher::WaitFrames(int frames_to_wait) { |
986 if (frames_to_wait <= 0) | 1008 if (frames_to_wait <= 0) |
987 return; | 1009 return; |
988 base::RunLoop run_loop; | 1010 base::RunLoop run_loop; |
989 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1011 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
990 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); | 1012 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); |
991 run_loop.Run(); | 1013 run_loop.Run(); |
992 } | 1014 } |
993 | 1015 |
994 } // namespace content | 1016 } // namespace content |
OLD | NEW |