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/app_window.h" | 5 #include "apps/app_window.h" |
6 #include "apps/app_window_registry.h" | 6 #include "apps/app_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/app/chrome_command_ids.h" |
10 #include "chrome/browser/apps/app_browsertest_util.h" | 10 #include "chrome/browser/apps/app_browsertest_util.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 ExtensionTestMessageListener move_listener2("move-captured", false); | 492 ExtensionTestMessageListener move_listener2("move-captured", false); |
493 SendMouseClick(ui_controls::RIGHT); | 493 SendMouseClick(ui_controls::RIGHT); |
494 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( | 494 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( |
495 gfx::Point(corner().x() + 51, corner().y() + 11))); | 495 gfx::Point(corner().x() + 51, corner().y() + 11))); |
496 ASSERT_TRUE(move_listener2.WaitUntilSatisfied()); | 496 ASSERT_TRUE(move_listener2.WaitUntilSatisfied()); |
497 } | 497 } |
498 } | 498 } |
499 | 499 |
500 #endif // defined(OS_LINUX) && !defined(USE_AURA) | 500 #endif // defined(OS_LINUX) && !defined(USE_AURA) |
501 | 501 |
| 502 // Tests that if a <webview> is focused before navigation then the guest starts |
| 503 // off focused. |
| 504 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusBeforeNavigation) { |
| 505 TestHelper("testFocusBeforeNavigation", "web_view/focus", NO_TEST_SERVER); |
| 506 } |
| 507 |
502 // Tests that setting focus on the <webview> sets focus on the guest. | 508 // Tests that setting focus on the <webview> sets focus on the guest. |
503 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusEvent) { | 509 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusEvent) { |
504 TestHelper("testFocusEvent", "web_view/focus", NO_TEST_SERVER); | 510 TestHelper("testFocusEvent", "web_view/focus", NO_TEST_SERVER); |
505 } | 511 } |
506 | 512 |
507 // Tests that setting focus on the <webview> sets focus on the guest. | 513 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusTracksEmbedder) { |
| 514 content::WebContents* embedder_web_contents = NULL; |
| 515 |
| 516 scoped_ptr<ExtensionTestMessageListener> done_listener( |
| 517 RunAppHelper("testFocusTracksEmbedder", "web_view/focus", NO_TEST_SERVER, |
| 518 &embedder_web_contents)); |
| 519 done_listener->WaitUntilSatisfied(); |
| 520 |
| 521 ExtensionTestMessageListener post_test_listener("POST_TEST_PASSED", false); |
| 522 post_test_listener.set_failure_message("POST_TEST_FAILED"); |
| 523 EXPECT_TRUE(content::ExecuteScript( |
| 524 embedder_web_contents, |
| 525 "window.runCommand('POST_testFocusTracksEmbedder');")); |
| 526 |
| 527 // Blur the embedder. |
| 528 embedder_web_contents->GetRenderViewHost()->Blur(); |
| 529 // Ensure that the guest is also blurred. |
| 530 ASSERT_TRUE(post_test_listener.WaitUntilSatisfied()); |
| 531 } |
| 532 |
| 533 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_AdvanceFocus) { |
| 534 content::WebContents* embedder_web_contents = NULL; |
| 535 |
| 536 { |
| 537 scoped_ptr<ExtensionTestMessageListener> done_listener( |
| 538 RunAppHelper("testAdvanceFocus", "web_view/focus", NO_TEST_SERVER, |
| 539 &embedder_web_contents)); |
| 540 done_listener->WaitUntilSatisfied(); |
| 541 } |
| 542 |
| 543 { |
| 544 ExtensionTestMessageListener listener("button1-focused", false); |
| 545 listener.set_failure_message("TEST_FAILED"); |
| 546 SimulateRWHMouseClick(embedder_web_contents->GetRenderViewHost(), |
| 547 blink::WebMouseEvent::ButtonLeft, 200, 20); |
| 548 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB, |
| 549 false, false, false, false); |
| 550 EXPECT_TRUE(content::ExecuteScript( |
| 551 embedder_web_contents, |
| 552 "window.runCommand('POST_testAdvanceFocus');")); |
| 553 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 554 } |
| 555 |
| 556 { |
| 557 // Wait for button1 to be focused again, this means we have seen |
| 558 // BrowserPluginGuest::OnTakeFocus. |
| 559 ExtensionTestMessageListener listener("button1-advance-focus", false); |
| 560 listener.set_failure_message("TEST_FAILED"); |
| 561 // TODO(fsamuel): A third Tab key press should not be necessary. |
| 562 // The browser plugin will take keyboard focus but it will not |
| 563 // focus an initial element. The initial element is dependent |
| 564 // upon tab direction which WebKit does not propagate to the plugin. |
| 565 // See http://crbug.com/147644. |
| 566 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 567 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 568 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 569 ASSERT_TRUE(listener.WaitUntilSatisfied()); |
| 570 } |
| 571 } |
| 572 |
| 573 // Tests that blurring <webview> also blurs the guest. |
508 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_BlurEvent) { | 574 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_BlurEvent) { |
509 TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER); | 575 TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER); |
510 } | 576 } |
511 | 577 |
512 // Tests that guests receive edit commands and respond appropriately. | 578 // Tests that guests receive edit commands and respond appropriately. |
513 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommands) { | 579 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommands) { |
514 ExtensionTestMessageListener guest_connected_listener("connected", false); | 580 ExtensionTestMessageListener guest_connected_listener("connected", false); |
515 LoadAndLaunchPlatformApp("web_view/edit_commands"); | 581 LoadAndLaunchPlatformApp("web_view/edit_commands"); |
516 // Wait until the guest process reports that it has established a message | 582 // Wait until the guest process reports that it has established a message |
517 // channel with the app. | 583 // channel with the app. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 | 850 |
785 // Now verify that the selection text propagates properly to RWHV. | 851 // Now verify that the selection text propagates properly to RWHV. |
786 content::RenderWidgetHostView* guest_rwhv = | 852 content::RenderWidgetHostView* guest_rwhv = |
787 guest_web_contents()->GetRenderWidgetHostView(); | 853 guest_web_contents()->GetRenderWidgetHostView(); |
788 ASSERT_TRUE(guest_rwhv); | 854 ASSERT_TRUE(guest_rwhv); |
789 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); | 855 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); |
790 ASSERT_TRUE(selected_text.size() >= 10u); | 856 ASSERT_TRUE(selected_text.size() >= 10u); |
791 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); | 857 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); |
792 } | 858 } |
793 #endif | 859 #endif |
OLD | NEW |