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

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

Issue 23625015: Consolidate TestURLFetcherFactory::SetFakeResponse (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 3 months 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 81126333b7908449e59d081f768e7ef9abcf93d1..b9189fdf7d6a6bb9ac3c740743ca77b4c0dc3225 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
@@ -123,6 +123,10 @@ class CouldExternalDataManagerBaseTest : public testing::Test {
void FetchAll();
+ void SetFakeResponse(const std::string& url,
+ const std::string& repsonse_data,
+ bool success);
+
base::MessageLoop message_loop_;
base::ScopedTempDir temp_dir_;
scoped_ptr<ResourceCache> resource_cache_;
@@ -229,6 +233,13 @@ void CouldExternalDataManagerBaseTest::FetchAll() {
external_data_manager_->FetchAll();
}
+void CloudExternalDataManagerBaseTest::SetFakeResponse(
+ const std::string& url,
+ const std::string& repsonse_data,
+ bool success) {
+ fetcher_factory_.SetFakeResponse(GURL(url), response_data, success);
+}
+
// Verifies that when no valid external data reference has been set for a
// policy, the attempt to retrieve the external data fails immediately.
TEST_F(CouldExternalDataManagerBaseTest, FailToFetchInvalid) {
@@ -272,7 +283,7 @@ TEST_F(CouldExternalDataManagerBaseTest, FailToFetchInvalid) {
// further download attempts.
TEST_F(CouldExternalDataManagerBaseTest, DownloadAndCache) {
// Serve valid external data for |k10BytePolicy|.
- fetcher_factory_.SetFakeResponse(k10BytePolicyURL, k10ByteData, true);
+ SetFakeResponse(k10BytePolicyURL, k10ByteData, true);
external_data_manager_->Connect(request_content_getter_);
// Retrieve external data for |k10BytePolicy|. Verify that a download happens
@@ -327,8 +338,8 @@ TEST_F(CouldExternalDataManagerBaseTest, DownloadAndCache) {
// served from the cache without further download attempts.
TEST_F(CouldExternalDataManagerBaseTest, DownloadAndCacheAll) {
// Serve valid external data for |k10BytePolicy| and |k20BytePolicy|.
- fetcher_factory_.SetFakeResponse(k10BytePolicyURL, k10ByteData, true);
- fetcher_factory_.SetFakeResponse(k20BytePolicyURL, k20ByteData, true);
+ SetFakeResponse(k10BytePolicyURL, k10ByteData, true);
+ SetFakeResponse(k20BytePolicyURL, k20ByteData, true);
external_data_manager_->Connect(request_content_getter_);
// Request that external data referenced by all policies be downloaded.
@@ -396,7 +407,7 @@ TEST_F(CouldExternalDataManagerBaseTest, DownloadAfterConnect) {
// Serve valid external data for |k10BytePolicy| and allow the
// external_data_manager_ to perform downloads.
- fetcher_factory_.SetFakeResponse(k10BytePolicyURL, k10ByteData, true);
+ SetFakeResponse(k10BytePolicyURL, k10ByteData, true);
external_data_manager_->Connect(request_content_getter_);
// Verify that a download happens and the callback is invoked with the
@@ -414,7 +425,7 @@ TEST_F(CouldExternalDataManagerBaseTest, DownloadAfterConnect) {
TEST_F(CouldExternalDataManagerBaseTest, DownloadError) {
// Make attempts to download the external data for |k20BytePolicy| fail with
// an error.
- fetcher_factory_.SetFakeResponse(k20BytePolicyURL, std::string(), false);
+ SetFakeResponse(k20BytePolicyURL, std::string(), false);
external_data_manager_->Connect(request_content_getter_);
// Attempt to retrieve external data for |k20BytePolicy|. Verify that the
@@ -449,7 +460,7 @@ TEST_F(CouldExternalDataManagerBaseTest, DownloadError) {
// Serve external data for |k20BytePolicy| that does not match the hash
// specified in its current external data reference.
- fetcher_factory_.SetFakeResponse(k20BytePolicyURL, k10ByteData, true);
+ SetFakeResponse(k20BytePolicyURL, k10ByteData, true);
// Attempt to retrieve external data for |k20BytePolicy| again. Verify that
// no callback is invoked still as the downloaded succeeds but returns data
@@ -618,7 +629,7 @@ TEST_F(CouldExternalDataManagerBaseTest, CacheCorruption) {
SetUpExternalDataManager();
// Serve external data for |k10BytePolicy| that exceeds the maximal external
// data size allowed for that policy.
- fetcher_factory_.SetFakeResponse(k10BytePolicyURL, k20ByteData, true);
+ SetFakeResponse(k10BytePolicyURL, k20ByteData, true);
external_data_manager_->Connect(request_content_getter_);
// Modify the external data reference for |k10BytePolicy| to match the
@@ -637,7 +648,7 @@ TEST_F(CouldExternalDataManagerBaseTest, CacheCorruption) {
ResetCallbackData();
// Serve valid external data for |k20BytePolicy|.
- fetcher_factory_.SetFakeResponse(k20BytePolicyURL, k20ByteData, true);
+ SetFakeResponse(k20BytePolicyURL, k20ByteData, true);
// Retrieve external data for |k20BytePolicy|. Verify that the callback is
// invoked with the valid downloaded data, not the invalid data in the cache.
@@ -678,8 +689,8 @@ TEST_F(CouldExternalDataManagerBaseTest, CacheCorruption) {
TEST_F(CouldExternalDataManagerBaseTest, PolicyChangeWhileDownloadPending) {
// Make attempts to download the external data for |k10BytePolicy| and
// |k20BytePolicy| fail with an error.
- fetcher_factory_.SetFakeResponse(k10BytePolicyURL, std::string(), false);
- fetcher_factory_.SetFakeResponse(k20BytePolicyURL, std::string(), false);
+ SetFakeResponse(k10BytePolicyURL, std::string(), false);
+ SetFakeResponse(k20BytePolicyURL, std::string(), false);
external_data_manager_->Connect(request_content_getter_);
// Attempt to retrieve external data for |k10BytePolicy| and |k20BytePolicy|.
@@ -704,7 +715,7 @@ TEST_F(CouldExternalDataManagerBaseTest, PolicyChangeWhileDownloadPending) {
// Serve valid external data for |k20BytePolicy|.
fetcher_factory_.ClearFakeResponses();
- fetcher_factory_.SetFakeResponse(k20BytePolicyURL, k10ByteData, true);
+ SetFakeResponse(k20BytePolicyURL, k10ByteData, true);
// 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