| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const GURL& url, | 45 const GURL& url, |
| 46 ui::PageTransition transition_type); | 46 ui::PageTransition transition_type); |
| 47 | 47 |
| 48 // TestRenderViewHostView ------------------------------------------------------ | 48 // TestRenderViewHostView ------------------------------------------------------ |
| 49 | 49 |
| 50 // Subclass the RenderViewHost's view so that we can call Show(), etc., | 50 // Subclass the RenderViewHost's view so that we can call Show(), etc., |
| 51 // without having side-effects. | 51 // without having side-effects. |
| 52 class TestRenderWidgetHostView : public RenderWidgetHostViewBase { | 52 class TestRenderWidgetHostView : public RenderWidgetHostViewBase { |
| 53 public: | 53 public: |
| 54 explicit TestRenderWidgetHostView(RenderWidgetHost* rwh); | 54 explicit TestRenderWidgetHostView(RenderWidgetHost* rwh); |
| 55 virtual ~TestRenderWidgetHostView(); | 55 ~TestRenderWidgetHostView() override; |
| 56 | 56 |
| 57 // RenderWidgetHostView implementation. | 57 // RenderWidgetHostView implementation. |
| 58 virtual void InitAsChild(gfx::NativeView parent_view) override {} | 58 void InitAsChild(gfx::NativeView parent_view) override {} |
| 59 virtual RenderWidgetHost* GetRenderWidgetHost() const override; | 59 RenderWidgetHost* GetRenderWidgetHost() const override; |
| 60 virtual void SetSize(const gfx::Size& size) override {} | 60 void SetSize(const gfx::Size& size) override {} |
| 61 virtual void SetBounds(const gfx::Rect& rect) override {} | 61 void SetBounds(const gfx::Rect& rect) override {} |
| 62 virtual gfx::Vector2dF GetLastScrollOffset() const override; | 62 gfx::Vector2dF GetLastScrollOffset() const override; |
| 63 virtual gfx::NativeView GetNativeView() const override; | 63 gfx::NativeView GetNativeView() const override; |
| 64 virtual gfx::NativeViewId GetNativeViewId() const override; | 64 gfx::NativeViewId GetNativeViewId() const override; |
| 65 virtual gfx::NativeViewAccessible GetNativeViewAccessible() override; | 65 gfx::NativeViewAccessible GetNativeViewAccessible() override; |
| 66 virtual ui::TextInputClient* GetTextInputClient() override; | 66 ui::TextInputClient* GetTextInputClient() override; |
| 67 virtual bool HasFocus() const override; | 67 bool HasFocus() const override; |
| 68 virtual bool IsSurfaceAvailableForCopy() const override; | 68 bool IsSurfaceAvailableForCopy() const override; |
| 69 virtual void Show() override; | 69 void Show() override; |
| 70 virtual void Hide() override; | 70 void Hide() override; |
| 71 virtual bool IsShowing() override; | 71 bool IsShowing() override; |
| 72 virtual gfx::Rect GetViewBounds() const override; | 72 gfx::Rect GetViewBounds() const override; |
| 73 #if defined(OS_MACOSX) | 73 #if defined(OS_MACOSX) |
| 74 virtual void SetActive(bool active) override; | 74 void SetActive(bool active) override; |
| 75 virtual void SetTakesFocusOnlyOnMouseDown(bool flag) override {} | 75 void SetTakesFocusOnlyOnMouseDown(bool flag) override {} |
| 76 virtual void SetWindowVisibility(bool visible) override {} | 76 void SetWindowVisibility(bool visible) override {} |
| 77 virtual void WindowFrameChanged() override {} | 77 void WindowFrameChanged() override {} |
| 78 virtual void ShowDefinitionForSelection() override {} | 78 void ShowDefinitionForSelection() override {} |
| 79 virtual bool SupportsSpeech() const override; | 79 bool SupportsSpeech() const override; |
| 80 virtual void SpeakSelection() override; | 80 void SpeakSelection() override; |
| 81 virtual bool IsSpeaking() const override; | 81 bool IsSpeaking() const override; |
| 82 virtual void StopSpeaking() override; | 82 void StopSpeaking() override; |
| 83 #endif // defined(OS_MACOSX) | 83 #endif // defined(OS_MACOSX) |
| 84 virtual void OnSwapCompositorFrame( | 84 void OnSwapCompositorFrame(uint32 output_surface_id, |
| 85 uint32 output_surface_id, | 85 scoped_ptr<cc::CompositorFrame> frame) override; |
| 86 scoped_ptr<cc::CompositorFrame> frame) override; | |
| 87 | 86 |
| 88 // RenderWidgetHostViewBase implementation. | 87 // RenderWidgetHostViewBase implementation. |
| 89 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 88 void InitAsPopup(RenderWidgetHostView* parent_host_view, |
| 90 const gfx::Rect& pos) override {} | 89 const gfx::Rect& pos) override {} |
| 91 virtual void InitAsFullscreen( | 90 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override {} |
| 92 RenderWidgetHostView* reference_host_view) override {} | 91 void WasShown() override {} |
| 93 virtual void WasShown() override {} | 92 void WasHidden() override {} |
| 94 virtual void WasHidden() override {} | 93 void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override { |
| 95 virtual void MovePluginWindows( | 94 } |
| 96 const std::vector<WebPluginGeometry>& moves) override {} | 95 void Focus() override {} |
| 97 virtual void Focus() override {} | 96 void Blur() override {} |
| 98 virtual void Blur() override {} | 97 void SetIsLoading(bool is_loading) override {} |
| 99 virtual void SetIsLoading(bool is_loading) override {} | 98 void UpdateCursor(const WebCursor& cursor) override {} |
| 100 virtual void UpdateCursor(const WebCursor& cursor) override {} | 99 void TextInputTypeChanged(ui::TextInputType type, |
| 101 virtual void TextInputTypeChanged(ui::TextInputType type, | 100 ui::TextInputMode input_mode, |
| 102 ui::TextInputMode input_mode, | 101 bool can_compose_inline) override {} |
| 103 bool can_compose_inline) override {} | 102 void ImeCancelComposition() override {} |
| 104 virtual void ImeCancelComposition() override {} | |
| 105 #if defined(OS_MACOSX) || defined(USE_AURA) | 103 #if defined(OS_MACOSX) || defined(USE_AURA) |
| 106 virtual void ImeCompositionRangeChanged( | 104 void ImeCompositionRangeChanged( |
| 107 const gfx::Range& range, | 105 const gfx::Range& range, |
| 108 const std::vector<gfx::Rect>& character_bounds) override {} | 106 const std::vector<gfx::Rect>& character_bounds) override {} |
| 109 #endif | 107 #endif |
| 110 virtual void RenderProcessGone(base::TerminationStatus status, | 108 void RenderProcessGone(base::TerminationStatus status, |
| 111 int error_code) override; | 109 int error_code) override; |
| 112 virtual void Destroy() override; | 110 void Destroy() override; |
| 113 virtual void SetTooltipText(const base::string16& tooltip_text) override {} | 111 void SetTooltipText(const base::string16& tooltip_text) override {} |
| 114 virtual void SelectionBoundsChanged( | 112 void SelectionBoundsChanged( |
| 115 const ViewHostMsg_SelectionBounds_Params& params) override {} | 113 const ViewHostMsg_SelectionBounds_Params& params) override {} |
| 116 virtual void CopyFromCompositingSurface( | 114 void CopyFromCompositingSurface(const gfx::Rect& src_subrect, |
| 117 const gfx::Rect& src_subrect, | 115 const gfx::Size& dst_size, |
| 118 const gfx::Size& dst_size, | 116 CopyFromCompositingSurfaceCallback& callback, |
| 119 CopyFromCompositingSurfaceCallback& callback, | 117 const SkColorType color_type) override; |
| 120 const SkColorType color_type) override; | 118 void CopyFromCompositingSurfaceToVideoFrame( |
| 121 virtual void CopyFromCompositingSurfaceToVideoFrame( | |
| 122 const gfx::Rect& src_subrect, | 119 const gfx::Rect& src_subrect, |
| 123 const scoped_refptr<media::VideoFrame>& target, | 120 const scoped_refptr<media::VideoFrame>& target, |
| 124 const base::Callback<void(bool)>& callback) override; | 121 const base::Callback<void(bool)>& callback) override; |
| 125 virtual bool CanCopyToVideoFrame() const override; | 122 bool CanCopyToVideoFrame() const override; |
| 126 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) override; | 123 bool HasAcceleratedSurface(const gfx::Size& desired_size) override; |
| 127 #if defined(OS_MACOSX) | 124 #if defined(OS_MACOSX) |
| 128 virtual bool PostProcessEventForPluginIme( | 125 bool PostProcessEventForPluginIme( |
| 129 const NativeWebKeyboardEvent& event) override; | 126 const NativeWebKeyboardEvent& event) override; |
| 130 #endif | 127 #endif |
| 131 #if defined(OS_ANDROID) | 128 #if defined(OS_ANDROID) |
| 132 virtual void LockCompositingSurface() override {} | 129 virtual void LockCompositingSurface() override {} |
| 133 virtual void UnlockCompositingSurface() override {} | 130 virtual void UnlockCompositingSurface() override {} |
| 134 #endif | 131 #endif |
| 135 virtual void GetScreenInfo(blink::WebScreenInfo* results) override {} | 132 void GetScreenInfo(blink::WebScreenInfo* results) override {} |
| 136 virtual gfx::Rect GetBoundsInRootWindow() override; | 133 gfx::Rect GetBoundsInRootWindow() override; |
| 137 virtual gfx::GLSurfaceHandle GetCompositingSurface() override; | 134 gfx::GLSurfaceHandle GetCompositingSurface() override; |
| 138 virtual bool LockMouse() override; | 135 bool LockMouse() override; |
| 139 virtual void UnlockMouse() override; | 136 void UnlockMouse() override; |
| 140 #if defined(OS_WIN) | 137 #if defined(OS_WIN) |
| 141 virtual void SetParentNativeViewAccessible( | 138 virtual void SetParentNativeViewAccessible( |
| 142 gfx::NativeViewAccessible accessible_parent) override; | 139 gfx::NativeViewAccessible accessible_parent) override; |
| 143 virtual gfx::NativeViewId GetParentForWindowlessPlugin() const override; | 140 virtual gfx::NativeViewId GetParentForWindowlessPlugin() const override; |
| 144 #endif | 141 #endif |
| 145 | 142 |
| 146 bool is_showing() const { return is_showing_; } | 143 bool is_showing() const { return is_showing_; } |
| 147 bool did_swap_compositor_frame() const { return did_swap_compositor_frame_; } | 144 bool did_swap_compositor_frame() const { return did_swap_compositor_frame_; } |
| 148 | 145 |
| 149 protected: | 146 protected: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 class TestRenderViewHost | 196 class TestRenderViewHost |
| 200 : public RenderViewHostImpl, | 197 : public RenderViewHostImpl, |
| 201 public RenderViewHostTester { | 198 public RenderViewHostTester { |
| 202 public: | 199 public: |
| 203 TestRenderViewHost(SiteInstance* instance, | 200 TestRenderViewHost(SiteInstance* instance, |
| 204 RenderViewHostDelegate* delegate, | 201 RenderViewHostDelegate* delegate, |
| 205 RenderWidgetHostDelegate* widget_delegate, | 202 RenderWidgetHostDelegate* widget_delegate, |
| 206 int routing_id, | 203 int routing_id, |
| 207 int main_frame_routing_id, | 204 int main_frame_routing_id, |
| 208 bool swapped_out); | 205 bool swapped_out); |
| 209 virtual ~TestRenderViewHost(); | 206 ~TestRenderViewHost() override; |
| 210 | 207 |
| 211 // RenderViewHostTester implementation. Note that CreateRenderView | 208 // RenderViewHostTester implementation. Note that CreateRenderView |
| 212 // is not specified since it is synonymous with the one from | 209 // is not specified since it is synonymous with the one from |
| 213 // RenderViewHostImpl, see below. | 210 // RenderViewHostImpl, see below. |
| 214 virtual void SimulateWasHidden() override; | 211 void SimulateWasHidden() override; |
| 215 virtual void SimulateWasShown() override; | 212 void SimulateWasShown() override; |
| 216 | 213 |
| 217 void TestOnUpdateStateWithFile( | 214 void TestOnUpdateStateWithFile( |
| 218 int page_id, const base::FilePath& file_path); | 215 int page_id, const base::FilePath& file_path); |
| 219 | 216 |
| 220 void TestOnStartDragging(const DropData& drop_data); | 217 void TestOnStartDragging(const DropData& drop_data); |
| 221 | 218 |
| 222 // If set, *delete_counter is incremented when this object destructs. | 219 // If set, *delete_counter is incremented when this object destructs. |
| 223 void set_delete_counter(int* delete_counter) { | 220 void set_delete_counter(int* delete_counter) { |
| 224 delete_counter_ = delete_counter; | 221 delete_counter_ = delete_counter; |
| 225 } | 222 } |
| 226 | 223 |
| 227 // Sets whether the RenderView currently exists or not. This controls the | 224 // Sets whether the RenderView currently exists or not. This controls the |
| 228 // return value from IsRenderViewLive, which the rest of the system uses to | 225 // return value from IsRenderViewLive, which the rest of the system uses to |
| 229 // check whether the RenderView has crashed or not. | 226 // check whether the RenderView has crashed or not. |
| 230 void set_render_view_created(bool created) { | 227 void set_render_view_created(bool created) { |
| 231 render_view_created_ = created; | 228 render_view_created_ = created; |
| 232 } | 229 } |
| 233 | 230 |
| 234 // The opener route id passed to CreateRenderView(). | 231 // The opener route id passed to CreateRenderView(). |
| 235 int opener_route_id() const { return opener_route_id_; } | 232 int opener_route_id() const { return opener_route_id_; } |
| 236 | 233 |
| 237 // RenderViewHost overrides -------------------------------------------------- | 234 // RenderViewHost overrides -------------------------------------------------- |
| 238 | 235 |
| 239 virtual bool CreateRenderView(const base::string16& frame_name, | 236 bool CreateRenderView(const base::string16& frame_name, |
| 240 int opener_route_id, | 237 int opener_route_id, |
| 241 int proxy_route_id, | 238 int proxy_route_id, |
| 242 int32 max_page_id, | 239 int32 max_page_id, |
| 243 bool window_was_created_with_opener) override; | 240 bool window_was_created_with_opener) override; |
| 244 virtual bool IsRenderViewLive() const override; | 241 bool IsRenderViewLive() const override; |
| 245 virtual bool IsFullscreen() const override; | 242 bool IsFullscreen() const override; |
| 246 | 243 |
| 247 private: | 244 private: |
| 248 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, FilterNavigate); | 245 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, FilterNavigate); |
| 249 | 246 |
| 250 void SendNavigateWithTransitionAndResponseCode(int page_id, | 247 void SendNavigateWithTransitionAndResponseCode(int page_id, |
| 251 const GURL& url, | 248 const GURL& url, |
| 252 ui::PageTransition transition, | 249 ui::PageTransition transition, |
| 253 int response_code); | 250 int response_code); |
| 254 | 251 |
| 255 // Calls OnNavigate on the RenderViewHost with the given information. | 252 // Calls OnNavigate on the RenderViewHost with the given information. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 private: | 319 private: |
| 323 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> | 320 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> |
| 324 ScopedSetSupportedScaleFactors; | 321 ScopedSetSupportedScaleFactors; |
| 325 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; | 322 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; |
| 326 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); | 323 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImplTestHarness); |
| 327 }; | 324 }; |
| 328 | 325 |
| 329 } // namespace content | 326 } // namespace content |
| 330 | 327 |
| 331 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ | 328 #endif // CONTENT_TEST_TEST_RENDER_VIEW_HOST_H_ |
| OLD | NEW |