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

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

Issue 2101663002: Send synthetic GestureTapDown to focus BrowserPlugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix coordinate conversions for focusing gestures. Created 4 years, 5 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 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 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after
3398 } 3398 }
3399 3399
3400 content::RenderWidgetHostView* guest_host_view = 3400 content::RenderWidgetHostView* guest_host_view =
3401 guest_contents->GetRenderWidgetHostView(); 3401 guest_contents->GetRenderWidgetHostView();
3402 EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset()); 3402 EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset());
3403 3403
3404 // Send scroll gesture to guest and verify embedder scrolls. 3404 // Send scroll gesture to guest and verify embedder scrolls.
3405 // Perform a scroll gesture of the same magnitude, but in the opposite 3405 // Perform a scroll gesture of the same magnitude, but in the opposite
3406 // direction and centered over the GuestView this time. 3406 // direction and centered over the GuestView this time.
3407 guest_rect = guest_contents->GetContainerBounds(); 3407 guest_rect = guest_contents->GetContainerBounds();
3408 embedder_rect = embedder_contents->GetContainerBounds();
3409 guest_rect.set_x(guest_rect.x() - embedder_rect.x());
3410 guest_rect.set_y(guest_rect.y() - embedder_rect.y());
3411 { 3408 {
3412 gfx::Point guest_scroll_location(guest_rect.x() + guest_rect.width() / 2, 3409 gfx::Point guest_scroll_location(guest_rect.width() / 2,
3413 guest_rect.y()); 3410 guest_rect.height() / 2);
3414 3411
3415 ScrollWaiter waiter(embedder_host_view); 3412 ScrollWaiter waiter(embedder_host_view);
3416 3413
3417 content::SimulateGestureScrollSequence(embedder_contents, 3414 content::SimulateGestureScrollSequence(guest_contents,
3418 guest_scroll_location, 3415 guest_scroll_location,
3419 gfx::Vector2dF(0, gesture_distance)); 3416 gfx::Vector2dF(0, gesture_distance));
3420 3417
3421 waiter.WaitForScrollChange(gfx::Vector2dF()); 3418 waiter.WaitForScrollChange(gfx::Vector2dF());
3422 } 3419 }
3423 } 3420 }
3424 3421
3425 class WebViewScrollGuestContentTest : public WebViewTest { 3422 class WebViewScrollGuestContentTest : public WebViewTest {
3426 public: 3423 public:
3427 ~WebViewScrollGuestContentTest() override {} 3424 ~WebViewScrollGuestContentTest() override {}
(...skipping 27 matching lines...) Expand all
3455 gfx::Rect embedder_rect = embedder_contents->GetContainerBounds(); 3452 gfx::Rect embedder_rect = embedder_contents->GetContainerBounds();
3456 gfx::Rect guest_rect = guest_contents->GetContainerBounds(); 3453 gfx::Rect guest_rect = guest_contents->GetContainerBounds();
3457 guest_rect.set_x(guest_rect.x() - embedder_rect.x()); 3454 guest_rect.set_x(guest_rect.x() - embedder_rect.x());
3458 guest_rect.set_y(guest_rect.y() - embedder_rect.y()); 3455 guest_rect.set_y(guest_rect.y() - embedder_rect.y());
3459 3456
3460 content::RenderWidgetHostView* embedder_host_view = 3457 content::RenderWidgetHostView* embedder_host_view =
3461 embedder_contents->GetRenderWidgetHostView(); 3458 embedder_contents->GetRenderWidgetHostView();
3462 EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset()); 3459 EXPECT_EQ(gfx::Vector2dF(), guest_host_view->GetLastScrollOffset());
3463 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset()); 3460 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset());
3464 3461
3465 gfx::Point guest_scroll_location(guest_rect.x() + guest_rect.width() / 2, 3462 gfx::Point guest_scroll_location(guest_rect.width() / 2, 0);
3466 guest_rect.y());
3467 3463
3468 float gesture_distance = 15.f; 3464 float gesture_distance = 15.f;
3469 { 3465 {
3470 gfx::Vector2dF expected_offset(0.f, gesture_distance); 3466 gfx::Vector2dF expected_offset(0.f, gesture_distance);
3471 3467
3472 ScrollWaiter waiter(guest_host_view); 3468 ScrollWaiter waiter(guest_host_view);
3473 3469
3474 content::SimulateGestureScrollSequence( 3470 content::SimulateGestureScrollSequence(
3475 embedder_contents, guest_scroll_location, 3471 guest_contents, guest_scroll_location,
3476 gfx::Vector2dF(0, -gesture_distance)); 3472 gfx::Vector2dF(0, -gesture_distance));
3477 3473
3478 waiter.WaitForScrollChange(expected_offset); 3474 waiter.WaitForScrollChange(expected_offset);
3479 } 3475 }
3480 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset()); 3476 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset());
3481 3477
3482 // Use fling gesture to scroll back, velocity should be big enough to scroll 3478 // Use fling gesture to scroll back, velocity should be big enough to scroll
3483 // content back. 3479 // content back.
3484 float fling_velocity = 300.f; 3480 float fling_velocity = 300.f;
3485 { 3481 {
3486 ScrollWaiter waiter(guest_host_view); 3482 ScrollWaiter waiter(guest_host_view);
3487 3483
3488 content::SimulateGestureFlingSequence( 3484 content::SimulateGestureFlingSequence(
3489 embedder_contents, guest_scroll_location, 3485 guest_contents, guest_scroll_location,
3490 gfx::Vector2dF(0, fling_velocity)); 3486 gfx::Vector2dF(0, fling_velocity));
3491 3487
3492 waiter.WaitForScrollChange(gfx::Vector2dF()); 3488 waiter.WaitForScrollChange(gfx::Vector2dF());
3493 } 3489 }
3494 3490
3495 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset()); 3491 EXPECT_EQ(gfx::Vector2dF(), embedder_host_view->GetLastScrollOffset());
3496 } 3492 }
3497 3493
3498 #if defined(USE_AURA) 3494 #if defined(USE_AURA)
3499 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation 3495 // TODO(wjmaclean): when WebViewTest is re-enabled on the site-isolation
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3590 gfx::Point embedder_origin = 3586 gfx::Point embedder_origin =
3591 GetEmbedderWebContents()->GetContainerBounds().origin(); 3587 GetEmbedderWebContents()->GetContainerBounds().origin();
3592 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); 3588 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y());
3593 3589
3594 // Generate and send synthetic touch event. 3590 // Generate and send synthetic touch event.
3595 content::SimulateTouchPressAt(GetEmbedderWebContents(), 3591 content::SimulateTouchPressAt(GetEmbedderWebContents(),
3596 guest_rect.CenterPoint()); 3592 guest_rect.CenterPoint());
3597 EXPECT_TRUE(aura_webview->HasFocus()); 3593 EXPECT_TRUE(aura_webview->HasFocus());
3598 } 3594 }
3599 #endif 3595 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698