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

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: 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/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..0ef3531095d08cf8bbc9e7534e32cc657a52d6e6 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
« no previous file with comments | « chrome/browser/chromeos/login/eula_browsertest.cc ('k') | chrome/browser/chromeos/policy/device_local_account_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698