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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 class FakeUser : public user_manager::User { | 54 class FakeUser : public user_manager::User { |
55 public: | 55 public: |
56 FakeUser() : User(kFakeUserEmail) { | 56 FakeUser() : User(kFakeUserEmail) { |
57 set_display_email(kFakeUserEmail); | 57 set_display_email(kFakeUserEmail); |
58 set_username_hash(kFakeUsernameHash); | 58 set_username_hash(kFakeUsernameHash); |
59 } | 59 } |
60 virtual ~FakeUser() {} | 60 virtual ~FakeUser() {} |
61 | 61 |
62 // User overrides | 62 // User overrides |
63 virtual user_manager::UserType GetType() const OVERRIDE { | 63 virtual user_manager::UserType GetType() const override { |
64 return user_manager::USER_TYPE_REGULAR; | 64 return user_manager::USER_TYPE_REGULAR; |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 DISALLOW_COPY_AND_ASSIGN(FakeUser); | 68 DISALLOW_COPY_AND_ASSIGN(FakeUser); |
69 }; | 69 }; |
70 | 70 |
71 class FakeWebTrustedCertsObserver | 71 class FakeWebTrustedCertsObserver |
72 : public UserNetworkConfigurationUpdater::WebTrustedCertsObserver { | 72 : public UserNetworkConfigurationUpdater::WebTrustedCertsObserver { |
73 public: | 73 public: |
74 FakeWebTrustedCertsObserver() {} | 74 FakeWebTrustedCertsObserver() {} |
75 | 75 |
76 virtual void OnTrustAnchorsChanged( | 76 virtual void OnTrustAnchorsChanged( |
77 const net::CertificateList& trust_anchors) OVERRIDE { | 77 const net::CertificateList& trust_anchors) override { |
78 trust_anchors_ = trust_anchors; | 78 trust_anchors_ = trust_anchors; |
79 } | 79 } |
80 net::CertificateList trust_anchors_; | 80 net::CertificateList trust_anchors_; |
81 | 81 |
82 private: | 82 private: |
83 DISALLOW_COPY_AND_ASSIGN(FakeWebTrustedCertsObserver); | 83 DISALLOW_COPY_AND_ASSIGN(FakeWebTrustedCertsObserver); |
84 }; | 84 }; |
85 | 85 |
86 class FakeNetworkDeviceHandler : public chromeos::FakeNetworkDeviceHandler { | 86 class FakeNetworkDeviceHandler : public chromeos::FakeNetworkDeviceHandler { |
87 public: | 87 public: |
88 FakeNetworkDeviceHandler() : allow_roaming_(false) {} | 88 FakeNetworkDeviceHandler() : allow_roaming_(false) {} |
89 | 89 |
90 virtual void SetCellularAllowRoaming(bool allow_roaming) OVERRIDE { | 90 virtual void SetCellularAllowRoaming(bool allow_roaming) override { |
91 allow_roaming_ = allow_roaming; | 91 allow_roaming_ = allow_roaming; |
92 } | 92 } |
93 | 93 |
94 bool allow_roaming_; | 94 bool allow_roaming_; |
95 | 95 |
96 private: | 96 private: |
97 DISALLOW_COPY_AND_ASSIGN(FakeNetworkDeviceHandler); | 97 DISALLOW_COPY_AND_ASSIGN(FakeNetworkDeviceHandler); |
98 }; | 98 }; |
99 | 99 |
100 class FakeCertificateImporter : public chromeos::onc::CertificateImporter { | 100 class FakeCertificateImporter : public chromeos::onc::CertificateImporter { |
(...skipping 16 matching lines...) Expand all Loading... |
117 } | 117 } |
118 | 118 |
119 unsigned int GetAndResetImportCount() { | 119 unsigned int GetAndResetImportCount() { |
120 unsigned int count = call_count_; | 120 unsigned int count = call_count_; |
121 call_count_ = 0; | 121 call_count_ = 0; |
122 return count; | 122 return count; |
123 } | 123 } |
124 | 124 |
125 virtual void ImportCertificates(const base::ListValue& certificates, | 125 virtual void ImportCertificates(const base::ListValue& certificates, |
126 ::onc::ONCSource source, | 126 ::onc::ONCSource source, |
127 const DoneCallback& done_callback) OVERRIDE { | 127 const DoneCallback& done_callback) override { |
128 if (expected_onc_source_ != ::onc::ONC_SOURCE_UNKNOWN) | 128 if (expected_onc_source_ != ::onc::ONC_SOURCE_UNKNOWN) |
129 EXPECT_EQ(expected_onc_source_, source); | 129 EXPECT_EQ(expected_onc_source_, source); |
130 if (expected_onc_certificates_) { | 130 if (expected_onc_certificates_) { |
131 EXPECT_TRUE(chromeos::onc::test_utils::Equals( | 131 EXPECT_TRUE(chromeos::onc::test_utils::Equals( |
132 expected_onc_certificates_.get(), &certificates)); | 132 expected_onc_certificates_.get(), &certificates)); |
133 } | 133 } |
134 ++call_count_; | 134 ++call_count_; |
135 done_callback.Run(true, onc_trusted_certificates_); | 135 done_callback.Run(true, onc_trusted_certificates_); |
136 } | 136 } |
137 | 137 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 *arg2 = list; | 195 *arg2 = list; |
196 return true; | 196 return true; |
197 } | 197 } |
198 | 198 |
199 } // namespace | 199 } // namespace |
200 | 200 |
201 class NetworkConfigurationUpdaterTest : public testing::Test { | 201 class NetworkConfigurationUpdaterTest : public testing::Test { |
202 protected: | 202 protected: |
203 NetworkConfigurationUpdaterTest() : certificate_importer_(NULL) {} | 203 NetworkConfigurationUpdaterTest() : certificate_importer_(NULL) {} |
204 | 204 |
205 virtual void SetUp() OVERRIDE { | 205 virtual void SetUp() override { |
206 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 206 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
207 .WillRepeatedly(Return(false)); | 207 .WillRepeatedly(Return(false)); |
208 provider_.Init(); | 208 provider_.Init(); |
209 PolicyServiceImpl::Providers providers; | 209 PolicyServiceImpl::Providers providers; |
210 providers.push_back(&provider_); | 210 providers.push_back(&provider_); |
211 policy_service_.reset(new PolicyServiceImpl(providers)); | 211 policy_service_.reset(new PolicyServiceImpl(providers)); |
212 | 212 |
213 scoped_ptr<base::DictionaryValue> fake_toplevel_onc = | 213 scoped_ptr<base::DictionaryValue> fake_toplevel_onc = |
214 chromeos::onc::ReadDictionaryFromJson(kFakeONC); | 214 chromeos::onc::ReadDictionaryFromJson(kFakeONC); |
215 | 215 |
216 base::ListValue* network_configs = NULL; | 216 base::ListValue* network_configs = NULL; |
217 fake_toplevel_onc->GetListWithoutPathExpansion( | 217 fake_toplevel_onc->GetListWithoutPathExpansion( |
218 onc::toplevel_config::kNetworkConfigurations, &network_configs); | 218 onc::toplevel_config::kNetworkConfigurations, &network_configs); |
219 AppendAll(*network_configs, &fake_network_configs_); | 219 AppendAll(*network_configs, &fake_network_configs_); |
220 | 220 |
221 base::DictionaryValue* global_config = NULL; | 221 base::DictionaryValue* global_config = NULL; |
222 fake_toplevel_onc->GetDictionaryWithoutPathExpansion( | 222 fake_toplevel_onc->GetDictionaryWithoutPathExpansion( |
223 onc::toplevel_config::kGlobalNetworkConfiguration, &global_config); | 223 onc::toplevel_config::kGlobalNetworkConfiguration, &global_config); |
224 fake_global_network_config_.MergeDictionary(global_config); | 224 fake_global_network_config_.MergeDictionary(global_config); |
225 | 225 |
226 base::ListValue* certs = NULL; | 226 base::ListValue* certs = NULL; |
227 fake_toplevel_onc->GetListWithoutPathExpansion( | 227 fake_toplevel_onc->GetListWithoutPathExpansion( |
228 onc::toplevel_config::kCertificates, &certs); | 228 onc::toplevel_config::kCertificates, &certs); |
229 AppendAll(*certs, &fake_certificates_); | 229 AppendAll(*certs, &fake_certificates_); |
230 | 230 |
231 certificate_importer_ = new FakeCertificateImporter; | 231 certificate_importer_ = new FakeCertificateImporter; |
232 certificate_importer_owned_.reset(certificate_importer_); | 232 certificate_importer_owned_.reset(certificate_importer_); |
233 } | 233 } |
234 | 234 |
235 virtual void TearDown() OVERRIDE { | 235 virtual void TearDown() override { |
236 network_configuration_updater_.reset(); | 236 network_configuration_updater_.reset(); |
237 provider_.Shutdown(); | 237 provider_.Shutdown(); |
238 base::RunLoop().RunUntilIdle(); | 238 base::RunLoop().RunUntilIdle(); |
239 } | 239 } |
240 | 240 |
241 void MarkPolicyProviderInitialized() { | 241 void MarkPolicyProviderInitialized() { |
242 Mock::VerifyAndClearExpectations(&provider_); | 242 Mock::VerifyAndClearExpectations(&provider_); |
243 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 243 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
244 .WillRepeatedly(Return(true)); | 244 .WillRepeatedly(Return(true)); |
245 provider_.SetAutoRefresh(); | 245 provider_.SetAutoRefresh(); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 EXPECT_EQ(ExpectedImportCertificatesCallCount(), | 673 EXPECT_EQ(ExpectedImportCertificatesCallCount(), |
674 certificate_importer_->GetAndResetImportCount()); | 674 certificate_importer_->GetAndResetImportCount()); |
675 } | 675 } |
676 | 676 |
677 INSTANTIATE_TEST_CASE_P(NetworkConfigurationUpdaterTestWithParamInstance, | 677 INSTANTIATE_TEST_CASE_P(NetworkConfigurationUpdaterTestWithParamInstance, |
678 NetworkConfigurationUpdaterTestWithParam, | 678 NetworkConfigurationUpdaterTestWithParam, |
679 testing::Values(key::kDeviceOpenNetworkConfiguration, | 679 testing::Values(key::kDeviceOpenNetworkConfiguration, |
680 key::kOpenNetworkConfiguration)); | 680 key::kOpenNetworkConfiguration)); |
681 | 681 |
682 } // namespace policy | 682 } // namespace policy |
OLD | NEW |