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

Side by Side Diff: chrome/browser/apps/web_view_interactive_browsertest.cc

Issue 281833003: BrowserPluginHostTest: Rewrite 3 focus related tests and 1 visibility test to browser_tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase @tott, fix conflict Created 6 years, 7 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 "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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 ExtensionTestMessageListener move_listener2("move-captured", false); 495 ExtensionTestMessageListener move_listener2("move-captured", false);
496 SendMouseClick(ui_controls::RIGHT); 496 SendMouseClick(ui_controls::RIGHT);
497 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( 497 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(
498 gfx::Point(corner().x() + 51, corner().y() + 11))); 498 gfx::Point(corner().x() + 51, corner().y() + 11)));
499 ASSERT_TRUE(move_listener2.WaitUntilSatisfied()); 499 ASSERT_TRUE(move_listener2.WaitUntilSatisfied());
500 } 500 }
501 } 501 }
502 502
503 #endif // defined(OS_LINUX) && !defined(USE_AURA) 503 #endif // defined(OS_LINUX) && !defined(USE_AURA)
504 504
505 // Tests that if a <webview> is focused before navigation then the guest starts
506 // off focused.
507 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusBeforeNavigation) {
508 TestHelper("testFocusBeforeNavigation", "web_view/focus", NO_TEST_SERVER);
509 }
510
505 // Tests that setting focus on the <webview> sets focus on the guest. 511 // Tests that setting focus on the <webview> sets focus on the guest.
506 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusEvent) { 512 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusEvent) {
507 TestHelper("testFocusEvent", "web_view/focus", NO_TEST_SERVER); 513 TestHelper("testFocusEvent", "web_view/focus", NO_TEST_SERVER);
508 } 514 }
509 515
510 // Tests that setting focus on the <webview> sets focus on the guest. 516 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusTracksEmbedder) {
517 content::WebContents* embedder_web_contents = NULL;
518
519 scoped_ptr<ExtensionTestMessageListener> done_listener(
520 RunAppHelper("testFocusTracksEmbedder", "web_view/focus", NO_TEST_SERVER,
521 &embedder_web_contents));
522 done_listener->WaitUntilSatisfied();
523
524 ExtensionTestMessageListener post_test_listener("POST_TEST_PASSED", false);
525 post_test_listener.set_failure_message("POST_TEST_FAILED");
526 EXPECT_TRUE(content::ExecuteScript(
527 embedder_web_contents,
528 "window.runCommand('POST_testFocusTracksEmbedder');"));
529
530 // Blur the embedder.
531 embedder_web_contents->GetRenderViewHost()->Blur();
532 // Ensure that the guest is also blurred.
533 ASSERT_TRUE(post_test_listener.WaitUntilSatisfied());
534 }
535
536 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_AdvanceFocus) {
537 content::WebContents* embedder_web_contents = NULL;
538
539 {
540 scoped_ptr<ExtensionTestMessageListener> done_listener(
541 RunAppHelper("testAdvanceFocus", "web_view/focus", NO_TEST_SERVER,
542 &embedder_web_contents));
543 done_listener->WaitUntilSatisfied();
544 }
545
546 {
547 ExtensionTestMessageListener listener("button1-focused", false);
548 listener.set_failure_message("TEST_FAILED");
549 SimulateRWHMouseClick(embedder_web_contents->GetRenderViewHost(),
550 blink::WebMouseEvent::ButtonLeft, 200, 20);
551 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB,
552 false, false, false, false);
553 ASSERT_TRUE(listener.WaitUntilSatisfied());
554 }
555
556 {
557 // Wait for button1 to be focused again, this means we were asked to
558 // move the focus to the next focusable element.
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 <webview> will take keyboard focus but it will not focus an initial
563 // element. The initial element is dependent upon tab direction which blink
564 // does not propagate to the plugin.
565 // See http://crbug.com/147644.
566 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB,
567 false, false, false, false);
568 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB,
569 false, false, false, false);
570 content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB,
571 false, false, false, false);
572 ASSERT_TRUE(listener.WaitUntilSatisfied());
573 }
574 }
575
576 // Tests that blurring <webview> also blurs the guest.
511 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_BlurEvent) { 577 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_BlurEvent) {
512 TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER); 578 TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER);
513 } 579 }
514 580
515 // Tests that guests receive edit commands and respond appropriately. 581 // Tests that guests receive edit commands and respond appropriately.
516 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommands) { 582 IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, EditCommands) {
517 ExtensionTestMessageListener guest_connected_listener("connected", false); 583 ExtensionTestMessageListener guest_connected_listener("connected", false);
518 LoadAndLaunchPlatformApp("web_view/edit_commands"); 584 LoadAndLaunchPlatformApp("web_view/edit_commands");
519 // Wait until the guest process reports that it has established a message 585 // Wait until the guest process reports that it has established a message
520 // channel with the app. 586 // channel with the app.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 853
788 // Now verify that the selection text propagates properly to RWHV. 854 // Now verify that the selection text propagates properly to RWHV.
789 content::RenderWidgetHostView* guest_rwhv = 855 content::RenderWidgetHostView* guest_rwhv =
790 guest_web_contents()->GetRenderWidgetHostView(); 856 guest_web_contents()->GetRenderWidgetHostView();
791 ASSERT_TRUE(guest_rwhv); 857 ASSERT_TRUE(guest_rwhv);
792 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); 858 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText());
793 ASSERT_TRUE(selected_text.size() >= 10u); 859 ASSERT_TRUE(selected_text.size() >= 10u);
794 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); 860 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10));
795 } 861 }
796 #endif 862 #endif
OLDNEW
« no previous file with comments | « chrome/browser/apps/web_view_browsertest.cc ('k') | chrome/test/data/extensions/platform_apps/web_view/focus/embedder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698