| 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 "content/public/test/text_input_test_utils.h" | 5 #include "content/public/test/text_input_test_utils.h" |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
| 8 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 7 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 8 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" | 9 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h" |
| 11 #include "content/browser/renderer_host/text_input_manager.h" | 10 #include "content/browser/renderer_host/text_input_manager.h" |
| 12 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
| 13 #include "content/common/text_input_state.h" | 12 #include "content/common/text_input_state.h" |
| 14 #include "content/public/browser/render_widget_host_view.h" | 13 #include "content/public/browser/render_widget_host_view.h" |
| 15 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 17 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 if (!manager || !manager->IsRegistered(view_base)) | 195 if (!manager || !manager->IsRegistered(view_base)) |
| 197 return false; | 196 return false; |
| 198 | 197 |
| 199 *type = manager->text_input_state_map_[view_base].type; | 198 *type = manager->text_input_state_map_[view_base].type; |
| 200 return true; | 199 return true; |
| 201 } | 200 } |
| 202 | 201 |
| 203 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) { | 202 RenderWidgetHostView* GetActiveViewFromWebContents(WebContents* web_contents) { |
| 204 return static_cast<WebContentsImpl*>(web_contents) | 203 return static_cast<WebContentsImpl*>(web_contents) |
| 205 ->GetTextInputManager() | 204 ->GetTextInputManager() |
| 206 ->active_view_for_testing(); | 205 ->GetActiveView(); |
| 207 } | 206 } |
| 208 | 207 |
| 209 TextInputManagerTester::TextInputManagerTester(WebContents* web_contents) | 208 TextInputManagerTester::TextInputManagerTester(WebContents* web_contents) |
| 210 : observer_(new InternalObserver(web_contents, this)) {} | 209 : observer_(new InternalObserver(web_contents, this)) {} |
| 211 | 210 |
| 212 TextInputManagerTester::~TextInputManagerTester() {} | 211 TextInputManagerTester::~TextInputManagerTester() {} |
| 213 | 212 |
| 214 void TextInputManagerTester::SetUpdateTextInputStateCalledCallback( | 213 void TextInputManagerTester::SetUpdateTextInputStateCalledCallback( |
| 215 const Callback& callback) { | 214 const Callback& callback) { |
| 216 observer_->set_update_text_input_state_called_callback(callback); | 215 observer_->set_update_text_input_state_called_callback(callback); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 231 const TextInputState* state = | 230 const TextInputState* state = |
| 232 observer_->text_input_manager()->GetTextInputState(); | 231 observer_->text_input_manager()->GetTextInputState(); |
| 233 if (!state) | 232 if (!state) |
| 234 return false; | 233 return false; |
| 235 *value = state->value; | 234 *value = state->value; |
| 236 return true; | 235 return true; |
| 237 } | 236 } |
| 238 | 237 |
| 239 const RenderWidgetHostView* TextInputManagerTester::GetActiveView() { | 238 const RenderWidgetHostView* TextInputManagerTester::GetActiveView() { |
| 240 DCHECK(observer_->text_input_manager()); | 239 DCHECK(observer_->text_input_manager()); |
| 241 return observer_->text_input_manager()->active_view_for_testing(); | 240 return observer_->text_input_manager()->GetActiveView(); |
| 242 } | 241 } |
| 243 | 242 |
| 244 const RenderWidgetHostView* TextInputManagerTester::GetUpdatedView() { | 243 const RenderWidgetHostView* TextInputManagerTester::GetUpdatedView() { |
| 245 return observer_->GetUpdatedView(); | 244 return observer_->GetUpdatedView(); |
| 246 } | 245 } |
| 247 | 246 |
| 248 bool TextInputManagerTester::IsTextInputStateChanged() { | 247 bool TextInputManagerTester::IsTextInputStateChanged() { |
| 249 return observer_->text_input_state_changed(); | 248 return observer_->text_input_state_changed(); |
| 250 } | 249 } |
| 251 | 250 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 316 |
| 318 #ifdef USE_AURA | 317 #ifdef USE_AURA |
| 319 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( | 318 RenderWidgetHostViewAura* view = static_cast<RenderWidgetHostViewAura*>( |
| 320 web_contents->GetRenderWidgetHostView()); | 319 web_contents->GetRenderWidgetHostView()); |
| 321 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); | 320 observer.reset(new InputMethodObserverAura(view->GetInputMethod())); |
| 322 #endif | 321 #endif |
| 323 return observer; | 322 return observer; |
| 324 } | 323 } |
| 325 | 324 |
| 326 } // namespace content | 325 } // namespace content |
| OLD | NEW |