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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 content::MockContentRendererClient content_renderer_client_; | 127 content::MockContentRendererClient 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 RenderThreadImpl* 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 content::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 #endif // CONTENT_TEST_RENDER_VIEW_FAKE_RESOURCES_TEST_H_ | 146 #endif // CONTENT_TEST_RENDER_VIEW_FAKE_RESOURCES_TEST_H_ |
OLD | NEW |