Chromium Code Reviews| 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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // 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 |
| 569 // 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. |
| 570 // Then, after |TextInputState.type| for a view is changed to text, the test | 570 // Then, after |TextInputState.type| for a view is changed to text, another key |
| 571 // sends a set composition IPC to the active widget and waits until the widget | 571 // is pressed (a character) and then the test verifies that TextInputManager |
| 572 // updates its composition range. | 572 // receives the corresponding update on the change in selection bounds on the |
| 573 // browser side. | |
| 573 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 574 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| 574 TrackCompositionRangeForAllFrames) { | 575 TrackSelectionBoundsForAllFrames) { |
| 575 CreateIframePage("a(b,c(a,b),d)"); | 576 CreateIframePage("a(b,c(a,b),d)"); |
| 576 std::vector<content::RenderFrameHost*> frames{ | 577 std::vector<content::RenderFrameHost*> frames{ |
| 577 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), | 578 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), |
| 578 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), | 579 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), |
| 579 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; | 580 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; |
| 580 std::vector<content::RenderWidgetHostView*> views; | 581 std::vector<content::RenderWidgetHostView*> views; |
| 581 for (auto* frame : frames) | 582 for (auto* frame : frames) |
| 582 views.push_back(frame->GetView()); | 583 views.push_back(frame->GetView()); |
| 583 for (size_t i = 0; i < frames.size(); ++i) | 584 for (size_t i = 0; i < frames.size(); ++i) |
| 584 AddInputFieldToFrame(frames[i], "text", "text", true); | 585 AddInputFieldToFrame(frames[i], "text", "", true); |
| 585 | 586 |
| 586 content::WebContents* web_contents = active_contents(); | 587 content::WebContents* web_contents = active_contents(); |
| 587 | 588 |
| 588 auto send_tab_set_composition_wait_for_bounds_change = [&web_contents]( | 589 auto send_tab_insert_text_wait_for_bounds_change = [&web_contents]( |
| 589 content::RenderWidgetHostView* view) { | 590 content::RenderWidgetHostView* view) { |
| 590 ViewTextInputTypeObserver type_observer(web_contents, view, | 591 ViewTextInputTypeObserver type_observer(web_contents, view, |
| 591 ui::TEXT_INPUT_TYPE_TEXT); | 592 ui::TEXT_INPUT_TYPE_TEXT); |
| 592 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, | 593 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, |
| 593 ui::VKEY_TAB, false, false, false, false); | 594 ui::VKEY_TAB, false, false, false, false); |
| 594 type_observer.Wait(); | 595 type_observer.Wait(); |
| 595 | 596 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view); |
| 596 ViewCompositionRangeChangedObserver range_observer(web_contents, view); | 597 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), |
| 597 EXPECT_TRUE(content::RequestCompositionInfoFromActiveWidget(web_contents)); | 598 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); |
| 598 range_observer.Wait(); | 599 bounds_observer.Wait(); |
|
erikchen
2016/08/17 23:31:16
I know that this is the same test we're using on A
EhsanK
2016/08/22 14:48:28
That is a good question. I think we should have te
| |
| 599 }; | 600 }; |
| 600 | 601 |
| 601 for (auto* view : views) | 602 for (auto* view : views) |
| 602 send_tab_set_composition_wait_for_bounds_change(view); | 603 send_tab_insert_text_wait_for_bounds_change(view); |
| 603 } | 604 } |
| 604 | 605 |
| 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) | |
| 608 // This test creates a page with multiple child frames and adds an <input> to | 606 // This test creates a page with multiple child frames and adds an <input> to |
| 609 // each frame. Then, sequentially, each <input> is focused by sending a tab key. | 607 // each frame. Then, sequentially, each <input> is focused by sending a tab key. |
| 610 // Then, after |TextInputState.type| for a view is changed to text, another key | 608 // Then, after |TextInputState.type| for a view is changed to text, the test |
| 611 // is pressed (a character) and then the test verifies that TextInputManager | 609 // sends a set composition IPC to the active widget and waits until the widget |
| 612 // receives the corresponding update on the change in selection bounds on the | 610 // updates its composition range. |
| 613 // browser side. | |
| 614 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 611 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| 615 TrackSelectionBoundsForAllFrames) { | 612 TrackCompositionRangeForAllFrames) { |
| 616 CreateIframePage("a(b,c(a,b),d)"); | 613 CreateIframePage("a(b,c(a,b),d)"); |
| 617 std::vector<content::RenderFrameHost*> frames{ | 614 std::vector<content::RenderFrameHost*> frames{ |
| 618 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), | 615 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), |
| 619 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), | 616 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), |
| 620 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; | 617 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; |
| 621 std::vector<content::RenderWidgetHostView*> views; | 618 std::vector<content::RenderWidgetHostView*> views; |
| 622 for (auto* frame : frames) | 619 for (auto* frame : frames) |
| 623 views.push_back(frame->GetView()); | 620 views.push_back(frame->GetView()); |
| 624 for (size_t i = 0; i < frames.size(); ++i) | 621 for (size_t i = 0; i < frames.size(); ++i) |
| 625 AddInputFieldToFrame(frames[i], "text", "", true); | 622 AddInputFieldToFrame(frames[i], "text", "text", true); |
| 626 | 623 |
| 627 content::WebContents* web_contents = active_contents(); | 624 content::WebContents* web_contents = active_contents(); |
| 628 | 625 |
| 629 auto send_tab_insert_text_wait_for_bounds_change = [&web_contents]( | 626 auto send_tab_set_composition_wait_for_bounds_change = [&web_contents]( |
| 630 content::RenderWidgetHostView* view) { | 627 content::RenderWidgetHostView* view) { |
| 631 ViewTextInputTypeObserver type_observer(web_contents, view, | 628 ViewTextInputTypeObserver type_observer(web_contents, view, |
| 632 ui::TEXT_INPUT_TYPE_TEXT); | 629 ui::TEXT_INPUT_TYPE_TEXT); |
| 633 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, | 630 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, |
| 634 ui::VKEY_TAB, false, false, false, false); | 631 ui::VKEY_TAB, false, false, false, false); |
| 635 type_observer.Wait(); | 632 type_observer.Wait(); |
| 636 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view); | 633 |
| 637 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), | 634 ViewCompositionRangeChangedObserver range_observer(web_contents, view); |
| 638 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); | 635 EXPECT_TRUE(content::RequestCompositionInfoFromActiveWidget(web_contents)); |
| 639 bounds_observer.Wait(); | 636 range_observer.Wait(); |
| 640 }; | 637 }; |
| 641 | 638 |
| 642 for (auto* view : views) | 639 for (auto* view : views) |
| 643 send_tab_insert_text_wait_for_bounds_change(view); | 640 send_tab_set_composition_wait_for_bounds_change(view); |
| 644 } | 641 } |
| 645 | 642 |
| 643 // TODO(ekaramad): Enable the following tests on other platforms when the | |
| 644 // corresponding feature is implemented (http://crbug.com/578168). | |
| 645 #if defined(USE_AURA) | |
| 646 // 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 |
| 647 // 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. |
| 648 // 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 |
| 649 // 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 |
| 650 // 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 |
| 651 // 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{ |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 | 858 |
| 859 // Set |TextInputState.show_ime_if_needed|. Expect IME. | 859 // Set |TextInputState.show_ime_if_needed|. Expect IME. |
| 860 sender.SetShowImeIfNeeded(true); | 860 sender.SetShowImeIfNeeded(true); |
| 861 EXPECT_TRUE(send_and_check_show_ime()); | 861 EXPECT_TRUE(send_and_check_show_ime()); |
| 862 | 862 |
| 863 // 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. |
| 864 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); | 864 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); |
| 865 EXPECT_FALSE(send_and_check_show_ime()); | 865 EXPECT_FALSE(send_and_check_show_ime()); |
| 866 } | 866 } |
| 867 #endif // USE_AURA | 867 #endif // USE_AURA |
| OLD | NEW |