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

Side by Side Diff: chrome/browser/captive_portal/captive_portal_browsertest.cc

Issue 541743002: Move url_request_mock_http_job to net/test/url_request/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 3 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 24 matching lines...) Expand all
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/navigation_controller.h" 36 #include "content/public/browser/navigation_controller.h"
37 #include "content/public/browser/notification_observer.h" 37 #include "content/public/browser/notification_observer.h"
38 #include "content/public/browser/notification_registrar.h" 38 #include "content/public/browser/notification_registrar.h"
39 #include "content/public/browser/notification_service.h" 39 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/notification_types.h" 40 #include "content/public/browser/notification_types.h"
41 #include "content/public/browser/render_frame_host.h" 41 #include "content/public/browser/render_frame_host.h"
42 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
43 #include "content/public/common/url_constants.h" 43 #include "content/public/common/url_constants.h"
44 #include "content/test/net/url_request_failed_job.h" 44 #include "content/test/net/url_request_failed_job.h"
45 #include "content/test/net/url_request_mock_http_job.h"
46 #include "net/base/net_errors.h" 45 #include "net/base/net_errors.h"
47 #include "net/http/transport_security_state.h" 46 #include "net/http/transport_security_state.h"
47 #include "net/test/url_request/url_request_mock_http_job.h"
48 #include "net/url_request/url_request.h" 48 #include "net/url_request/url_request.h"
49 #include "net/url_request/url_request_context.h" 49 #include "net/url_request/url_request_context.h"
50 #include "net/url_request/url_request_context_getter.h" 50 #include "net/url_request/url_request_context_getter.h"
51 #include "net/url_request/url_request_filter.h" 51 #include "net/url_request/url_request_filter.h"
52 #include "net/url_request/url_request_job.h" 52 #include "net/url_request/url_request_job.h"
53 #include "net/url_request/url_request_status.h" 53 #include "net/url_request/url_request_status.h"
54 #include "testing/gtest/include/gtest/gtest.h" 54 #include "testing/gtest/include/gtest/gtest.h"
55 55
56 using captive_portal::CaptivePortalResult; 56 using captive_portal::CaptivePortalResult;
57 using content::BrowserThread; 57 using content::BrowserThread;
58 using content::URLRequestFailedJob; 58 using content::URLRequestFailedJob;
59 using content::URLRequestMockHTTPJob; 59 using net::URLRequestMockHTTPJob;
60 using content::WebContents; 60 using content::WebContents;
61 61
62 namespace { 62 namespace {
63 63
64 // Path of the fake login page, when using the TestServer. 64 // Path of the fake login page, when using the TestServer.
65 const char* const kTestServerLoginPath = "files/captive_portal/login.html"; 65 const char* const kTestServerLoginPath = "files/captive_portal/login.html";
66 66
67 // Path of a page with an iframe that has a mock SSL timeout, when using the 67 // Path of a page with an iframe that has a mock SSL timeout, when using the
68 // TestServer. 68 // TestServer.
69 const char* const kTestServerIframeTimeoutPath = 69 const char* const kTestServerIframeTimeoutPath =
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 if (request->url() == GURL(kMockHttpsUrl) || 421 if (request->url() == GURL(kMockHttpsUrl) ||
422 request->url() == GURL(kMockHttpsUrl2)) { 422 request->url() == GURL(kMockHttpsUrl2)) {
423 if (behind_captive_portal_) 423 if (behind_captive_portal_)
424 return new URLRequestTimeoutOnDemandJob(request, network_delegate); 424 return new URLRequestTimeoutOnDemandJob(request, network_delegate);
425 // Once logged in to the portal, HTTPS requests return the page that was 425 // Once logged in to the portal, HTTPS requests return the page that was
426 // actually requested. 426 // actually requested.
427 return new URLRequestMockHTTPJob( 427 return new URLRequestMockHTTPJob(
428 request, 428 request,
429 network_delegate, 429 network_delegate,
430 root_http.Append(FILE_PATH_LITERAL("title2.html"))); 430 root_http.Append(FILE_PATH_LITERAL("title2.html")),
431 content::BrowserThread::GetBlockingPool());
431 } else if (request->url() == GURL(kMockHttpsQuickTimeoutUrl)) { 432 } else if (request->url() == GURL(kMockHttpsQuickTimeoutUrl)) {
432 if (behind_captive_portal_) 433 if (behind_captive_portal_)
433 return new URLRequestFailedJob( 434 return new URLRequestFailedJob(
434 request, network_delegate, net::ERR_CONNECTION_TIMED_OUT); 435 request, network_delegate, net::ERR_CONNECTION_TIMED_OUT);
435 // Once logged in to the portal, HTTPS requests return the page that was 436 // Once logged in to the portal, HTTPS requests return the page that was
436 // actually requested. 437 // actually requested.
437 return new URLRequestMockHTTPJob( 438 return new URLRequestMockHTTPJob(
438 request, 439 request,
439 network_delegate, 440 network_delegate,
440 root_http.Append(FILE_PATH_LITERAL("title2.html"))); 441 root_http.Append(FILE_PATH_LITERAL("title2.html")),
442 content::BrowserThread::GetBlockingPool());
441 } else { 443 } else {
442 // The URL should be the captive portal test URL. 444 // The URL should be the captive portal test URL.
443 EXPECT_TRUE(GURL(kMockCaptivePortalTestUrl) == request->url() || 445 EXPECT_TRUE(GURL(kMockCaptivePortalTestUrl) == request->url() ||
444 GURL(kMockCaptivePortal511Url) == request->url()); 446 GURL(kMockCaptivePortal511Url) == request->url());
445 447
446 if (behind_captive_portal_) { 448 if (behind_captive_portal_) {
447 // Prior to logging in to the portal, the HTTP test URLs are intercepted 449 // Prior to logging in to the portal, the HTTP test URLs are intercepted
448 // by the captive portal. 450 // by the captive portal.
449 if (GURL(kMockCaptivePortal511Url) == request->url()) { 451 if (GURL(kMockCaptivePortal511Url) == request->url()) {
450 return new URLRequestMockHTTPJob( 452 return new URLRequestMockHTTPJob(
451 request, 453 request,
452 network_delegate, 454 network_delegate,
453 root_http.Append(FILE_PATH_LITERAL("captive_portal/page511.html"))); 455 root_http.Append(FILE_PATH_LITERAL("captive_portal/page511.html")),
456 content::BrowserThread::GetBlockingPool());
454 } 457 }
455 return new URLRequestMockHTTPJob( 458 return new URLRequestMockHTTPJob(
456 request, 459 request,
457 network_delegate, 460 network_delegate,
458 root_http.Append(FILE_PATH_LITERAL("captive_portal/login.html"))); 461 root_http.Append(FILE_PATH_LITERAL("captive_portal/login.html")),
462 content::BrowserThread::GetBlockingPool());
459 } 463 }
460 464
461 // After logging in to the portal, the test URLs return a 204 response. 465 // After logging in to the portal, the test URLs return a 204 response.
462 return new URLRequestMockHTTPJob( 466 return new URLRequestMockHTTPJob(
463 request, 467 request,
464 network_delegate, 468 network_delegate,
465 root_http.Append(FILE_PATH_LITERAL("captive_portal/page204.html"))); 469 root_http.Append(FILE_PATH_LITERAL("captive_portal/page204.html")),
470 content::BrowserThread::GetBlockingPool());
466 } 471 }
467 } 472 }
468 473
469 // Creates a server-side redirect for use with the TestServer. 474 // Creates a server-side redirect for use with the TestServer.
470 std::string CreateServerRedirect(const std::string& dest_url) { 475 std::string CreateServerRedirect(const std::string& dest_url) {
471 const char* const kServerRedirectBase = "server-redirect?"; 476 const char* const kServerRedirectBase = "server-redirect?";
472 return kServerRedirectBase + dest_url; 477 return kServerRedirectBase + dest_url;
473 } 478 }
474 479
475 // Returns the total number of loading tabs across all Browsers, for all 480 // Returns the total number of loading tabs across all Browsers, for all
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 content::BrowserThread::PostTask( 2199 content::BrowserThread::PostTask(
2195 content::BrowserThread::IO, FROM_HERE, 2200 content::BrowserThread::IO, FROM_HERE,
2196 base::Bind(&AddHstsHost, 2201 base::Bind(&AddHstsHost,
2197 make_scoped_refptr(browser()->profile()->GetRequestContext()), 2202 make_scoped_refptr(browser()->profile()->GetRequestContext()),
2198 http_timeout_url.host())); 2203 http_timeout_url.host()));
2199 2204
2200 SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1); 2205 SlowLoadBehindCaptivePortal(browser(), true, http_timeout_url, 1, 1);
2201 Login(browser(), 1, 0); 2206 Login(browser(), 1, 0);
2202 FailLoadsAfterLogin(browser(), 1); 2207 FailLoadsAfterLogin(browser(), 1);
2203 } 2208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698