Chromium Code Reviews| Index: chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc |
| diff --git a/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc b/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc |
| index 19e18971b4fcebfd9909c8c31ea2d642a54721b8..302b7dd0ed74b061bd60c42019d930b3ceafdccf 100644 |
| --- a/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc |
| +++ b/chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc |
| @@ -166,7 +166,7 @@ class ViewTextInputTypeObserver : public TextInputManagerObserverBase { |
| } |
| private: |
| - void VerifyType(content::TextInputManagerTester* tester) { |
| + void VerifyType(content::TextInputManagerTester* text_input_manager_tester) { |
| ui::TextInputType type; |
| if (!content::GetTextInputTypeForView(web_contents_, view_, &type)) |
| return; |
| @@ -181,6 +181,33 @@ class ViewTextInputTypeObserver : public TextInputManagerObserverBase { |
| DISALLOW_COPY_AND_ASSIGN(ViewTextInputTypeObserver); |
| }; |
| +// This class observers the |expected_view| for the first change in its |
|
kenrb
2016/06/28 19:15:23
nit: /s/observers/observes
EhsanK
2016/06/29 17:09:58
Done.
|
| +// selection bounds. |
| +class ViewsSelectionBoundsChangedObserver |
| + : public TextInputManagerObserverBase { |
| + public: |
| + explicit ViewsSelectionBoundsChangedObserver( |
| + content::WebContents* web_contents, |
| + content::RenderWidgetHostView* expected_view) |
| + : TextInputManagerObserverBase(web_contents), |
| + expected_view_(expected_view) { |
| + tester()->SetOnSelectionBoundsChangedCallback( |
| + base::Bind(&ViewsSelectionBoundsChangedObserver::VerifyChange, |
| + base::Unretained(this))); |
| + } |
| + |
| + private: |
| + void VerifyChange( |
| + content::TextInputManagerTester* text_input_manager_tester) { |
| + if (expected_view_ == tester()->GetUpdatedView()) |
| + OnSuccess(); |
| + } |
| + |
| + const content::RenderWidgetHostView* const expected_view_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ViewsSelectionBoundsChangedObserver); |
| +}; |
| + |
| } // namespace |
| // Main class for all TextInputState and IME related tests. |
| @@ -446,6 +473,44 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| reset_state_observer.Wait(); |
| } |
| +// This test creates a page with multiple child frames and adds an <input> to |
| +// each frame. Then, sequentially, each <input> is focused by sending a tab key. |
| +// Then, after |TextInputState.type| for a view is changed to text, another key |
| +// is pressed (a character) and then the test verifies that TextInputManager |
| +// receives the corresponding update on the change in selection bounds on the |
| +// browser side. |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest, |
| + TrackSelectionBoundsForChildFrames) { |
| + CreateIframePage("a(b,c(a,b),d)"); |
| + std::vector<content::RenderFrameHost*> frames{ |
| + GetFrame(IndexVector{}), GetFrame(IndexVector{0}), |
| + GetFrame(IndexVector{1}), GetFrame(IndexVector{1, 0}), |
| + GetFrame(IndexVector{1, 1}), GetFrame(IndexVector{2})}; |
| + std::vector<content::RenderWidgetHostView*> views; |
| + for (auto frame : frames) |
| + views.push_back(frame->GetView()); |
| + for (size_t i = 0; i < frames.size(); ++i) |
| + AddInputFieldToFrame(frames[i], "text", "", true); |
| + |
| + content::WebContents* web_contents = active_contents(); |
| + |
| + auto send_tab_insert_text_wait_for_bounds_change = [&web_contents]( |
| + content::RenderWidgetHostView* view) { |
| + ViewTextInputTypeObserver type_observer(web_contents, view, |
| + ui::TEXT_INPUT_TYPE_TEXT); |
| + SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, |
| + ui::VKEY_TAB, false, false, false, false); |
| + type_observer.Wait(); |
| + ViewsSelectionBoundsChangedObserver bounds_observer(web_contents, view); |
| + SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('E'), |
| + ui::DomCode::US_E, ui::VKEY_E, false, false, false, false); |
| + bounds_observer.Wait(); |
| + }; |
| + |
| + for (auto view : views) |
| + send_tab_insert_text_wait_for_bounds_change(view); |
| +} |
| + |
| // TODO(ekaramad): The following tests are specifically written for Aura and are |
| // based on InputMethodObserver. Write similar tests for Mac/Android/Mus |
| // (crbug.com/602723). |