OLD | NEW |
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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 // receives the corresponding update on the change in selection bounds on the | 576 // receives the corresponding update on the change in selection bounds on the |
577 // browser side. | 577 // browser side. |
578 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 578 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
579 TrackSelectionBoundsForAllFrames) { | 579 TrackSelectionBoundsForAllFrames) { |
580 CreateIframePage("a(b,c(a,b),d)"); | 580 CreateIframePage("a(b,c(a,b),d)"); |
581 std::vector<content::RenderFrameHost*> frames{ | 581 std::vector<content::RenderFrameHost*> frames{ |
582 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), | 582 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), |
583 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), | 583 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), |
584 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; | 584 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; |
585 std::vector<content::RenderWidgetHostView*> views; | 585 std::vector<content::RenderWidgetHostView*> views; |
586 for (auto frame : frames) | 586 for (auto* frame : frames) |
587 views.push_back(frame->GetView()); | 587 views.push_back(frame->GetView()); |
588 for (size_t i = 0; i < frames.size(); ++i) | 588 for (size_t i = 0; i < frames.size(); ++i) |
589 AddInputFieldToFrame(frames[i], "text", "", true); | 589 AddInputFieldToFrame(frames[i], "text", "", true); |
590 | 590 |
591 content::WebContents* web_contents = active_contents(); | 591 content::WebContents* web_contents = active_contents(); |
592 | 592 |
593 auto send_tab_insert_text_wait_for_bounds_change = [&web_contents]( | 593 auto send_tab_insert_text_wait_for_bounds_change = [&web_contents]( |
594 content::RenderWidgetHostView* view) { | 594 content::RenderWidgetHostView* view) { |
595 ViewTextInputTypeObserver type_observer(web_contents, view, | 595 ViewTextInputTypeObserver type_observer(web_contents, view, |
596 ui::TEXT_INPUT_TYPE_TEXT); | 596 ui::TEXT_INPUT_TYPE_TEXT); |
597 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, | 597 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, |
598 ui::VKEY_TAB, false, false, false, false); | 598 ui::VKEY_TAB, false, false, false, false); |
599 type_observer.Wait(); | 599 type_observer.Wait(); |
600 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view); | 600 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view); |
601 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), | 601 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), |
602 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); | 602 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); |
603 bounds_observer.Wait(); | 603 bounds_observer.Wait(); |
604 }; | 604 }; |
605 | 605 |
606 for (auto view : views) | 606 for (auto* view : views) |
607 send_tab_insert_text_wait_for_bounds_change(view); | 607 send_tab_insert_text_wait_for_bounds_change(view); |
608 } | 608 } |
609 | 609 |
610 // This test creates a page with multiple child frames and adds an <input> to | 610 // This test creates a page with multiple child frames and adds an <input> to |
611 // each frame. Then, sequentially, each <input> is focused by sending a tab key. | 611 // each frame. Then, sequentially, each <input> is focused by sending a tab key. |
612 // Then, after |TextInputState.type| for a view is changed to text, the test | 612 // Then, after |TextInputState.type| for a view is changed to text, the test |
613 // sends a set composition IPC to the active widget and waits until the widget | 613 // sends a set composition IPC to the active widget and waits until the widget |
614 // updates its composition range. | 614 // updates its composition range. |
615 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 615 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
616 TrackCompositionRangeForAllFrames) { | 616 TrackCompositionRangeForAllFrames) { |
617 // TODO(ekaramd): After IME methods are implemented for WebFrameWidgetImpl, | 617 // TODO(ekaramd): After IME methods are implemented for WebFrameWidgetImpl, |
618 // change the page so that it contains child frames as well | 618 // change the page so that it contains child frames as well |
619 // (crbug.com/626746). | 619 // (crbug.com/626746). |
620 CreateIframePage("a()"); | 620 CreateIframePage("a()"); |
621 std::vector<content::RenderFrameHost*> frames{GetFrame(IndexVector{})}; | 621 std::vector<content::RenderFrameHost*> frames{GetFrame(IndexVector{})}; |
622 std::vector<content::RenderWidgetHostView*> views; | 622 std::vector<content::RenderWidgetHostView*> views; |
623 for (auto frame : frames) | 623 for (auto* frame : frames) |
624 views.push_back(frame->GetView()); | 624 views.push_back(frame->GetView()); |
625 for (size_t i = 0; i < frames.size(); ++i) | 625 for (size_t i = 0; i < frames.size(); ++i) |
626 AddInputFieldToFrame(frames[i], "text", "", true); | 626 AddInputFieldToFrame(frames[i], "text", "", true); |
627 | 627 |
628 content::WebContents* web_contents = active_contents(); | 628 content::WebContents* web_contents = active_contents(); |
629 | 629 |
630 auto send_tab_set_composition_wait_for_bounds_change = | 630 auto send_tab_set_composition_wait_for_bounds_change = |
631 [&web_contents](content::RenderWidgetHostView* view) { | 631 [&web_contents](content::RenderWidgetHostView* view) { |
632 ViewTextInputTypeObserver type_observer(web_contents, view, | 632 ViewTextInputTypeObserver type_observer(web_contents, view, |
633 ui::TEXT_INPUT_TYPE_TEXT); | 633 ui::TEXT_INPUT_TYPE_TEXT); |
634 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, | 634 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, |
635 ui::VKEY_TAB, false, false, false, false); | 635 ui::VKEY_TAB, false, false, false, false); |
636 type_observer.Wait(); | 636 type_observer.Wait(); |
637 ViewCompositionRangeChangedObserver range_observer(web_contents, view); | 637 ViewCompositionRangeChangedObserver range_observer(web_contents, view); |
638 content::SetCompositionForRenderWidgetHost( | 638 content::SetCompositionForRenderWidgetHost( |
639 view->GetRenderWidgetHost(), base::ASCIIToUTF16("text"), | 639 view->GetRenderWidgetHost(), base::ASCIIToUTF16("text"), |
640 {ui::CompositionUnderline()}, gfx::Range::InvalidRange(), 0, 0); | 640 {ui::CompositionUnderline()}, gfx::Range::InvalidRange(), 0, 0); |
641 range_observer.Wait(); | 641 range_observer.Wait(); |
642 }; | 642 }; |
643 | 643 |
644 for (auto view : views) | 644 for (auto* view : views) |
645 send_tab_set_composition_wait_for_bounds_change(view); | 645 send_tab_set_composition_wait_for_bounds_change(view); |
646 } | 646 } |
647 | 647 |
648 // This test creates a page with multiple child frames and adds an <input> to | 648 // This test creates a page with multiple child frames and adds an <input> to |
649 // each frame. Then, sequentially, each <input> is focused by sending a tab key. | 649 // each frame. Then, sequentially, each <input> is focused by sending a tab key. |
650 // After focusing each input, the whole text is automatically selected and a | 650 // After focusing each input, the whole text is automatically selected and a |
651 // ViewHostMsg_SelectionChanged IPC sent back to the browser. This test verifies | 651 // ViewHostMsg_SelectionChanged IPC sent back to the browser. This test verifies |
652 // that the browser tracks the text selection from all frames. | 652 // that the browser tracks the text selection from all frames. |
653 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 653 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
654 TrackTextSelectionForAllFrames) { | 654 TrackTextSelectionForAllFrames) { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 | 841 |
842 // Set |TextInputState.show_ime_if_needed|. Expect IME. | 842 // Set |TextInputState.show_ime_if_needed|. Expect IME. |
843 sender.SetShowImeIfNeeded(true); | 843 sender.SetShowImeIfNeeded(true); |
844 EXPECT_TRUE(send_and_check_show_ime()); | 844 EXPECT_TRUE(send_and_check_show_ime()); |
845 | 845 |
846 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. | 846 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. |
847 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); | 847 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); |
848 EXPECT_FALSE(send_and_check_show_ime()); | 848 EXPECT_FALSE(send_and_check_show_ime()); |
849 } | 849 } |
850 #endif // USE_AURA | 850 #endif // USE_AURA |
OLD | NEW |