Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/renderer_host/mock_render_process_host.h" | 11 #include "chrome/browser/renderer_host/mock_render_process_host.h" |
| 12 #include "chrome/browser/renderer_host/render_view_host.h" | 12 #include "chrome/browser/renderer_host/render_view_host.h" |
| 13 #include "chrome/browser/renderer_host/render_widget_host_view.h" | |
| 14 #include "chrome/browser/tab_contents/navigation_controller.h" | |
| 15 #include "chrome/browser/tab_contents/site_instance.h" | 13 #include "chrome/browser/tab_contents/site_instance.h" |
| 16 #include "chrome/browser/tab_contents/test_web_contents.h" | 14 #include "chrome/browser/tab_contents/test_web_contents.h" |
| 17 #include "chrome/test/testing_profile.h" | 15 #include "chrome/test/testing_profile.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 17 |
| 18 #if defined(OS_WIN) | |
| 19 #include "chrome/browser/renderer_host/render_widget_host_view.h" | |
| 20 #include "chrome/browser/tab_contents/navigation_controller.h" | |
| 21 #else | |
|
pink (ping after 24hrs)
2009/02/05 01:02:12
#elif defined(OS_POSIX)
| |
| 22 #include "chrome/common/temp_scaffolding_stubs.h" | |
| 23 #endif | |
| 24 | |
| 20 class TestWebContents; | 25 class TestWebContents; |
| 21 | 26 |
| 22 // This file provides a testing framework for mocking out the RenderProcessHost | 27 // This file provides a testing framework for mocking out the RenderProcessHost |
| 23 // layer. It allows you to test RenderViewHost, WebContents, | 28 // layer. It allows you to test RenderViewHost, WebContents, |
| 24 // NavigationController, and other layers above that without running an actual | 29 // NavigationController, and other layers above that without running an actual |
| 25 // renderer process. | 30 // renderer process. |
| 26 // | 31 // |
| 27 // To use, derive your test base class from RenderViewHostTestHarness. | 32 // To use, derive your test base class from RenderViewHostTestHarness. |
| 28 | 33 |
| 29 // TestRenderViewHostView ------------------------------------------------------ | 34 // TestRenderViewHostView ------------------------------------------------------ |
| 30 | 35 |
| 31 // Subclass the RenderViewHost's view so that we can call Show(), etc., | 36 // Subclass the RenderViewHost's view so that we can call Show(), etc., |
| 32 // without having side-effects. | 37 // without having side-effects. |
| 33 class TestRenderWidgetHostView : public RenderWidgetHostView { | 38 class TestRenderWidgetHostView : public RenderWidgetHostView { |
| 34 public: | 39 public: |
| 35 TestRenderWidgetHostView() : is_showing_(false) {} | 40 TestRenderWidgetHostView() : is_showing_(false) {} |
| 36 | 41 |
| 37 virtual RenderWidgetHost* GetRenderWidgetHost() const { return NULL; } | 42 virtual RenderWidgetHost* GetRenderWidgetHost() const { return NULL; } |
| 38 virtual void DidBecomeSelected() {} | 43 virtual void DidBecomeSelected() {} |
| 39 virtual void WasHidden() {} | 44 virtual void WasHidden() {} |
| 40 virtual void SetSize(const gfx::Size& size) {} | 45 virtual void SetSize(const gfx::Size& size) {} |
| 41 virtual gfx::NativeView GetPluginNativeView() { return NULL; } | 46 virtual gfx::NativeView GetPluginNativeView() { return NULL; } |
| 42 virtual void MovePluginWindows( | 47 virtual void MovePluginWindows( |
| 43 const std::vector<WebPluginGeometry>& plugin_window_moves) {} | 48 const std::vector<WebPluginGeometry>& plugin_window_moves) {} |
| 49 #if defined(OS_WIN) | |
| 44 virtual void ForwardMouseEventToRenderer(UINT message, | 50 virtual void ForwardMouseEventToRenderer(UINT message, |
| 45 WPARAM wparam, | 51 WPARAM wparam, |
| 46 LPARAM lparam) {} | 52 LPARAM lparam) {} |
| 53 #endif | |
| 47 virtual void Focus() {} | 54 virtual void Focus() {} |
| 48 virtual void Blur() {} | 55 virtual void Blur() {} |
| 49 virtual bool HasFocus() { return true; } | 56 virtual bool HasFocus() { return true; } |
| 50 virtual void AdvanceFocus(bool reverse) {} | 57 virtual void AdvanceFocus(bool reverse) {} |
| 51 virtual void Show() { is_showing_ = true; } | 58 virtual void Show() { is_showing_ = true; } |
| 52 virtual void Hide() { is_showing_ = false; } | 59 virtual void Hide() { is_showing_ = false; } |
| 53 virtual gfx::Rect GetViewBounds() const { return gfx::Rect(); } | 60 virtual gfx::Rect GetViewBounds() const { return gfx::Rect(); } |
| 54 virtual void SetIsLoading(bool is_loading) {} | 61 virtual void SetIsLoading(bool is_loading) {} |
| 55 virtual void UpdateCursor(const WebCursor& cursor) {} | 62 virtual void UpdateCursor(const WebCursor& cursor) {} |
| 56 virtual void UpdateCursorIfOverSelf() {} | 63 virtual void UpdateCursorIfOverSelf() {} |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 // We clean up the WebContents by calling CloseContents, which deletes itself. | 216 // We clean up the WebContents by calling CloseContents, which deletes itself. |
| 210 // This in turn causes the destruction of these other things. | 217 // This in turn causes the destruction of these other things. |
| 211 MockRenderProcessHost* process_; | 218 MockRenderProcessHost* process_; |
| 212 TestWebContents* contents_; | 219 TestWebContents* contents_; |
| 213 NavigationController* controller_; | 220 NavigationController* controller_; |
| 214 | 221 |
| 215 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); | 222 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); |
| 216 }; | 223 }; |
| 217 | 224 |
| 218 #endif // CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 225 #endif // CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
| OLD | NEW |