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

Side by Side Diff: chrome/browser/chromeos/policy/cloud_external_data_manager_base_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h" 5 #include "chrome/browser/chromeos/policy/cloud_external_data_manager_base.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/message_loop/message_loop_proxy.h" 14 #include "base/message_loop/message_loop_proxy.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/sha1.h" 16 #include "base/sha1.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/test/test_simple_task_runner.h" 19 #include "base/test/test_simple_task_runner.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "chrome/browser/chromeos/policy/cloud_external_data_store.h" 21 #include "chrome/browser/chromeos/policy/cloud_external_data_store.h"
22 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h" 22 #include "chrome/browser/policy/cloud/mock_cloud_policy_store.h"
23 #include "chrome/browser/policy/cloud/resource_cache.h" 23 #include "chrome/browser/policy/cloud/resource_cache.h"
24 #include "chrome/browser/policy/external_data_fetcher.h" 24 #include "chrome/browser/policy/external_data_fetcher.h"
25 #include "chrome/browser/policy/policy_map.h" 25 #include "chrome/browser/policy/policy_map.h"
26 #include "chrome/browser/policy/policy_types.h" 26 #include "chrome/browser/policy/policy_types.h"
27 #include "net/http/http_status_code.h"
27 #include "net/url_request/test_url_fetcher_factory.h" 28 #include "net/url_request/test_url_fetcher_factory.h"
28 #include "net/url_request/url_fetcher.h" 29 #include "net/url_request/url_fetcher.h"
29 #include "net/url_request/url_fetcher_delegate.h" 30 #include "net/url_request/url_fetcher_delegate.h"
30 #include "net/url_request/url_request_test_util.h" 31 #include "net/url_request/url_request_test_util.h"
31 #include "policy/policy_constants.h" 32 #include "policy/policy_constants.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 #include "url/gurl.h" 34 #include "url/gurl.h"
34 35
35 namespace policy { 36 namespace policy {
36 37
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 callback_data_[id] = data.release(); 230 callback_data_[id] = data.release();
230 } 231 }
231 232
232 void CloudExternalDataManagerBaseTest::FetchAll() { 233 void CloudExternalDataManagerBaseTest::FetchAll() {
233 external_data_manager_->FetchAll(); 234 external_data_manager_->FetchAll();
234 } 235 }
235 236
236 void CloudExternalDataManagerBaseTest::SetFakeResponse( 237 void CloudExternalDataManagerBaseTest::SetFakeResponse(
237 const std::string& url, 238 const std::string& url,
238 const std::string& response_data, 239 const std::string& response_data,
239 bool success) { 240 bool success) {
achuithb 2013/11/01 20:57:04 Any reason not to fix this param instead?
Raghu Simha 2013/11/01 21:55:16 I only fixed calls to FakeURLFetcherFactory::SetFa
240 fetcher_factory_.SetFakeResponse(GURL(url), response_data, success); 241 fetcher_factory_.SetFakeResponse(GURL(url),
242 response_data,
243 success ? net::HTTP_OK :
244 net::HTTP_INTERNAL_SERVER_ERROR);
241 } 245 }
242 246
243 // Verifies that when no valid external data reference has been set for a 247 // Verifies that when no valid external data reference has been set for a
244 // policy, the attempt to retrieve the external data fails immediately. 248 // policy, the attempt to retrieve the external data fails immediately.
245 TEST_F(CloudExternalDataManagerBaseTest, FailToFetchInvalid) { 249 TEST_F(CloudExternalDataManagerBaseTest, FailToFetchInvalid) {
246 external_data_manager_->Connect(request_content_getter_); 250 external_data_manager_->Connect(request_content_getter_);
247 251
248 // Attempt to retrieve external data for |kStringPolicy|, which is a string 252 // Attempt to retrieve external data for |kStringPolicy|, which is a string
249 // policy that does not reference any external data. 253 // policy that does not reference any external data.
250 external_data_manager_->Fetch(kStringPolicy, ConstructFetchCallback(0)); 254 external_data_manager_->Fetch(kStringPolicy, ConstructFetchCallback(0));
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 ConstructMetadata(k20BytePolicyURL, base::SHA1HashString(k10ByteData))); 729 ConstructMetadata(k20BytePolicyURL, base::SHA1HashString(k10ByteData)));
726 cloud_policy_store_.NotifyStoreLoaded(); 730 cloud_policy_store_.NotifyStoreLoaded();
727 base::RunLoop().RunUntilIdle(); 731 base::RunLoop().RunUntilIdle();
728 EXPECT_EQ(1u, callback_data_.size()); 732 EXPECT_EQ(1u, callback_data_.size());
729 ASSERT_TRUE(callback_data_[1]); 733 ASSERT_TRUE(callback_data_[1]);
730 EXPECT_EQ(k10ByteData, *callback_data_[1]); 734 EXPECT_EQ(k10ByteData, *callback_data_[1]);
731 ResetCallbackData(); 735 ResetCallbackData();
732 } 736 }
733 737
734 } // namespace policy 738 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698