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

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

Issue 2895173002: Network traffic annotation added to browser unittests. (Closed)
Patch Set: One more file added. Created 3 years, 7 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
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/macros.h" 10 #include "base/macros.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Checks that redirects in main frame loads are not deferred. 241 // Checks that redirects in main frame loads are not deferred.
242 TEST_F(PrerenderResourceThrottleTest, RedirectMainFrame) { 242 TEST_F(PrerenderResourceThrottleTest, RedirectMainFrame) {
243 test_contents()->Start(); 243 test_contents()->Start();
244 RunEvents(); 244 RunEvents();
245 245
246 // Fake a request. 246 // Fake a request.
247 net::TestURLRequestContext url_request_context; 247 net::TestURLRequestContext url_request_context;
248 DeferredRedirectDelegate delegate; 248 DeferredRedirectDelegate delegate;
249 std::unique_ptr<net::URLRequest> request(url_request_context.CreateRequest( 249 std::unique_ptr<net::URLRequest> request(url_request_context.CreateRequest(
250 net::URLRequestMockHTTPJob::GetMockUrl("prerender/image-deferred.png"), 250 net::URLRequestMockHTTPJob::GetMockUrl("prerender/image-deferred.png"),
251 net::DEFAULT_PRIORITY, &delegate)); 251 net::DEFAULT_PRIORITY, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS));
252 content::ResourceRequestInfo::AllocateForTesting( 252 content::ResourceRequestInfo::AllocateForTesting(
253 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, NULL, kDefaultChildId, 253 request.get(), content::RESOURCE_TYPE_MAIN_FRAME, NULL, kDefaultChildId,
254 kDefaultRouteId, MSG_ROUTING_NONE, 254 kDefaultRouteId, MSG_ROUTING_NONE,
255 /*is_main_frame=*/true, 255 /*is_main_frame=*/true,
256 /*parent_is_main_frame=*/false, 256 /*parent_is_main_frame=*/false,
257 /*allow_download=*/true, 257 /*allow_download=*/true,
258 /*is_async=*/true, content::PREVIEWS_OFF); 258 /*is_async=*/true, content::PREVIEWS_OFF);
259 259
260 // Install a prerender throttle. 260 // Install a prerender throttle.
261 PrerenderResourceThrottle throttle(request.get()); 261 PrerenderResourceThrottle throttle(request.get());
(...skipping 15 matching lines...) Expand all
277 // prerender. 277 // prerender.
278 TEST_F(PrerenderResourceThrottleTest, RedirectSyncXHR) { 278 TEST_F(PrerenderResourceThrottleTest, RedirectSyncXHR) {
279 test_contents()->Start(); 279 test_contents()->Start();
280 RunEvents(); 280 RunEvents();
281 281
282 // Fake a request. 282 // Fake a request.
283 net::TestURLRequestContext url_request_context; 283 net::TestURLRequestContext url_request_context;
284 DeferredRedirectDelegate delegate; 284 DeferredRedirectDelegate delegate;
285 std::unique_ptr<net::URLRequest> request(url_request_context.CreateRequest( 285 std::unique_ptr<net::URLRequest> request(url_request_context.CreateRequest(
286 net::URLRequestMockHTTPJob::GetMockUrl("prerender/image-deferred.png"), 286 net::URLRequestMockHTTPJob::GetMockUrl("prerender/image-deferred.png"),
287 net::DEFAULT_PRIORITY, &delegate)); 287 net::DEFAULT_PRIORITY, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS));
288 content::ResourceRequestInfo::AllocateForTesting( 288 content::ResourceRequestInfo::AllocateForTesting(
289 request.get(), content::RESOURCE_TYPE_XHR, NULL, kDefaultChildId, 289 request.get(), content::RESOURCE_TYPE_XHR, NULL, kDefaultChildId,
290 kDefaultRouteId, MSG_ROUTING_NONE, 290 kDefaultRouteId, MSG_ROUTING_NONE,
291 /*is_main_frame=*/false, 291 /*is_main_frame=*/false,
292 /*parent_is_main_frame=*/false, 292 /*parent_is_main_frame=*/false,
293 /*allow_download=*/true, 293 /*allow_download=*/true,
294 /*is_async=*/false, content::PREVIEWS_OFF); 294 /*is_async=*/false, content::PREVIEWS_OFF);
295 295
296 // Install a prerender throttle. 296 // Install a prerender throttle.
297 PrerenderResourceThrottle throttle(request.get()); 297 PrerenderResourceThrottle throttle(request.get());
298 delegate.SetThrottle(&throttle); 298 delegate.SetThrottle(&throttle);
299 299
300 // Start the request and wait for a redirect. 300 // Start the request and wait for a redirect.
301 request->Start(); 301 request->Start();
302 delegate.Run(); 302 delegate.Run();
303 // This calls WillRedirectRequestOnUI(). 303 // This calls WillRedirectRequestOnUI().
304 RunEvents(); 304 RunEvents();
305 305
306 // We should have cancelled the prerender. 306 // We should have cancelled the prerender.
307 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT, 307 EXPECT_EQ(FINAL_STATUS_BAD_DEFERRED_REDIRECT,
308 test_contents()->final_status()); 308 test_contents()->final_status());
309 309
310 // Cleanup work so the prerender is gone. 310 // Cleanup work so the prerender is gone.
311 test_contents()->Cancel(); 311 test_contents()->Cancel();
312 RunEvents(); 312 RunEvents();
313 } 313 }
314 314
315 } // namespace prerender 315 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698