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

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

Issue 2479663002: Move compositor InputHandler from RenderViewImpl to RenderWidget. (Closed)
Patch Set: Add early out to accommodate null frameWidget in webkit_unit_tests. 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 5254 matching lines...) Expand 10 before | Expand all | Expand 10 after
5265 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( 5265 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>(
5266 root->child_at(0)->current_frame_host()->GetView()); 5266 root->child_at(0)->current_frame_host()->GetView());
5267 SurfaceHitTestReadyNotifier notifier( 5267 SurfaceHitTestReadyNotifier notifier(
5268 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); 5268 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv));
5269 notifier.WaitForSurfaceReady(); 5269 notifier.WaitForSurfaceReady();
5270 5270
5271 // Simulate touch event to sub-frame. 5271 // Simulate touch event to sub-frame.
5272 gfx::Point child_center(150, 150); 5272 gfx::Point child_center(150, 150);
5273 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( 5273 auto* rwhv = static_cast<RenderWidgetHostViewAura*>(
5274 contents->GetRenderWidgetHostView()); 5274 contents->GetRenderWidgetHostView());
5275
5276 // Wait until renderer's compositor thread is synced.
5277 RenderWidgetHost* child_render_widget_host =
5278 root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
5279 {
5280 auto observer =
5281 base::MakeUnique<MainThreadFrameObserver>(child_render_widget_host);
5282 observer->Wait();
5283 }
5284
5275 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, 5285 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0,
5276 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); 5286 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
5277 rwhv->OnTouchEvent(&touch_event); 5287 rwhv->OnTouchEvent(&touch_event);
5288 {
5289 auto observer =
5290 base::MakeUnique<MainThreadFrameObserver>(child_render_widget_host);
5291 observer->Wait();
5292 }
5278 5293
5279 // Verify touch handler in subframe was invoked 5294 // Verify touch handler in subframe was invoked.
5280 std::string result; 5295 std::string result;
5281 EXPECT_TRUE(ExecuteScriptAndExtractString( 5296 EXPECT_TRUE(ExecuteScriptAndExtractString(
5282 root->child_at(0), 5297 root->child_at(0),
5283 "window.domAutomationController.send(getLastTouchEvent());", &result)); 5298 "window.domAutomationController.send(getLastTouchEvent());", &result));
5284 EXPECT_EQ("touchstart", result); 5299 EXPECT_EQ("touchstart", result);
5285 } 5300 }
5286 5301
5302 // This test verifies that the test in
5303 // SitePerProcessBrowserTest.SubframeTouchEventRouting also works properly for
5304 // the main frame. Prior to the CL in which this test is introduced, use of
5305 // MainThreadFrameObserver in SubframeTouchEventRouting was not necessary since
5306 // the touch events were handled on the main thread. Now they are handled on the
5307 // compositor thread, hence the need to synchronize.
5308 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5309 MainframeTouchEventRouting) {
5310 GURL main_url(embedded_test_server()->GetURL(
5311 "/page_with_touch_handler.html"));
5312 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5313
5314 WebContentsImpl* contents = web_contents();
5315 FrameTreeNode* root = contents->GetFrameTree()->root();
5316
5317 // Synchronize with the renderers to guarantee that the
5318 // surface information required for event hit testing is ready.
5319 auto* rwhv = static_cast<RenderWidgetHostViewAura*>(
5320 contents->GetRenderWidgetHostView());
5321
5322 // Simulate touch event to sub-frame.
5323 gfx::Point frame_center(150, 150);
5324
5325 // Wait until renderer's compositor thread is synced.
5326 RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost();
5327 {
5328 auto observer =
5329 base::MakeUnique<MainThreadFrameObserver>(render_widget_host);
5330 observer->Wait();
5331 }
5332
5333 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, frame_center, 0, 0,
5334 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
5335 rwhv->OnTouchEvent(&touch_event);
5336 {
5337 auto observer =
5338 base::MakeUnique<MainThreadFrameObserver>(render_widget_host);
5339 observer->Wait();
5340 }
5341
5342 // Verify touch handler in subframe was invoked.
5343 std::string result;
5344 EXPECT_TRUE(ExecuteScriptAndExtractString(
5345 root, "window.domAutomationController.send(getLastTouchEvent());",
5346 &result));
5347 EXPECT_EQ("touchstart", result);
5348 }
5349
5287 namespace { 5350 namespace {
5288 5351
5289 // Declared here to be close to the SubframeGestureEventRouting test. 5352 // Declared here to be close to the SubframeGestureEventRouting test.
5290 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, 5353 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner,
5291 SyntheticGesture::Result result) { 5354 SyntheticGesture::Result result) {
5292 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); 5355 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
5293 runner->Quit(); 5356 runner->Quit();
5294 } 5357 }
5295 5358
5296 } // namespace anonymous 5359 } // namespace anonymous
(...skipping 3259 matching lines...) Expand 10 before | Expand all | Expand 10 after
8556 EXPECT_TRUE(NavigateToURL(shell(), b_url)); 8619 EXPECT_TRUE(NavigateToURL(shell(), b_url));
8557 8620
8558 base::string16 expected_title(base::UTF8ToUTF16("foo")); 8621 base::string16 expected_title(base::UTF8ToUTF16("foo"));
8559 TitleWatcher title_watcher(popup2->web_contents(), expected_title); 8622 TitleWatcher title_watcher(popup2->web_contents(), expected_title);
8560 EXPECT_TRUE(ExecuteScript( 8623 EXPECT_TRUE(ExecuteScript(
8561 shell(), "window.open('','popup2').postMessage('foo', '*');")); 8624 shell(), "window.open('','popup2').postMessage('foo', '*');"));
8562 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 8625 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
8563 } 8626 }
8564 8627
8565 } // namespace content 8628 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/gpu/compositor_dependencies.h » ('j') | content/renderer/render_widget.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698