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

Side by Side Diff: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc

Issue 2240553003: Track text selection on the browser side (Mac) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added #ifdef Created 4 years, 4 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 type_observer.Wait(); 635 type_observer.Wait();
636 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view); 636 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view);
637 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), 637 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'),
638 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); 638 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false);
639 bounds_observer.Wait(); 639 bounds_observer.Wait();
640 }; 640 };
641 641
642 for (auto* view : views) 642 for (auto* view : views)
643 send_tab_insert_text_wait_for_bounds_change(view); 643 send_tab_insert_text_wait_for_bounds_change(view);
644 } 644 }
645 #endif
645 646
646 // This test creates a page with multiple child frames and adds an <input> to 647 // This test creates a page with multiple child frames and adds an <input> to
647 // each frame. Then, sequentially, each <input> is focused by sending a tab key. 648 // each frame. Then, sequentially, each <input> is focused by sending a tab key.
648 // After focusing each input, a sequence of key presses (character 'E') are sent 649 // After focusing each input, a sequence of key presses (character 'E') are sent
649 // to the focused widget and then the whole text is selected using Ctrl+A. The 650 // to the focused widget. The test then verifies that the selection length
650 // test then verifies that the selection length equals the length of the 651 // equals the length of the sequence of 'E's.
651 // sequence of 'E's.
652 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, 652 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
653 TrackTextSelectionForAllFrames) { 653 TrackTextSelectionForAllFrames) {
654 CreateIframePage("a(b,c(a,b),d)"); 654 CreateIframePage("a(b,c(a,b),d)");
655 std::vector<content::RenderFrameHost*> frames{ 655 std::vector<content::RenderFrameHost*> frames{
656 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), 656 GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
657 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), 657 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}),
658 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; 658 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})};
659 std::vector<std::string> values{"main", "b", "c", "ca", "cb", "d"}; 659 std::vector<std::string> values{"main", "b", "c", "ca", "cb", "d"};
660 std::vector<content::RenderWidgetHostView*> views; 660 std::vector<content::RenderWidgetHostView*> views;
661 for (auto* frame : frames) 661 for (auto* frame : frames)
(...skipping 11 matching lines...) Expand all
673 }; 673 };
674 674
675 auto send_keys_select_all_wait_for_selection_change = [&web_contents]( 675 auto send_keys_select_all_wait_for_selection_change = [&web_contents](
676 content::RenderWidgetHostView* view, size_t count) { 676 content::RenderWidgetHostView* view, size_t count) {
677 ViewTextSelectionObserver observer(web_contents, view, count); 677 ViewTextSelectionObserver observer(web_contents, view, count);
678 for (size_t i = 0; i < count; ++i) { 678 for (size_t i = 0; i < count; ++i) {
679 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), 679 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'),
680 ui::DomCode::US_E, ui::VKEY_E, false, false, false, 680 ui::DomCode::US_E, ui::VKEY_E, false, false, false,
681 false); 681 false);
682 } 682 }
683 // Send Ctrl+A to select the whole text.
684 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('a'),
685 ui::DomCode::US_A, ui::VKEY_A, true, false, false, false);
686 observer.Wait(); 683 observer.Wait();
687 }; 684 };
688 685
689 size_t count = 2; 686 size_t count = 2;
690 for (size_t i = 0; i < views.size(); ++i) { 687 for (size_t i = 0; i < views.size(); ++i) {
691 // First focus the <input>. 688 // First focus the <input>.
692 send_tab_and_wait_for_value(values[i]); 689 send_tab_and_wait_for_value(values[i]);
693 690
694 // Send a sequence of |count| 'E' keys and wait until the view receives a 691 // Send a sequence of |count| 'E' keys and wait until the view receives a
695 // selection change update for a text of the corresponding size, |count|. 692 // selection change update for a text of the corresponding size, |count|.
696 send_keys_select_all_wait_for_selection_change(views[i], count++); 693 send_keys_select_all_wait_for_selection_change(views[i], count++);
697 } 694 }
698 } 695 }
699 696
697 #if defined(USE_AURA)
700 // The following test verifies that when the active widget changes value, it is 698 // The following test verifies that when the active widget changes value, it is
701 // always from nullptr to non-null or vice versa. 699 // always from nullptr to non-null or vice versa.
702 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, 700 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
703 ResetTextInputStateOnActiveWidgetChange) { 701 ResetTextInputStateOnActiveWidgetChange) {
704 CreateIframePage("a(b,c(a,b),d)"); 702 CreateIframePage("a(b,c(a,b),d)");
705 std::vector<content::RenderFrameHost*> frames{ 703 std::vector<content::RenderFrameHost*> frames{
706 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), 704 GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
707 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), 705 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}),
708 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; 706 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})};
709 std::vector<content::RenderWidgetHostView*> views; 707 std::vector<content::RenderWidgetHostView*> views;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 856
859 // Set |TextInputState.show_ime_if_needed|. Expect IME. 857 // Set |TextInputState.show_ime_if_needed|. Expect IME.
860 sender.SetShowImeIfNeeded(true); 858 sender.SetShowImeIfNeeded(true);
861 EXPECT_TRUE(send_and_check_show_ime()); 859 EXPECT_TRUE(send_and_check_show_ime());
862 860
863 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. 861 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME.
864 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); 862 sender.SetType(ui::TEXT_INPUT_TYPE_NONE);
865 EXPECT_FALSE(send_and_check_show_ime()); 863 EXPECT_FALSE(send_and_check_show_ime());
866 } 864 }
867 #endif // USE_AURA 865 #endif // USE_AURA
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698