Chromium Code Reviews| Index: content/public/test/text_input_test_utils.cc |
| diff --git a/content/public/test/text_input_test_utils.cc b/content/public/test/text_input_test_utils.cc |
| index 594c4bedf0864aeaa4050407982367b4d48c08ef..eecb11e8360ddf0ffbe441b97cea06fd94804466 100644 |
| --- a/content/public/test/text_input_test_utils.cc |
| +++ b/content/public/test/text_input_test_utils.cc |
| @@ -18,12 +18,14 @@ |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_observer.h" |
| #include "content/public/test/test_utils.h" |
| +#include "ui/base/ime/composition_text.h" |
| #include "ui/base/ime/input_method.h" |
| #include "ui/base/ime/input_method_observer.h" |
| namespace ui { |
| + |
|
Charlie Reis
2016/07/11 23:56:19
nit: No blank line needed.
EhsanK
2016/07/12 18:31:14
Acknowledged.
|
| class TextInputClient; |
| -} |
| +} // namespace ui |
|
Charlie Reis
2016/07/11 23:56:19
nit: No close comment.
EhsanK
2016/07/12 18:31:14
Acknowledged.
|
| namespace content { |
| @@ -58,6 +60,11 @@ class TextInputManagerTester::InternalObserver |
| on_selection_bounds_changed_callback_ = callback; |
| } |
| + void set_on_ime_composition_range_changed_callback( |
| + const base::Closure& callback) { |
| + on_ime_composition_range_changed_callback_ = callback; |
| + } |
| + |
| const RenderWidgetHostView* GetUpdatedView() const { return updated_view_; } |
| bool text_input_state_changed() const { return text_input_state_changed_; } |
| @@ -84,6 +91,14 @@ class TextInputManagerTester::InternalObserver |
| on_selection_bounds_changed_callback_.Run(); |
| } |
| + void OnImeCompositionRangeChanged( |
| + TextInputManager* text_input_manager, |
| + RenderWidgetHostViewBase* updated_view) override { |
| + updated_view_ = updated_view; |
| + if (!on_ime_composition_range_changed_callback_.is_null()) |
| + on_ime_composition_range_changed_callback_.Run(); |
| + } |
| + |
| // WebContentsObserver implementation. |
| void WebContentsDestroyed() override { text_input_manager_ = nullptr; } |
| @@ -93,6 +108,7 @@ class TextInputManagerTester::InternalObserver |
| bool text_input_state_changed_; |
| base::Closure update_text_input_state_callback_; |
| base::Closure on_selection_bounds_changed_callback_; |
| + base::Closure on_ime_composition_range_changed_callback_; |
| DISALLOW_COPY_AND_ASSIGN(InternalObserver); |
| }; |
| @@ -216,6 +232,20 @@ bool GetTextInputTypeForView(WebContents* web_contents, |
| return true; |
| } |
| +void SetCompositionTextForFocusedTextInputClient( |
| + WebContents* web_contents, |
| + const ui::CompositionText& composition) { |
| +#if defined(USE_AURA) |
| + // We need the tab's view. |
|
Charlie Reis
2016/07/11 23:56:19
Please elaborate why this one needs to care about
EhsanK
2016/07/12 18:31:14
I wanted to make sure the cast to RenderWidgetHost
|
| + WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents); |
| + while (contents->GetOuterWebContents()) |
| + contents = contents->GetOuterWebContents(); |
| + static_cast<RenderWidgetHostViewAura*>(contents->GetRenderWidgetHostView()) |
| + ->SetCompositionText(composition); |
| + return; |
| +#endif |
| +} |
| + |
| size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents) { |
| std::unordered_set<RenderWidgetHostView*> views; |
| TextInputManager* manager = |
| @@ -244,6 +274,11 @@ void TextInputManagerTester::SetOnSelectionBoundsChangedCallback( |
| observer_->set_on_selection_bounds_changed_callback(callback); |
| } |
| +void TextInputManagerTester::SetOnImeCompositionRangeChangedCallback( |
| + const base::Closure& callback) { |
| + observer_->set_on_ime_composition_range_changed_callback(callback); |
| +} |
| + |
| bool TextInputManagerTester::GetTextInputType(ui::TextInputType* type) { |
| DCHECK(observer_->text_input_manager()); |
| const TextInputState* state = |