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

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

Issue 2479663002: Move compositor InputHandler from RenderViewImpl to RenderWidget. (Closed)
Patch Set: Rebase to master@{#429880}. Created 4 years, 1 month 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 5224 matching lines...) Expand 10 before | Expand all | Expand 10 after
5235 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( 5235 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>(
5236 root->child_at(0)->current_frame_host()->GetView()); 5236 root->child_at(0)->current_frame_host()->GetView());
5237 SurfaceHitTestReadyNotifier notifier( 5237 SurfaceHitTestReadyNotifier notifier(
5238 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); 5238 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv));
5239 notifier.WaitForSurfaceReady(); 5239 notifier.WaitForSurfaceReady();
5240 5240
5241 // Simulate touch event to sub-frame. 5241 // Simulate touch event to sub-frame.
5242 gfx::Point child_center(150, 150); 5242 gfx::Point child_center(150, 150);
5243 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( 5243 auto* rwhv = static_cast<RenderWidgetHostViewAura*>(
5244 contents->GetRenderWidgetHostView()); 5244 contents->GetRenderWidgetHostView());
5245
5246 // Wait until renderer's compositor thread is synced.
5247 RenderWidgetHost* child_render_widget_host =
5248 root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
5249 {
5250 std::unique_ptr<MainThreadFrameObserver> observer(
dcheng 2016/11/04 21:00:02 Nit: auto observer = base::MakeUnique<MTFO>(...);
wjmaclean 2016/11/07 15:57:27 Done.
5251 new MainThreadFrameObserver(child_render_widget_host));
5252 observer->Wait();
5253 }
5254
5245 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, 5255 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0,
5246 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); 5256 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
5247 rwhv->OnTouchEvent(&touch_event); 5257 rwhv->OnTouchEvent(&touch_event);
5258 {
5259 std::unique_ptr<MainThreadFrameObserver> observer(
5260 new MainThreadFrameObserver(child_render_widget_host));
5261 observer->Wait();
5262 }
5248 5263
5249 // Verify touch handler in subframe was invoked 5264 // Verify touch handler in subframe was invoked
5250 std::string result; 5265 std::string result;
5251 EXPECT_TRUE(ExecuteScriptAndExtractString( 5266 EXPECT_TRUE(ExecuteScriptAndExtractString(
5252 root->child_at(0), 5267 root->child_at(0),
5253 "window.domAutomationController.send(getLastTouchEvent());", &result)); 5268 "window.domAutomationController.send(getLastTouchEvent());", &result));
5254 EXPECT_EQ("touchstart", result); 5269 EXPECT_EQ("touchstart", result);
5255 } 5270 }
5256 5271
5272 // This test verifies that the test in
5273 // SitePerProcessBrowserTest.SubframeTouchEventRouting also works properly for
5274 // the main frame. Prior to the CL in which this test is introduced, use of
5275 // MainThreadFrameObserver in SubframeTouchEventRouting was not necessary since
5276 // the touch events were handled on the main thread. Now they are handled on the
5277 // compositor thread, hence the need to synchronize.
5278 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5279 MainframeTouchEventRouting) {
5280 GURL main_url(embedded_test_server()->GetURL(
5281 "/page_with_touch_handler.html"));
5282 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5283
5284 WebContentsImpl* contents = web_contents();
5285 FrameTreeNode* root = contents->GetFrameTree()->root();
5286
5287 // Synchronize with the renderers to guarantee that the
5288 // surface information required for event hit testing is ready.
5289 auto* rwhv = static_cast<RenderWidgetHostViewAura*>(
5290 contents->GetRenderWidgetHostView());
5291
5292 // Simulate touch event to sub-frame.
5293 gfx::Point frame_center(150, 150);
5294
5295 // Wait until renderer's compositor thread is synced.
5296 RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost();
5297 {
5298 std::unique_ptr<MainThreadFrameObserver> observer(
5299 new MainThreadFrameObserver(render_widget_host));
5300 observer->Wait();
5301 }
5302
5303 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, frame_center, 0, 0,
5304 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
5305 rwhv->OnTouchEvent(&touch_event);
5306 {
5307 std::unique_ptr<MainThreadFrameObserver> observer(
5308 new MainThreadFrameObserver(render_widget_host));
5309 observer->Wait();
5310 }
5311
5312 // Verify touch handler in subframe was invoked
5313 std::string result;
5314 EXPECT_TRUE(ExecuteScriptAndExtractString(
5315 root, "window.domAutomationController.send(getLastTouchEvent());",
5316 &result));
5317 EXPECT_EQ("touchstart", result);
5318 }
5319
5257 namespace { 5320 namespace {
5258 5321
5259 // Declared here to be close to the SubframeGestureEventRouting test. 5322 // Declared here to be close to the SubframeGestureEventRouting test.
5260 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, 5323 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner,
5261 SyntheticGesture::Result result) { 5324 SyntheticGesture::Result result) {
5262 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); 5325 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
5263 runner->Quit(); 5326 runner->Quit();
5264 } 5327 }
5265 5328
5266 } // namespace anonymous 5329 } // namespace anonymous
(...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after
8526 EXPECT_TRUE(NavigateToURL(shell(), b_url)); 8589 EXPECT_TRUE(NavigateToURL(shell(), b_url));
8527 8590
8528 base::string16 expected_title(base::UTF8ToUTF16("foo")); 8591 base::string16 expected_title(base::UTF8ToUTF16("foo"));
8529 TitleWatcher title_watcher(popup2->web_contents(), expected_title); 8592 TitleWatcher title_watcher(popup2->web_contents(), expected_title);
8530 EXPECT_TRUE(ExecuteScript( 8593 EXPECT_TRUE(ExecuteScript(
8531 shell(), "window.open('','popup2').postMessage('foo', '*');")); 8594 shell(), "window.open('','popup2').postMessage('foo', '*');"));
8532 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 8595 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
8533 } 8596 }
8534 8597
8535 } // namespace content 8598 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/input/input_handler_manager.h » ('j') | content/renderer/render_widget.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698