Francois Doray | 6789a48 | 2017-12-14 00:21:53 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/test/mock_render_widget_host_delegate.h" |
| 6 | |
| 7 | #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 8 | #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 9 | #include "content/public/browser/native_web_keyboard_event.h" |
| 10 | #include "ui/display/screen.h" |
| 11 | |
| 12 | namespace content { |
| 13 | |
Darren Shen | ca53d5f | 2018-05-15 04:56:01 | [diff] [blame] | 14 | MockRenderWidgetHostDelegate::MockRenderWidgetHostDelegate() |
| 15 | : text_input_manager_(false /* should_do_learning */) {} |
| 16 | |
Francois Doray | 6789a48 | 2017-12-14 00:21:53 | [diff] [blame] | 17 | MockRenderWidgetHostDelegate::~MockRenderWidgetHostDelegate() = default; |
| 18 | |
| 19 | void MockRenderWidgetHostDelegate::ResizeDueToAutoResize( |
| 20 | RenderWidgetHostImpl* render_widget_host, |
Fady Samuel | 9794711 | 2018-05-05 16:24:54 | [diff] [blame] | 21 | const gfx::Size& new_size) {} |
Francois Doray | 6789a48 | 2017-12-14 00:21:53 | [diff] [blame] | 22 | |
Francois Doray | 6789a48 | 2017-12-14 00:21:53 | [diff] [blame] | 23 | KeyboardEventProcessingResult |
| 24 | MockRenderWidgetHostDelegate::PreHandleKeyboardEvent( |
| 25 | const NativeWebKeyboardEvent& event) { |
| 26 | last_event_ = std::make_unique<NativeWebKeyboardEvent>(event); |
| 27 | return pre_handle_keyboard_event_result_; |
| 28 | } |
| 29 | |
| 30 | void MockRenderWidgetHostDelegate::ExecuteEditCommand( |
| 31 | const std::string& command, |
| 32 | const base::Optional<base::string16>& value) {} |
| 33 | |
| 34 | void MockRenderWidgetHostDelegate::Cut() {} |
| 35 | |
| 36 | void MockRenderWidgetHostDelegate::Copy() {} |
| 37 | |
| 38 | void MockRenderWidgetHostDelegate::Paste() {} |
| 39 | |
| 40 | void MockRenderWidgetHostDelegate::SelectAll() {} |
| 41 | |
Kevin McNee | 32e2fc5 | 2019-01-09 00:02:41 | [diff] [blame] | 42 | void MockRenderWidgetHostDelegate::CreateInputEventRouter() { |
| 43 | rwh_input_event_router_ = |
| 44 | std::make_unique<RenderWidgetHostInputEventRouter>(); |
| 45 | } |
| 46 | |
| 47 | RenderWidgetHostInputEventRouter* |
| 48 | MockRenderWidgetHostDelegate::GetInputEventRouter() { |
| 49 | return rwh_input_event_router_.get(); |
| 50 | } |
| 51 | |
Francois Doray | 6789a48 | 2017-12-14 00:21:53 | [diff] [blame] | 52 | RenderWidgetHostImpl* MockRenderWidgetHostDelegate::GetFocusedRenderWidgetHost( |
| 53 | RenderWidgetHostImpl* widget_host) { |
| 54 | return !!focused_widget_ ? focused_widget_ : widget_host; |
| 55 | } |
| 56 | |
| 57 | void MockRenderWidgetHostDelegate::SendScreenRects() { |
| 58 | if (rwh_) |
| 59 | rwh_->SendScreenRects(); |
| 60 | } |
| 61 | |
| 62 | TextInputManager* MockRenderWidgetHostDelegate::GetTextInputManager() { |
| 63 | return &text_input_manager_; |
| 64 | } |
| 65 | |
Lucas Furukawa Gadani | e1c5dfda | 2018-11-29 17:57:41 | [diff] [blame] | 66 | bool MockRenderWidgetHostDelegate::IsFullscreenForCurrentTab() { |
Francois Doray | 6789a48 | 2017-12-14 00:21:53 | [diff] [blame] | 67 | return is_fullscreen_; |
| 68 | } |
| 69 | |
| 70 | } // namespace content |