Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1667)

Side by Side Diff: chrome/browser/prerender/prerender_resource_throttle_unittest.cc

Issue 1391423002: net: Remove FilePath version of URLRequestMockHTTPJob::GetMockUrl(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke review Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/unload_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <set> 5 #include <set>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 base::MessageLoopForIO message_loop_; 197 base::MessageLoopForIO message_loop_;
198 content::TestBrowserThread ui_thread_; 198 content::TestBrowserThread ui_thread_;
199 content::TestBrowserThread io_thread_; 199 content::TestBrowserThread io_thread_;
200 200
201 TestPrerenderManager prerender_manager_; 201 TestPrerenderManager prerender_manager_;
202 TestPrerenderContents test_contents_; 202 TestPrerenderContents test_contents_;
203 }; 203 };
204 204
205 // Checks that deferred redirects are throttled and resumed correctly. 205 // Checks that deferred redirects are throttled and resumed correctly.
206 TEST_F(PrerenderResourceThrottleTest, RedirectResume) { 206 TEST_F(PrerenderResourceThrottleTest, RedirectResume) {
207 const base::FilePath::CharType kRedirectPath[] =
208 FILE_PATH_LITERAL("prerender/image-deferred.png");
209
210 test_contents()->Start(); 207 test_contents()->Start();
211 RunEvents(); 208 RunEvents();
212 209
213 // Fake a request. 210 // Fake a request.
214 net::TestURLRequestContext url_request_context; 211 net::TestURLRequestContext url_request_context;
215 DeferredRedirectDelegate delegate; 212 DeferredRedirectDelegate delegate;
216 scoped_ptr<net::URLRequest> request(url_request_context.CreateRequest( 213 scoped_ptr<net::URLRequest> request(url_request_context.CreateRequest(
217 net::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), 214 net::URLRequestMockHTTPJob::GetMockUrl("prerender/image-deferred.png"),
218 net::DEFAULT_PRIORITY, 215 net::DEFAULT_PRIORITY,
219 &delegate)); 216 &delegate));
220 content::ResourceRequestInfo::AllocateForTesting( 217 content::ResourceRequestInfo::AllocateForTesting(
221 request.get(), 218 request.get(),
222 content::RESOURCE_TYPE_IMAGE, 219 content::RESOURCE_TYPE_IMAGE,
223 NULL, 220 NULL,
224 kDefaultChildId, 221 kDefaultChildId,
225 kDefaultRouteId, 222 kDefaultRouteId,
226 MSG_ROUTING_NONE, 223 MSG_ROUTING_NONE,
227 false, // is_main_frame 224 false, // is_main_frame
(...skipping 15 matching lines...) Expand all
243 // Display the prerendered RenderView and wait for the throttle to 240 // Display the prerendered RenderView and wait for the throttle to
244 // notice. 241 // notice.
245 test_contents()->Use(); 242 test_contents()->Use();
246 delegate.Run(); 243 delegate.Run();
247 EXPECT_TRUE(delegate.resume_called()); 244 EXPECT_TRUE(delegate.resume_called());
248 EXPECT_FALSE(delegate.cancel_called()); 245 EXPECT_FALSE(delegate.cancel_called());
249 } 246 }
250 247
251 // Checks that redirects in main frame loads are not deferred. 248 // Checks that redirects in main frame loads are not deferred.
252 TEST_F(PrerenderResourceThrottleTest, RedirectMainFrame) { 249 TEST_F(PrerenderResourceThrottleTest, RedirectMainFrame) {
253 const base::FilePath::CharType kRedirectPath[] =
254 FILE_PATH_LITERAL("prerender/image-deferred.png");
255
256 test_contents()->Start(); 250 test_contents()->Start();
257 RunEvents(); 251 RunEvents();
258 252
259 // Fake a request. 253 // Fake a request.
260 net::TestURLRequestContext url_request_context; 254 net::TestURLRequestContext url_request_context;
261 DeferredRedirectDelegate delegate; 255 DeferredRedirectDelegate delegate;
262 scoped_ptr<net::URLRequest> request(url_request_context.CreateRequest( 256 scoped_ptr<net::URLRequest> request(url_request_context.CreateRequest(
263 net::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), 257 net::URLRequestMockHTTPJob::GetMockUrl("prerender/image-deferred.png"),
264 net::DEFAULT_PRIORITY, 258 net::DEFAULT_PRIORITY,
265 &delegate)); 259 &delegate));
266 content::ResourceRequestInfo::AllocateForTesting( 260 content::ResourceRequestInfo::AllocateForTesting(
267 request.get(), 261 request.get(),
268 content::RESOURCE_TYPE_MAIN_FRAME, 262 content::RESOURCE_TYPE_MAIN_FRAME,
269 NULL, 263 NULL,
270 kDefaultChildId, 264 kDefaultChildId,
271 kDefaultRouteId, 265 kDefaultRouteId,
272 MSG_ROUTING_NONE, 266 MSG_ROUTING_NONE,
273 true, // is_main_frame 267 true, // is_main_frame
(...skipping 13 matching lines...) Expand all
287 RunEvents(); 281 RunEvents();
288 282
289 // Cleanup work so the prerender is gone. 283 // Cleanup work so the prerender is gone.
290 test_contents()->Cancel(); 284 test_contents()->Cancel();
291 RunEvents(); 285 RunEvents();
292 } 286 }
293 287
294 // Checks that attempting to defer a synchronous request aborts the 288 // Checks that attempting to defer a synchronous request aborts the
295 // prerender. 289 // prerender.
296 TEST_F(PrerenderResourceThrottleTest, RedirectSyncXHR) { 290 TEST_F(PrerenderResourceThrottleTest, RedirectSyncXHR) {
297 const base::FilePath::CharType kRedirectPath[] =
298 FILE_PATH_LITERAL("prerender/image-deferred.png");
299
300 test_contents()->Start(); 291 test_contents()->Start();
301 RunEvents(); 292 RunEvents();
302 293
303 // Fake a request. 294 // Fake a request.
304 net::TestURLRequestContext url_request_context; 295 net::TestURLRequestContext url_request_context;
305 DeferredRedirectDelegate delegate; 296 DeferredRedirectDelegate delegate;
306 scoped_ptr<net::URLRequest> request(url_request_context.CreateRequest( 297 scoped_ptr<net::URLRequest> request(url_request_context.CreateRequest(
307 net::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(kRedirectPath)), 298 net::URLRequestMockHTTPJob::GetMockUrl("prerender/image-deferred.png"),
308 net::DEFAULT_PRIORITY, 299 net::DEFAULT_PRIORITY,
309 &delegate)); 300 &delegate));
310 content::ResourceRequestInfo::AllocateForTesting( 301 content::ResourceRequestInfo::AllocateForTesting(
311 request.get(), 302 request.get(),
312 content::RESOURCE_TYPE_XHR, 303 content::RESOURCE_TYPE_XHR,
313 NULL, 304 NULL,
314 kDefaultChildId, 305 kDefaultChildId,
315 kDefaultRouteId, 306 kDefaultRouteId,
316 MSG_ROUTING_NONE, 307 MSG_ROUTING_NONE,
317 false, // is_main_frame 308 false, // is_main_frame
(...skipping 14 matching lines...) Expand all
332 // We should have cancelled the prerender. 323 // We should have cancelled the prerender.
333 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT, 324 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT,
334 test_contents()->final_status()); 325 test_contents()->final_status());
335 326
336 // Cleanup work so the prerender is gone. 327 // Cleanup work so the prerender is gone.
337 test_contents()->Cancel(); 328 test_contents()->Cancel();
338 RunEvents(); 329 RunEvents();
339 } 330 }
340 331
341 } // namespace prerender 332 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/unload_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698