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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 2479663002: Move compositor InputHandler from RenderViewImpl to RenderWidget. (Closed)
Patch Set: Check for layerTreeView while setting handlers. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 16ca7360e42f744b4350b171671d56cfb311225b..7d438a2152aa1462e204af31f7c9e1bd9fcfaa87 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -5382,11 +5382,26 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
gfx::Point child_center(150, 150);
auto* rwhv = static_cast<RenderWidgetHostViewAura*>(
contents->GetRenderWidgetHostView());
+
+ // Wait until renderer's compositor thread is synced.
+ RenderWidgetHost* child_render_widget_host =
+ root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
+ {
+ auto observer =
+ base::MakeUnique<MainThreadFrameObserver>(child_render_widget_host);
+ observer->Wait();
+ }
+
ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0,
ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
rwhv->OnTouchEvent(&touch_event);
+ {
+ auto observer =
+ base::MakeUnique<MainThreadFrameObserver>(child_render_widget_host);
+ observer->Wait();
+ }
- // Verify touch handler in subframe was invoked
+ // Verify touch handler in subframe was invoked.
std::string result;
EXPECT_TRUE(ExecuteScriptAndExtractString(
root->child_at(0),
@@ -5394,6 +5409,54 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
EXPECT_EQ("touchstart", result);
}
+// This test verifies that the test in
+// SitePerProcessBrowserTest.SubframeTouchEventRouting also works properly for
+// the main frame. Prior to the CL in which this test is introduced, use of
+// MainThreadFrameObserver in SubframeTouchEventRouting was not necessary since
+// the touch events were handled on the main thread. Now they are handled on the
+// compositor thread, hence the need to synchronize.
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
+ MainframeTouchEventRouting) {
+ GURL main_url(embedded_test_server()->GetURL(
+ "/page_with_touch_handler.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+
+ WebContentsImpl* contents = web_contents();
+ FrameTreeNode* root = contents->GetFrameTree()->root();
+
+ // Synchronize with the renderers to guarantee that the
+ // surface information required for event hit testing is ready.
+ auto* rwhv = static_cast<RenderWidgetHostViewAura*>(
+ contents->GetRenderWidgetHostView());
+
+ // Simulate touch event to sub-frame.
+ gfx::Point frame_center(150, 150);
+
+ // Wait until renderer's compositor thread is synced.
+ RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost();
+ {
+ auto observer =
+ base::MakeUnique<MainThreadFrameObserver>(render_widget_host);
+ observer->Wait();
+ }
+
+ ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, frame_center, 0, 0,
+ ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
+ rwhv->OnTouchEvent(&touch_event);
+ {
+ auto observer =
+ base::MakeUnique<MainThreadFrameObserver>(render_widget_host);
dcheng 2017/01/16 11:05:40 Nit: this can just be directly on the stack: Main
wjmaclean 2017/01/17 18:23:27 Done.
+ observer->Wait();
+ }
+
+ // Verify touch handler in subframe was invoked.
+ std::string result;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ root, "window.domAutomationController.send(getLastTouchEvent());",
+ &result));
+ EXPECT_EQ("touchstart", result);
+}
+
namespace {
// Declared here to be close to the SubframeGestureEventRouting test.

Powered by Google App Engine
This is Rietveld 408576698