summaryrefslogtreecommitdiffstats
path: root/chrome/service
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-06 18:36:32 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-06 18:36:32 +0000
commit911a0bc8f2dea094d6d9be4dbf236e90db720cd5 (patch)
tree4eb4b0eb75019eccf92c6eac1658310fc229dda7 /chrome/service
parent45ba64ab757f1eb681d9b285330634b4bc437747 (diff)
downloadchromium_src-911a0bc8f2dea094d6d9be4dbf236e90db720cd5.zip
chromium_src-911a0bc8f2dea094d6d9be4dbf236e90db720cd5.tar.gz
chromium_src-911a0bc8f2dea094d6d9be4dbf236e90db720cd5.tar.bz2
[sync] Allow FakeURLFetcher to return an arbitrary URLRequestStatus
In r232724, FakeURLFetcher went from being able to return only HTTP/200 or HTTP/500, to being able to return any arbitrary HttpResponseCode. However, the URLRequestStatus returned was hard coded to FAILURE for HTTP/5xx and SUCCESS for all other codes. This patch further modifies FakeURLFetcher to be able to return arbitrary URLRequestStatus values in addition to an HttpResponseCode. We no longer hard code the URLRequestStatus based on the HttpResponseCode being returned. It also updates all call sites that currently use FakeURLFetcher. R=achuith@chromium.org, ajwong@chromium.org, akalin@chromium.org, mattm@chromium.org, mmenke@chromium.org, nyquist@chromium.org, sky@chromium.org, tim@chromium.org, vitalybuka@chromium.org TBR=bengr, sergeyu BUG=313905 TEST=All existing tests pass trybots and waterfall Review URL: https://codereview.chromium.org/60923002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233304 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r--chrome/service/cloud_print/printer_job_handler_unittest.cc77
1 files changed, 51 insertions, 26 deletions
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), _))