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

Unified Diff: chrome/browser/chromeos/policy/cloud_external_data_manager_base_unittest.cc

Issue 60923002: [sync] Allow FakeURLFetcher to return an arbitrary URLRequestStatus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/browser/chromeos/policy/cloud_external_data_manager_base_unittest.cc
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 d795fc589e11c2ddc814aff71411d249abdc9528..7c92c5d39920f7f329543aeb1e67deed394a20b6 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"
@@ -284,7 +285,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 +341,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 +412,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 +432,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 +468,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 +638,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 +658,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 +701,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 +730,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

Powered by Google App Engine
This is Rietveld 408576698