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 #include "content/public/test/render_view_fake_resources_test.h" | 5 #include "content/public/test/render_view_fake_resources_test.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 body = "content not found"; | 156 body = "content not found"; |
157 } else { | 157 } else { |
158 headers = "HTTP/1.1 200 OK\0Content-Type:text/html\0\0"; | 158 headers = "HTTP/1.1 200 OK\0Content-Type:text/html\0\0"; |
159 body = it->second; | 159 body = it->second; |
160 } | 160 } |
161 | 161 |
162 ResourceResponseHead response_head; | 162 ResourceResponseHead response_head; |
163 response_head.headers = new net::HttpResponseHeaders(headers); | 163 response_head.headers = new net::HttpResponseHeaders(headers); |
164 response_head.mime_type = "text/html"; | 164 response_head.mime_type = "text/html"; |
165 ASSERT_TRUE(channel_->Send(new ResourceMsg_ReceivedResponse( | 165 ASSERT_TRUE(channel_->Send(new ResourceMsg_ReceivedResponse( |
166 message.routing_id(), request_id, response_head))); | 166 request_id, response_head))); |
167 | 167 |
168 base::SharedMemory shared_memory; | 168 base::SharedMemory shared_memory; |
169 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(body.size())); | 169 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(body.size())); |
170 memcpy(shared_memory.memory(), body.data(), body.size()); | 170 memcpy(shared_memory.memory(), body.data(), body.size()); |
171 | 171 |
172 base::SharedMemoryHandle handle; | 172 base::SharedMemoryHandle handle; |
173 ASSERT_TRUE(shared_memory.GiveToProcess(base::Process::Current().handle(), | 173 ASSERT_TRUE(shared_memory.GiveToProcess(base::Process::Current().handle(), |
174 &handle)); | 174 &handle)); |
175 | 175 |
176 ASSERT_TRUE(channel_->Send(new ResourceMsg_SetDataBuffer( | 176 ASSERT_TRUE(channel_->Send(new ResourceMsg_SetDataBuffer( |
177 message.routing_id(), | |
178 request_id, | 177 request_id, |
179 handle, | 178 handle, |
180 body.size(), | 179 body.size(), |
181 0))); | 180 0))); |
182 | 181 |
183 ASSERT_TRUE(channel_->Send(new ResourceMsg_DataReceived( | 182 ASSERT_TRUE(channel_->Send(new ResourceMsg_DataReceived( |
184 message.routing_id(), | |
185 request_id, | 183 request_id, |
186 0, | 184 0, |
187 body.size(), | 185 body.size(), |
188 body.size()))); | 186 body.size()))); |
189 | 187 |
190 ASSERT_TRUE(channel_->Send(new ResourceMsg_RequestComplete( | 188 ASSERT_TRUE(channel_->Send(new ResourceMsg_RequestComplete( |
191 message.routing_id(), | |
192 request_id, | 189 request_id, |
193 net::OK, | 190 net::OK, |
194 false, | 191 false, |
195 std::string(), | 192 std::string(), |
196 base::TimeTicks()))); | 193 base::TimeTicks()))); |
197 } | 194 } |
198 | 195 |
199 void RenderViewFakeResourcesTest::OnRenderViewReady() { | 196 void RenderViewFakeResourcesTest::OnRenderViewReady() { |
200 // Grab a pointer to the new view using RenderViewVisitor. | 197 // Grab a pointer to the new view using RenderViewVisitor. |
201 ASSERT_TRUE(!view_); | 198 ASSERT_TRUE(!view_); |
(...skipping 16 matching lines...) Expand all Loading... |
218 params.url = GURL(history_item.urlString()); | 215 params.url = GURL(history_item.urlString()); |
219 params.transition = PAGE_TRANSITION_FORWARD_BACK; | 216 params.transition = PAGE_TRANSITION_FORWARD_BACK; |
220 params.page_state = HistoryItemToPageState(history_item); | 217 params.page_state = HistoryItemToPageState(history_item); |
221 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 218 params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
222 params.request_time = base::Time::Now(); | 219 params.request_time = base::Time::Now(); |
223 channel_->Send(new ViewMsg_Navigate(impl->routing_id(), params)); | 220 channel_->Send(new ViewMsg_Navigate(impl->routing_id(), params)); |
224 message_loop_.Run(); | 221 message_loop_.Run(); |
225 } | 222 } |
226 | 223 |
227 } // namespace content | 224 } // namespace content |
OLD | NEW |