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

Unified Diff: chrome/service/cloud_print/printer_job_handler_unittest.cc

Issue 48713008: [sync] Allow FakeURLFetcher to return arbitrary HTTP response codes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/service/cloud_print/printer_job_handler_unittest.cc
diff --git a/chrome/service/cloud_print/printer_job_handler_unittest.cc b/chrome/service/cloud_print/printer_job_handler_unittest.cc
index 20f802749399bbc58bbc3f7ed4695f49c9761571..f8d3e5cce6dd33c32156c8fcc8129e54b9239ef5 100644
--- a/chrome/service/cloud_print/printer_job_handler_unittest.cc
+++ b/chrome/service/cloud_print/printer_job_handler_unittest.cc
@@ -15,6 +15,7 @@
#include "chrome/service/cloud_print/print_system.h"
#include "chrome/service/cloud_print/printer_job_handler.h"
#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_test_util.h"
#include "printing/backend/print_backend.h"
@@ -281,9 +282,12 @@ class TestURLFetcherCallback {
const GURL& url,
net::URLFetcherDelegate* d,
const std::string& response_data,
- bool success) {
+ net::HttpStatusCode response_code) {
scoped_ptr<net::FakeURLFetcher> fetcher(
- new net::FakeURLFetcher(url, d, response_data, success));
+ new net::FakeURLFetcher(url,
+ d,
Vitaly Buka (NO REVIEWS) 2013/11/01 21:01:02 According http://google-styleguide.googlecode.com/
Raghu Simha 2013/11/01 21:55:16 After a rebase, this all fits in one line. Fixed.
+ response_data,
+ response_code));
OnRequestCreate(url, fetcher.get());
return fetcher.Pass();
}
@@ -497,11 +501,11 @@ void PrinterJobHandlerTest::SetUp() {
void PrinterJobHandlerTest::MakeJobFetchReturnNoJobs() {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(0), true);
+ JobListResponse(0), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonFailure),
- JobListResponse(0), true);
+ JobListResponse(0), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonRetry),
- JobListResponse(0), true);
+ JobListResponse(0), net::HTTP_OK);
}
void PrinterJobHandlerTest::MessageLoopQuitNowHelper(
@@ -543,16 +547,16 @@ void PrinterJobHandlerTest::AddMimeHeader(const GURL& url,
void PrinterJobHandlerTest::SetUpJobSuccessTest(int job_num) {
factory_.SetFakeResponse(TicketURI(job_num),
- kExamplePrintTicket, true);
+ kExamplePrintTicket, net::HTTP_OK);
factory_.SetFakeResponse(DownloadURI(job_num),
- kExamplePrintData, true);
+ kExamplePrintData, net::HTTP_OK);
factory_.SetFakeResponse(DoneURI(job_num),
StatusResponse(job_num, "DONE"),
- true);
+ net::HTTP_OK);
factory_.SetFakeResponse(InProgressURI(job_num),
StatusResponse(job_num, "IN_PROGRESS"),
- true);
+ net::HTTP_OK);
// The times requirement is relaxed for the ticket URI
// in order to accommodate TicketDownloadFailureTest
@@ -656,9 +660,9 @@ MockPrintSystem::MockPrintSystem()
// Disabled - http://crbug.com/184245
TEST_F(PrinterJobHandlerTest, DISABLED_HappyPathTest) {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(1), true);
+ JobListResponse(1), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonQueryMore),
- JobListResponse(0), true);
+ JobListResponse(0), net::HTTP_OK);
EXPECT_CALL(url_callback_,
OnRequestCreate(JobListURI(kJobFetchReasonStartup), _))
@@ -673,12 +677,14 @@ TEST_F(PrinterJobHandlerTest, DISABLED_HappyPathTest) {
TEST_F(PrinterJobHandlerTest, TicketDownloadFailureTest) {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(2), true);
+ JobListResponse(2), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonFailure),
- JobListResponse(2), true);
+ JobListResponse(2), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonQueryMore),
- JobListResponse(0), true);
- factory_.SetFakeResponse(TicketURI(1), std::string(), false);
+ JobListResponse(0), net::HTTP_OK);
+ factory_.SetFakeResponse(TicketURI(1),
Vitaly Buka (NO REVIEWS) 2013/11/01 21:01:02 same
Raghu Simha 2013/11/01 21:55:16 Done.
+ std::string(),
+ net::HTTP_INTERNAL_SERVER_ERROR);
EXPECT_CALL(url_callback_, OnRequestCreate(TicketURI(1), _))
.Times(AtLeast(1));
@@ -703,13 +709,13 @@ TEST_F(PrinterJobHandlerTest, TicketDownloadFailureTest) {
// re-enable it
TEST_F(PrinterJobHandlerTest, DISABLED_ManyFailureTest) {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(1), true);
+ JobListResponse(1), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonFailure),
- JobListResponse(1), true);
+ JobListResponse(1), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonRetry),
- JobListResponse(1), true);
+ JobListResponse(1), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonQueryMore),
- JobListResponse(0), true);
+ JobListResponse(0), net::HTTP_OK);
EXPECT_CALL(url_callback_,
OnRequestCreate(JobListURI(kJobFetchReasonStartup), _))
@@ -729,14 +735,16 @@ TEST_F(PrinterJobHandlerTest, DISABLED_ManyFailureTest) {
SetUpJobSuccessTest(1);
- factory_.SetFakeResponse(TicketURI(1), std::string(), false);
+ factory_.SetFakeResponse(TicketURI(1),
+ std::string(),
+ net::HTTP_INTERNAL_SERVER_ERROR);
loop_.PostDelayedTask(FROM_HERE,
base::Bind(&net::FakeURLFetcherFactory::SetFakeResponse,
base::Unretained(&factory_),
TicketURI(1),
kExamplePrintTicket,
- true),
+ net::HTTP_OK),
base::TimeDelta::FromSeconds(1));
@@ -748,13 +756,17 @@ TEST_F(PrinterJobHandlerTest, DISABLED_ManyFailureTest) {
// constant values) seconds and re-enable it
TEST_F(PrinterJobHandlerTest, DISABLED_CompleteFailureTest) {
factory_.SetFakeResponse(JobListURI(kJobFetchReasonStartup),
- JobListResponse(1), true);
+ JobListResponse(1), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonFailure),
- JobListResponse(1), true);
+ JobListResponse(1), net::HTTP_OK);
factory_.SetFakeResponse(JobListURI(kJobFetchReasonRetry),
- JobListResponse(1), true);
- factory_.SetFakeResponse(ErrorURI(1), StatusResponse(1, "ERROR"), true);
- factory_.SetFakeResponse(TicketURI(1), std::string(), false);
+ JobListResponse(1), net::HTTP_OK);
+ factory_.SetFakeResponse(ErrorURI(1),
+ StatusResponse(1, "ERROR"),
Vitaly Buka (NO REVIEWS) 2013/11/01 21:01:02 same
Raghu Simha 2013/11/01 21:55:16 Done here and the line below.
+ net::HTTP_OK);
+ factory_.SetFakeResponse(TicketURI(1),
+ std::string(),
+ net::HTTP_INTERNAL_SERVER_ERROR);
EXPECT_CALL(url_callback_,
OnRequestCreate(JobListURI(kJobFetchReasonStartup), _))

Powered by Google App Engine
This is Rietveld 408576698