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/aura/window.h" |
| 23 #include "ui/aura/window_delegate.h" |
22 #include "ui/base/ime/dummy_text_input_client.h" | 24 #include "ui/base/ime/dummy_text_input_client.h" |
23 #include "ui/base/layout.h" | 25 #include "ui/base/layout.h" |
24 #include "ui/base/page_transition_types.h" | 26 #include "ui/base/page_transition_types.h" |
25 #include "ui/gfx/geometry/vector2d_f.h" | 27 #include "ui/gfx/geometry/vector2d_f.h" |
26 | 28 |
27 // This file provides a testing framework for mocking out the RenderProcessHost | 29 // This file provides a testing framework for mocking out the RenderProcessHost |
28 // layer. It allows you to test RenderViewHost, WebContentsImpl, | 30 // layer. It allows you to test RenderViewHost, WebContentsImpl, |
29 // NavigationController, and other layers above that without running an actual | 31 // NavigationController, and other layers above that without running an actual |
30 // renderer process. | 32 // renderer process. |
31 // | 33 // |
(...skipping 17 matching lines...) Expand all Loading... |
49 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, | 51 void InitNavigateParams(FrameHostMsg_DidCommitProvisionalLoad_Params* params, |
50 int nav_entry_id, | 52 int nav_entry_id, |
51 bool did_create_new_entry, | 53 bool did_create_new_entry, |
52 const GURL& url, | 54 const GURL& url, |
53 ui::PageTransition transition_type); | 55 ui::PageTransition transition_type); |
54 | 56 |
55 // TestRenderWidgetHostView ---------------------------------------------------- | 57 // TestRenderWidgetHostView ---------------------------------------------------- |
56 | 58 |
57 // Subclass the RenderViewHost's view so that we can call Show(), etc., | 59 // Subclass the RenderViewHost's view so that we can call Show(), etc., |
58 // without having side-effects. | 60 // without having side-effects. |
59 class TestRenderWidgetHostView : public RenderWidgetHostViewBase { | 61 class TestRenderWidgetHostView : public RenderWidgetHostViewBase, |
| 62 public aura::WindowDelegate { |
60 public: | 63 public: |
61 explicit TestRenderWidgetHostView(RenderWidgetHost* rwh); | 64 explicit TestRenderWidgetHostView(RenderWidgetHost* rwh); |
62 ~TestRenderWidgetHostView() override; | 65 ~TestRenderWidgetHostView() override; |
63 | 66 |
64 // RenderWidgetHostView implementation. | 67 // RenderWidgetHostView: |
65 void InitAsChild(gfx::NativeView parent_view) override {} | 68 void InitAsChild(gfx::NativeView parent_view) override {} |
66 RenderWidgetHost* GetRenderWidgetHost() const override; | 69 RenderWidgetHost* GetRenderWidgetHost() const override; |
67 void SetSize(const gfx::Size& size) override {} | 70 void SetSize(const gfx::Size& size) override {} |
68 void SetBounds(const gfx::Rect& rect) override {} | 71 void SetBounds(const gfx::Rect& rect) override {} |
69 gfx::Vector2dF GetLastScrollOffset() const override; | 72 gfx::Vector2dF GetLastScrollOffset() const override; |
70 gfx::NativeView GetNativeView() const override; | 73 gfx::NativeView GetNativeView() const override; |
71 gfx::NativeViewAccessible GetNativeViewAccessible() override; | 74 gfx::NativeViewAccessible GetNativeViewAccessible() override; |
72 ui::TextInputClient* GetTextInputClient() override; | 75 ui::TextInputClient* GetTextInputClient() override; |
73 bool HasFocus() const override; | 76 bool HasFocus() const override; |
74 void Show() override; | 77 void Show() override; |
(...skipping 14 matching lines...) Expand all Loading... |
89 void StopSpeaking() override; | 92 void StopSpeaking() override; |
90 #endif // defined(OS_MACOSX) | 93 #endif // defined(OS_MACOSX) |
91 void DidCreateNewRendererCompositorFrameSink( | 94 void DidCreateNewRendererCompositorFrameSink( |
92 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) | 95 cc::mojom::MojoCompositorFrameSinkClient* renderer_compositor_frame_sink) |
93 override; | 96 override; |
94 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, | 97 void SubmitCompositorFrame(const cc::LocalSurfaceId& local_surface_id, |
95 cc::CompositorFrame frame) override; | 98 cc::CompositorFrame frame) override; |
96 void ClearCompositorFrame() override {} | 99 void ClearCompositorFrame() override {} |
97 void SetNeedsBeginFrames(bool needs_begin_frames) override {} | 100 void SetNeedsBeginFrames(bool needs_begin_frames) override {} |
98 | 101 |
99 // RenderWidgetHostViewBase implementation. | 102 // RenderWidgetHostViewBase: |
100 void InitAsPopup(RenderWidgetHostView* parent_host_view, | 103 void InitAsPopup(RenderWidgetHostView* parent_host_view, |
101 const gfx::Rect& bounds) override {} | 104 const gfx::Rect& bounds) override {} |
102 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override {} | 105 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override {} |
103 void Focus() override {} | 106 void Focus() override {} |
104 void SetIsLoading(bool is_loading) override {} | 107 void SetIsLoading(bool is_loading) override {} |
105 void UpdateCursor(const WebCursor& cursor) override {} | 108 void UpdateCursor(const WebCursor& cursor) override {} |
106 void RenderProcessGone(base::TerminationStatus status, | 109 void RenderProcessGone(base::TerminationStatus status, |
107 int error_code) override; | 110 int error_code) override; |
108 void Destroy() override; | 111 void Destroy() override; |
109 void SetTooltipText(const base::string16& tooltip_text) override {} | 112 void SetTooltipText(const base::string16& tooltip_text) override {} |
110 bool HasAcceleratedSurface(const gfx::Size& desired_size) override; | 113 bool HasAcceleratedSurface(const gfx::Size& desired_size) override; |
111 gfx::Rect GetBoundsInRootWindow() override; | 114 gfx::Rect GetBoundsInRootWindow() override; |
112 bool LockMouse() override; | 115 bool LockMouse() override; |
113 void UnlockMouse() override; | 116 void UnlockMouse() override; |
114 cc::FrameSinkId GetFrameSinkId() override; | 117 cc::FrameSinkId GetFrameSinkId() override; |
115 | 118 |
| 119 // aura::WindowDelegate: |
| 120 gfx::Size GetMinimumSize() const override; |
| 121 gfx::Size GetMaximumSize() const override; |
| 122 void OnBoundsChanged(const gfx::Rect& old_bounds, |
| 123 const gfx::Rect& new_bounds) override {} |
| 124 gfx::NativeCursor GetCursor(const gfx::Point& point) override; |
| 125 int GetNonClientComponent(const gfx::Point& point) const override; |
| 126 bool ShouldDescendIntoChildForEventHandling( |
| 127 aura::Window* child, |
| 128 const gfx::Point& location) override; |
| 129 bool CanFocus() override; |
| 130 void OnCaptureLost() override {} |
| 131 void OnPaint(const ui::PaintContext& context) override {} |
| 132 void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
| 133 void OnWindowDestroying(aura::Window* window) override {} |
| 134 void OnWindowDestroyed(aura::Window* window) override {} |
| 135 void OnWindowTargetVisibilityChanged(bool visible) override {} |
| 136 bool HasHitTestMask() const override; |
| 137 void GetHitTestMask(gfx::Path* mask) const override; |
| 138 |
116 bool is_showing() const { return is_showing_; } | 139 bool is_showing() const { return is_showing_; } |
117 bool is_occluded() const { return is_occluded_; } | 140 bool is_occluded() const { return is_occluded_; } |
118 bool did_swap_compositor_frame() const { return did_swap_compositor_frame_; } | 141 bool did_swap_compositor_frame() const { return did_swap_compositor_frame_; } |
119 void reset_did_swap_compositor_frame() { did_swap_compositor_frame_ = false; } | 142 void reset_did_swap_compositor_frame() { did_swap_compositor_frame_ = false; } |
120 bool did_change_compositor_frame_sink() { | 143 bool did_change_compositor_frame_sink() { |
121 return did_change_compositor_frame_sink_; | 144 return did_change_compositor_frame_sink_; |
122 } | 145 } |
123 void reset_did_change_compositor_frame_sink() { | 146 void reset_did_change_compositor_frame_sink() { |
124 did_change_compositor_frame_sink_ = false; | 147 did_change_compositor_frame_sink_ = false; |
125 } | 148 } |
126 | 149 |
127 protected: | 150 protected: |
128 RenderWidgetHostImpl* rwh_; | 151 RenderWidgetHostImpl* rwh_; |
129 cc::FrameSinkId frame_sink_id_; | 152 cc::FrameSinkId frame_sink_id_; |
130 | 153 |
131 private: | 154 private: |
132 bool is_showing_; | 155 bool is_showing_; |
133 bool is_occluded_; | 156 bool is_occluded_; |
134 bool did_swap_compositor_frame_; | 157 bool did_swap_compositor_frame_; |
135 bool did_change_compositor_frame_sink_ = false; | 158 bool did_change_compositor_frame_sink_ = false; |
136 SkColor background_color_; | 159 SkColor background_color_; |
137 ui::DummyTextInputClient text_input_client_; | 160 ui::DummyTextInputClient text_input_client_; |
| 161 aura::Window* window_; |
138 }; | 162 }; |
139 | 163 |
140 #if defined(COMPILER_MSVC) | 164 #if defined(COMPILER_MSVC) |
141 // See comment for same warning on RenderViewHostImpl. | 165 // See comment for same warning on RenderViewHostImpl. |
142 #pragma warning(push) | 166 #pragma warning(push) |
143 #pragma warning(disable: 4250) | 167 #pragma warning(disable: 4250) |
144 #endif | 168 #endif |
145 | 169 |
146 // TestRenderViewHost ---------------------------------------------------------- | 170 // TestRenderViewHost ---------------------------------------------------------- |
147 | 171 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 private: | 329 private: |
306 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors> | 330 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors> |
307 ScopedSetSupportedScaleFactors; | 331 ScopedSetSupportedScaleFactors; |
308 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; | 332 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; |
309 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); | 333 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); |
310 }; | 334 }; |
311 | 335 |
312 } // namespace content | 336 } // namespace content |
313 | 337 |
314 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 338 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
OLD | NEW |