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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2034213002: Reland: Fix touchpad gesture routing to renderers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Got rid of delta checks in test Created 4 years, 6 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_input_event_router.cc ('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/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 4817 matching lines...) Expand 10 before | Expand all | Expand 10 after
4828 // Use new window to navigate main window. 4828 // Use new window to navigate main window.
4829 std::string script = 4829 std::string script =
4830 "window.opener.location.href = '" + cross_url.spec() + "'"; 4830 "window.opener.location.href = '" + cross_url.spec() + "'";
4831 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script)); 4831 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script));
4832 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 4832 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4833 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); 4833 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url);
4834 } 4834 }
4835 4835
4836 // Ensure that a cross-process subframe with a touch-handler can receive touch 4836 // Ensure that a cross-process subframe with a touch-handler can receive touch
4837 // events. 4837 // events.
4838 #if defined(USE_AURA) 4838 #if defined(USE_AURA)
Charlie Reis 2016/06/23 00:07:40 Wow, this whole Aura-only section of the tests is
mohsen 2016/06/23 19:42:27 Acknowledged.
4839 // Browser process hit testing is not implemented on Android, and this test 4839 // Browser process hit testing is not implemented on Android, and this test
4840 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). 4840 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent().
4841 // https://crbug.com/491334 4841 // https://crbug.com/491334
4842 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4842 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4843 SubframeTouchEventRouting) { 4843 SubframeTouchEventRouting) {
4844 GURL main_url(embedded_test_server()->GetURL( 4844 GURL main_url(embedded_test_server()->GetURL(
4845 "/frame_tree/page_with_positioned_nested_frames.html")); 4845 "/frame_tree/page_with_positioned_nested_frames.html"));
4846 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4846 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4847 4847
4848 WebContentsImpl* contents = web_contents(); 4848 WebContentsImpl* contents = web_contents();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
4974 EXPECT_EQ(expected_target, router_touch_target); 4974 EXPECT_EQ(expected_target, router_touch_target);
4975 ui::TouchEvent touch_event_released(ui::ET_TOUCH_RELEASED, touch_point, 4975 ui::TouchEvent touch_event_released(ui::ET_TOUCH_RELEASED, touch_point,
4976 0, 0, ui::EventTimeForNow(), 30.f, 30.f, 4976 0, 0, ui::EventTimeForNow(), 30.f, 30.f,
4977 0.f, 0.f); 4977 0.f, 0.f);
4978 root_view_aura->OnTouchEvent(&touch_event_released); 4978 root_view_aura->OnTouchEvent(&touch_event_released);
4979 EXPECT_EQ(nullptr, router_touch_target); 4979 EXPECT_EQ(nullptr, router_touch_target);
4980 } 4980 }
4981 4981
4982 void SendGestureTapSequenceWithExpectedTarget( 4982 void SendGestureTapSequenceWithExpectedTarget(
4983 RenderWidgetHostViewBase* root_view, 4983 RenderWidgetHostViewBase* root_view,
4984 gfx::Point gesture_point, 4984 const gfx::Point& gesture_point,
4985 RenderWidgetHostViewBase*& router_gesture_target, 4985 RenderWidgetHostViewBase*& router_gesture_target,
4986 const RenderWidgetHostViewBase* old_expected_target, 4986 const RenderWidgetHostViewBase* old_expected_target,
4987 const RenderWidgetHostViewBase* expected_target) { 4987 const RenderWidgetHostViewBase* expected_target) {
4988 auto root_view_aura = static_cast<RenderWidgetHostViewAura*>(root_view); 4988 auto root_view_aura = static_cast<RenderWidgetHostViewAura*>(root_view);
4989 4989
4990 ui::GestureEventDetails gesture_begin_details(ui::ET_GESTURE_BEGIN); 4990 ui::GestureEventDetails gesture_begin_details(ui::ET_GESTURE_BEGIN);
4991 gesture_begin_details.set_device_type( 4991 gesture_begin_details.set_device_type(
4992 ui::GestureDeviceType::DEVICE_TOUCHSCREEN); 4992 ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
4993 ui::GestureEvent gesture_begin_event(gesture_point.x(), gesture_point.y(), 0, 4993 ui::GestureEvent gesture_begin_event(gesture_point.x(), gesture_point.y(), 0,
4994 ui::EventTimeForNow(), 4994 ui::EventTimeForNow(),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5032 ui::GestureEventDetails gesture_end_details(ui::ET_GESTURE_END); 5032 ui::GestureEventDetails gesture_end_details(ui::ET_GESTURE_END);
5033 gesture_end_details.set_device_type( 5033 gesture_end_details.set_device_type(
5034 ui::GestureDeviceType::DEVICE_TOUCHSCREEN); 5034 ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
5035 ui::GestureEvent gesture_end_event(gesture_point.x(), gesture_point.y(), 0, 5035 ui::GestureEvent gesture_end_event(gesture_point.x(), gesture_point.y(), 0,
5036 ui::EventTimeForNow(), 5036 ui::EventTimeForNow(),
5037 gesture_end_details); 5037 gesture_end_details);
5038 root_view_aura->OnGestureEvent(&gesture_end_event); 5038 root_view_aura->OnGestureEvent(&gesture_end_event);
5039 EXPECT_EQ(expected_target, router_gesture_target); 5039 EXPECT_EQ(expected_target, router_gesture_target);
5040 } 5040 }
5041 5041
5042 void SendTouchpadPinchSequenceWithExpectedTarget(
5043 RenderWidgetHostViewBase* root_view,
5044 const gfx::Point& gesture_point,
5045 RenderWidgetHostViewBase*& router_touchpad_gesture_target,
sadrul 2016/06/13 18:14:59 This is weird.
mohsen 2016/06/23 19:42:27 Acknowledged.
5046 RenderWidgetHostViewBase* expected_target) {
5047 auto root_view_aura = static_cast<RenderWidgetHostViewAura*>(root_view);
5048
5049 ui::GestureEventDetails pinch_begin_details(ui::ET_GESTURE_PINCH_BEGIN);
5050 pinch_begin_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD);
5051 ui::GestureEvent pinch_begin(gesture_point.x(), gesture_point.y(), 0,
5052 ui::EventTimeForNow(), pinch_begin_details);
5053 root_view_aura->OnGestureEvent(&pinch_begin);
5054 EXPECT_EQ(expected_target, router_touchpad_gesture_target);
5055
5056 ui::GestureEventDetails pinch_update_details(ui::ET_GESTURE_PINCH_UPDATE);
5057 pinch_update_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD);
5058 ui::GestureEvent pinch_update(gesture_point.x(), gesture_point.y(), 0,
5059 ui::EventTimeForNow(), pinch_update_details);
5060 root_view_aura->OnGestureEvent(&pinch_update);
5061 EXPECT_EQ(expected_target, router_touchpad_gesture_target);
5062
5063 ui::GestureEventDetails pinch_end_details(ui::ET_GESTURE_PINCH_END);
5064 pinch_end_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD);
5065 ui::GestureEvent pinch_end(gesture_point.x(), gesture_point.y(), 0,
5066 ui::EventTimeForNow(), pinch_end_details);
5067 root_view_aura->OnGestureEvent(&pinch_end);
5068 EXPECT_EQ(expected_target, router_touchpad_gesture_target);
5069 }
5070
5042 } // namespace anonymous 5071 } // namespace anonymous
5043 5072
5044 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5073 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5045 InputEventRouterGestureTargetQueueTest) { 5074 InputEventRouterGestureTargetQueueTest) {
5046 GURL main_url(embedded_test_server()->GetURL( 5075 GURL main_url(embedded_test_server()->GetURL(
5047 "/frame_tree/page_with_positioned_nested_frames.html")); 5076 "/frame_tree/page_with_positioned_nested_frames.html"));
5048 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 5077 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5049 5078
5050 WebContentsImpl* contents = web_contents(); 5079 WebContentsImpl* contents = web_contents();
5051 FrameTreeNode* root = contents->GetFrameTree()->root(); 5080 FrameTreeNode* root = contents->GetFrameTree()->root();
(...skipping 11 matching lines...) Expand all
5063 SurfaceHitTestReadyNotifier notifier( 5092 SurfaceHitTestReadyNotifier notifier(
5064 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); 5093 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
5065 notifier.WaitForSurfaceReady(); 5094 notifier.WaitForSurfaceReady();
5066 5095
5067 // All touches & gestures are sent to the main frame's view, and should be 5096 // All touches & gestures are sent to the main frame's view, and should be
5068 // routed appropriately from there. 5097 // routed appropriately from there.
5069 auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>( 5098 auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>(
5070 contents->GetRenderWidgetHostView()); 5099 contents->GetRenderWidgetHostView());
5071 5100
5072 RenderWidgetHostInputEventRouter* router = contents->GetInputEventRouter(); 5101 RenderWidgetHostInputEventRouter* router = contents->GetInputEventRouter();
5073 EXPECT_TRUE(router->gesture_target_queue_.empty()); 5102 EXPECT_TRUE(router->touchscreen_gesture_target_queue_.empty());
5074 EXPECT_EQ(nullptr, router->gesture_target_); 5103 EXPECT_EQ(nullptr, router->touchscreen_gesture_target_.target);
5075 5104
5076 // Send touch sequence to main-frame. 5105 // Send touch sequence to main-frame.
5077 gfx::Point main_frame_point(25, 25); 5106 gfx::Point main_frame_point(25, 25);
5078 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point, 5107 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point,
5079 router->touch_target_, rwhv_parent); 5108 router->touch_target_.target, rwhv_parent);
5080 EXPECT_EQ(1LU, router->gesture_target_queue_.size()); 5109 EXPECT_EQ(1LU, router->touchscreen_gesture_target_queue_.size());
5081 EXPECT_EQ(nullptr, router->gesture_target_); 5110 EXPECT_EQ(nullptr, router->touchscreen_gesture_target_.target);
5082
5083 5111
5084 // Send touch sequence to child. 5112 // Send touch sequence to child.
5085 gfx::Point child_center(150, 150); 5113 gfx::Point child_center(150, 150);
5086 SendTouchTapWithExpectedTarget(rwhv_parent, child_center, 5114 SendTouchTapWithExpectedTarget(rwhv_parent, child_center,
5087 router->touch_target_, rwhv_child); 5115 router->touch_target_.target, rwhv_child);
5088 EXPECT_EQ(2LU, router->gesture_target_queue_.size()); 5116 EXPECT_EQ(2LU, router->touchscreen_gesture_target_queue_.size());
5089 EXPECT_EQ(nullptr, router->gesture_target_); 5117 EXPECT_EQ(nullptr, router->touchscreen_gesture_target_.target);
5090 5118
5091 // Send another touch sequence to main frame. 5119 // Send another touch sequence to main frame.
5092 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point, 5120 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point,
5093 router->touch_target_, rwhv_parent); 5121 router->touch_target_.target, rwhv_parent);
5094 EXPECT_EQ(3LU, router->gesture_target_queue_.size()); 5122 EXPECT_EQ(3LU, router->touchscreen_gesture_target_queue_.size());
5095 EXPECT_EQ(nullptr, router->gesture_target_); 5123 EXPECT_EQ(nullptr, router->touchscreen_gesture_target_.target);
5096 5124
5097 // Send Gestures to clear GestureTargetQueue. 5125 // Send Gestures to clear GestureTargetQueue.
5098 5126
5099 // The first touch sequence should generate a GestureTapDown, sent to the 5127 // The first touch sequence should generate a GestureTapDown, sent to the
5100 // main frame. 5128 // main frame.
5101 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, main_frame_point, 5129 SendGestureTapSequenceWithExpectedTarget(
5102 router->gesture_target_, nullptr, 5130 rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target,
5103 rwhv_parent); 5131 nullptr, rwhv_parent);
5104 EXPECT_EQ(2LU, router->gesture_target_queue_.size()); 5132 EXPECT_EQ(2LU, router->touchscreen_gesture_target_queue_.size());
5105 // Note: rwhv_parent is the target used for GestureFlingCancel sent by 5133 // Note: rwhv_parent is the target used for GestureFlingCancel sent by
5106 // RenderWidgetHostViewAura::OnGestureEvent() at the start of the next gesture 5134 // RenderWidgetHostViewAura::OnGestureEvent() at the start of the next gesture
5107 // sequence; the sequence itself goes to rwhv_child. 5135 // sequence; the sequence itself goes to rwhv_child.
5108 EXPECT_EQ(rwhv_parent, router->gesture_target_); 5136 EXPECT_EQ(rwhv_parent, router->touchscreen_gesture_target_.target);
5109 5137
5110 // The second touch sequence should generate a GestureTapDown, sent to the 5138 // The second touch sequence should generate a GestureTapDown, sent to the
5111 // child frame. 5139 // child frame.
5112 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, child_center, 5140 SendGestureTapSequenceWithExpectedTarget(
5113 router->gesture_target_, rwhv_parent, 5141 rwhv_parent, child_center, router->touchscreen_gesture_target_.target,
5114 rwhv_child); 5142 rwhv_parent, rwhv_child);
5115 EXPECT_EQ(1LU, router->gesture_target_queue_.size()); 5143 EXPECT_EQ(1LU, router->touchscreen_gesture_target_queue_.size());
5116 EXPECT_EQ(rwhv_child, router->gesture_target_); 5144 EXPECT_EQ(rwhv_child, router->touchscreen_gesture_target_.target);
5117 5145
5118 // The third touch sequence should generate a GestureTapDown, sent to the 5146 // The third touch sequence should generate a GestureTapDown, sent to the
5119 // main frame. 5147 // main frame.
5120 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, main_frame_point, 5148 SendGestureTapSequenceWithExpectedTarget(
5121 router->gesture_target_, rwhv_child, 5149 rwhv_parent, main_frame_point, router->touchscreen_gesture_target_.target,
5122 rwhv_parent); 5150 rwhv_child, rwhv_parent);
5123 EXPECT_EQ(0LU, router->gesture_target_queue_.size()); 5151 EXPECT_EQ(0LU, router->touchscreen_gesture_target_queue_.size());
5124 EXPECT_EQ(rwhv_parent, router->gesture_target_); 5152 EXPECT_EQ(rwhv_parent, router->touchscreen_gesture_target_.target);
5153 }
5154
5155 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5156 InputEventRouterTouchpadGestureTargetTest) {
5157 GURL main_url(embedded_test_server()->GetURL(
5158 "/frame_tree/page_with_positioned_nested_frames.html"));
5159 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5160
5161 WebContentsImpl* contents = web_contents();
5162 FrameTreeNode* root = contents->GetFrameTree()->root();
5163 ASSERT_EQ(1U, root->child_count());
5164
5165 GURL frame_url(
5166 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html"));
5167 NavigateFrameToURL(root->child_at(0), frame_url);
5168 auto child_frame_host = root->child_at(0)->current_frame_host();
5169
5170 // Synchronize with the child and parent renderers to guarantee that the
5171 // surface information required for event hit testing is ready.
5172 auto rwhv_child =
5173 static_cast<RenderWidgetHostViewBase*>(child_frame_host->GetView());
5174 SurfaceHitTestReadyNotifier notifier(
5175 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
5176 notifier.WaitForSurfaceReady();
5177
5178 // All touches & gestures are sent to the main frame's view, and should be
5179 // routed appropriately from there.
5180 auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>(
5181 contents->GetRenderWidgetHostView());
5182
5183 RenderWidgetHostInputEventRouter* router = contents->GetInputEventRouter();
5184 EXPECT_EQ(nullptr, router->touchpad_gesture_target_.target);
5185
5186 // Send touchpad pinch sequence to main-frame.
5187 gfx::Point main_frame_point(25, 25);
5188 SendTouchpadPinchSequenceWithExpectedTarget(
5189 rwhv_parent, main_frame_point, router->touchpad_gesture_target_.target,
5190 rwhv_parent);
5191
5192 // Send touchpad pinch sequence to child.
5193 gfx::Point child_center(150, 150);
5194 SendTouchpadPinchSequenceWithExpectedTarget(
5195 rwhv_parent, child_center, router->touchpad_gesture_target_.target,
5196 rwhv_child);
5197
5198 // Send another touchpad pinch sequence to main frame.
5199 SendTouchpadPinchSequenceWithExpectedTarget(
5200 rwhv_parent, main_frame_point, router->touchpad_gesture_target_.target,
5201 rwhv_parent);
5125 } 5202 }
5126 #endif // defined(USE_AURA) 5203 #endif // defined(USE_AURA)
5127 5204
5128 // A WebContentsDelegate to capture ContextMenu creation events. 5205 // A WebContentsDelegate to capture ContextMenu creation events.
5129 class ContextMenuObserverDelegate : public WebContentsDelegate { 5206 class ContextMenuObserverDelegate : public WebContentsDelegate {
5130 public: 5207 public:
5131 ContextMenuObserverDelegate() 5208 ContextMenuObserverDelegate()
5132 : context_menu_created_(false), 5209 : context_menu_created_(false),
5133 message_loop_runner_(new MessageLoopRunner) {} 5210 message_loop_runner_(new MessageLoopRunner) {}
5134 5211
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
7223 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); 7300 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
7224 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7301 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7225 7302
7226 // Cross-site navigation should preserve the fullscreen flags. 7303 // Cross-site navigation should preserve the fullscreen flags.
7227 NavigateFrameToURL(root->child_at(0)->child_at(0), 7304 NavigateFrameToURL(root->child_at(0)->child_at(0),
7228 embedded_test_server()->GetURL("d.com", "/title1.html")); 7305 embedded_test_server()->GetURL("d.com", "/title1.html"));
7229 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7306 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7230 } 7307 }
7231 7308
7232 } // namespace content 7309 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_input_event_router.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698