| 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 595 |
| 596 ViewCompositionRangeChangedObserver range_observer(web_contents, view); | 596 ViewCompositionRangeChangedObserver range_observer(web_contents, view); |
| 597 EXPECT_TRUE(content::RequestCompositionInfoFromActiveWidget(web_contents)); | 597 EXPECT_TRUE(content::RequestCompositionInfoFromActiveWidget(web_contents)); |
| 598 range_observer.Wait(); | 598 range_observer.Wait(); |
| 599 }; | 599 }; |
| 600 | 600 |
| 601 for (auto* view : views) | 601 for (auto* view : views) |
| 602 send_tab_set_composition_wait_for_bounds_change(view); | 602 send_tab_set_composition_wait_for_bounds_change(view); |
| 603 } | 603 } |
| 604 | 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) | |
| 608 // This test creates a page with multiple child frames and adds an <input> to | 605 // 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. | 606 // 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 | 607 // Then, after |TextInputState.type| for a view is changed to text, another key |
| 611 // is pressed (a character) and then the test verifies that TextInputManager | 608 // is pressed (a character) and then the test verifies that TextInputManager |
| 612 // receives the corresponding update on the change in selection bounds on the | 609 // receives the corresponding update on the change in selection bounds on the |
| 613 // browser side. | 610 // browser side. |
| 614 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 611 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| 615 TrackSelectionBoundsForAllFrames) { | 612 TrackSelectionBoundsForAllFrames) { |
| 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{ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 635 type_observer.Wait(); | 632 type_observer.Wait(); |
| 636 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view); | 633 ViewSelectionBoundsChangedObserver bounds_observer(web_contents, view); |
| 637 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), | 634 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), |
| 638 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); | 635 ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); |
| 639 bounds_observer.Wait(); | 636 bounds_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_insert_text_wait_for_bounds_change(view); |
| 644 } | 641 } |
| 645 #endif | |
| 646 | 642 |
| 647 // This test creates a page with multiple child frames and adds an <input> to | 643 // This test creates a page with multiple child frames and adds an <input> to |
| 648 // each frame. Then, sequentially, each <input> is focused by sending a tab key. | 644 // each frame. Then, sequentially, each <input> is focused by sending a tab key. |
| 649 // After focusing each input, a sequence of key presses (character 'E') are sent | 645 // After focusing each input, a sequence of key presses (character 'E') are sent |
| 650 // to the focused widget. The test then verifies that the selection length | 646 // to the focused widget. The test then verifies that the selection length |
| 651 // equals the length of the sequence of 'E's. | 647 // equals the length of the sequence of 'E's. |
| 652 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 648 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| 653 TrackTextSelectionForAllFrames) { | 649 TrackTextSelectionForAllFrames) { |
| 654 CreateIframePage("a(b,c(a,b),d)"); | 650 CreateIframePage("a(b,c(a,b),d)"); |
| 655 std::vector<content::RenderFrameHost*> frames{ | 651 std::vector<content::RenderFrameHost*> frames{ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 for (size_t i = 0; i < views.size(); ++i) { | 683 for (size_t i = 0; i < views.size(); ++i) { |
| 688 // First focus the <input>. | 684 // First focus the <input>. |
| 689 send_tab_and_wait_for_value(values[i]); | 685 send_tab_and_wait_for_value(values[i]); |
| 690 | 686 |
| 691 // Send a sequence of |count| 'E' keys and wait until the view receives a | 687 // Send a sequence of |count| 'E' keys and wait until the view receives a |
| 692 // selection change update for a text of the corresponding size, |count|. | 688 // selection change update for a text of the corresponding size, |count|. |
| 693 send_keys_select_all_wait_for_selection_change(views[i], count++); | 689 send_keys_select_all_wait_for_selection_change(views[i], count++); |
| 694 } | 690 } |
| 695 } | 691 } |
| 696 | 692 |
| 693 // TODO(ekaramad): Enable the following tests on other platforms when the |
| 694 // corresponding feature is implemented (http://crbug.com/578168). |
| 697 #if defined(USE_AURA) | 695 #if defined(USE_AURA) |
| 698 // The following test verifies that when the active widget changes value, it is | 696 // The following test verifies that when the active widget changes value, it is |
| 699 // always from nullptr to non-null or vice versa. | 697 // always from nullptr to non-null or vice versa. |
| 700 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 698 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| 701 ResetTextInputStateOnActiveWidgetChange) { | 699 ResetTextInputStateOnActiveWidgetChange) { |
| 702 CreateIframePage("a(b,c(a,b),d)"); | 700 CreateIframePage("a(b,c(a,b),d)"); |
| 703 std::vector<content::RenderFrameHost*> frames{ | 701 std::vector<content::RenderFrameHost*> frames{ |
| 704 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), | 702 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), |
| 705 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), | 703 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), |
| 706 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; | 704 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 | 854 |
| 857 // Set |TextInputState.show_ime_if_needed|. Expect IME. | 855 // Set |TextInputState.show_ime_if_needed|. Expect IME. |
| 858 sender.SetShowImeIfNeeded(true); | 856 sender.SetShowImeIfNeeded(true); |
| 859 EXPECT_TRUE(send_and_check_show_ime()); | 857 EXPECT_TRUE(send_and_check_show_ime()); |
| 860 | 858 |
| 861 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. | 859 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. |
| 862 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); | 860 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); |
| 863 EXPECT_FALSE(send_and_check_show_ime()); | 861 EXPECT_FALSE(send_and_check_show_ime()); |
| 864 } | 862 } |
| 865 #endif // USE_AURA | 863 #endif // USE_AURA |
| OLD | NEW |