OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 5 #ifndef CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
6 #define CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 6 #define CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "cc/surfaces/frame_sink_id.h" | 16 #include "cc/surfaces/frame_sink_id.h" |
17 #include "content/browser/renderer_host/render_view_host_impl.h" | 17 #include "content/browser/renderer_host/render_view_host_impl.h" |
18 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
19 #include "content/public/common/web_preferences.h" | 19 #include "content/public/common/web_preferences.h" |
20 #include "content/public/test/mock_render_process_host.h" | 20 #include "content/public/test/mock_render_process_host.h" |
21 #include "content/public/test/test_renderer_host.h" | 21 #include "content/public/test/test_renderer_host.h" |
22 #include "ui/base/ime/dummy_text_input_client.h" | 22 #include "ui/base/ime/dummy_text_input_client.h" |
23 #include "ui/base/layout.h" | 23 #include "ui/base/layout.h" |
24 #include "ui/base/page_transition_types.h" | 24 #include "ui/base/page_transition_types.h" |
25 #include "ui/gfx/geometry/vector2d_f.h" | 25 #include "ui/gfx/geometry/vector2d_f.h" |
26 | 26 |
27 #if defined(USE_AURA) | |
28 #include "ui/aura/window.h" | |
29 #endif | |
30 | |
31 // This file provides a testing framework for mocking out the RenderProcessHost | 27 // This file provides a testing framework for mocking out the RenderProcessHost |
32 // layer. It allows you to test RenderViewHost, WebContentsImpl, | 28 // layer. It allows you to test RenderViewHost, WebContentsImpl, |
33 // NavigationController, and other layers above that without running an actual | 29 // NavigationController, and other layers above that without running an actual |
34 // renderer process. | 30 // renderer process. |
35 // | 31 // |
36 // To use, derive your test base class from RenderViewHostImplTestHarness. | 32 // To use, derive your test base class from RenderViewHostImplTestHarness. |
37 | 33 |
38 struct FrameHostMsg_DidCommitProvisionalLoad_Params; | 34 struct FrameHostMsg_DidCommitProvisionalLoad_Params; |
39 | 35 |
40 namespace gfx { | 36 namespace gfx { |
(...skipping 17 matching lines...) Expand all Loading... |
58 | 54 |
59 // TestRenderWidgetHostView ---------------------------------------------------- | 55 // TestRenderWidgetHostView ---------------------------------------------------- |
60 | 56 |
61 // Subclass the RenderViewHost's view so that we can call Show(), etc., | 57 // Subclass the RenderViewHost's view so that we can call Show(), etc., |
62 // without having side-effects. | 58 // without having side-effects. |
63 class TestRenderWidgetHostView : public RenderWidgetHostViewBase { | 59 class TestRenderWidgetHostView : public RenderWidgetHostViewBase { |
64 public: | 60 public: |
65 explicit TestRenderWidgetHostView(RenderWidgetHost* rwh); | 61 explicit TestRenderWidgetHostView(RenderWidgetHost* rwh); |
66 ~TestRenderWidgetHostView() override; | 62 ~TestRenderWidgetHostView() override; |
67 | 63 |
68 // RenderWidgetHostView: | 64 // RenderWidgetHostView implementation. |
69 void InitAsChild(gfx::NativeView parent_view) override {} | 65 void InitAsChild(gfx::NativeView parent_view) override {} |
70 RenderWidgetHost* GetRenderWidgetHost() const override; | 66 RenderWidgetHost* GetRenderWidgetHost() const override; |
71 void SetSize(const gfx::Size& size) override {} | 67 void SetSize(const gfx::Size& size) override {} |
72 void SetBounds(const gfx::Rect& rect) override {} | 68 void SetBounds(const gfx::Rect& rect) override {} |
73 gfx::Vector2dF GetLastScrollOffset() const override; | 69 gfx::Vector2dF GetLastScrollOffset() const override; |
74 gfx::NativeView GetNativeView() const override; | 70 gfx::NativeView GetNativeView() const override; |
75 gfx::NativeViewAccessible GetNativeViewAccessible() override; | 71 gfx::NativeViewAccessible GetNativeViewAccessible() override; |
76 ui::TextInputClient* GetTextInputClient() override; | 72 ui::TextInputClient* GetTextInputClient() override; |
77 bool HasFocus() const override; | 73 bool HasFocus() const override; |
78 void Show() override; | 74 void Show() override; |
(...skipping 14 matching lines...) Expand all Loading... |
93 void StopSpeaking() override; | 89 void StopSpeaking() override; |
94 #endif // defined(OS_MACOSX) | 90 #endif // defined(OS_MACOSX) |
95 void DidCreateNewRendererCompositorFrameSink( | 91 void DidCreateNewRendererCompositorFrameSink( |
96 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) | 92 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) |
97 override; | 93 override; |
98 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, | 94 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, |
99 cc::CompositorFrame frame) override; | 95 cc::CompositorFrame frame) override; |
100 void ClearCompositorFrame() override {} | 96 void ClearCompositorFrame() override {} |
101 void SetNeedsBeginFrames(bool needs_begin_frames) override {} | 97 void SetNeedsBeginFrames(bool needs_begin_frames) override {} |
102 | 98 |
103 // RenderWidgetHostViewBase: | 99 // RenderWidgetHostViewBase implementation. |
104 void InitAsPopup(RenderWidgetHostView* parent_host_view, | 100 void InitAsPopup(RenderWidgetHostView* parent_host_view, |
105 const gfx::Rect& bounds) override {} | 101 const gfx::Rect& bounds) override {} |
106 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override {} | 102 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override {} |
107 void Focus() override {} | 103 void Focus() override {} |
108 void SetIsLoading(bool is_loading) override {} | 104 void SetIsLoading(bool is_loading) override {} |
109 void UpdateCursor(const WebCursor& cursor) override {} | 105 void UpdateCursor(const WebCursor& cursor) override {} |
110 void RenderProcessGone(base::TerminationStatus status, | 106 void RenderProcessGone(base::TerminationStatus status, |
111 int error_code) override; | 107 int error_code) override; |
112 void Destroy() override; | 108 void Destroy() override; |
113 void SetTooltipText(const base::string16& tooltip_text) override {} | 109 void SetTooltipText(const base::string16& tooltip_text) override {} |
(...skipping 18 matching lines...) Expand all Loading... |
132 RenderWidgetHostImpl* rwh_; | 128 RenderWidgetHostImpl* rwh_; |
133 cc::FrameSinkId frame_sink_id_; | 129 cc::FrameSinkId frame_sink_id_; |
134 | 130 |
135 private: | 131 private: |
136 bool is_showing_; | 132 bool is_showing_; |
137 bool is_occluded_; | 133 bool is_occluded_; |
138 bool did_swap_compositor_frame_; | 134 bool did_swap_compositor_frame_; |
139 bool did_change_compositor_frame_sink_ = false; | 135 bool did_change_compositor_frame_sink_ = false; |
140 SkColor background_color_; | 136 SkColor background_color_; |
141 ui::DummyTextInputClient text_input_client_; | 137 ui::DummyTextInputClient text_input_client_; |
142 | |
143 #if defined(USE_AURA) | |
144 std::unique_ptr<aura::Window> window_; | |
145 #endif | |
146 }; | 138 }; |
147 | 139 |
148 #if defined(COMPILER_MSVC) | 140 #if defined(COMPILER_MSVC) |
149 // See comment for same warning on RenderViewHostImpl. | 141 // See comment for same warning on RenderViewHostImpl. |
150 #pragma warning(push) | 142 #pragma warning(push) |
151 #pragma warning(disable: 4250) | 143 #pragma warning(disable: 4250) |
152 #endif | 144 #endif |
153 | 145 |
154 // TestRenderViewHost ---------------------------------------------------------- | 146 // TestRenderViewHost ---------------------------------------------------------- |
155 | 147 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 private: | 305 private: |
314 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors> | 306 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors> |
315 ScopedSetSupportedScaleFactors; | 307 ScopedSetSupportedScaleFactors; |
316 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; | 308 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; |
317 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); | 309 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); |
318 }; | 310 }; |
319 | 311 |
320 } // namespace content | 312 } // namespace content |
321 | 313 |
322 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 314 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
OLD | NEW |