| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <queue> | 5 #include <queue> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 3317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3328 ScrollWaiter waiter(embedder_host_view); | 3328 ScrollWaiter waiter(embedder_host_view); |
| 3329 | 3329 |
| 3330 content::SimulateGestureScrollSequence(embedder_contents, | 3330 content::SimulateGestureScrollSequence(embedder_contents, |
| 3331 guest_scroll_location, | 3331 guest_scroll_location, |
| 3332 gfx::Vector2dF(0, gesture_distance)); | 3332 gfx::Vector2dF(0, gesture_distance)); |
| 3333 | 3333 |
| 3334 waiter.WaitForScrollChange(gfx::Vector2dF()); | 3334 waiter.WaitForScrollChange(gfx::Vector2dF()); |
| 3335 } | 3335 } |
| 3336 } | 3336 } |
| 3337 | 3337 |
| 3338 class WebViewScrollGuestContentTest : public WebViewTest { |
| 3339 public: |
| 3340 ~WebViewScrollGuestContentTest() override {} |
| 3341 |
| 3342 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 3343 WebViewTest::SetUpCommandLine(command_line); |
| 3344 |
| 3345 command_line->AppendSwitchASCII(switches::kTouchEvents, |
| 3346 switches::kTouchEventsEnabled); |
| 3347 } |
| 3348 }; |
| 3349 |
| 3350 INSTANTIATE_TEST_CASE_P(WebViewScrollGuestContent, |
| 3351 WebViewScrollGuestContentTest, |
| 3352 testing::Values(false)); |
| 3353 |
| 3354 IN_PROC_BROWSER_TEST_P(WebViewScrollGuestContentTest, ScrollGuestContent) { |
| 3355 LoadAppWithGuest("web_view/scrollable_embedder_and_guest"); |
| 3356 |
| 3357 content::WebContents* embedder_contents = GetEmbedderWebContents(); |
| 3358 |
| 3359 std::vector<content::WebContents*> guest_web_contents_list; |
| 3360 GetGuestViewManager()->WaitForNumGuestsCreated(1u); |
| 3361 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list); |
| 3362 ASSERT_EQ(1u, guest_web_contents_list.size()); |
| 3363 |
| 3364 content::WebContents* guest_contents = guest_web_contents_list[0]; |
| 3365 content::RenderWidgetHostView* guest_host_view = |
| 3366 guest_contents->GetRenderWidgetHostView(); |
| 3367 |
| 3368 gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); |
| 3369 gfx::Rect guest_rect = guest_contents->GetContainerBounds(); |
| 3370 guest_rect.set_x(guest_rect.x() - embedder_rect.x()); |
| 3371 guest_rect.set_y(guest_rect.y() - embedder_rect.y()); |
| 3372 |
| 3373 content::RenderWidgetHostView* embedder_host_view = |
| 3374 embedder_contents->GetRenderWidgetHostView(); |
| 3375 EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset()); |
| 3376 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset()); |
| 3377 |
| 3378 gfx::Point guest_scroll_location(guest_rect.x() + guest_rect.width() / 2, |
| 3379 guest_rect.y()); |
| 3380 |
| 3381 float gesture_distance = 15.f; |
| 3382 { |
| 3383 gfx::Vector2dF expected_offset(0.f, gesture_distance); |
| 3384 |
| 3385 ScrollWaiter waiter(guest_host_view); |
| 3386 |
| 3387 content::SimulateGestureScrollSequence( |
| 3388 embedder_contents, guest_scroll_location, |
| 3389 gfx::Vector2dF(0, -gesture_distance)); |
| 3390 |
| 3391 waiter.WaitForScrollChange(expected_offset); |
| 3392 } |
| 3393 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset()); |
| 3394 |
| 3395 // Use fling gesture to scroll back, velocity should be big enough to scroll |
| 3396 // content back. |
| 3397 float fling_velocity = 300.f; |
| 3398 { |
| 3399 ScrollWaiter waiter(guest_host_view); |
| 3400 |
| 3401 content::SimulateGestureFlingSequence( |
| 3402 embedder_contents, guest_scroll_location, |
| 3403 gfx::Vector2dF(0, fling_velocity)); |
| 3404 |
| 3405 waiter.WaitForScrollChange(gfx::Vector2dF()); |
| 3406 } |
| 3407 |
| 3408 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset()); |
| 3409 } |
| 3410 |
| 3338 #if defined(USE_AURA) | 3411 #if defined(USE_AURA) |
| 3339 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation | 3412 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation |
| 3340 // bots, then re-enable this test class as well. | 3413 // bots, then re-enable this test class as well. |
| 3341 // https://crbug.com/503751 | 3414 // https://crbug.com/503751 |
| 3342 class WebViewFocusTest : public WebViewTest { | 3415 class WebViewFocusTest : public WebViewTest { |
| 3343 public: | 3416 public: |
| 3344 ~WebViewFocusTest() override {} | 3417 ~WebViewFocusTest() override {} |
| 3345 | 3418 |
| 3346 void SetUpCommandLine(base::CommandLine* command_line) override { | 3419 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 3347 WebViewTest::SetUpCommandLine(command_line); | 3420 WebViewTest::SetUpCommandLine(command_line); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3430 gfx::Point embedder_origin = | 3503 gfx::Point embedder_origin = |
| 3431 GetEmbedderWebContents()->GetContainerBounds().origin(); | 3504 GetEmbedderWebContents()->GetContainerBounds().origin(); |
| 3432 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); | 3505 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); |
| 3433 | 3506 |
| 3434 // Generate and send synthetic touch event. | 3507 // Generate and send synthetic touch event. |
| 3435 content::SimulateTouchPressAt(GetEmbedderWebContents(), | 3508 content::SimulateTouchPressAt(GetEmbedderWebContents(), |
| 3436 guest_rect.CenterPoint()); | 3509 guest_rect.CenterPoint()); |
| 3437 EXPECT_TRUE(aura_webview->HasFocus()); | 3510 EXPECT_TRUE(aura_webview->HasFocus()); |
| 3438 } | 3511 } |
| 3439 #endif | 3512 #endif |
| OLD | NEW |