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

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: Fixed DCHECK's 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
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 5021 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 gfx::Point gesture_point,
sadrul 2016/06/08 15:56:30 const&
mohsen 2016/06/08 23:32:26 Done. (here and another place that I copied this c
5045 RenderWidgetHostViewBase*& router_touchpad_gesture_target,
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);
sadrul 2016/06/08 15:56:30 Is it possible to also test the location of the ev
mohsen 2016/06/08 23:32:26 Do you mean the delta as in |RWHIER::TargetData::d
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_);
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_, 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_);
5082 5111
5083 5112
5084 // Send touch sequence to child. 5113 // Send touch sequence to child.
5085 gfx::Point child_center(150, 150); 5114 gfx::Point child_center(150, 150);
5086 SendTouchTapWithExpectedTarget(rwhv_parent, child_center, 5115 SendTouchTapWithExpectedTarget(rwhv_parent, child_center,
5087 router->touch_target_, rwhv_child); 5116 router->touch_target_, rwhv_child);
5088 EXPECT_EQ(2LU, router->gesture_target_queue_.size()); 5117 EXPECT_EQ(2LU, router->touchscreen_gesture_target_queue_.size());
5089 EXPECT_EQ(nullptr, router->gesture_target_); 5118 EXPECT_EQ(nullptr, router->touchscreen_gesture_target_);
5090 5119
5091 // Send another touch sequence to main frame. 5120 // Send another touch sequence to main frame.
5092 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point, 5121 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point,
5093 router->touch_target_, rwhv_parent); 5122 router->touch_target_, rwhv_parent);
5094 EXPECT_EQ(3LU, router->gesture_target_queue_.size()); 5123 EXPECT_EQ(3LU, router->touchscreen_gesture_target_queue_.size());
5095 EXPECT_EQ(nullptr, router->gesture_target_); 5124 EXPECT_EQ(nullptr, router->touchscreen_gesture_target_);
5096 5125
5097 // Send Gestures to clear GestureTargetQueue. 5126 // Send Gestures to clear GestureTargetQueue.
5098 5127
5099 // The first touch sequence should generate a GestureTapDown, sent to the 5128 // The first touch sequence should generate a GestureTapDown, sent to the
5100 // main frame. 5129 // main frame.
5101 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, main_frame_point, 5130 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, main_frame_point,
5102 router->gesture_target_, nullptr, 5131 router->touchscreen_gesture_target_,
5103 rwhv_parent); 5132 nullptr, rwhv_parent);
5104 EXPECT_EQ(2LU, router->gesture_target_queue_.size()); 5133 EXPECT_EQ(2LU, router->touchscreen_gesture_target_queue_.size());
5105 // Note: rwhv_parent is the target used for GestureFlingCancel sent by 5134 // Note: rwhv_parent is the target used for GestureFlingCancel sent by
5106 // RenderWidgetHostViewAura::OnGestureEvent() at the start of the next gesture 5135 // RenderWidgetHostViewAura::OnGestureEvent() at the start of the next gesture
5107 // sequence; the sequence itself goes to rwhv_child. 5136 // sequence; the sequence itself goes to rwhv_child.
5108 EXPECT_EQ(rwhv_parent, router->gesture_target_); 5137 EXPECT_EQ(rwhv_parent, router->touchscreen_gesture_target_);
5109 5138
5110 // The second touch sequence should generate a GestureTapDown, sent to the 5139 // The second touch sequence should generate a GestureTapDown, sent to the
5111 // child frame. 5140 // child frame.
5112 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, child_center, 5141 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, child_center,
5113 router->gesture_target_, rwhv_parent, 5142 router->touchscreen_gesture_target_,
5114 rwhv_child); 5143 rwhv_parent, rwhv_child);
5115 EXPECT_EQ(1LU, router->gesture_target_queue_.size()); 5144 EXPECT_EQ(1LU, router->touchscreen_gesture_target_queue_.size());
5116 EXPECT_EQ(rwhv_child, router->gesture_target_); 5145 EXPECT_EQ(rwhv_child, router->touchscreen_gesture_target_);
5117 5146
5118 // The third touch sequence should generate a GestureTapDown, sent to the 5147 // The third touch sequence should generate a GestureTapDown, sent to the
5119 // main frame. 5148 // main frame.
5120 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, main_frame_point, 5149 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, main_frame_point,
5121 router->gesture_target_, rwhv_child, 5150 router->touchscreen_gesture_target_,
5122 rwhv_parent); 5151 rwhv_child, rwhv_parent);
5123 EXPECT_EQ(0LU, router->gesture_target_queue_.size()); 5152 EXPECT_EQ(0LU, router->touchscreen_gesture_target_queue_.size());
5124 EXPECT_EQ(rwhv_parent, router->gesture_target_); 5153 EXPECT_EQ(rwhv_parent, router->touchscreen_gesture_target_);
5154 }
5155
5156 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5157 InputEventRouterTouchpadGestureTargetTest) {
5158 GURL main_url(embedded_test_server()->GetURL(
5159 "/frame_tree/page_with_positioned_nested_frames.html"));
5160 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5161
5162 WebContentsImpl* contents = web_contents();
5163 FrameTreeNode* root = contents->GetFrameTree()->root();
5164 ASSERT_EQ(1U, root->child_count());
5165
5166 GURL frame_url(
5167 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html"));
5168 NavigateFrameToURL(root->child_at(0), frame_url);
5169 auto child_frame_host = root->child_at(0)->current_frame_host();
5170
5171 // Synchronize with the child and parent renderers to guarantee that the
5172 // surface information required for event hit testing is ready.
5173 auto rwhv_child =
5174 static_cast<RenderWidgetHostViewBase*>(child_frame_host->GetView());
5175 SurfaceHitTestReadyNotifier notifier(
5176 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
5177 notifier.WaitForSurfaceReady();
5178
5179 // All touches & gestures are sent to the main frame's view, and should be
5180 // routed appropriately from there.
5181 auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>(
5182 contents->GetRenderWidgetHostView());
5183
5184 RenderWidgetHostInputEventRouter* router = contents->GetInputEventRouter();
5185 EXPECT_EQ(nullptr, router->touchpad_gesture_target_);
5186
5187 // Send touchpad pinch sequence to main-frame.
5188 gfx::Point main_frame_point(25, 25);
5189 SendTouchpadPinchSequenceWithExpectedTarget(rwhv_parent, main_frame_point,
5190 router->touchpad_gesture_target_,
5191 rwhv_parent);
5192
5193 // Send touchpad pinch sequence to child.
5194 gfx::Point child_center(150, 150);
5195 SendTouchpadPinchSequenceWithExpectedTarget(
5196 rwhv_parent, child_center, router->touchpad_gesture_target_, rwhv_child);
5197
5198 // Send another touchpad pinch sequence to main frame.
5199 SendTouchpadPinchSequenceWithExpectedTarget(rwhv_parent, main_frame_point,
5200 router->touchpad_gesture_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

Powered by Google App Engine
This is Rietveld 408576698