OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/host/policy_watcher.h" | 5 #include "remoting/host/policy_watcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // Simulate a policy file/registry/preference update. | 232 // Simulate a policy file/registry/preference update. |
233 policy_loader_->SetPolicies(policy_bundle); | 233 policy_loader_->SetPolicies(policy_bundle); |
234 policy_loader_->PostReloadOnBackgroundThread(true /* force reload asap */); | 234 policy_loader_->PostReloadOnBackgroundThread(true /* force reload asap */); |
235 base::RunLoop().RunUntilIdle(); | 235 base::RunLoop().RunUntilIdle(); |
236 } | 236 } |
237 | 237 |
238 const policy::Schema* GetPolicySchema() { | 238 const policy::Schema* GetPolicySchema() { |
239 return policy_watcher_->GetPolicySchema(); | 239 return policy_watcher_->GetPolicySchema(); |
240 } | 240 } |
241 | 241 |
| 242 // TODO(jamiewalch): Update this to use PolicyWatcher::GetDefaultValues() |
242 const base::DictionaryValue& GetDefaultValues() { | 243 const base::DictionaryValue& GetDefaultValues() { |
243 return *(policy_watcher_->default_values_); | 244 return *(policy_watcher_->default_values_); |
244 } | 245 } |
245 | 246 |
246 MOCK_METHOD0(PostPolicyWatcherShutdown, void()); | 247 MOCK_METHOD0(PostPolicyWatcherShutdown, void()); |
247 | 248 |
248 static const char* kHostDomain; | 249 static const char* kHostDomain; |
249 static const char* kClientDomain; | 250 static const char* kClientDomain; |
250 static const char* kPortRange; | 251 static const char* kPortRange; |
251 base::MessageLoop message_loop_; | 252 base::MessageLoop message_loop_; |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 StartWatching(); | 763 StartWatching(); |
763 } | 764 } |
764 | 765 |
765 TEST_F(PolicyWatcherTest, DeprecatedEmpty) { | 766 TEST_F(PolicyWatcherTest, DeprecatedEmpty) { |
766 EXPECT_CALL(mock_policy_callback_, | 767 EXPECT_CALL(mock_policy_callback_, |
767 OnPolicyUpdatePtr(IsPolicies(&GetDefaultValues()))); | 768 OnPolicyUpdatePtr(IsPolicies(&GetDefaultValues()))); |
768 SetPolicies(deprecated_empty_strings_); | 769 SetPolicies(deprecated_empty_strings_); |
769 StartWatching(); | 770 StartWatching(); |
770 } | 771 } |
771 | 772 |
| 773 TEST_F(PolicyWatcherTest, GetCurrentPolicies) { |
| 774 testing::InSequence sequence; |
| 775 EXPECT_CALL(mock_policy_callback_, |
| 776 OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); |
| 777 EXPECT_CALL(mock_policy_callback_, |
| 778 OnPolicyUpdatePtr(IsPolicies(&nat_false_))); |
| 779 |
| 780 StartWatching(); |
| 781 SetPolicies(nat_false_); |
| 782 std::unique_ptr<base::DictionaryValue> current_policies = |
| 783 policy_watcher_->GetCurrentPolicies(); |
| 784 ASSERT_TRUE(*current_policies == nat_false_others_default_); |
| 785 } |
| 786 |
772 } // namespace remoting | 787 } // namespace remoting |
OLD | NEW |