| 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_PUBLIC_TEST_RENDER_VIEW_TEST_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ |
| 6 #define CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ | 6 #define CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 namespace content { | 43 namespace content { |
| 44 class ContentBrowserClient; | 44 class ContentBrowserClient; |
| 45 class ContentClient; | 45 class ContentClient; |
| 46 class ContentRendererClient; | 46 class ContentRendererClient; |
| 47 class FakeCompositorDependencies; | 47 class FakeCompositorDependencies; |
| 48 class MockRenderProcess; | 48 class MockRenderProcess; |
| 49 class PageState; | 49 class PageState; |
| 50 class RendererMainPlatformDelegate; | 50 class RendererMainPlatformDelegate; |
| 51 class RendererBlinkPlatformImplNoSandboxImpl; | 51 class RendererBlinkPlatformImplTestOverrideImpl; |
| 52 class RenderView; | 52 class RenderView; |
| 53 | 53 |
| 54 class RenderViewTest : public testing::Test, blink::WebLeakDetectorClient { | 54 class RenderViewTest : public testing::Test, blink::WebLeakDetectorClient { |
| 55 public: | 55 public: |
| 56 // A special BlinkPlatformImpl class for getting rid off the dependency to the | 56 // A special BlinkPlatformImpl class with overrides that are useful for |
| 57 // sandbox, which is not available in RenderViewTest. | 57 // RenderViewTest. |
| 58 class RendererBlinkPlatformImplNoSandbox { | 58 class RendererBlinkPlatformImplTestOverride { |
| 59 public: | 59 public: |
| 60 RendererBlinkPlatformImplNoSandbox(); | 60 RendererBlinkPlatformImplTestOverride(); |
| 61 ~RendererBlinkPlatformImplNoSandbox(); | 61 ~RendererBlinkPlatformImplTestOverride(); |
| 62 blink::Platform* Get() const; | 62 blink::Platform* Get() const; |
| 63 void Shutdown(); | 63 void Shutdown(); |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler_; | 66 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler_; |
| 67 scoped_ptr<RendererBlinkPlatformImplNoSandboxImpl> blink_platform_impl_; | 67 scoped_ptr<RendererBlinkPlatformImplTestOverrideImpl> blink_platform_impl_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 RenderViewTest(); | 70 RenderViewTest(); |
| 71 ~RenderViewTest() override; | 71 ~RenderViewTest() override; |
| 72 | 72 |
| 73 protected: | 73 protected: |
| 74 // Spins the message loop to process all messages that are currently pending. | 74 // Spins the message loop to process all messages that are currently pending. |
| 75 void ProcessPendingMessages(); | 75 void ProcessPendingMessages(); |
| 76 | 76 |
| 77 // Returns a pointer to the main frame. | 77 // Returns a pointer to the main frame. |
| 78 blink::WebLocalFrame* GetMainFrame(); | 78 blink::WebLocalFrame* GetMainFrame(); |
| 79 | 79 |
| 80 // Executes the given JavaScript in the context of the main frame. The input | 80 // Executes the given JavaScript in the context of the main frame. The input |
| 81 // is a NULL-terminated UTF-8 string. | 81 // is a NULL-terminated UTF-8 string. |
| 82 void ExecuteJavaScriptForTests(const char* js); | 82 void ExecuteJavaScriptForTests(const char* js); |
| 83 | 83 |
| 84 // Executes the given JavaScript and sets the int value it evaluates to in | 84 // Executes the given JavaScript and sets the int value it evaluates to in |
| 85 // |result|. | 85 // |result|. |
| 86 // Returns true if the JavaScript was evaluated correctly to an int value, | 86 // Returns true if the JavaScript was evaluated correctly to an int value, |
| 87 // false otherwise. | 87 // false otherwise. |
| 88 bool ExecuteJavaScriptAndReturnIntValue(const base::string16& script, | 88 bool ExecuteJavaScriptAndReturnIntValue(const base::string16& script, |
| 89 int* result); | 89 int* result); |
| 90 | 90 |
| 91 // Loads the given HTML into the main frame as a data: URL and blocks until | 91 // Loads |html| into the main frame as a data: URL and blocks until the |
| 92 // the navigation is committed. | 92 // navigation is committed. |
| 93 void LoadHTML(const char* html); | 93 void LoadHTML(const char* html); |
| 94 | 94 |
| 95 // Pretends to load |url| into the main frame, but substitutes |html| for the |
| 96 // response body (and does not include any response headers). This can be used |
| 97 // instead of LoadHTML for tests that cannot use a data: url (for example if |
| 98 // document.location needs to be set to something specific.) |
| 99 void LoadHTMLWithUrlOverride(const char* html, const char* url); |
| 100 |
| 95 // Returns the current PageState. | 101 // Returns the current PageState. |
| 96 // In OOPIF enabled modes, this returns a PageState object for the main frame. | 102 // In OOPIF enabled modes, this returns a PageState object for the main frame. |
| 97 PageState GetCurrentPageState(); | 103 PageState GetCurrentPageState(); |
| 98 | 104 |
| 99 // Navigates the main frame back or forward in session history and commits. | 105 // Navigates the main frame back or forward in session history and commits. |
| 100 // The caller must capture a PageState for the target page. | 106 // The caller must capture a PageState for the target page. |
| 101 void GoBack(const PageState& state); | 107 void GoBack(const PageState& state); |
| 102 void GoForward(const PageState& state); | 108 void GoForward(const PageState& state); |
| 103 | 109 |
| 104 // Sends one native key event over IPC. | 110 // Sends one native key event over IPC. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 187 |
| 182 // blink::WebLeakDetectorClient implementation. | 188 // blink::WebLeakDetectorClient implementation. |
| 183 void onLeakDetectionComplete(const Result& result) override; | 189 void onLeakDetectionComplete(const Result& result) override; |
| 184 | 190 |
| 185 base::MessageLoop msg_loop_; | 191 base::MessageLoop msg_loop_; |
| 186 scoped_ptr<FakeCompositorDependencies> compositor_deps_; | 192 scoped_ptr<FakeCompositorDependencies> compositor_deps_; |
| 187 scoped_ptr<MockRenderProcess> mock_process_; | 193 scoped_ptr<MockRenderProcess> mock_process_; |
| 188 // We use a naked pointer because we don't want to expose RenderViewImpl in | 194 // We use a naked pointer because we don't want to expose RenderViewImpl in |
| 189 // the embedder's namespace. | 195 // the embedder's namespace. |
| 190 RenderView* view_; | 196 RenderView* view_; |
| 191 RendererBlinkPlatformImplNoSandbox blink_platform_impl_; | 197 RendererBlinkPlatformImplTestOverride blink_platform_impl_; |
| 192 scoped_ptr<ContentClient> content_client_; | 198 scoped_ptr<ContentClient> content_client_; |
| 193 scoped_ptr<ContentBrowserClient> content_browser_client_; | 199 scoped_ptr<ContentBrowserClient> content_browser_client_; |
| 194 scoped_ptr<ContentRendererClient> content_renderer_client_; | 200 scoped_ptr<ContentRendererClient> content_renderer_client_; |
| 195 scoped_ptr<MockRenderThread> render_thread_; | 201 scoped_ptr<MockRenderThread> render_thread_; |
| 196 | 202 |
| 197 // Used to setup the process so renderers can run. | 203 // Used to setup the process so renderers can run. |
| 198 scoped_ptr<RendererMainPlatformDelegate> platform_; | 204 scoped_ptr<RendererMainPlatformDelegate> platform_; |
| 199 scoped_ptr<MainFunctionParams> params_; | 205 scoped_ptr<MainFunctionParams> params_; |
| 200 scoped_ptr<base::CommandLine> command_line_; | 206 scoped_ptr<base::CommandLine> command_line_; |
| 201 | 207 |
| 202 // For Mojo. | 208 // For Mojo. |
| 203 scoped_ptr<base::TestIOThread> test_io_thread_; | 209 scoped_ptr<base::TestIOThread> test_io_thread_; |
| 204 scoped_ptr<mojo::test::ScopedIPCSupport> ipc_support_; | 210 scoped_ptr<mojo::test::ScopedIPCSupport> ipc_support_; |
| 205 | 211 |
| 206 #if defined(OS_MACOSX) | 212 #if defined(OS_MACOSX) |
| 207 scoped_ptr<base::mac::ScopedNSAutoreleasePool> autorelease_pool_; | 213 scoped_ptr<base::mac::ScopedNSAutoreleasePool> autorelease_pool_; |
| 208 #endif | 214 #endif |
| 209 | 215 |
| 210 private: | 216 private: |
| 211 void GoToOffset(int offset, const PageState& state); | 217 void GoToOffset(int offset, const PageState& state); |
| 212 }; | 218 }; |
| 213 | 219 |
| 214 } // namespace content | 220 } // namespace content |
| 215 | 221 |
| 216 #endif // CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ | 222 #endif // CONTENT_PUBLIC_TEST_RENDER_VIEW_TEST_H_ |
| OLD | NEW |