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 
MockRenderWidgetHostDelegate()14 MockRenderWidgetHostDelegate::MockRenderWidgetHostDelegate()
15     : text_input_manager_(false /* should_do_learning */) {}
16 
17 MockRenderWidgetHostDelegate::~MockRenderWidgetHostDelegate() = default;
18 
ResizeDueToAutoResize(RenderWidgetHostImpl * render_widget_host,const gfx::Size & new_size)19 void MockRenderWidgetHostDelegate::ResizeDueToAutoResize(
20     RenderWidgetHostImpl* render_widget_host,
21     const gfx::Size& new_size) {}
22 
23 KeyboardEventProcessingResult
PreHandleKeyboardEvent(const NativeWebKeyboardEvent & event)24 MockRenderWidgetHostDelegate::PreHandleKeyboardEvent(
25     const NativeWebKeyboardEvent& event) {
26   last_event_ = std::make_unique<NativeWebKeyboardEvent>(event);
27   return pre_handle_keyboard_event_result_;
28 }
29 
ExecuteEditCommand(const std::string & command,const base::Optional<base::string16> & value)30 void MockRenderWidgetHostDelegate::ExecuteEditCommand(
31     const std::string& command,
32     const base::Optional<base::string16>& value) {}
33 
Undo()34 void MockRenderWidgetHostDelegate::Undo() {}
35 
Redo()36 void MockRenderWidgetHostDelegate::Redo() {}
37 
Cut()38 void MockRenderWidgetHostDelegate::Cut() {}
39 
Copy()40 void MockRenderWidgetHostDelegate::Copy() {}
41 
Paste()42 void MockRenderWidgetHostDelegate::Paste() {}
43 
PasteAndMatchStyle()44 void MockRenderWidgetHostDelegate::PasteAndMatchStyle() {}
45 
SelectAll()46 void MockRenderWidgetHostDelegate::SelectAll() {}
47 
CreateInputEventRouter()48 void MockRenderWidgetHostDelegate::CreateInputEventRouter() {
49   rwh_input_event_router_ =
50       std::make_unique<RenderWidgetHostInputEventRouter>();
51 }
52 
53 RenderWidgetHostInputEventRouter*
GetInputEventRouter()54 MockRenderWidgetHostDelegate::GetInputEventRouter() {
55   return rwh_input_event_router_.get();
56 }
57 
GetFocusedRenderWidgetHost(RenderWidgetHostImpl * widget_host)58 RenderWidgetHostImpl* MockRenderWidgetHostDelegate::GetFocusedRenderWidgetHost(
59     RenderWidgetHostImpl* widget_host) {
60   return !!focused_widget_ ? focused_widget_ : widget_host;
61 }
62 
SendScreenRects()63 void MockRenderWidgetHostDelegate::SendScreenRects() {
64   if (rwh_)
65     rwh_->SendScreenRects();
66 }
67 
GetTextInputManager()68 TextInputManager* MockRenderWidgetHostDelegate::GetTextInputManager() {
69   return &text_input_manager_;
70 }
71 
IsFullscreen()72 bool MockRenderWidgetHostDelegate::IsFullscreen() {
73   return is_fullscreen_;
74 }
75 
GetDelegateView()76 RenderViewHostDelegateView* MockRenderWidgetHostDelegate::GetDelegateView() {
77   return &rvh_delegate_view_;
78 }
79 
GetFrameTree()80 FrameTree* MockRenderWidgetHostDelegate::GetFrameTree() {
81   return frame_tree_;
82 }
83 
ShouldIgnoreInputEvents()84 bool MockRenderWidgetHostDelegate::ShouldIgnoreInputEvents() {
85   return should_ignore_input_events_;
86 }
87 
88 }  // namespace content
89