Chromium Code Reviews| Index: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc |
| diff --git a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc |
| index f4820ed19496c3b3c13135610280369ad677745a..d6897fe4bfcd4815cad7fe19fbfdc8825eff18ff 100644 |
| --- a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc |
| +++ b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc |
| @@ -287,6 +287,10 @@ class WebViewInteractiveTest |
| mouse_event.x = mouse_event.windowX = x; |
| mouse_event.y = mouse_event.windowY = y; |
| mouse_event.modifiers = 0; |
| + // Needed for the WebViewTest.ContextMenuPositionAfterCSSTransforms |
| + gfx::Rect rect = rwh->GetView()->GetViewBounds(); |
| + mouse_event.globalX = x + rwh->GetView()->GetViewBounds().x(); |
|
lazyboy
2015/09/01 19:45:46
You want to use rect.x() and rect.y() here.
Ehsaan
2015/09/02 15:18:20
Done.
|
| + mouse_event.globalY = y + rwh->GetView()->GetViewBounds().y(); |
| mouse_event.type = blink::WebInputEvent::MouseDown; |
| rwh->ForwardMouseEvent(mouse_event); |
| @@ -849,6 +853,56 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ContextMenuParamCoordinates) { |
| ASSERT_EQ(20, menu_observer.params().y); |
| } |
| +// Tests whether <webview> context menu sees <webview> local coordinates in its |
| +// RenderViewContextMenu params, when it is subject to CSS transforms. |
| +IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, |
| + ContextMenuParamsAfterCSSTransforms) { |
| + LoadAndLaunchPlatformApp("web_view/context_menus/coordinates_with_transforms", |
| + "Launched"); |
| + |
| + if (embedder_web_contents_ == nullptr) |
|
lazyboy
2015/09/01 19:45:47
nit: if (!embedder_web_contents_)
Ehsaan
2015/09/02 15:18:20
Done.
|
| + embedder_web_contents_ = GetFirstAppWindowWebContents(); |
| + EXPECT_TRUE(embedder_web_contents() != nullptr); |
| + |
| + if (guest_web_contents_ == nullptr) |
| + guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated(); |
| + EXPECT_TRUE(guest_web_contents()); |
| + |
| + // We will send the input event to the embedder rather than the guest. This |
| + // is a more realistic model of what happens in reality. We need to do this |
| + // to make sure the MouseDown event is received at the |
| + // RenderWidgetHostViewGuest for the embedder so that the |
|
lazyboy
2015/09/01 19:45:47
embedder shouldn't have RWHVGuest, you mean just R
Ehsaan
2015/09/02 15:18:20
I mean, the View which takes BrowserPlugin's IPC f
|
| + // ChromeWebViewGuestDelegate is notified about the potential position of the |
| + // context menu. |
| + std::vector<std::string> transforms = {"rotate(20deg)", "scale(1.5, 2.0)", |
| + "translate(20px, 30px)", "NONE"}; |
| + for (size_t index = 0; index < transforms.size(); ++index) { |
| + std::string command = |
| + base::StringPrintf("setTransform('%s')", transforms[index].c_str()); |
| + scoped_ptr<ExtensionTestMessageListener> transform_set_listener( |
|
lazyboy
2015/09/01 19:45:47
scoped_ptr seems unnecessary here, you can just us
Ehsaan
2015/09/02 15:18:20
Done.
|
| + new ExtensionTestMessageListener("TRANSFORM_SET", false)); |
| + EXPECT_TRUE(content::ExecuteScript(embedder_web_contents(), command)); |
| + ASSERT_TRUE(transform_set_listener->WaitUntilSatisfied()); |
| + gfx::Rect embedder_view_bounds = |
| + embedder_web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
| + gfx::Rect guest_view_bounds = |
| + guest_web_contents()->GetRenderWidgetHostView()->GetViewBounds(); |
| + |
| + int windowX = 150, windowY = 150; |
|
lazyboy
2015/09/01 19:45:46
nit: window_x, window_y, better set it as point gf
Ehsaan
2015/09/02 15:18:20
Done.
|
| + ContextMenuWaiter menu_observer(content::NotificationService::AllSources()); |
| + SimulateRWHMouseClick( |
| + embedder_web_contents()->GetRenderViewHost(), |
| + blink::WebMouseEvent::ButtonRight, |
| + /* Using window coordinates for the embedder */ |
| + windowX + guest_view_bounds.x() - embedder_view_bounds.x(), |
| + windowY + guest_view_bounds.y() - embedder_view_bounds.y()); |
| + |
| + menu_observer.WaitForMenuOpenAndClose(); |
| + EXPECT_EQ(menu_observer.params().x, windowX); |
| + EXPECT_EQ(menu_observer.params().y, windowY); |
| + } |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, ExecuteCode) { |
| ASSERT_TRUE(RunPlatformAppTestWithArg( |
| "platform_apps/web_view/common", "execute_code")) << message_; |