#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/google/core/browser/google_util.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
-#include "content/test/net/url_request_failed_job.h"
-#include "content/test/net/url_request_mock_http_job.h"
-#include "grit/generated_resources.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/http/failing_http_transaction_factory.h"
#include "net/http/http_cache.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
+#include "net/test/url_request/url_request_failed_job.h"
+#include "net/test/url_request/url_request_mock_http_job.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_filter.h"
using content::BrowserThread;
using content::NavigationController;
-using content::URLRequestFailedJob;
+using net::URLRequestFailedJob;
using net::URLRequestTestJob;
namespace {
void ToggleHelpBox(Browser* browser) {
EXPECT_TRUE(content::ExecuteScript(
browser->tab_strip_model()->GetActiveWebContents(),
- "document.getElementById('more-less-button').click();"));
+ "document.getElementById('details-button').click();"));
}
// Returns true if |browser| is displaying the text representation of
// |error_code| on the current page.
bool WARN_UNUSED_RESULT IsDisplayingNetError(Browser* browser,
net::Error error_code) {
- // Get the error as a string, and remove the leading "net::", which is not
- // included on error pages.
- std::string error_string(net::ErrorToString(error_code));
- DCHECK(StartsWithASCII(error_string, "net::", true));
- error_string.erase(0, 5);
-
- return IsDisplayingText(browser, error_string);
+ return IsDisplayingText(browser, net::ErrorToShortString(error_code));
}
// Checks that the local error page is being displayed, without remotely
public:
explicit FailFirstNRequestsInterceptor(int requests_to_fail)
: requests_(0), failures_(0), requests_to_fail_(requests_to_fail) {}
- virtual ~FailFirstNRequestsInterceptor() {}
+ ~FailFirstNRequestsInterceptor() override {}
// net::URLRequestInterceptor implementation
- virtual net::URLRequestJob* MaybeInterceptRequest(
+ net::URLRequestJob* MaybeInterceptRequest(
net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE {
+ net::NetworkDelegate* network_delegate) const override {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
requests_++;
if (failures_ < requests_to_fail_) {
weak_factory_(this) {
}
- virtual ~LinkDoctorInterceptor() {}
+ ~LinkDoctorInterceptor() override {}
// net::URLRequestInterceptor implementation
- virtual net::URLRequestJob* MaybeInterceptRequest(
+ net::URLRequestJob* MaybeInterceptRequest(
net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE {
+ net::NetworkDelegate* network_delegate) const override {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
BrowserThread::PostTask(
base::FilePath root_http;
PathService::Get(chrome::DIR_TEST_DATA, &root_http);
- return new content::URLRequestMockHTTPJob(
- request, network_delegate,
- root_http.AppendASCII("mock-link-doctor.json"));
+ return new net::URLRequestMockHTTPJob(
+ request,
+ network_delegate,
+ root_http.AppendASCII("mock-link-doctor.json"),
+ BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
}
void WaitForRequests(int requests_to_wait_for) {
// Add a mock for the search engine the error page will use.
base::FilePath root_http;
PathService::Get(chrome::DIR_TEST_DATA, &root_http);
- content::URLRequestMockHTTPJob::AddHostnameToFileHandler(
- search_url.host(), root_http.AppendASCII("title3.html"));
+ net::URLRequestMockHTTPJob::AddHostnameToFileHandler(
+ search_url.host(),
+ root_http.AppendASCII("title3.html"),
+ BrowserThread::GetBlockingPool());
}
class ErrorPageTest : public InProcessBrowserTest {
};
ErrorPageTest() : link_doctor_interceptor_(NULL) {}
- virtual ~ErrorPageTest() {}
+ ~ErrorPageTest() override {}
// Navigates the active tab to a mock url created for the file at |file_path|.
// Needed for StaleCacheStatus and StaleCacheStatusFailedCorrections tests.
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ void SetUpCommandLine(CommandLine* command_line) override {
command_line->AppendSwitch(switches::kEnableOfflineLoadStaleCache);
}
void NavigateToFileURL(const base::FilePath::StringType& file_path) {
ui_test_utils::NavigateToURL(
browser(),
- content::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(file_path)));
+ net::URLRequestMockHTTPJob::GetMockUrl(base::FilePath(file_path)));
}
// Navigates to the given URL and waits for |num_navigations| to occur, and
const char* js_cache_probe =
"try {\n"
" domAutomationController.send(\n"
- " 'staleLoadButton' in templateData ? 'yes' : 'no');\n"
+ " loadTimeData.valueExists('staleLoadButton') ? 'yes' : 'no');\n"
"} catch (e) {\n"
" domAutomationController.send(e.message);\n"
"}\n";
}
protected:
- virtual void SetUpOnMainThread() OVERRIDE {
+ void SetUpOnMainThread() override {
link_doctor_interceptor_ = new LinkDoctorInterceptor();
scoped_ptr<net::URLRequestInterceptor> owned_interceptor(
link_doctor_interceptor_);
public:
explicit TestFailProvisionalLoadObserver(content::WebContents* contents)
: content::WebContentsObserver(contents) {}
- virtual ~TestFailProvisionalLoadObserver() {}
+ ~TestFailProvisionalLoadObserver() override {}
// This method is invoked when the provisional load failed.
- virtual void DidFailProvisionalLoad(
- int64 frame_id,
- const base::string16& frame_unique_name,
- bool is_main_frame,
+ void DidFailProvisionalLoad(
+ content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
- const base::string16& error_description,
- content::RenderViewHost* render_view_host) OVERRIDE {
+ const base::string16& error_description) override {
fail_url_ = validated_url;
}
// navigation corrections.
IN_PROC_BROWSER_TEST_F(ErrorPageTest, IFrameDNSError_Basic) {
NavigateToURLAndWaitForTitle(
- content::URLRequestMockHTTPJob::GetMockUrl(
+ net::URLRequestMockHTTPJob::GetMockUrl(
base::FilePath(FILE_PATH_LITERAL("iframe_dns_error.html"))),
"Blah",
1);
// 404 page.
IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) {
NavigateToURLAndWaitForTitle(
- content::URLRequestMockHTTPJob::GetMockUrl(
+ net::URLRequestMockHTTPJob::GetMockUrl(
base::FilePath(FILE_PATH_LITERAL("page404.html"))),
"SUCCESS",
1);
class ErrorPageAutoReloadTest : public InProcessBrowserTest {
public:
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ void SetUpCommandLine(CommandLine* command_line) override {
command_line->AppendSwitch(switches::kEnableOfflineAutoReload);
}
class AddressUnreachableInterceptor : public net::URLRequestInterceptor {
public:
AddressUnreachableInterceptor() {}
- virtual ~AddressUnreachableInterceptor() {}
+ ~AddressUnreachableInterceptor() override {}
// net::URLRequestInterceptor:
- virtual net::URLRequestJob* MaybeInterceptRequest(
+ net::URLRequestJob* MaybeInterceptRequest(
net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE {
+ net::NetworkDelegate* network_delegate) const override {
return new URLRequestFailedJob(request,
network_delegate,
net::ERR_ADDRESS_UNREACHABLE);
class ErrorPageNavigationCorrectionsFailTest : public ErrorPageTest {
public:
// InProcessBrowserTest:
- virtual void SetUpOnMainThread() OVERRIDE {
+ void SetUpOnMainThread() override {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ErrorPageNavigationCorrectionsFailTest::AddFilters));
}
- virtual void CleanUpOnMainThread() OVERRIDE {
+ void TearDownOnMainThread() override {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ErrorPageNavigationCorrectionsFailTest::RemoveFilters));
// Adds a filter that causes all correction service requests to fail with
// ERR_ADDRESS_UNREACHABLE.
//
- // Also adds the content::URLRequestFailedJob filter.
+ // Also adds the net::URLRequestFailedJob filter.
static void AddFilters() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- content::URLRequestFailedJob::AddUrlHandler();
+ URLRequestFailedJob::AddUrlHandler();
net::URLRequestFilter::GetInstance()->AddUrlInterceptor(
google_util::LinkDoctorBaseURL(),
static const char kHostnameJSUnicode[];
// InProcessBrowserTest:
- virtual void SetUpOnMainThread() OVERRIDE {
+ void SetUpOnMainThread() override {
// Clear AcceptLanguages to force punycode decoding.
browser()->profile()->GetPrefs()->SetString(prefs::kAcceptLanguages,
std::string());
base::Bind(&ErrorPageForIDNTest::AddFilters));
}
- virtual void CleanUpOnMainThread() OVERRIDE {
+ void TearDownOnMainThread() override {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ErrorPageForIDNTest::RemoveFilters));
private:
static void AddFilters() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- content::URLRequestFailedJob::AddUrlHandlerForHostname(kHostname);
+ URLRequestFailedJob::AddUrlHandlerForHostname(kHostname);
}
static void RemoveFilters() {