OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // RenderViewFakeResourcesTest can be used as a base class for tests that need | 5 // RenderViewFakeResourcesTest can be used as a base class for tests that need |
6 // to simulate loading network resources (such as http: urls) into a | 6 // to simulate loading network resources (such as http: urls) into a |
7 // RenderView. It does this by handling the relevant IPC messages that the | 7 // RenderView. It does this by handling the relevant IPC messages that the |
8 // renderer would normally send to the browser, and responding with static | 8 // renderer would normally send to the browser, and responding with static |
9 // content from an internal map. A request for a url that is not in the map | 9 // content from an internal map. A request for a url that is not in the map |
10 // will return a 404. Currently, content is always returned as text/html, and | 10 // will return a 404. Currently, content is always returned as text/html, and |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 #include "base/memory/scoped_ptr.h" | 48 #include "base/memory/scoped_ptr.h" |
49 #include "base/message_loop.h" | 49 #include "base/message_loop.h" |
50 #include "chrome/renderer/chrome_content_renderer_client.h" | 50 #include "chrome/renderer/chrome_content_renderer_client.h" |
51 #include "content/public/renderer/render_view_visitor.h" | 51 #include "content/public/renderer/render_view_visitor.h" |
52 #include "ipc/ipc_channel.h" | 52 #include "ipc/ipc_channel.h" |
53 #include "testing/gtest/include/gtest/gtest.h" | 53 #include "testing/gtest/include/gtest/gtest.h" |
54 | 54 |
55 class MockRenderProcess; | 55 class MockRenderProcess; |
56 class RendererMainPlatformDelegate; | 56 class RendererMainPlatformDelegate; |
57 class RenderThread; | 57 class RenderThreadImpl; |
58 class RenderView; | 58 class RenderView; |
59 struct ResourceHostMsg_Request; | 59 struct ResourceHostMsg_Request; |
60 | 60 |
61 namespace WebKit { | 61 namespace WebKit { |
62 class WebFrame; | 62 class WebFrame; |
63 class WebHistoryItem; | 63 class WebHistoryItem; |
64 } | 64 } |
65 | 65 |
66 namespace safe_browsing { | 66 namespace safe_browsing { |
67 | 67 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Notification that the render view we've created is ready to use. | 121 // Notification that the render view we've created is ready to use. |
122 void OnRenderViewReady(); | 122 void OnRenderViewReady(); |
123 | 123 |
124 static const int32 kViewId; // arbitrary id for our testing view | 124 static const int32 kViewId; // arbitrary id for our testing view |
125 | 125 |
126 MessageLoopForIO message_loop_; | 126 MessageLoopForIO message_loop_; |
127 chrome::ChromeContentRendererClient chrome_content_renderer_client_; | 127 chrome::ChromeContentRendererClient chrome_content_renderer_client_; |
128 // channel that the renderer uses to talk to the browser. | 128 // channel that the renderer uses to talk to the browser. |
129 // For this test, we will handle the browser end of the channel. | 129 // For this test, we will handle the browser end of the channel. |
130 scoped_ptr<IPC::Channel> channel_; | 130 scoped_ptr<IPC::Channel> channel_; |
131 RenderThread* render_thread_; // owned by mock_process_ | 131 RenderThreadImpl* render_thread_; // owned by mock_process_ |
132 scoped_ptr<MockRenderProcess> mock_process_; | 132 scoped_ptr<MockRenderProcess> mock_process_; |
133 RenderView* view_; // not owned, deletes itself on close | 133 RenderView* view_; // not owned, deletes itself on close |
134 | 134 |
135 // Map of url -> response body for network requests from the renderer. | 135 // Map of url -> response body for network requests from the renderer. |
136 // Any urls not in this map are served a 404 error. | 136 // Any urls not in this map are served a 404 error. |
137 std::map<std::string, std::string> responses_; | 137 std::map<std::string, std::string> responses_; |
138 | 138 |
139 private: | 139 private: |
140 // A helper for GoBack and GoForward. | 140 // A helper for GoBack and GoForward. |
141 void GoToOffset(int offset, const WebKit::WebHistoryItem& history_item); | 141 void GoToOffset(int offset, const WebKit::WebHistoryItem& history_item); |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(RenderViewFakeResourcesTest); | 143 DISALLOW_COPY_AND_ASSIGN(RenderViewFakeResourcesTest); |
144 }; | 144 }; |
145 | 145 |
146 } // namespace safe_browsing | 146 } // namespace safe_browsing |
147 | 147 |
148 #endif // CHROME_RENDERER_SAFE_BROWSING_RENDER_VIEW_FAKE_RESOURCES_TEST_H_ | 148 #endif // CHROME_RENDERER_SAFE_BROWSING_RENDER_VIEW_FAKE_RESOURCES_TEST_H_ |
OLD | NEW |