| OLD | NEW |
| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // This helper accounts for Android devices which use page scale factor | 266 // This helper accounts for Android devices which use page scale factor |
| 267 // different from 1.0. Coordinate targeting needs to be adjusted before | 267 // different from 1.0. Coordinate targeting needs to be adjusted before |
| 268 // hit testing. | 268 // hit testing. |
| 269 double GetPageScaleFactor(Shell* shell) { | 269 double GetPageScaleFactor(Shell* shell) { |
| 270 return RenderWidgetHostImpl::From( | 270 return RenderWidgetHostImpl::From( |
| 271 shell->web_contents()->GetRenderViewHost()->GetWidget()) | 271 shell->web_contents()->GetRenderViewHost()->GetWidget()) |
| 272 ->last_frame_metadata() | 272 ->last_frame_metadata() |
| 273 .page_scale_factor; | 273 .page_scale_factor; |
| 274 } | 274 } |
| 275 | 275 |
| 276 bool callback_received = false; |
| 277 int received_frame_id = -2; |
| 278 |
| 279 void callback(int frame_id) { |
| 280 received_frame_id = frame_id; |
| 281 callback_received = true; |
| 282 } |
| 283 |
| 276 // Helper function that performs a surface hittest. | 284 // Helper function that performs a surface hittest. |
| 277 void SurfaceHitTestTestHelper( | 285 void SurfaceHitTestTestHelper( |
| 278 Shell* shell, | 286 Shell* shell, |
| 279 net::test_server::EmbeddedTestServer* embedded_test_server) { | 287 net::test_server::EmbeddedTestServer* embedded_test_server) { |
| 280 GURL main_url(embedded_test_server->GetURL( | 288 GURL main_url(embedded_test_server->GetURL( |
| 281 "/frame_tree/page_with_positioned_frame.html")); | 289 "/frame_tree/page_with_positioned_frame.html")); |
| 282 EXPECT_TRUE(NavigateToURL(shell, main_url)); | 290 EXPECT_TRUE(NavigateToURL(shell, main_url)); |
| 283 | 291 |
| 284 // It is safe to obtain the root frame tree node here, as it doesn't change. | 292 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 285 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) | 293 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 blink::WebInputEvent::kTimeStampForTesting); | 331 blink::WebInputEvent::kTimeStampForTesting); |
| 324 child_event.button = blink::WebPointerProperties::Button::kLeft; | 332 child_event.button = blink::WebPointerProperties::Button::kLeft; |
| 325 child_event.SetPositionInWidget( | 333 child_event.SetPositionInWidget( |
| 326 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x() + 5) * | 334 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x() + 5) * |
| 327 scale_factor), | 335 scale_factor), |
| 328 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y() + 5) * | 336 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y() + 5) * |
| 329 scale_factor)); | 337 scale_factor)); |
| 330 child_event.click_count = 1; | 338 child_event.click_count = 1; |
| 331 main_frame_monitor.ResetEventReceived(); | 339 main_frame_monitor.ResetEventReceived(); |
| 332 child_frame_monitor.ResetEventReceived(); | 340 child_frame_monitor.ResetEventReceived(); |
| 341 |
| 342 callback_received = false; |
| 343 root->current_frame_host()->GetFrameInputHandler()->HitTestFrameAt( |
| 344 (gfx::PointF)child_event.PositionInWidget(), base::Bind(&callback)); |
| 345 while (!callback_received) { |
| 346 base::RunLoop run_loop; |
| 347 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 348 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); |
| 349 run_loop.Run(); |
| 350 } |
| 351 ASSERT_EQ(4, received_frame_id); |
| 352 |
| 333 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); | 353 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); |
| 334 | 354 |
| 335 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 355 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
| 336 // The expected result coordinates are (5, 5), but can get slightly | 356 // The expected result coordinates are (5, 5), but can get slightly |
| 337 // different results due to rounding error with some page scale factors. | 357 // different results due to rounding error with some page scale factors. |
| 338 EXPECT_NEAR(5, child_frame_monitor.event().PositionInWidget().x, 2); | 358 EXPECT_NEAR(5, child_frame_monitor.event().PositionInWidget().x, 2); |
| 339 EXPECT_NEAR(5, child_frame_monitor.event().PositionInWidget().y, 2); | 359 EXPECT_NEAR(5, child_frame_monitor.event().PositionInWidget().y, 2); |
| 340 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 360 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
| 341 | 361 |
| 342 child_frame_monitor.ResetEventReceived(); | 362 child_frame_monitor.ResetEventReceived(); |
| (...skipping 10572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10915 SimpleTap(gfx::Point(point_outside_iframe.x(), point_outside_iframe.y())); | 10935 SimpleTap(gfx::Point(point_outside_iframe.x(), point_outside_iframe.y())); |
| 10916 selection_controller_client->Wait(); | 10936 selection_controller_client->Wait(); |
| 10917 | 10937 |
| 10918 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, | 10938 EXPECT_EQ(ui::TouchSelectionController::INACTIVE, |
| 10919 parent_view->touch_selection_controller()->active_status()); | 10939 parent_view->touch_selection_controller()->active_status()); |
| 10920 } | 10940 } |
| 10921 | 10941 |
| 10922 #endif // defined(OS_ANDROID) | 10942 #endif // defined(OS_ANDROID) |
| 10923 | 10943 |
| 10924 } // namespace content | 10944 } // namespace content |
| OLD | NEW |