summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/login/eula_browsertest.cc12
-rw-r--r--chrome/browser/chromeos/policy/cloud_external_data_manager_base_unittest.cc43
-rw-r--r--chrome/browser/chromeos/policy/device_local_account_browsertest.cc9
-rw-r--r--chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc4
-rw-r--r--chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.cc4
-rw-r--r--chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc10
-rw-r--r--chrome/browser/profile_resetter/profile_resetter_unittest.cc19
-rw-r--r--chrome/browser/safe_browsing/client_side_detection_service_unittest.cc100
-rw-r--r--chrome/browser/safe_browsing/download_protection_service_unittest.cc26
-rw-r--r--chrome/browser/signin/signin_browsertest.cc12
-rw-r--r--chrome/browser/sync/test/integration/sync_test.cc21
-rw-r--r--chrome/browser/ui/search/instant_extended_interactive_uitest.cc7
-rw-r--r--chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc32
-rw-r--r--chrome/service/cloud_print/printer_job_handler_unittest.cc77
-rw-r--r--components/dom_distiller/core/distiller_url_fetcher_unittest.cc5
-rw-r--r--components/precache/core/precache_fetcher_unittest.cc58
-rw-r--r--net/url_request/test_url_fetcher_factory.cc46
-rw-r--r--net/url_request/test_url_fetcher_factory.h62
-rw-r--r--remoting/host/token_validator_factory_impl_unittest.cc19
19 files changed, 359 insertions, 207 deletions
diff --git a/chrome/browser/chromeos/login/eula_browsertest.cc b/chrome/browser/chromeos/login/eula_browsertest.cc
index c760cc2..d75083c 100644
--- a/chrome/browser/chromeos/login/eula_browsertest.cc
+++ b/chrome/browser/chromeos/login/eula_browsertest.cc
@@ -12,6 +12,7 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_status.h"
#include "testing/gmock/include/gmock/gmock.h"
using ::testing::Exactly;
@@ -36,9 +37,10 @@ class TestURLFetcherCallback {
const GURL& url,
net::URLFetcherDelegate* d,
const std::string& response_data,
- net::HttpStatusCode response_code) {
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
scoped_ptr<net::FakeURLFetcher> fetcher(
- new net::FakeURLFetcher(url, d, response_data, response_code));
+ new net::FakeURLFetcher(url, d, response_data, response_code, status));
OnRequestCreate(url, fetcher.get());
return fetcher.Pass();
}
@@ -60,7 +62,8 @@ IN_PROC_BROWSER_TEST_F(TermsOfServiceProcessBrowserTest, LoadOnline) {
NULL,
base::Bind(&TestURLFetcherCallback::CreateURLFetcher,
base::Unretained(&url_callback)));
- factory.SetFakeResponse(GURL(kEULAURL), kFakeOnlineEULA, net::HTTP_OK);
+ factory.SetFakeResponse(GURL(kEULAURL), kFakeOnlineEULA,
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
EXPECT_CALL(url_callback, OnRequestCreate(GURL(kEULAURL), _))
.Times(Exactly(1))
.WillRepeatedly(Invoke(AddMimeHeader));
@@ -80,7 +83,8 @@ IN_PROC_BROWSER_TEST_F(TermsOfServiceProcessBrowserTest, LoadOnline) {
// Make sure offline version is shown.
IN_PROC_BROWSER_TEST_F(TermsOfServiceProcessBrowserTest, LoadOffline) {
net::FakeURLFetcherFactory factory(NULL);
- factory.SetFakeResponse(GURL(kEULAURL), "", net::HTTP_INTERNAL_SERVER_ERROR);
+ factory.SetFakeResponse(GURL(kEULAURL), "", net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUITermsURL));
content::WebContents* web_contents =
diff --git a/chrome/browser/chromeos/policy/cloud_external_data_manager_base_unittest.cc b/chrome/browser/chromeos/policy/cloud_external_data_manager_base_unittest.cc
index d795fc5..0ef3531 100644
--- a/chrome/browser/chromeos/policy/cloud_external_data_manager_base_unittest.cc
+++ b/chrome/browser/chromeos/policy/cloud_external_data_manager_base_unittest.cc
@@ -28,6 +28,7 @@
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_delegate.h"
+#include "net/url_request/url_request_status.h"
#include "net/url_request/url_request_test_util.h"
#include "policy/policy_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -126,7 +127,8 @@ class CloudExternalDataManagerBaseTest : public testing::Test {
void SetFakeResponse(const std::string& url,
const std::string& repsonse_data,
- net::HttpStatusCode response_code);
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status);
base::MessageLoop message_loop_;
base::ScopedTempDir temp_dir_;
@@ -237,8 +239,10 @@ void CloudExternalDataManagerBaseTest::FetchAll() {
void CloudExternalDataManagerBaseTest::SetFakeResponse(
const std::string& url,
const std::string& response_data,
- net::HttpStatusCode response_code) {
- fetcher_factory_.SetFakeResponse(GURL(url), response_data, response_code);
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
+ fetcher_factory_.SetFakeResponse(
+ GURL(url), response_data, response_code, status);
}
// Verifies that when no valid external data reference has been set for a
@@ -284,7 +288,8 @@ TEST_F(CloudExternalDataManagerBaseTest, FailToFetchInvalid) {
// further download attempts.
TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCache) {
// Serve valid external data for |k10BytePolicy|.
- SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK);
+ SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
external_data_manager_->Connect(request_content_getter_);
// Retrieve external data for |k10BytePolicy|. Verify that a download happens
@@ -339,8 +344,10 @@ TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCache) {
// served from the cache without further download attempts.
TEST_F(CloudExternalDataManagerBaseTest, DownloadAndCacheAll) {
// Serve valid external data for |k10BytePolicy| and |k20BytePolicy|.
- SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK);
- SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK);
+ SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
+ SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
external_data_manager_->Connect(request_content_getter_);
// Request that external data referenced by all policies be downloaded.
@@ -408,7 +415,8 @@ TEST_F(CloudExternalDataManagerBaseTest, DownloadAfterConnect) {
// Serve valid external data for |k10BytePolicy| and allow the
// external_data_manager_ to perform downloads.
- SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK);
+ SetFakeResponse(k10BytePolicyURL, k10ByteData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
external_data_manager_->Connect(request_content_getter_);
// Verify that a download happens and the callback is invoked with the
@@ -427,7 +435,8 @@ TEST_F(CloudExternalDataManagerBaseTest, DownloadError) {
// Make attempts to download the external data for |k20BytePolicy| fail with
// an error.
SetFakeResponse(k20BytePolicyURL, std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
external_data_manager_->Connect(request_content_getter_);
// Attempt to retrieve external data for |k20BytePolicy|. Verify that the
@@ -462,7 +471,8 @@ TEST_F(CloudExternalDataManagerBaseTest, DownloadError) {
// Serve external data for |k20BytePolicy| that does not match the hash
// specified in its current external data reference.
- SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK);
+ SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
// Attempt to retrieve external data for |k20BytePolicy| again. Verify that
// no callback is invoked still as the downloaded succeeds but returns data
@@ -631,7 +641,8 @@ TEST_F(CloudExternalDataManagerBaseTest, CacheCorruption) {
SetUpExternalDataManager();
// Serve external data for |k10BytePolicy| that exceeds the maximal external
// data size allowed for that policy.
- SetFakeResponse(k10BytePolicyURL, k20ByteData, net::HTTP_OK);
+ SetFakeResponse(k10BytePolicyURL, k20ByteData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
external_data_manager_->Connect(request_content_getter_);
// Modify the external data reference for |k10BytePolicy| to match the
@@ -650,7 +661,8 @@ TEST_F(CloudExternalDataManagerBaseTest, CacheCorruption) {
ResetCallbackData();
// Serve valid external data for |k20BytePolicy|.
- SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK);
+ SetFakeResponse(k20BytePolicyURL, k20ByteData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
// Retrieve external data for |k20BytePolicy|. Verify that the callback is
// invoked with the valid downloaded data, not the invalid data in the cache.
@@ -692,9 +704,11 @@ TEST_F(CloudExternalDataManagerBaseTest, PolicyChangeWhileDownloadPending) {
// Make attempts to download the external data for |k10BytePolicy| and
// |k20BytePolicy| fail with an error.
SetFakeResponse(k10BytePolicyURL, std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
SetFakeResponse(k20BytePolicyURL, std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
external_data_manager_->Connect(request_content_getter_);
// Attempt to retrieve external data for |k10BytePolicy| and |k20BytePolicy|.
@@ -719,7 +733,8 @@ TEST_F(CloudExternalDataManagerBaseTest, PolicyChangeWhileDownloadPending) {
// Serve valid external data for |k20BytePolicy|.
fetcher_factory_.ClearFakeResponses();
- SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK);
+ SetFakeResponse(k20BytePolicyURL, k10ByteData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
// Modify the external data reference for |k20BytePolicy| to match the
// external data now being served. Verify that the callback is invoked with
diff --git a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
index 6a24f9b..86614d7 100644
--- a/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
+++ b/chrome/browser/chromeos/policy/device_local_account_browsertest.cc
@@ -97,6 +97,7 @@
#include "net/test/embedded_test_server/http_response.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher_delegate.h"
+#include "net/url_request/url_request_status.h"
#include "policy/policy_constants.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -256,10 +257,11 @@ scoped_ptr<net::FakeURLFetcher> RunCallbackAndReturnFakeURLFetcher(
const GURL& url,
net::URLFetcherDelegate* delegate,
const std::string& response_data,
- net::HttpStatusCode response_code) {
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
task_runner->PostTask(FROM_HERE, callback);
return make_scoped_ptr(new net::FakeURLFetcher(
- url, delegate, response_data, response_code));
+ url, delegate, response_data, response_code, status));
}
} // namespace
@@ -837,7 +839,8 @@ IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExternalData) {
run_loop->QuitClosure())));
fetcher_factory->SetFakeResponse(GURL(kExternalDataURL),
kExternalData,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
// TODO(bartfab): The test injects an ExternalDataFetcher for an arbitrary
// policy. This is only done because there are no policies that reference
diff --git a/chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc b/chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc
index d81df86..7ab0eb9 100644
--- a/chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc
+++ b/chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc
@@ -15,6 +15,7 @@
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher_impl.h"
+#include "net/url_request/url_request_status.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -107,7 +108,8 @@ TEST_F(CloudPrintPrinterListTest, SuccessOAuth2) {
fetcher_factory_->SetFakeResponse(
GURL("http://SoMeUrL.com/cloudprint/search"),
kSampleSuccessResponseOAuth,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
CloudPrintBaseApiFlow* cloudprint_flow =
printer_list_->GetOAuth2ApiFlowForTests();
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.cc
index 0796606..25f33d5 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.cc
@@ -123,7 +123,9 @@ void DataReductionProxySettingsTestBase::SetProbeResult(
GURL(test_url),
settings,
response,
- success ? net::HTTP_OK : net::HTTP_INTERNAL_SERVER_ERROR)));
+ success ? net::HTTP_OK : net::HTTP_INTERNAL_SERVER_ERROR,
+ success ? net::URLRequestStatus::SUCCESS :
+ net::URLRequestStatus::FAILED)));
}
}
diff --git a/chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc b/chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc
index ceca2cf..35a95bb 100644
--- a/chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc
+++ b/chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher_browsertest.cc
@@ -12,6 +12,7 @@
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher.h"
+#include "net/url_request/url_request_status.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/codec/png_codec.h"
@@ -111,7 +112,8 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
NotificationBitmapFetcher fetcher(url, &delegate);
- url_fetcher_factory_->SetFakeResponse(url, image_string, net::HTTP_OK);
+ url_fetcher_factory_->SetFakeResponse(url, image_string, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
// We expect that the image decoder will get called and return
// an image in a callback to OnImageDecoded().
@@ -163,7 +165,8 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
url_fetcher_factory_->SetFakeResponse(url,
std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
fetcher.Start(browser()->profile());
@@ -179,7 +182,8 @@ IN_PROC_BROWSER_TEST_F(NotificationBitmapFetcherBrowserTest,
NotificationBitmapFetcherTestDelegate delegate(kAsyncCall);
NotificationBitmapFetcher fetcher(url, &delegate);
url_fetcher_factory_->SetFakeResponse(
- url, std::string("Not a real bitmap"), net::HTTP_OK);
+ url, std::string("Not a real bitmap"),
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
fetcher.Start(browser()->profile());
diff --git a/chrome/browser/profile_resetter/profile_resetter_unittest.cc b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
index 27d6df8..45818a2 100644
--- a/chrome/browser/profile_resetter/profile_resetter_unittest.cc
+++ b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
@@ -30,6 +30,7 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_status.h"
#include "url/gurl.h"
@@ -174,7 +175,8 @@ class ConfigParserTest : public testing::Test {
const GURL& url,
net::URLFetcherDelegate* fetcher_delegate,
const std::string& response_data,
- net::HttpStatusCode response_code);
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status);
MOCK_METHOD0(Callback, void(void));
@@ -214,13 +216,12 @@ scoped_ptr<net::FakeURLFetcher> ConfigParserTest::CreateFakeURLFetcher(
const GURL& url,
net::URLFetcherDelegate* fetcher_delegate,
const std::string& response_data,
- net::HttpStatusCode response_code) {
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
request_listener_.real_delegate = fetcher_delegate;
scoped_ptr<net::FakeURLFetcher> fetcher(
- new net::FakeURLFetcher(url,
- &request_listener_,
- response_data,
- response_code));
+ new net::FakeURLFetcher(
+ url, &request_listener_, response_data, response_code, status));
scoped_refptr<net::HttpResponseHeaders> download_headers =
new net::HttpResponseHeaders("");
download_headers->AddHeader("Content-Type: text/xml");
@@ -653,7 +654,8 @@ TEST_F(ProfileResetterTest, ResetFewFlags) {
// Tries to load unavailable config file.
TEST_F(ConfigParserTest, NoConnectivity) {
const GURL url("http://test");
- factory().SetFakeResponse(url, "", net::HTTP_INTERNAL_SERVER_ERROR);
+ factory().SetFakeResponse(url, "", net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
scoped_ptr<BrandcodeConfigFetcher> fetcher = WaitForRequest(GURL(url));
EXPECT_FALSE(fetcher->GetSettings());
@@ -667,7 +669,8 @@ TEST_F(ConfigParserTest, ParseConfig) {
ReplaceString(&xml_config,
"placeholder_for_id",
"abbaabbaabbaabbaabbaabbaabbaabba");
- factory().SetFakeResponse(url, xml_config, net::HTTP_OK);
+ factory().SetFakeResponse(url, xml_config, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
scoped_ptr<BrandcodeConfigFetcher> fetcher = WaitForRequest(GURL(url));
scoped_ptr<BrandcodedDefaultSettings> settings = fetcher->GetSettings();
diff --git a/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc
index 41b1bca..b5f64d5 100644
--- a/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc
@@ -107,28 +107,28 @@ class ClientSideDetectionServiceTest : public testing::Test {
}
void SetModelFetchResponse(std::string response_data,
- net::HttpStatusCode response_code) {
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
factory_->SetFakeResponse(GURL(ClientSideDetectionService::kClientModelUrl),
- response_data,
- response_code);
+ response_data, response_code, status);
}
void SetClientReportPhishingResponse(std::string response_data,
- net::HttpStatusCode response_code) {
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
factory_->SetFakeResponse(
ClientSideDetectionService::GetClientReportUrl(
ClientSideDetectionService::kClientReportPhishingUrl),
- response_data,
- response_code);
+ response_data, response_code, status);
}
void SetClientReportMalwareResponse(std::string response_data,
- net::HttpStatusCode response_code) {
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
factory_->SetFakeResponse(
ClientSideDetectionService::GetClientReportUrl(
ClientSideDetectionService::kClientReportMalwareUrl),
- response_data,
- response_code);
+ response_data, response_code, status);
}
int GetNumReports(std::queue<base::Time>* report_times) {
@@ -260,7 +260,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
service.SetEnabledAndRefreshState(true);
// The model fetch failed.
- SetModelFetchResponse("blamodel", net::HTTP_INTERNAL_SERVER_ERROR);
+ SetModelFetchResponse("blamodel", net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_FETCH_FAILED))
.WillOnce(QuitCurrentMessageLoop());
@@ -269,7 +270,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
Mock::VerifyAndClearExpectations(&service);
// Empty model file.
- SetModelFetchResponse(std::string(), net::HTTP_OK);
+ SetModelFetchResponse(std::string(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(ClientSideDetectionService::MODEL_EMPTY))
.WillOnce(QuitCurrentMessageLoop());
service.StartFetchModel();
@@ -279,7 +281,7 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
// Model is too large.
SetModelFetchResponse(
std::string(ClientSideDetectionService::kMaxModelSizeBytes + 1, 'x'),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_TOO_LARGE))
.WillOnce(QuitCurrentMessageLoop());
@@ -288,7 +290,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
Mock::VerifyAndClearExpectations(&service);
// Unable to parse the model file.
- SetModelFetchResponse("Invalid model file", net::HTTP_OK);
+ SetModelFetchResponse("Invalid model file", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_PARSE_ERROR))
.WillOnce(QuitCurrentMessageLoop());
@@ -299,7 +302,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
// Model that is missing some required fields (missing the version field).
ClientSideModel model;
model.set_max_words_per_term(4);
- SetModelFetchResponse(model.SerializePartialAsString(), net::HTTP_OK);
+ SetModelFetchResponse(model.SerializePartialAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_MISSING_FIELDS))
.WillOnce(QuitCurrentMessageLoop());
@@ -311,7 +315,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
model.set_version(10);
model.add_hashes("bla");
model.add_page_term(1); // Should be 0 instead of 1.
- SetModelFetchResponse(model.SerializePartialAsString(), net::HTTP_OK);
+ SetModelFetchResponse(model.SerializePartialAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_BAD_HASH_IDS))
.WillOnce(QuitCurrentMessageLoop());
@@ -322,7 +327,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
// Model version number is wrong.
model.set_version(-1);
- SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK);
+ SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_INVALID_VERSION_NUMBER))
.WillOnce(QuitCurrentMessageLoop());
@@ -332,7 +338,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
// Normal model.
model.set_version(10);
- SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK);
+ SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_SUCCESS))
.WillOnce(QuitCurrentMessageLoop());
@@ -344,7 +351,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
// model that is currently loaded in the service object to 11.
service.model_.reset(new ClientSideModel(model));
service.model_->set_version(11);
- SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK);
+ SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_INVALID_VERSION_NUMBER))
.WillOnce(QuitCurrentMessageLoop());
@@ -354,7 +362,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
// Model version hasn't changed since the last reload.
service.model_->set_version(10);
- SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK);
+ SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(service, EndFetchModel(
ClientSideDetectionService::MODEL_NOT_CHANGED))
.WillOnce(QuitCurrentMessageLoop());
@@ -364,7 +373,8 @@ TEST_F(ClientSideDetectionServiceTest, FetchModelTest) {
}
TEST_F(ClientSideDetectionServiceTest, ServiceObjectDeletedBeforeCallbackDone) {
- SetModelFetchResponse("bogus model", net::HTTP_OK);
+ SetModelFetchResponse("bogus model", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
csd_service_.reset(ClientSideDetectionService::Create(NULL));
csd_service_->SetEnabledAndRefreshState(true);
EXPECT_TRUE(csd_service_.get() != NULL);
@@ -377,7 +387,8 @@ TEST_F(ClientSideDetectionServiceTest, ServiceObjectDeletedBeforeCallbackDone) {
}
TEST_F(ClientSideDetectionServiceTest, SendClientReportPhishingRequest) {
- SetModelFetchResponse("bogus model", net::HTTP_OK);
+ SetModelFetchResponse("bogus model", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
csd_service_.reset(ClientSideDetectionService::Create(NULL));
csd_service_->SetEnabledAndRefreshState(true);
@@ -387,21 +398,23 @@ TEST_F(ClientSideDetectionServiceTest, SendClientReportPhishingRequest) {
base::Time before = base::Time::Now();
// Invalid response body from the server.
- SetClientReportPhishingResponse("invalid proto response", net::HTTP_OK);
+ SetClientReportPhishingResponse("invalid proto response", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_FALSE(SendClientReportPhishingRequest(url, score));
// Normal behavior.
ClientPhishingResponse response;
response.set_phishy(true);
- SetClientReportPhishingResponse(response.SerializeAsString(),
- net::HTTP_OK);
+ SetClientReportPhishingResponse(response.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_TRUE(SendClientReportPhishingRequest(url, score));
// This request will fail
GURL second_url("http://b.com/");
response.set_phishy(false);
SetClientReportPhishingResponse(response.SerializeAsString(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
EXPECT_FALSE(SendClientReportPhishingRequest(second_url, score));
base::Time after = base::Time::Now();
@@ -425,38 +438,44 @@ TEST_F(ClientSideDetectionServiceTest, SendClientReportPhishingRequest) {
}
TEST_F(ClientSideDetectionServiceTest, SendClientReportMalwareRequest) {
- SetModelFetchResponse("bogus model", net::HTTP_OK);
+ SetModelFetchResponse("bogus model", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
csd_service_.reset(ClientSideDetectionService::Create(NULL));
csd_service_->SetEnabledAndRefreshState(true);
GURL url("http://a.com/");
base::Time before = base::Time::Now();
// Invalid response body from the server.
- SetClientReportMalwareResponse("invalid proto response", net::HTTP_OK);
+ SetClientReportMalwareResponse("invalid proto response", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_FALSE(SendClientReportMalwareRequest(url));
// Missing bad_url.
ClientMalwareResponse response;
response.set_blacklist(true);
- SetClientReportMalwareResponse(response.SerializeAsString(), net::HTTP_OK);
+ SetClientReportMalwareResponse(response.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_FALSE(SendClientReportMalwareRequest(url));
// Normal behavior.
response.set_blacklist(true);
response.set_bad_url("http://response-bad.com/");
- SetClientReportMalwareResponse(response.SerializeAsString(), net::HTTP_OK);
+ SetClientReportMalwareResponse(response.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_TRUE(SendClientReportMalwareRequest(url));
CheckConfirmedMalwareUrl(GURL("http://response-bad.com/"));
// This request will fail
response.set_blacklist(false);
SetClientReportMalwareResponse(response.SerializeAsString(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
EXPECT_FALSE(SendClientReportMalwareRequest(url));
// server blacklist decision is false, and response is succesful
response.set_blacklist(false);
- SetClientReportMalwareResponse(response.SerializeAsString(), net::HTTP_OK);
+ SetClientReportMalwareResponse(response.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_FALSE(SendClientReportMalwareRequest(url));
// Check that we have recorded all 4 requests within the correct time range.
@@ -466,7 +485,8 @@ TEST_F(ClientSideDetectionServiceTest, SendClientReportMalwareRequest) {
// Another normal behavior will fail because of the limit is hit
response.set_blacklist(true);
- SetClientReportMalwareResponse(response.SerializeAsString(), net::HTTP_OK);
+ SetClientReportMalwareResponse(response.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_FALSE(SendClientReportMalwareRequest(url));
report_times = GetMalwareReportTimes();
@@ -480,7 +500,8 @@ TEST_F(ClientSideDetectionServiceTest, SendClientReportMalwareRequest) {
}
TEST_F(ClientSideDetectionServiceTest, GetNumReportTest) {
- SetModelFetchResponse("bogus model", net::HTTP_OK);
+ SetModelFetchResponse("bogus model", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
csd_service_.reset(ClientSideDetectionService::Create(NULL));
std::queue<base::Time>& report_times = GetPhishingReportTimes();
@@ -495,14 +516,16 @@ TEST_F(ClientSideDetectionServiceTest, GetNumReportTest) {
}
TEST_F(ClientSideDetectionServiceTest, CacheTest) {
- SetModelFetchResponse("bogus model", net::HTTP_OK);
+ SetModelFetchResponse("bogus model", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
csd_service_.reset(ClientSideDetectionService::Create(NULL));
TestCache();
}
TEST_F(ClientSideDetectionServiceTest, IsPrivateIPAddress) {
- SetModelFetchResponse("bogus model", net::HTTP_OK);
+ SetModelFetchResponse("bogus model", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
csd_service_.reset(ClientSideDetectionService::Create(NULL));
EXPECT_TRUE(csd_service_->IsPrivateIPAddress("10.1.2.3"));
@@ -633,7 +656,8 @@ TEST_F(ClientSideDetectionServiceTest, SetEnabledAndRefreshState) {
ClientSideModel model;
model.set_version(10);
model.set_max_words_per_term(4);
- SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK);
+ SetModelFetchResponse(model.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(*service, ScheduleFetchModel(_))
.WillOnce(Invoke(service, &MockClientSideDetectionService::Schedule));
EXPECT_CALL(*service, EndFetchModel(
@@ -665,8 +689,8 @@ TEST_F(ClientSideDetectionServiceTest, SetEnabledAndRefreshState) {
// Requests always return false when the service is disabled.
ClientPhishingResponse response;
response.set_phishy(true);
- SetClientReportPhishingResponse(response.SerializeAsString(),
- net::HTTP_OK);
+ SetClientReportPhishingResponse(response.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_FALSE(SendClientReportPhishingRequest(GURL("http://a.com/"), 0.4f));
// Pending requests also return false if the service is disabled before they
diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
index 9954fd1..c75d3a5 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -32,6 +32,7 @@
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher_delegate.h"
+#include "net/url_request/url_request_status.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/zlib/google/zip.h"
@@ -401,9 +402,8 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadFetchFailed) {
net::FakeURLFetcherFactory factory(NULL);
// HTTP request will fail.
factory.SetFakeResponse(
- DownloadProtectionService::GetDownloadRequestUrl(),
- std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ DownloadProtectionService::GetDownloadRequestUrl(), std::string(),
+ net::HTTP_INTERNAL_SERVER_ERROR, net::URLRequestStatus::FAILED);
base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp"));
base::FilePath a_exe(FILE_PATH_LITERAL("a.exe"));
@@ -445,7 +445,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp"));
base::FilePath a_exe(FILE_PATH_LITERAL("a.exe"));
@@ -483,7 +483,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializePartialAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
download_service_->CheckClientDownload(
&item,
@@ -501,7 +501,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
download_service_->CheckClientDownload(
&item,
@@ -521,7 +521,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
download_service_->CheckClientDownload(
&item,
@@ -546,7 +546,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
download_service_->CheckClientDownload(
&item,
@@ -568,7 +568,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
download_service_->CheckClientDownload(
&item,
@@ -589,7 +589,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp"));
base::FilePath a_exe(FILE_PATH_LITERAL("a.exe"));
@@ -635,7 +635,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadZip) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
base::ScopedTempDir download_dir;
ASSERT_TRUE(download_dir.CreateUniqueTempDir());
@@ -702,7 +702,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadZip) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
download_service_->CheckClientDownload(
&item,
@@ -765,7 +765,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientCrxDownloadSuccess) {
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp"));
base::FilePath a_crx(FILE_PATH_LITERAL("a.crx"));
diff --git a/chrome/browser/signin/signin_browsertest.cc b/chrome/browser/signin/signin_browsertest.cc
index aebd1f8..a8f5395 100644
--- a/chrome/browser/signin/signin_browsertest.cc
+++ b/chrome/browser/signin/signin_browsertest.cc
@@ -27,6 +27,7 @@
#include "google_apis/gaia/gaia_urls.h"
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_status.h"
namespace {
const char kNonSigninURL[] = "www.google.com";
@@ -55,12 +56,11 @@ class SigninBrowserTest : public InProcessBrowserTest {
factory_.reset(new net::URLFetcherImplFactory());
fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get()));
fake_factory_->SetFakeResponse(
- GaiaUrls::GetInstance()->service_login_url(),
- std::string(),
- net::HTTP_OK);
- fake_factory_->SetFakeResponse(GURL(kNonSigninURL),
- std::string(),
- net::HTTP_OK);
+ GaiaUrls::GetInstance()->service_login_url(), std::string(),
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
+ fake_factory_->SetFakeResponse(
+ GURL(kNonSigninURL), std::string(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
// Yield control back to the InProcessBrowserTest framework.
InProcessBrowserTest::SetUp();
}
diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc
index 28e1e64..be97945 100644
--- a/chrome/browser/sync/test/integration/sync_test.cc
+++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -430,23 +430,28 @@ void SyncTest::SetupMockGaiaResponses() {
fake_factory_->SetFakeResponse(
GaiaUrls::GetInstance()->client_login_url(),
"SID=sid\nLSID=lsid",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_factory_->SetFakeResponse(
GaiaUrls::GetInstance()->get_user_info_url(),
"email=user@gmail.com\ndisplayEmail=user@gmail.com",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_factory_->SetFakeResponse(
GaiaUrls::GetInstance()->issue_auth_token_url(),
"auth",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_factory_->SetFakeResponse(
GURL(GoogleURLTracker::kSearchDomainCheckURL),
".google.com",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_factory_->SetFakeResponse(
GaiaUrls::GetInstance()->client_login_to_oauth2_url(),
"some_response",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_factory_->SetFakeResponse(
GaiaUrls::GetInstance()->oauth2_token_url(),
"{"
@@ -455,11 +460,13 @@ void SyncTest::SetupMockGaiaResponses() {
" \"expires_in\": 3600,"
" \"token_type\": \"Bearer\""
"}",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_factory_->SetFakeResponse(
GaiaUrls::GetInstance()->oauth1_login_url(),
"SID=sid\nLSID=lsid\nAuth=auth_token",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
}
void SyncTest::ClearMockGaiaResponses() {
diff --git a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
index 97879d2..d1493f0 100644
--- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
+++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
@@ -79,6 +79,7 @@
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher_impl.h"
+#include "net/url_request/url_request_status.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/l10n/l10n_util.h"
@@ -924,7 +925,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) {
"{\"google:clientdata\":{\"phi\": 0},"
"\"google:suggesttype\":[\"QUERY\", \"QUERY\"],"
"\"google:suggestrelevance\":[1400, 9]}]",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
SetOmniboxText("pupp");
while (!omnibox()->model()->autocomplete_controller()->done()) {
@@ -969,7 +971,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, ClearPrefetchedResults) {
"[\"dogs\",[\"https://dogs.com\"],[],[],"
"{\"google:suggesttype\":[\"NAVIGATION\"],"
"\"google:suggestrelevance\":[2]}]",
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
SetOmniboxText("dogs");
while (!omnibox()->model()->autocomplete_controller()->done()) {
diff --git a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
index 87d26e0..76f25fe 100644
--- a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_browsertest.cc
@@ -22,6 +22,7 @@
#include "chrome/test/base/web_ui_browsertest.h"
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_status.h"
#include "net/url_request/url_request_test_util.h"
using testing::InvokeWithoutArgs;
@@ -294,10 +295,11 @@ class MockableFakeURLFetcherCreator {
const GURL& url,
net::URLFetcherDelegate* delegate,
const std::string& response_data,
- net::HttpStatusCode response_code) {
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
OnCreateFakeURLFetcher(url.spec());
- return scoped_ptr<net::FakeURLFetcher>(
- new net::FakeURLFetcher(url, delegate, response_data, response_code));
+ return scoped_ptr<net::FakeURLFetcher>(new net::FakeURLFetcher(
+ url, delegate, response_data, response_code, status));
}
net::FakeURLFetcherFactory::FakeURLFetcherCreator callback() {
@@ -337,32 +339,38 @@ class LocalDiscoveryUITest : public WebUIBrowserTest {
fake_fetcher_factory().SetFakeResponse(
GURL(kURLInfo),
kResponseInfo,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_fetcher_factory().SetFakeResponse(
GURL(kURLRegisterStart),
kResponseRegisterStart,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_fetcher_factory().SetFakeResponse(
GURL(kURLRegisterClaimToken),
kResponseRegisterClaimTokenNoConfirm,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_fetcher_factory().SetFakeResponse(
GURL(kURLCloudPrintConfirm),
kResponseCloudPrintConfirm,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_fetcher_factory().SetFakeResponse(
GURL(kURLRegisterComplete),
kResponseRegisterComplete,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_fetcher_factory().SetFakeResponse(
GURL(kURLGaiaToken),
kResponseGaiaToken,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(fake_url_fetcher_creator(), OnCreateFakeURLFetcher(
kURLGaiaToken))
@@ -482,12 +490,14 @@ IN_PROC_BROWSER_TEST_F(LocalDiscoveryUITest, RegisterTest) {
fake_fetcher_factory().SetFakeResponse(
GURL(kURLRegisterClaimToken),
kResponseRegisterClaimTokenConfirm,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
fake_fetcher_factory().SetFakeResponse(
GURL(kURLInfo),
kResponseInfoWithID,
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
{
InSequence s;
diff --git a/chrome/service/cloud_print/printer_job_handler_unittest.cc b/chrome/service/cloud_print/printer_job_handler_unittest.cc
index 1eeaa44..a97a1f1 100644
--- a/chrome/service/cloud_print/printer_job_handler_unittest.cc
+++ b/chrome/service/cloud_print/printer_job_handler_unittest.cc
@@ -17,6 +17,7 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_status.h"
#include "net/url_request/url_request_test_util.h"
#include "printing/backend/print_backend.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -282,9 +283,10 @@ class TestURLFetcherCallback {
const GURL& url,
net::URLFetcherDelegate* d,
const std::string& response_data,
- net::HttpStatusCode response_code) {
+ net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
scoped_ptr<net::FakeURLFetcher> fetcher(
- new net::FakeURLFetcher(url, d, response_data, response_code));
+ new net::FakeURLFetcher(url, d, response_data, response_code, status));
OnRequestCreate(url, fetcher.get());
return fetcher.Pass();
}
@@ -498,11 +500,14 @@ void PrinterJobHandlerTest::SetUp() {
void PrinterJobHandlerTest::MakeJobFetchReturnNoJobs() {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(0), net::HTTP_OK);
+ JobListResponse(0), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonFailure),
- JobListResponse(0), net::HTTP_OK);
+ JobListResponse(0), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonRetry),
- JobListResponse(0), net::HTTP_OK);
+ JobListResponse(0), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
}
void PrinterJobHandlerTest::MessageLoopQuitNowHelper(
@@ -544,16 +549,20 @@ void PrinterJobHandlerTest::AddMimeHeader(const GURL& url,
void PrinterJobHandlerTest::SetUpJobSuccessTest(int job_num) {
factory_.SetFakeResponse(TicketURI(job_num),
- kExamplePrintTicket, net::HTTP_OK);
+ kExamplePrintTicket, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(DownloadURI(job_num),
- kExamplePrintData, net::HTTP_OK);
+ kExamplePrintData, net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(DoneURI(job_num),
StatusResponse(job_num, "DONE"),
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(InProgressURI(job_num),
StatusResponse(job_num, "IN_PROGRESS"),
- net::HTTP_OK);
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
// The times requirement is relaxed for the ticket URI
// in order to accommodate TicketDownloadFailureTest
@@ -657,9 +666,11 @@ MockPrintSystem::MockPrintSystem()
// Disabled - http://crbug.com/184245
TEST_F(PrinterJobHandlerTest, DISABLED_HappyPathTest) {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(1), net::HTTP_OK);
+ JobListResponse(1), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonQueryMore),
- JobListResponse(0), net::HTTP_OK);
+ JobListResponse(0), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(url_callback_,
OnRequestCreate(JobListURI(kJobFetchReasonStartup), _))
@@ -674,13 +685,17 @@ TEST_F(PrinterJobHandlerTest, DISABLED_HappyPathTest) {
TEST_F(PrinterJobHandlerTest, TicketDownloadFailureTest) {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(2), net::HTTP_OK);
+ JobListResponse(2), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonFailure),
- JobListResponse(2), net::HTTP_OK);
+ JobListResponse(2), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonQueryMore),
- JobListResponse(0), net::HTTP_OK);
+ JobListResponse(0), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(TicketURI(1), std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
EXPECT_CALL(url_callback_, OnRequestCreate(TicketURI(1), _))
.Times(AtLeast(1));
@@ -705,13 +720,17 @@ TEST_F(PrinterJobHandlerTest, TicketDownloadFailureTest) {
// re-enable it
TEST_F(PrinterJobHandlerTest, DISABLED_ManyFailureTest) {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(1), net::HTTP_OK);
+ JobListResponse(1), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonFailure),
- JobListResponse(1), net::HTTP_OK);
+ JobListResponse(1), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonRetry),
- JobListResponse(1), net::HTTP_OK);
+ JobListResponse(1), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonQueryMore),
- JobListResponse(0), net::HTTP_OK);
+ JobListResponse(0), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
EXPECT_CALL(url_callback_,
OnRequestCreate(JobListURI(kJobFetchReasonStartup), _))
@@ -733,14 +752,16 @@ TEST_F(PrinterJobHandlerTest, DISABLED_ManyFailureTest) {
factory_.SetFakeResponse(TicketURI(1),
std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
loop_.PostDelayedTask(FROM_HERE,
base::Bind(&net::FakeURLFetcherFactory::SetFakeResponse,
base::Unretained(&factory_),
TicketURI(1),
kExamplePrintTicket,
- net::HTTP_OK),
+ net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS),
base::TimeDelta::FromSeconds(1));
@@ -752,15 +773,19 @@ TEST_F(PrinterJobHandlerTest, DISABLED_ManyFailureTest) {
// constant values) seconds and re-enable it
TEST_F(PrinterJobHandlerTest, DISABLED_CompleteFailureTest) {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(1), net::HTTP_OK);
+ JobListResponse(1), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonFailure),
- JobListResponse(1), net::HTTP_OK);
+ JobListResponse(1), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonRetry),
- JobListResponse(1), net::HTTP_OK);
+ JobListResponse(1), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(ErrorURI(1), StatusResponse(1, "ERROR"),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(TicketURI(1), std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
EXPECT_CALL(url_callback_,
OnRequestCreate(JobListURI(kJobFetchReasonStartup), _))
diff --git a/components/dom_distiller/core/distiller_url_fetcher_unittest.cc b/components/dom_distiller/core/distiller_url_fetcher_unittest.cc
index 8dddd2f..9f4a806 100644
--- a/components/dom_distiller/core/distiller_url_fetcher_unittest.cc
+++ b/components/dom_distiller/core/distiller_url_fetcher_unittest.cc
@@ -10,6 +10,7 @@
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_status.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -33,11 +34,11 @@ public:
factory_->SetFakeResponse(
GURL(kTestPageA),
std::string(kTestPageAResponse, sizeof(kTestPageAResponse)),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
factory_->SetFakeResponse(
GURL(kTestPageB),
std::string(kTestPageBResponse, sizeof(kTestPageBResponse)),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR, net::URLRequestStatus::FAILED);
}
void Fetch(const std::string& url,
diff --git a/components/precache/core/precache_fetcher_unittest.cc b/components/precache/core/precache_fetcher_unittest.cc
index e2fe2ad..2552586 100644
--- a/components/precache/core/precache_fetcher_unittest.cc
+++ b/components/precache/core/precache_fetcher_unittest.cc
@@ -19,6 +19,7 @@
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_status.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -30,9 +31,10 @@ class TestURLFetcherCallback {
public:
scoped_ptr<net::FakeURLFetcher> CreateURLFetcher(
const GURL& url, net::URLFetcherDelegate* delegate,
- const std::string& response_data, net::HttpStatusCode response_code) {
- scoped_ptr<net::FakeURLFetcher> fetcher(
- new net::FakeURLFetcher(url, delegate, response_data, response_code));
+ const std::string& response_data, net::HttpStatusCode response_code,
+ net::URLRequestStatus::Status status) {
+ scoped_ptr<net::FakeURLFetcher> fetcher(new net::FakeURLFetcher(
+ url, delegate, response_data, response_code, status));
if (response_code == net::HTTP_OK) {
scoped_refptr<net::HttpResponseHeaders> download_headers =
@@ -124,19 +126,21 @@ TEST_F(PrecacheFetcherTest, FullPrecache) {
good_manifest.add_resource(); // Resource with no URL, should not be fetched.
good_manifest.add_resource()->set_url(kGoodResourceURL);
- factory_.SetFakeResponse(GURL(kConfigURL),
- config.SerializeAsString(),
- net::HTTP_OK);
- factory_.SetFakeResponse(GURL(kManifestFetchFailureURL),
- "",
- net::HTTP_INTERNAL_SERVER_ERROR);
- factory_.SetFakeResponse(GURL(kBadManifestURL), "bad protobuf", net::HTTP_OK);
+ factory_.SetFakeResponse(GURL(kConfigURL), config.SerializeAsString(),
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
+ factory_.SetFakeResponse(GURL(kManifestFetchFailureURL), "",
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
+ factory_.SetFakeResponse(GURL(kBadManifestURL), "bad protobuf", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(GURL(kGoodManifestURL),
- good_manifest.SerializeAsString(), net::HTTP_OK);
+ good_manifest.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
factory_.SetFakeResponse(GURL(kResourceFetchFailureURL),
- "",
- net::HTTP_INTERNAL_SERVER_ERROR);
- factory_.SetFakeResponse(GURL(kGoodResourceURL), "good", net::HTTP_OK);
+ "", net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
+ factory_.SetFakeResponse(GURL(kGoodResourceURL), "good", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(),
&precache_delegate_);
@@ -163,9 +167,9 @@ TEST_F(PrecacheFetcherTest, ConfigFetchFailure) {
std::list<GURL> starting_urls(1, GURL("http://starting-url.com"));
- factory_.SetFakeResponse(GURL(kConfigURL),
- "",
- net::HTTP_INTERNAL_SERVER_ERROR);
+ factory_.SetFakeResponse(GURL(kConfigURL), "",
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(),
&precache_delegate_);
@@ -186,7 +190,8 @@ TEST_F(PrecacheFetcherTest, BadConfig) {
std::list<GURL> starting_urls(1, GURL("http://starting-url.com"));
- factory_.SetFakeResponse(GURL(kConfigURL), "bad protobuf", net::HTTP_OK);
+ factory_.SetFakeResponse(GURL(kConfigURL), "bad protobuf", net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(),
&precache_delegate_);
@@ -211,9 +216,8 @@ TEST_F(PrecacheFetcherTest, Cancel) {
config.add_whitelisted_starting_url("http://starting-url.com");
config.set_maximum_rank_starting_url(1);
- factory_.SetFakeResponse(GURL(kConfigURL),
- config.SerializeAsString(),
- net::HTTP_OK);
+ factory_.SetFakeResponse(GURL(kConfigURL), config.SerializeAsString(),
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
scoped_ptr<PrecacheFetcher> precache_fetcher(new PrecacheFetcher(
starting_urls, request_context_.get(), &precache_delegate_));
@@ -241,7 +245,7 @@ TEST_F(PrecacheFetcherTest, PrecacheUsingDefaultConfigSettingsURL) {
factory_.SetFakeResponse(GURL(PRECACHE_CONFIG_SETTINGS_URL),
PrecacheConfigurationSettings().SerializeAsString(),
- net::HTTP_OK);
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(),
&precache_delegate_);
@@ -275,12 +279,10 @@ TEST_F(PrecacheFetcherTest, PrecacheUsingDefaultManifestURLPrefix) {
GURL manifest_url(PRECACHE_MANIFEST_URL_PREFIX
"http%253A%252F%252Fstarting-url.com%252F");
- factory_.SetFakeResponse(GURL(kConfigURL),
- config.SerializeAsString(),
- net::HTTP_OK);
- factory_.SetFakeResponse(manifest_url,
- PrecacheManifest().SerializeAsString(),
- net::HTTP_OK);
+ factory_.SetFakeResponse(GURL(kConfigURL), config.SerializeAsString(),
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
+ factory_.SetFakeResponse(manifest_url, PrecacheManifest().SerializeAsString(),
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
PrecacheFetcher precache_fetcher(starting_urls, request_context_.get(),
&precache_delegate_);
diff --git a/net/url_request/test_url_fetcher_factory.cc b/net/url_request/test_url_fetcher_factory.cc
index 62fbb07..c95e07d 100644
--- a/net/url_request/test_url_fetcher_factory.cc
+++ b/net/url_request/test_url_fetcher_factory.cc
@@ -11,6 +11,7 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "net/base/host_port_pair.h"
+#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_fetcher_impl.h"
@@ -283,14 +284,26 @@ void TestURLFetcherFactory::SetDelegateForTests(
FakeURLFetcher::FakeURLFetcher(const GURL& url,
URLFetcherDelegate* d,
const std::string& response_data,
- HttpStatusCode response_code)
+ HttpStatusCode response_code,
+ URLRequestStatus::Status status)
: TestURLFetcher(0, url, d),
weak_factory_(this) {
- set_status(URLRequestStatus(
- // Status is FAILED for HTTP/5xx server errors, and SUCCESS otherwise.
- response_code >= HTTP_INTERNAL_SERVER_ERROR ? URLRequestStatus::FAILED :
- URLRequestStatus::SUCCESS,
- 0));
+ Error error = OK;
+ switch(status) {
+ case URLRequestStatus::SUCCESS:
+ // |error| is initialized to OK.
+ break;
+ case URLRequestStatus::IO_PENDING:
+ error = ERR_IO_PENDING;
+ break;
+ case URLRequestStatus::CANCELED:
+ error = ERR_ABORTED;
+ break;
+ case URLRequestStatus::FAILED:
+ error = ERR_FAILED;
+ break;
+ }
+ set_status(URLRequestStatus(status, error));
set_response_code(response_code);
SetResponseString(response_data);
}
@@ -330,11 +343,10 @@ scoped_ptr<FakeURLFetcher> FakeURLFetcherFactory::DefaultFakeURLFetcherCreator(
const GURL& url,
URLFetcherDelegate* delegate,
const std::string& response_data,
- HttpStatusCode response_code) {
- return scoped_ptr<FakeURLFetcher>(new FakeURLFetcher(url,
- delegate,
- response_data,
- response_code));
+ HttpStatusCode response_code,
+ URLRequestStatus::Status status) {
+ return scoped_ptr<FakeURLFetcher>(
+ new FakeURLFetcher(url, delegate, response_data, response_code, status));
}
FakeURLFetcherFactory::~FakeURLFetcherFactory() {}
@@ -356,7 +368,8 @@ URLFetcher* FakeURLFetcherFactory::CreateURLFetcher(
}
scoped_ptr<FakeURLFetcher> fake_fetcher =
- creator_.Run(url, d, it->second.first, it->second.second);
+ creator_.Run(url, d, it->second.response_data,
+ it->second.response_code, it->second.status);
// TODO: Make URLFetcherFactory::CreateURLFetcher return a scoped_ptr
return fake_fetcher.release();
}
@@ -364,9 +377,14 @@ URLFetcher* FakeURLFetcherFactory::CreateURLFetcher(
void FakeURLFetcherFactory::SetFakeResponse(
const GURL& url,
const std::string& response_data,
- HttpStatusCode response_code) {
+ HttpStatusCode response_code,
+ URLRequestStatus::Status status) {
// Overwrite existing URL if it already exists.
- fake_responses_[url] = std::make_pair(response_data, response_code);
+ FakeURLResponse response;
+ response.response_data = response_data;
+ response.response_code = response_code;
+ response.status = status;
+ fake_responses_[url] = response;
}
void FakeURLFetcherFactory::ClearFakeResponses() {
diff --git a/net/url_request/test_url_fetcher_factory.h b/net/url_request/test_url_fetcher_factory.h
index 50ab815..ff46dba 100644
--- a/net/url_request/test_url_fetcher_factory.h
+++ b/net/url_request/test_url_fetcher_factory.h
@@ -287,7 +287,8 @@ class FakeURLFetcher : public TestURLFetcher {
FakeURLFetcher(const GURL& url,
URLFetcherDelegate* d,
const std::string& response_data,
- HttpStatusCode response_code);
+ HttpStatusCode response_code,
+ URLRequestStatus::Status status);
// Start the request. This will call the given delegate asynchronously
// with the pre-baked response as parameter.
@@ -326,18 +327,29 @@ class FakeURLFetcher : public TestURLFetcher {
// // want to respond with a simple html page and an HTTP/200 code.
// factory.SetFakeResponse("http://a.com/success",
// "<html><body>hello world</body></html>",
-// HTTP_OK);
-// // You know that class SomeService will request url http://a.com/failure and
-// // you want to test the service class by returning a server error.
-// factory.SetFakeResponse("http://a.com/failure",
+// HTTP_OK,
+// URLRequestStatus::SUCCESS);
+// // You know that class SomeService will request url http://a.com/servererror
+// // and you want to test the service class by returning a server error.
+// factory.SetFakeResponse("http://a.com/servererror",
// "",
-// HTTP_INTERNAL_SERVER_ERROR);
-// // You know that class SomeService will request url http://a.com/error and
-// // you want to test the service class by returning a specific error code,
-// // say, a HTTP/401 error.
-// factory.SetFakeResponse("http://a.com/error",
+// HTTP_INTERNAL_SERVER_ERROR,
+// URLRequestStatus::SUCCESS);
+// // You know that class SomeService will request url http://a.com/autherror
+// // and you want to test the service class by returning a specific error
+// // code, say, a HTTP/401 error.
+// factory.SetFakeResponse("http://a.com/autherror",
// "some_response",
-// HTTP_UNAUTHORIZED);
+// HTTP_UNAUTHORIZED,
+// URLRequestStatus::SUCCESS);
+//
+// // You know that class SomeService will request url http://a.com/failure
+// // and you want to test the service class by returning a failure in the
+// // network layer.
+// factory.SetFakeResponse("http://a.com/failure",
+// "",
+// HTTP_INTERNAL_SERVER_ERROR,
+// URLRequestStatus::FAILURE);
//
// SomeService service;
// service.Run(); // Will eventually request these three URLs.
@@ -350,13 +362,16 @@ class FakeURLFetcherFactory : public URLFetcherFactory,
// |delegate| Delegate for FakeURLFetcher
// |response_data| response data for FakeURLFetcher
// |response_code| response code for FakeURLFetcher
+ // |status| URL fetch status for FakeURLFetcher
// These arguments should by default be used in instantiating FakeURLFetcher
- // as follows: new FakeURLFetcher(url, delegate, response_data, response_code)
+ // like so:
+ // new FakeURLFetcher(url, delegate, response_data, response_code, status)
typedef base::Callback<scoped_ptr<FakeURLFetcher>(
const GURL&,
URLFetcherDelegate*,
const std::string&,
- HttpStatusCode)> FakeURLFetcherCreator;
+ HttpStatusCode,
+ URLRequestStatus::Status)> FakeURLFetcherCreator;
// |default_factory|, which can be NULL, is a URLFetcherFactory that
// will be used to construct a URLFetcher in case the URL being created
@@ -390,20 +405,28 @@ class FakeURLFetcherFactory : public URLFetcherFactory,
// Sets the fake response for a given URL. The |response_data| may be empty.
// The |response_code| may be any HttpStatusCode. For instance, HTTP_OK will
// return an HTTP/200 and HTTP_INTERNAL_SERVER_ERROR will return an HTTP/500.
- // Note: The URLRequestStatus of FakeURLFetchers created by the factory will
- // be FAILED for HttpStatusCodes HTTP/5xx, and SUCCESS for all other codes.
+ // The |status| argument may be any URLRequestStatus::Status value. Typically,
+ // requests that return a valid HttpStatusCode have the SUCCESS status, while
+ // requests that indicate a failure to connect to the server have the FAILED
+ // status.
void SetFakeResponse(const GURL& url,
const std::string& response_data,
- HttpStatusCode response_code);
+ HttpStatusCode response_code,
+ URLRequestStatus::Status status);
// Clear all the fake responses that were previously set via
// SetFakeResponse().
void ClearFakeResponses();
private:
+ struct FakeURLResponse {
+ std::string response_data;
+ HttpStatusCode response_code;
+ URLRequestStatus::Status status;
+ };
+ typedef std::map<GURL, FakeURLResponse> FakeResponseMap;
+
const FakeURLFetcherCreator creator_;
- typedef std::map<GURL,
- std::pair<std::string, HttpStatusCode> > FakeResponseMap;
FakeResponseMap fake_responses_;
URLFetcherFactory* const default_factory_;
@@ -411,7 +434,8 @@ class FakeURLFetcherFactory : public URLFetcherFactory,
const GURL& url,
URLFetcherDelegate* delegate,
const std::string& response_data,
- HttpStatusCode response_code);
+ HttpStatusCode response_code,
+ URLRequestStatus::Status status);
DISALLOW_COPY_AND_ASSIGN(FakeURLFetcherFactory);
};
diff --git a/remoting/host/token_validator_factory_impl_unittest.cc b/remoting/host/token_validator_factory_impl_unittest.cc
index 1eb14f7..8737917 100644
--- a/remoting/host/token_validator_factory_impl_unittest.cc
+++ b/remoting/host/token_validator_factory_impl_unittest.cc
@@ -10,6 +10,7 @@
#include "base/values.h"
#include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_status.h"
#include "net/url_request/url_request_test_util.h"
#include "remoting/base/rsa_key_pair.h"
#include "remoting/base/test_rsa_key_pair.h"
@@ -94,8 +95,10 @@ TEST_F(TokenValidatorFactoryImplTest, Success) {
net::FakeURLFetcherFactory factory(NULL);
token_validator_ = token_validator_factory_->CreateTokenValidator(
kLocalJid, kRemoteJid);
- factory.SetFakeResponse(GURL(kTokenValidationUrl), CreateResponse(
- token_validator_->token_scope()), net::HTTP_OK);
+ factory.SetFakeResponse(
+ GURL(kTokenValidationUrl),
+ CreateResponse(token_validator_->token_scope()),
+ net::HTTP_OK, net::URLRequestStatus::SUCCESS);
token_validator_->ValidateThirdPartyToken(
kToken, base::Bind(&TokenValidatorFactoryImplTest::SuccessCallback,
base::Unretained(this)));
@@ -106,9 +109,9 @@ TEST_F(TokenValidatorFactoryImplTest, BadToken) {
net::FakeURLFetcherFactory factory(NULL);
token_validator_ = token_validator_factory_->CreateTokenValidator(
kLocalJid, kRemoteJid);
- factory.SetFakeResponse(GURL(kTokenValidationUrl),
- std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ factory.SetFakeResponse(GURL(kTokenValidationUrl), std::string(),
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
token_validator_->ValidateThirdPartyToken(
kToken, base::Bind(&TokenValidatorFactoryImplTest::FailureCallback,
base::Unretained(this)));
@@ -120,7 +123,8 @@ TEST_F(TokenValidatorFactoryImplTest, BadScope) {
token_validator_ = token_validator_factory_->CreateTokenValidator(
kLocalJid, kRemoteJid);
factory.SetFakeResponse(
- GURL(kTokenValidationUrl), CreateResponse(kBadScope), net::HTTP_OK);
+ GURL(kTokenValidationUrl), CreateResponse(kBadScope), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
token_validator_->ValidateThirdPartyToken(
kToken, base::Bind(&TokenValidatorFactoryImplTest::FailureCallback,
base::Unretained(this)));
@@ -133,7 +137,8 @@ TEST_F(TokenValidatorFactoryImplTest, DeleteOnFailure) {
kLocalJid, kRemoteJid);
factory.SetFakeResponse(GURL(kTokenValidationUrl),
std::string(),
- net::HTTP_INTERNAL_SERVER_ERROR);
+ net::HTTP_INTERNAL_SERVER_ERROR,
+ net::URLRequestStatus::FAILED);
token_validator_->ValidateThirdPartyToken(
kToken, base::Bind(
&TokenValidatorFactoryImplTest::DeleteOnFailureCallback,