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

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

Issue 2235283003: Track composition range and character bounds on the browser side (Mac) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased to fix some crashing tests 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB, 558 SimulateKeyPress(active_contents(), ui::DomKey::TAB, ui::DomCode::TAB,
559 ui::VKEY_TAB, false, false, false, false); 559 ui::VKEY_TAB, false, false, false, false);
560 set_state_observer.Wait(); 560 set_state_observer.Wait();
561 561
562 TextInputManagerTypeObserver reset_state_observer(active_contents(), 562 TextInputManagerTypeObserver reset_state_observer(active_contents(),
563 ui::TEXT_INPUT_TYPE_NONE); 563 ui::TEXT_INPUT_TYPE_NONE);
564 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 564 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
565 reset_state_observer.Wait(); 565 reset_state_observer.Wait();
566 } 566 }
567 567
568 // TODO(ekaramad): Enable the following tests on other platforms when the
569 // corresponding feature is implemented (http://crbug.com/578168).
570 #if defined(USE_AURA)
571 // This test creates a page with multiple child frames and adds an <input> to 568 // This test creates a page with multiple child frames and adds an <input> to
572 // each frame. Then, sequentially, each <input> is focused by sending a tab key. 569 // each frame. Then, sequentially, each <input> is focused by sending a tab key.
573 // Then, after |TextInputState.type| for a view is changed to text, another key 570 // Then, after |TextInputState.type| for a view is changed to text, the test
574 // is pressed (a character) and then the test verifies that TextInputManager 571 // sends a set composition IPC to the active widget and waits until the widget
575 // receives the corresponding update on the change in selection bounds on the 572 // updates its composition range.
576 // browser side.
577 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, 573 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
578 TrackSelectionBoundsForAllFrames) { 574 TrackCompositionRangeForAllFrames) {
579 CreateIframePage("a(b,c(a,b),d)"); 575 CreateIframePage("a(b,c(a,b),d)");
580 std::vector<content::RenderFrameHost*> frames{ 576 std::vector<content::RenderFrameHost*> frames{
581 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), 577 GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
582 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), 578 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}),
583 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; 579 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})};
584 std::vector<content::RenderWidgetHostView*> views; 580 std::vector<content::RenderWidgetHostView*> views;
585 for (auto* frame : frames) 581 for (auto* frame : frames)
586 views.push_back(frame->GetView()); 582 views.push_back(frame->GetView());
587 for (size_t i = 0; i < frames.size(); ++i) 583 for (size_t i = 0; i < frames.size(); ++i)
588 AddInputFieldToFrame(frames[i], "text", "", true); 584 AddInputFieldToFrame(frames[i], "text", "text", true);
589 585
590 content::WebContents* web_contents = active_contents(); 586 content::WebContents* web_contents = active_contents();
591 587
592 auto send_tab_insert_text_wait_for_bounds_change = [&web_contents]( 588 auto send_tab_set_composition_wait_for_bounds_change = [&web_contents](
593 content::RenderWidgetHostView* view) { 589 content::RenderWidgetHostView* view) {
594 ViewTextInputTypeObserver type_observer(web_contents, view, 590 ViewTextInputTypeObserver type_observer(web_contents, view,
595 ui::TEXT_INPUT_TYPE_TEXT); 591 ui::TEXT_INPUT_TYPE_TEXT);
596 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, 592 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB,
597 ui::VKEY_TAB, false, false, false, false); 593 ui::VKEY_TAB, false, false, false, false);
598 type_observer.Wait(); 594 type_observer.Wait();
599 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view); 595
600 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), 596 ViewCompositionRangeChangedObserver range_observer(web_contents, view);
601 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); 597 EXPECT_TRUE(content::RequestCompositionInfoFromActiveWidget(web_contents));
602 bounds_observer.Wait(); 598 range_observer.Wait();
603 }; 599 };
604 600
605 for (auto* view : views) 601 for (auto* view : views)
606 send_tab_insert_text_wait_for_bounds_change(view); 602 send_tab_set_composition_wait_for_bounds_change(view);
607 } 603 }
608 604
605 // TODO(ekaramad): Enable the following tests on other platforms when the
606 // corresponding feature is implemented (http://crbug.com/578168).
607 #if defined(USE_AURA)
609 // This test creates a page with multiple child frames and adds an <input> to 608 // This test creates a page with multiple child frames and adds an <input> to
610 // each frame. Then, sequentially, each <input> is focused by sending a tab key. 609 // each frame. Then, sequentially, each <input> is focused by sending a tab key.
611 // Then, after |TextInputState.type| for a view is changed to text, the test 610 // Then, after |TextInputState.type| for a view is changed to text, another key
612 // sends a set composition IPC to the active widget and waits until the widget 611 // is pressed (a character) and then the test verifies that TextInputManager
613 // updates its composition range. 612 // receives the corresponding update on the change in selection bounds on the
613 // browser side.
614 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, 614 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
615 TrackCompositionRangeForAllFrames) { 615 TrackSelectionBoundsForAllFrames) {
616 CreateIframePage("a(b,c(a,b),d)"); 616 CreateIframePage("a(b,c(a,b),d)");
617 std::vector<content::RenderFrameHost*> frames{ 617 std::vector<content::RenderFrameHost*> frames{
618 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), 618 GetFrame(IndexVector{}), GetFrame(IndexVector{0}),
619 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), 619 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}),
620 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; 620 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})};
621 std::vector<content::RenderWidgetHostView*> views; 621 std::vector<content::RenderWidgetHostView*> views;
622 for (auto* frame : frames) 622 for (auto* frame : frames)
623 views.push_back(frame->GetView()); 623 views.push_back(frame->GetView());
624 for (size_t i = 0; i < frames.size(); ++i) 624 for (size_t i = 0; i < frames.size(); ++i)
625 AddInputFieldToFrame(frames[i], "text", "text", true); 625 AddInputFieldToFrame(frames[i], "text", "", true);
626 626
627 content::WebContents* web_contents = active_contents(); 627 content::WebContents* web_contents = active_contents();
628 628
629 auto send_tab_set_composition_wait_for_bounds_change = [&web_contents]( 629 auto send_tab_insert_text_wait_for_bounds_change = [&web_contents](
630 content::RenderWidgetHostView* view) { 630 content::RenderWidgetHostView* view) {
631 ViewTextInputTypeObserver type_observer(web_contents, view, 631 ViewTextInputTypeObserver type_observer(web_contents, view,
632 ui::TEXT_INPUT_TYPE_TEXT); 632 ui::TEXT_INPUT_TYPE_TEXT);
633 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, 633 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB,
634 ui::VKEY_TAB, false, false, false, false); 634 ui::VKEY_TAB, false, false, false, false);
635 type_observer.Wait(); 635 type_observer.Wait();
636 ViewCompositionRangeChangedObserver range_observer(web_contents, view); 636 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view);
637 EXPECT_TRUE(content::RequestCompositionInfoFromActiveWidget(web_contents)); 637 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'),
638 range_observer.Wait(); 638 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false);
639 bounds_observer.Wait();
639 }; 640 };
640 641
641 for (auto* view : views) 642 for (auto* view : views)
642 send_tab_set_composition_wait_for_bounds_change(view); 643 send_tab_insert_text_wait_for_bounds_change(view);
643 } 644 }
644 645
645 // This test creates a page with multiple child frames and adds an <input> to 646 // This test creates a page with multiple child frames and adds an <input> to
646 // each frame. Then, sequentially, each <input> is focused by sending a tab key. 647 // each frame. Then, sequentially, each <input> is focused by sending a tab key.
647 // After focusing each input, a sequence of key presses (character 'E') are sent 648 // After focusing each input, a sequence of key presses (character 'E') are sent
648 // to the focused widget and then the whole text is selected using Ctrl+A. The 649 // to the focused widget and then the whole text is selected using Ctrl+A. The
649 // test then verifies that the selection length equals the length of the 650 // test then verifies that the selection length equals the length of the
650 // sequence of 'E's. 651 // sequence of 'E's.
651 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, 652 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
652 TrackTextSelectionForAllFrames) { 653 TrackTextSelectionForAllFrames) {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 858
858 // Set |TextInputState.show_ime_if_needed|. Expect IME. 859 // Set |TextInputState.show_ime_if_needed|. Expect IME.
859 sender.SetShowImeIfNeeded(true); 860 sender.SetShowImeIfNeeded(true);
860 EXPECT_TRUE(send_and_check_show_ime()); 861 EXPECT_TRUE(send_and_check_show_ime());
861 862
862 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. 863 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME.
863 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); 864 sender.SetType(ui::TEXT_INPUT_TYPE_NONE);
864 EXPECT_FALSE(send_and_check_show_ime()); 865 EXPECT_FALSE(send_and_check_show_ime());
865 } 866 }
866 #endif // USE_AURA 867 #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