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

Side by Side Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 2015373002: Fix webview crash on attempt to scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed content_tests (handle case when view is not available), added expected event into Fling test … Created 4 years, 6 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/scrollable_embedder_and_guest/guest.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3390 matching lines...) Expand 10 before | Expand all | Expand 10 after
3401 ScrollWaiter waiter(embedder_host_view); 3401 ScrollWaiter waiter(embedder_host_view);
3402 3402
3403 content::SimulateGestureScrollSequence(embedder_contents, 3403 content::SimulateGestureScrollSequence(embedder_contents,
3404 guest_scroll_location, 3404 guest_scroll_location,
3405 gfx::Vector2dF(0, gesture_distance)); 3405 gfx::Vector2dF(0, gesture_distance));
3406 3406
3407 waiter.WaitForScrollChange(gfx::Vector2dF()); 3407 waiter.WaitForScrollChange(gfx::Vector2dF());
3408 } 3408 }
3409 } 3409 }
3410 3410
3411 class WebViewScrollGuestContentTest : public WebViewTest {
3412 public:
3413 ~WebViewScrollGuestContentTest() override {}
3414
3415 void SetUpCommandLine(base::CommandLine* command_line) override {
3416 WebViewTest::SetUpCommandLine(command_line);
3417
3418 command_line->AppendSwitchASCII(switches::kTouchEvents,
3419 switches::kTouchEventsEnabled);
3420 }
3421 };
3422
3423 INSTANTIATE_TEST_CASE_P(WebViewScrollGuestContent,
3424 WebViewScrollGuestContentTest,
3425 testing::Values(false));
3426
3427 IN_PROC_BROWSER_TEST_P(WebViewScrollGuestContentTest, ScrollGuestContent) {
3428 LoadAppWithGuest("web_view/scrollable_embedder_and_guest");
3429
3430 content::WebContents* embedder_contents = GetEmbedderWebContents();
3431
3432 std::vector<content::WebContents*> guest_web_contents_list;
3433 GetGuestViewManager()->WaitForNumGuestsCreated(1u);
3434 GetGuestViewManager()->GetGuestWebContentsList(&guest_web_contents_list);
3435 ASSERT_EQ(1u, guest_web_contents_list.size());
3436
3437 content::WebContents* guest_contents = guest_web_contents_list[0];
3438 content::RenderWidgetHostView* guest_host_view =
3439 guest_contents->GetRenderWidgetHostView();
3440
3441 gfx::Rect embedder_rect = embedder_contents->GetContainerBounds();
3442 gfx::Rect guest_rect = guest_contents->GetContainerBounds();
3443 guest_rect.set_x(guest_rect.x() - embedder_rect.x());
3444 guest_rect.set_y(guest_rect.y() - embedder_rect.y());
3445
3446 content::RenderWidgetHostView* embedder_host_view =
3447 embedder_contents->GetRenderWidgetHostView();
3448 EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset());
3449 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset());
3450
3451 gfx::Point guest_scroll_location(guest_rect.x() + guest_rect.width() / 2,
3452 guest_rect.y());
3453
3454 float gesture_distance = 15.f;
3455 {
3456 gfx::Vector2dF expected_offset(0.f, gesture_distance);
3457
3458 ScrollWaiter waiter(guest_host_view);
3459
3460 content::SimulateGestureScrollSequence(
3461 embedder_contents, guest_scroll_location,
3462 gfx::Vector2dF(0, -gesture_distance));
3463
3464 waiter.WaitForScrollChange(expected_offset);
3465 }
3466 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset());
3467
3468 // Use fling gesture to scroll back, velocity should be big enough to scroll
3469 // content back.
3470 float fling_velocity = 300.f;
3471 {
3472 ScrollWaiter waiter(guest_host_view);
3473
3474 content::SimulateGestureFlingSequence(
3475 embedder_contents, guest_scroll_location,
3476 gfx::Vector2dF(0, fling_velocity));
3477
3478 waiter.WaitForScrollChange(gfx::Vector2dF());
3479 }
3480
3481 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset());
3482 }
3483
3411 #if defined(USE_AURA) 3484 #if defined(USE_AURA)
3412 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation 3485 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation
3413 // bots, then re-enable this test class as well. 3486 // bots, then re-enable this test class as well.
3414 // https://crbug.com/503751 3487 // https://crbug.com/503751
3415 class WebViewFocusTest : public WebViewTest { 3488 class WebViewFocusTest : public WebViewTest {
3416 public: 3489 public:
3417 ~WebViewFocusTest() override {} 3490 ~WebViewFocusTest() override {}
3418 3491
3419 void SetUpCommandLine(base::CommandLine* command_line) override { 3492 void SetUpCommandLine(base::CommandLine* command_line) override {
3420 WebViewTest::SetUpCommandLine(command_line); 3493 WebViewTest::SetUpCommandLine(command_line);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3503 gfx::Point embedder_origin = 3576 gfx::Point embedder_origin =
3504 GetEmbedderWebContents()->GetContainerBounds().origin(); 3577 GetEmbedderWebContents()->GetContainerBounds().origin();
3505 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); 3578 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y());
3506 3579
3507 // Generate and send synthetic touch event. 3580 // Generate and send synthetic touch event.
3508 content::SimulateTouchPressAt(GetEmbedderWebContents(), 3581 content::SimulateTouchPressAt(GetEmbedderWebContents(),
3509 guest_rect.CenterPoint()); 3582 guest_rect.CenterPoint());
3510 EXPECT_TRUE(aura_webview->HasFocus()); 3583 EXPECT_TRUE(aura_webview->HasFocus());
3511 } 3584 }
3512 #endif 3585 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/scrollable_embedder_and_guest/guest.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698