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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 expected_selection_length_(expected_selection_length) { | 248 expected_selection_length_(expected_selection_length) { |
| 249 tester()->SetOnTextSelectionChangedCallback(base::Bind( | 249 tester()->SetOnTextSelectionChangedCallback(base::Bind( |
| 250 &ViewTextSelectionObserver::VerifyChange, base::Unretained(this))); | 250 &ViewTextSelectionObserver::VerifyChange, base::Unretained(this))); |
| 251 } | 251 } |
| 252 | 252 |
| 253 private: | 253 private: |
| 254 void VerifyChange() { | 254 void VerifyChange() { |
| 255 if (expected_view_ == tester()->GetUpdatedView()) { | 255 if (expected_view_ == tester()->GetUpdatedView()) { |
| 256 size_t selection_length; | 256 size_t selection_length; |
| 257 if (tester()->GetCurrentTextSelectionLength(&selection_length) && | 257 if (tester()->GetCurrentTextSelectionLength(&selection_length) && |
| 258 expected_selection_length_ == selection_length) | 258 expected_selection_length_ == selection_length) { |
| 259 OnSuccess(); | 259 OnSuccess(); |
| 260 } | |
|
Charlie Reis
2016/08/08 17:12:01
nit: No change needed here.
EhsanK
2016/08/09 16:42:29
Acknowledged.
| |
| 260 } | 261 } |
| 261 } | 262 } |
| 262 | 263 |
| 263 const content::RenderWidgetHostView* const expected_view_; | 264 const content::RenderWidgetHostView* const expected_view_; |
| 264 const size_t expected_selection_length_; | 265 const size_t expected_selection_length_; |
| 265 | 266 |
| 266 DISALLOW_COPY_AND_ASSIGN(ViewTextSelectionObserver); | 267 DISALLOW_COPY_AND_ASSIGN(ViewTextSelectionObserver); |
| 267 }; | 268 }; |
| 268 | 269 |
| 269 // This class monitors all the changes in TextInputState and keeps a record of | 270 // This class monitors all the changes in TextInputState and keeps a record of |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 send_tab_insert_text_wait_for_bounds_change(view); | 608 send_tab_insert_text_wait_for_bounds_change(view); |
| 608 } | 609 } |
| 609 | 610 |
| 610 // This test creates a page with multiple child frames and adds an <input> to | 611 // 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. | 612 // 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 | 613 // 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 | 614 // sends a set composition IPC to the active widget and waits until the widget |
| 614 // updates its composition range. | 615 // updates its composition range. |
| 615 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, | 616 IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| 616 TrackCompositionRangeForAllFrames) { | 617 TrackCompositionRangeForAllFrames) { |
| 617 // TODO(ekaramd): After IME methods are implemented for WebFrameWidgetImpl, | 618 CreateIframePage("a(b,c(a,b),d)"); |
| 618 // change the page so that it contains child frames as well | 619 std::vector<content::RenderFrameHost*> frames{ |
| 619 // (crbug.com/626746). | 620 GetFrame(IndexVector{}), GetFrame(IndexVector{0}), |
| 620 CreateIframePage("a()"); | 621 GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), |
| 621 std::vector<content::RenderFrameHost*> frames{GetFrame(IndexVector{})}; | 622 GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; |
| 622 std::vector<content::RenderWidgetHostView*> views; | 623 std::vector<content::RenderWidgetHostView*> views; |
| 623 for (auto* frame : frames) | 624 for (auto* frame : frames) |
| 624 views.push_back(frame->GetView()); | 625 views.push_back(frame->GetView()); |
| 625 for (size_t i = 0; i < frames.size(); ++i) | 626 for (size_t i = 0; i < frames.size(); ++i) |
| 626 AddInputFieldToFrame(frames[i], "text", "", true); | 627 AddInputFieldToFrame(frames[i], "text", "text", true); |
| 627 | 628 |
| 628 content::WebContents* web_contents = active_contents(); | 629 content::WebContents* web_contents = active_contents(); |
| 629 | 630 |
| 630 auto send_tab_set_composition_wait_for_bounds_change = | 631 auto send_tab_set_composition_wait_for_bounds_change = [&web_contents]( |
| 631 [&web_contents](content::RenderWidgetHostView* view) { | 632 content::RenderWidgetHostView* view) { |
| 632 ViewTextInputTypeObserver type_observer(web_contents, view, | 633 ViewTextInputTypeObserver type_observer(web_contents, view, |
| 633 ui::TEXT_INPUT_TYPE_TEXT); | 634 ui::TEXT_INPUT_TYPE_TEXT); |
| 634 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, | 635 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, |
| 635 ui::VKEY_TAB, false, false, false, false); | 636 ui::VKEY_TAB, false, false, false, false); |
| 636 type_observer.Wait(); | 637 type_observer.Wait(); |
| 637 ViewCompositionRangeChangedObserver range_observer(web_contents, view); | 638 ViewCompositionRangeChangedObserver range_observer(web_contents, view); |
| 638 content::SetCompositionForRenderWidgetHost( | 639 EXPECT_TRUE(content::RequestCompositionInfoFromActiveWidget(web_contents)); |
| 639 view->GetRenderWidgetHost(), base::ASCIIToUTF16("text"), | 640 range_observer.Wait(); |
| 640 {ui::CompositionUnderline()}, gfx::Range::InvalidRange(), 0, 0); | 641 }; |
| 641 range_observer.Wait(); | |
| 642 }; | |
| 643 | 642 |
| 644 for (auto* view : views) | 643 for (auto* view : views) |
| 645 send_tab_set_composition_wait_for_bounds_change(view); | 644 send_tab_set_composition_wait_for_bounds_change(view); |
| 646 } | 645 } |
| 647 | 646 |
| 648 // 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 |
| 649 // 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. |
| 650 // After focusing each input, the whole text is automatically selected and a | 649 // After focusing each input, the whole text is automatically selected and a |
| 651 // ViewHostMsg_SelectionChanged IPC sent back to the browser. This test verifies | 650 // ViewHostMsg_SelectionChanged IPC sent back to the browser. This test verifies |
| 652 // that the browser tracks the text selection from all frames. | 651 // that the browser tracks the text selection from all frames. |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 841 | 840 |
| 842 // Set |TextInputState.show_ime_if_needed|. Expect IME. | 841 // Set |TextInputState.show_ime_if_needed|. Expect IME. |
| 843 sender.SetShowImeIfNeeded(true); | 842 sender.SetShowImeIfNeeded(true); |
| 844 EXPECT_TRUE(send_and_check_show_ime()); | 843 EXPECT_TRUE(send_and_check_show_ime()); |
| 845 | 844 |
| 846 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. | 845 // Set |TextInputState.type| to ui::TEXT_INPUT_TYPE_NONE. Expect no IME. |
| 847 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); | 846 sender.SetType(ui::TEXT_INPUT_TYPE_NONE); |
| 848 EXPECT_FALSE(send_and_check_show_ime()); | 847 EXPECT_FALSE(send_and_check_show_ime()); |
| 849 } | 848 } |
| 850 #endif // USE_AURA | 849 #endif // USE_AURA |
| OLD | NEW |