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

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

Issue 2649573003: Revert of Move compositor InputHandler from RenderViewImpl to RenderWidget. (Closed)
Patch Set: 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 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 5381 matching lines...) Expand 10 before | Expand all | Expand 10 after
5392 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); 5392 root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
5393 InputRouterImpl* child_input_router = 5393 InputRouterImpl* child_input_router =
5394 static_cast<InputRouterImpl*>(child_render_widget_host->input_router()); 5394 static_cast<InputRouterImpl*>(child_render_widget_host->input_router());
5395 EXPECT_EQ(TOUCH_ACTION_AUTO, 5395 EXPECT_EQ(TOUCH_ACTION_AUTO,
5396 child_input_router->touch_action_filter_.allowed_touch_action()); 5396 child_input_router->touch_action_filter_.allowed_touch_action());
5397 5397
5398 // Simulate touch event to sub-frame. 5398 // Simulate touch event to sub-frame.
5399 gfx::Point child_center(150, 150); 5399 gfx::Point child_center(150, 150);
5400 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( 5400 auto* rwhv = static_cast<RenderWidgetHostViewAura*>(
5401 contents->GetRenderWidgetHostView()); 5401 contents->GetRenderWidgetHostView());
5402
5403 // Wait until renderer's compositor thread is synced.
5404 {
5405 MainThreadFrameObserver observer(child_render_widget_host);
5406 observer.Wait();
5407 }
5408
5409 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, 5402 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0,
5410 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); 5403 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
5411 rwhv->OnTouchEvent(&touch_event); 5404 rwhv->OnTouchEvent(&touch_event);
5412 {
5413 MainThreadFrameObserver observer(child_render_widget_host);
5414 observer.Wait();
5415 }
5416 5405
5417 // Verify touch handler in subframe was invoked. 5406 // Verify touch handler in subframe was invoked
5418 std::string result; 5407 std::string result;
5419 EXPECT_TRUE(ExecuteScriptAndExtractString( 5408 EXPECT_TRUE(ExecuteScriptAndExtractString(
5420 root->child_at(0), 5409 root->child_at(0),
5421 "window.domAutomationController.send(getLastTouchEvent());", &result)); 5410 "window.domAutomationController.send(getLastTouchEvent());", &result));
5422 EXPECT_EQ("touchstart", result); 5411 EXPECT_EQ("touchstart", result);
5423 5412
5424 // Verify the presence of the touch handler in the child frame correctly 5413 // Verify the presence of the touch handler in the child frame correctly
5425 // propagates touch-action:none information back to the child's input router. 5414 // propagates touch-action:none information back to the child's input router.
5426 EXPECT_EQ(TOUCH_ACTION_NONE, 5415 EXPECT_EQ(TOUCH_ACTION_NONE,
5427 child_input_router->touch_action_filter_.allowed_touch_action()); 5416 child_input_router->touch_action_filter_.allowed_touch_action());
5428 } 5417 }
5429 5418
5430 // This test verifies that the test in
5431 // SitePerProcessBrowserTest.SubframeTouchEventRouting also works properly for
5432 // the main frame. Prior to the CL in which this test is introduced, use of
5433 // MainThreadFrameObserver in SubframeTouchEventRouting was not necessary since
5434 // the touch events were handled on the main thread. Now they are handled on the
5435 // compositor thread, hence the need to synchronize.
5436 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5437 MainframeTouchEventRouting) {
5438 GURL main_url(embedded_test_server()->GetURL(
5439 "/page_with_touch_handler.html"));
5440 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5441
5442 WebContentsImpl* contents = web_contents();
5443 FrameTreeNode* root = contents->GetFrameTree()->root();
5444
5445 // Synchronize with the renderers to guarantee that the
5446 // surface information required for event hit testing is ready.
5447 auto* rwhv = static_cast<RenderWidgetHostViewAura*>(
5448 contents->GetRenderWidgetHostView());
5449
5450 // There's no intrinsic reason the following values can't be equal, but they
5451 // aren't at present, and if they become the same this test will need to be
5452 // updated to accommodate.
5453 EXPECT_NE(TOUCH_ACTION_AUTO, TOUCH_ACTION_NONE);
5454
5455 // Verify the main frame's input router is initially set for
5456 // TOUCH_ACTION_AUTO. The
5457 // TouchStart event will trigger TOUCH_ACTION_NONE being sent back to the
5458 // browser.
5459 RenderWidgetHostImpl* render_widget_host =
5460 root->current_frame_host()->GetRenderWidgetHost();
5461 InputRouterImpl* input_router =
5462 static_cast<InputRouterImpl*>(render_widget_host->input_router());
5463 EXPECT_EQ(TOUCH_ACTION_AUTO,
5464 input_router->touch_action_filter_.allowed_touch_action());
5465
5466 // Simulate touch event to sub-frame.
5467 gfx::Point frame_center(150, 150);
5468
5469 // Wait until renderer's compositor thread is synced.
5470 {
5471 auto observer =
5472 base::MakeUnique<MainThreadFrameObserver>(render_widget_host);
5473 observer->Wait();
5474 }
5475
5476 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, frame_center, 0, 0,
5477 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
5478 rwhv->OnTouchEvent(&touch_event);
5479 {
5480 auto observer =
5481 base::MakeUnique<MainThreadFrameObserver>(render_widget_host);
5482 observer->Wait();
5483 }
5484
5485 // Verify touch handler in subframe was invoked.
5486 std::string result;
5487 EXPECT_TRUE(ExecuteScriptAndExtractString(
5488 root, "window.domAutomationController.send(getLastTouchEvent());",
5489 &result));
5490 EXPECT_EQ("touchstart", result);
5491
5492 // Verify the presence of the touch handler in the child frame correctly
5493 // propagates touch-action:none information back to the child's input router.
5494 EXPECT_EQ(TOUCH_ACTION_NONE,
5495 input_router->touch_action_filter_.allowed_touch_action());
5496 }
5497
5498 namespace { 5419 namespace {
5499 5420
5500 // Declared here to be close to the SubframeGestureEventRouting test. 5421 // Declared here to be close to the SubframeGestureEventRouting test.
5501 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, 5422 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner,
5502 SyntheticGesture::Result result) { 5423 SyntheticGesture::Result result) {
5503 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); 5424 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
5504 runner->Quit(); 5425 runner->Quit();
5505 } 5426 }
5506 5427
5507 } // namespace anonymous 5428 } // namespace anonymous
(...skipping 3663 matching lines...) Expand 10 before | Expand all | Expand 10 after
9171 shell(), embedded_test_server()->GetURL("b.com", "/title3.html"))); 9092 shell(), embedded_test_server()->GetURL("b.com", "/title3.html")));
9172 9093
9173 // Pretend that a.com just requested a context menu. This used to cause a 9094 // Pretend that a.com just requested a context menu. This used to cause a
9174 // because the RenderWidgetHostView is destroyed when the frame is swapped and 9095 // because the RenderWidgetHostView is destroyed when the frame is swapped and
9175 // added to pending delete list. 9096 // added to pending delete list.
9176 rfh->OnMessageReceived( 9097 rfh->OnMessageReceived(
9177 FrameHostMsg_ContextMenu(rfh->GetRoutingID(), ContextMenuParams())); 9098 FrameHostMsg_ContextMenu(rfh->GetRoutingID(), ContextMenuParams()));
9178 } 9099 }
9179 9100
9180 } // namespace content 9101 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_input_event_router.cc ('k') | content/renderer/gpu/compositor_dependencies.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698