| 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 cbed2345122ed555231647ae60adcfa7fd1260e6..7daaa1dd91b91b6149ffc7c7fe962009e2ca2eee 100644
|
| --- a/content/public/test/text_input_test_utils.cc
|
| +++ b/content/public/test/text_input_test_utils.cc
|
| @@ -71,6 +71,10 @@ class TextInputManagerTester::InternalObserver
|
| on_text_selection_changed_callback_ = callback;
|
| }
|
|
|
| + TextInputManager::CompositionRangeInfo* last_composition_range_info() const {
|
| + return last_composition_range_info_.get();
|
| + }
|
| +
|
| RenderWidgetHostView* GetUpdatedView() const { return updated_view_; }
|
|
|
| bool text_input_state_changed() const { return text_input_state_changed_; }
|
| @@ -101,6 +105,9 @@ class TextInputManagerTester::InternalObserver
|
| TextInputManager* text_input_manager,
|
| RenderWidgetHostViewBase* updated_view) override {
|
| updated_view_ = updated_view;
|
| + last_composition_range_info_.reset(
|
| + new TextInputManager::CompositionRangeInfo(
|
| + *text_input_manager_->GetCompositionRangeInfo()));
|
| if (!on_ime_composition_range_changed_callback_.is_null())
|
| on_ime_composition_range_changed_callback_.Run();
|
| }
|
| @@ -119,6 +126,8 @@ class TextInputManagerTester::InternalObserver
|
| TextInputManager* text_input_manager_;
|
| RenderWidgetHostViewBase* updated_view_;
|
| bool text_input_state_changed_;
|
| + std::unique_ptr<TextInputManager::CompositionRangeInfo>
|
| + last_composition_range_info_;
|
| base::Closure update_text_input_state_callback_;
|
| base::Closure on_selection_bounds_changed_callback_;
|
| base::Closure on_ime_composition_range_changed_callback_;
|
| @@ -279,6 +288,25 @@ void SendImeCommitTextToWidget(
|
| text, web_composition_underlines, replacement_range, relative_cursor_pos);
|
| }
|
|
|
| +void SendImeSetCompositionTextToWidget(
|
| + RenderWidgetHost* rwh,
|
| + const base::string16& text,
|
| + const std::vector<ui::CompositionUnderline>& underlines,
|
| + const gfx::Range& replacement_range,
|
| + int selection_start,
|
| + int selection_end) {
|
| + std::vector<blink::WebCompositionUnderline> web_composition_underlines;
|
| + for (auto underline : underlines) {
|
| + web_composition_underlines.emplace_back(
|
| + static_cast<int>(underline.start_offset),
|
| + static_cast<int>(underline.end_offset), underline.color,
|
| + underline.thick, underline.background_color);
|
| + }
|
| + RenderWidgetHostImpl::From(rwh)->ImeSetComposition(
|
| + text, web_composition_underlines, replacement_range, selection_start,
|
| + selection_end);
|
| +}
|
| +
|
| size_t GetRegisteredViewsCountFromTextInputManager(WebContents* web_contents) {
|
| std::unordered_set<RenderWidgetHostView*> views;
|
| TextInputManager* manager =
|
| @@ -356,6 +384,13 @@ bool TextInputManagerTester::GetCurrentTextSelectionLength(size_t* length) {
|
| return true;
|
| }
|
|
|
| +bool TextInputManagerTester::GetLastCompositionRangeLength(uint32_t* length) {
|
| + if (!observer_->last_composition_range_info())
|
| + return false;
|
| + *length = observer_->last_composition_range_info()->range.length();
|
| + return true;
|
| +}
|
| +
|
| bool TextInputManagerTester::IsTextInputStateChanged() {
|
| return observer_->text_input_state_changed();
|
| }
|
|
|