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