| 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 "apps/shell_window.h" | 5 #include "apps/shell_window.h" |
| 6 #include "apps/shell_window_registry.h" | 6 #include "apps/shell_window_registry.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/apps/app_browsertest_util.h" | 10 #include "chrome/browser/apps/app_browsertest_util.h" |
| 10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 11 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util.
h" |
| 14 #include "chrome/browser/tab_contents/render_view_context_menu_test_util.h" |
| 12 #include "chrome/test/base/interactive_test_utils.h" | 15 #include "chrome/test/base/interactive_test_utils.h" |
| 13 #include "chrome/test/base/test_launcher_utils.h" | 16 #include "chrome/test/base/test_launcher_utils.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 18 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
| 19 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_view.h" | 23 #include "content/public/browser/web_contents_view.h" |
| 21 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 246 } |
| 244 | 247 |
| 245 content::WebContents* embedder_web_contents() { | 248 content::WebContents* embedder_web_contents() { |
| 246 return embedder_web_contents_; | 249 return embedder_web_contents_; |
| 247 } | 250 } |
| 248 | 251 |
| 249 gfx::Point corner() { | 252 gfx::Point corner() { |
| 250 return corner_; | 253 return corner_; |
| 251 } | 254 } |
| 252 | 255 |
| 253 void SimulateRWHMouseClick(content::RenderWidgetHost* rwh, int x, int y) { | 256 void SimulateRWHMouseClick(content::RenderWidgetHost* rwh, |
| 257 blink::WebMouseEvent::Button button, |
| 258 int x, |
| 259 int y) { |
| 254 blink::WebMouseEvent mouse_event; | 260 blink::WebMouseEvent mouse_event; |
| 255 mouse_event.button = blink::WebMouseEvent::ButtonLeft; | 261 mouse_event.button = button; |
| 256 mouse_event.x = mouse_event.windowX = x; | 262 mouse_event.x = mouse_event.windowX = x; |
| 257 mouse_event.y = mouse_event.windowY = y; | 263 mouse_event.y = mouse_event.windowY = y; |
| 258 mouse_event.modifiers = 0; | 264 mouse_event.modifiers = 0; |
| 259 | 265 |
| 260 mouse_event.type = blink::WebInputEvent::MouseDown; | 266 mouse_event.type = blink::WebInputEvent::MouseDown; |
| 261 rwh->ForwardMouseEvent(mouse_event); | 267 rwh->ForwardMouseEvent(mouse_event); |
| 262 mouse_event.type = blink::WebInputEvent::MouseUp; | 268 mouse_event.type = blink::WebInputEvent::MouseUp; |
| 263 rwh->ForwardMouseEvent(mouse_event); | 269 rwh->ForwardMouseEvent(mouse_event); |
| 264 } | 270 } |
| 265 | 271 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 base::string16 expected_title = base::ASCIIToUTF16("PASSED2"); | 326 base::string16 expected_title = base::ASCIIToUTF16("PASSED2"); |
| 321 base::string16 error_title = base::ASCIIToUTF16("FAILED"); | 327 base::string16 error_title = base::ASCIIToUTF16("FAILED"); |
| 322 content::TitleWatcher title_watcher(guest_web_contents(), expected_title); | 328 content::TitleWatcher title_watcher(guest_web_contents(), expected_title); |
| 323 title_watcher.AlsoWaitForTitle(error_title); | 329 title_watcher.AlsoWaitForTitle(error_title); |
| 324 EXPECT_TRUE(content::ExecuteScript(guest_web_contents(), | 330 EXPECT_TRUE(content::ExecuteScript(guest_web_contents(), |
| 325 "changeTitle();")); | 331 "changeTitle();")); |
| 326 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 332 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 327 | 333 |
| 328 gfx::Rect popup_bounds = popup_rwh->GetView()->GetViewBounds(); | 334 gfx::Rect popup_bounds = popup_rwh->GetView()->GetViewBounds(); |
| 329 // (2, 2) is expected to lie on the first datalist element. | 335 // (2, 2) is expected to lie on the first datalist element. |
| 330 SimulateRWHMouseClick(popup_rwh, 2, 2); | 336 SimulateRWHMouseClick(popup_rwh, blink::WebMouseEvent::ButtonLeft, 2, 2); |
| 331 | 337 |
| 332 content::RenderViewHost* embedder_rvh = | 338 content::RenderViewHost* embedder_rvh = |
| 333 GetFirstShellWindowWebContents()->GetRenderViewHost(); | 339 GetFirstShellWindowWebContents()->GetRenderViewHost(); |
| 334 gfx::Rect embedder_bounds = embedder_rvh->GetView()->GetViewBounds(); | 340 gfx::Rect embedder_bounds = embedder_rvh->GetView()->GetViewBounds(); |
| 335 gfx::Vector2d diff = popup_bounds.origin() - embedder_bounds.origin(); | 341 gfx::Vector2d diff = popup_bounds.origin() - embedder_bounds.origin(); |
| 336 LOG(INFO) << "DIFF: x = " << diff.x() << ", y = " << diff.y(); | 342 LOG(INFO) << "DIFF: x = " << diff.x() << ", y = " << diff.y(); |
| 337 | 343 |
| 338 const int left_spacing = 40 + padding.x(); // div.style.paddingLeft = 40px. | 344 const int left_spacing = 40 + padding.x(); // div.style.paddingLeft = 40px. |
| 339 // div.style.paddingTop = 50px + (input box height = 26px). | 345 // div.style.paddingTop = 50px + (input box height = 26px). |
| 340 const int top_spacing = 50 + 26 + padding.y(); | 346 const int top_spacing = 50 + 26 + padding.y(); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 | 762 |
| 757 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); | 763 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); |
| 758 } | 764 } |
| 759 | 765 |
| 760 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, | 766 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, |
| 761 PointerLock_PointerLockLostWithFocus) { | 767 PointerLock_PointerLockLostWithFocus) { |
| 762 TestHelper("testPointerLockLostWithFocus", | 768 TestHelper("testPointerLockLostWithFocus", |
| 763 "web_view/pointerlock", | 769 "web_view/pointerlock", |
| 764 NO_TEST_SERVER); | 770 NO_TEST_SERVER); |
| 765 } | 771 } |
| 772 |
| 773 #if defined(OS_MACOSX) |
| 774 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, TextSelection) { |
| 775 SetupTest("web_view/text_selection", |
| 776 "/extensions/platform_apps/web_view/text_selection/guest.html"); |
| 777 ASSERT_TRUE(guest_web_contents()); |
| 778 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 779 GetPlatformAppWindow())); |
| 780 |
| 781 // Wait until guest sees a context menu, select an arbitrary item (copy). |
| 782 ExtensionTestMessageListener ctx_listener("MSG_CONTEXTMENU", false); |
| 783 ContextMenuNotificationObserver menu_observer(IDC_CONTENT_CONTEXT_COPY); |
| 784 SimulateRWHMouseClick(guest_web_contents()->GetRenderViewHost(), |
| 785 blink::WebMouseEvent::ButtonRight, 20, 20); |
| 786 ASSERT_TRUE(ctx_listener.WaitUntilSatisfied()); |
| 787 |
| 788 // Now verify that the selection text propagates properly to RWHV. |
| 789 content::RenderWidgetHostView* guest_rwhv = |
| 790 guest_web_contents()->GetRenderWidgetHostView(); |
| 791 ASSERT_TRUE(guest_rwhv); |
| 792 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); |
| 793 ASSERT_TRUE(selected_text.size() >= 10u); |
| 794 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); |
| 795 } |
| 796 #endif |
| OLD | NEW |