| OLD | NEW |
| 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/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/test/test_simple_task_runner.h" | 18 #include "base/test/test_simple_task_runner.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.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 "components/policy/core/common/cloud/mock_cloud_policy_store.h" | 22 #include "components/policy/core/common/cloud/mock_cloud_policy_store.h" |
| 23 #include "components/policy/core/common/cloud/resource_cache.h" | 23 #include "components/policy/core/common/cloud/resource_cache.h" |
| 24 #include "components/policy/core/common/external_data_fetcher.h" | 24 #include "components/policy/core/common/external_data_fetcher.h" |
| 25 #include "components/policy/core/common/policy_map.h" | 25 #include "components/policy/core/common/policy_map.h" |
| 26 #include "components/policy/core/common/policy_test_utils.h" | 26 #include "components/policy/core/common/policy_test_utils.h" |
| 27 #include "components/policy/core/common/policy_types.h" | 27 #include "components/policy/core/common/policy_types.h" |
| 28 #include "crypto/sha2.h" | 28 #include "crypto/sha2.h" |
| 29 #include "net/http/http_status_code.h" | 29 #include "net/http/http_status_code.h" |
| 30 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 30 #include "net/url_request/test_url_fetcher_factory.h" | 31 #include "net/url_request/test_url_fetcher_factory.h" |
| 31 #include "net/url_request/url_fetcher.h" | 32 #include "net/url_request/url_fetcher.h" |
| 32 #include "net/url_request/url_fetcher_delegate.h" | 33 #include "net/url_request/url_fetcher_delegate.h" |
| 33 #include "net/url_request/url_request_status.h" | 34 #include "net/url_request/url_request_status.h" |
| 34 #include "net/url_request/url_request_test_util.h" | 35 #include "net/url_request/url_request_test_util.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 36 #include "url/gurl.h" | 37 #include "url/gurl.h" |
| 37 | 38 |
| 38 namespace policy { | 39 namespace policy { |
| 39 | 40 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 68 class FakeURLFetcherFactory : public net::FakeURLFetcherFactory { | 69 class FakeURLFetcherFactory : public net::FakeURLFetcherFactory { |
| 69 public: | 70 public: |
| 70 FakeURLFetcherFactory(); | 71 FakeURLFetcherFactory(); |
| 71 ~FakeURLFetcherFactory() override; | 72 ~FakeURLFetcherFactory() override; |
| 72 | 73 |
| 73 // net::FakeURLFetcherFactory: | 74 // net::FakeURLFetcherFactory: |
| 74 std::unique_ptr<net::URLFetcher> CreateURLFetcher( | 75 std::unique_ptr<net::URLFetcher> CreateURLFetcher( |
| 75 int id, | 76 int id, |
| 76 const GURL& url, | 77 const GURL& url, |
| 77 net::URLFetcher::RequestType request_type, | 78 net::URLFetcher::RequestType request_type, |
| 78 net::URLFetcherDelegate* delegate) override; | 79 net::URLFetcherDelegate* delegate, |
| 80 net::NetworkTrafficAnnotationTag traffic_annotation) override; |
| 79 | 81 |
| 80 private: | 82 private: |
| 81 DISALLOW_COPY_AND_ASSIGN(FakeURLFetcherFactory); | 83 DISALLOW_COPY_AND_ASSIGN(FakeURLFetcherFactory); |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 FakeURLFetcherFactory::FakeURLFetcherFactory() | 86 FakeURLFetcherFactory::FakeURLFetcherFactory() |
| 85 : net::FakeURLFetcherFactory(NULL) { | 87 : net::FakeURLFetcherFactory(NULL) { |
| 86 } | 88 } |
| 87 | 89 |
| 88 FakeURLFetcherFactory::~FakeURLFetcherFactory() { | 90 FakeURLFetcherFactory::~FakeURLFetcherFactory() { |
| 89 } | 91 } |
| 90 | 92 |
| 91 std::unique_ptr<net::URLFetcher> FakeURLFetcherFactory::CreateURLFetcher( | 93 std::unique_ptr<net::URLFetcher> FakeURLFetcherFactory::CreateURLFetcher( |
| 92 int id, | 94 int id, |
| 93 const GURL& url, | 95 const GURL& url, |
| 94 net::URLFetcher::RequestType request_type, | 96 net::URLFetcher::RequestType request_type, |
| 95 net::URLFetcherDelegate* delegate) { | 97 net::URLFetcherDelegate* delegate, |
| 98 net::NetworkTrafficAnnotationTag traffic_annotation) { |
| 96 std::unique_ptr<net::URLFetcher> fetcher = | 99 std::unique_ptr<net::URLFetcher> fetcher = |
| 97 net::FakeURLFetcherFactory::CreateURLFetcher(id, url, request_type, | 100 net::FakeURLFetcherFactory::CreateURLFetcher( |
| 98 delegate); | 101 id, url, request_type, delegate, traffic_annotation); |
| 99 EXPECT_TRUE(fetcher); | 102 EXPECT_TRUE(fetcher); |
| 100 return fetcher; | 103 return fetcher; |
| 101 } | 104 } |
| 102 | 105 |
| 103 } // namespace | 106 } // namespace |
| 104 | 107 |
| 105 class CloudExternalDataManagerBaseTest : public testing::Test { | 108 class CloudExternalDataManagerBaseTest : public testing::Test { |
| 106 protected: | 109 protected: |
| 107 CloudExternalDataManagerBaseTest(); | 110 CloudExternalDataManagerBaseTest(); |
| 108 | 111 |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 crypto::SHA256HashString(k10ByteData))); | 760 crypto::SHA256HashString(k10ByteData))); |
| 758 cloud_policy_store_.NotifyStoreLoaded(); | 761 cloud_policy_store_.NotifyStoreLoaded(); |
| 759 base::RunLoop().RunUntilIdle(); | 762 base::RunLoop().RunUntilIdle(); |
| 760 EXPECT_EQ(1u, callback_data_.size()); | 763 EXPECT_EQ(1u, callback_data_.size()); |
| 761 ASSERT_TRUE(callback_data_[1]); | 764 ASSERT_TRUE(callback_data_[1]); |
| 762 EXPECT_EQ(k10ByteData, *callback_data_[1]); | 765 EXPECT_EQ(k10ByteData, *callback_data_[1]); |
| 763 ResetCallbackData(); | 766 ResetCallbackData(); |
| 764 } | 767 } |
| 765 | 768 |
| 766 } // namespace policy | 769 } // namespace policy |
| OLD | NEW |