OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "remoting/host/policy_hack/fake_policy_watcher.h" | 9 #include "remoting/host/policy_hack/fake_policy_watcher.h" |
10 #include "remoting/host/policy_hack/mock_policy_callback.h" | 10 #include "remoting/host/policy_hack/mock_policy_callback.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 nat_true_domain_empty_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 43 nat_true_domain_empty_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
44 nat_true_domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, ""); | 44 nat_true_domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, ""); |
45 nat_true_domain_full_.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 45 nat_true_domain_full_.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
46 nat_true_domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, | 46 nat_true_domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, |
47 kHostDomain); | 47 kHostDomain); |
48 nat_false_domain_empty_.SetBoolean(PolicyWatcher::kNatPolicyName, false); | 48 nat_false_domain_empty_.SetBoolean(PolicyWatcher::kNatPolicyName, false); |
49 nat_false_domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, ""); | 49 nat_false_domain_empty_.SetString(PolicyWatcher::kHostDomainPolicyName, ""); |
50 nat_false_domain_full_.SetBoolean(PolicyWatcher::kNatPolicyName, false); | 50 nat_false_domain_full_.SetBoolean(PolicyWatcher::kNatPolicyName, false); |
51 nat_false_domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, | 51 nat_false_domain_full_.SetString(PolicyWatcher::kHostDomainPolicyName, |
52 kHostDomain); | 52 kHostDomain); |
| 53 SetDefaults(nat_true_domain_empty_others_default_); |
| 54 nat_true_domain_empty_others_default_.SetBoolean( |
| 55 PolicyWatcher::kNatPolicyName, true); |
| 56 nat_true_domain_empty_others_default_.SetString( |
| 57 PolicyWatcher::kHostDomainPolicyName, ""); |
53 } | 58 } |
54 | 59 |
55 protected: | 60 protected: |
56 void StartWatching() { | 61 void StartWatching() { |
57 policy_watcher_->StartWatching(policy_callback_); | 62 policy_watcher_->StartWatching(policy_callback_); |
58 message_loop_.RunUntilIdle(); | 63 message_loop_.RunUntilIdle(); |
59 } | 64 } |
60 | 65 |
61 void StopWatching() { | 66 void StopWatching() { |
62 base::WaitableEvent stop_event(false, false); | 67 base::WaitableEvent stop_event(false, false); |
(...skipping 15 matching lines...) Expand all Loading... |
78 base::DictionaryValue domain_empty_; | 83 base::DictionaryValue domain_empty_; |
79 base::DictionaryValue domain_full_; | 84 base::DictionaryValue domain_full_; |
80 base::DictionaryValue nat_true_others_default_; | 85 base::DictionaryValue nat_true_others_default_; |
81 base::DictionaryValue nat_false_others_default_; | 86 base::DictionaryValue nat_false_others_default_; |
82 base::DictionaryValue domain_empty_others_default_; | 87 base::DictionaryValue domain_empty_others_default_; |
83 base::DictionaryValue domain_full_others_default_; | 88 base::DictionaryValue domain_full_others_default_; |
84 base::DictionaryValue nat_true_domain_empty_; | 89 base::DictionaryValue nat_true_domain_empty_; |
85 base::DictionaryValue nat_true_domain_full_; | 90 base::DictionaryValue nat_true_domain_full_; |
86 base::DictionaryValue nat_false_domain_empty_; | 91 base::DictionaryValue nat_false_domain_empty_; |
87 base::DictionaryValue nat_false_domain_full_; | 92 base::DictionaryValue nat_false_domain_full_; |
| 93 base::DictionaryValue nat_true_domain_empty_others_default_; |
88 | 94 |
89 private: | 95 private: |
90 void SetDefaults(base::DictionaryValue& dict) { | 96 void SetDefaults(base::DictionaryValue& dict) { |
91 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); | 97 dict.SetBoolean(PolicyWatcher::kNatPolicyName, true); |
| 98 dict.SetBoolean(PolicyWatcher::kRequireTwoFactorPolicyName, false); |
92 dict.SetString(PolicyWatcher::kHostDomainPolicyName, ""); | 99 dict.SetString(PolicyWatcher::kHostDomainPolicyName, ""); |
| 100 dict.SetString(PolicyWatcher::kTalkGadgetPolicyName, "chromoting"); |
93 } | 101 } |
94 }; | 102 }; |
95 | 103 |
96 const char* PolicyWatcherTest::kHostDomain = "google.com"; | 104 const char* PolicyWatcherTest::kHostDomain = "google.com"; |
97 | 105 |
98 MATCHER_P(IsPolicies, dict, "") { | 106 MATCHER_P(IsPolicies, dict, "") { |
99 return arg->Equals(dict); | 107 return arg->Equals(dict); |
100 } | 108 } |
101 | 109 |
102 TEST_F(PolicyWatcherTest, None) { | 110 TEST_F(PolicyWatcherTest, None) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 StartWatching(); | 222 StartWatching(); |
215 policy_watcher_->SetPolicies(&empty_); | 223 policy_watcher_->SetPolicies(&empty_); |
216 policy_watcher_->SetPolicies(&nat_false_); | 224 policy_watcher_->SetPolicies(&nat_false_); |
217 policy_watcher_->SetPolicies(&nat_true_); | 225 policy_watcher_->SetPolicies(&nat_true_); |
218 StopWatching(); | 226 StopWatching(); |
219 } | 227 } |
220 | 228 |
221 TEST_F(PolicyWatcherTest, ChangeOneRepeatedlyThenTwo) { | 229 TEST_F(PolicyWatcherTest, ChangeOneRepeatedlyThenTwo) { |
222 testing::InSequence sequence; | 230 testing::InSequence sequence; |
223 EXPECT_CALL(mock_policy_callback_, | 231 EXPECT_CALL(mock_policy_callback_, |
224 OnPolicyUpdatePtr(IsPolicies(&nat_true_domain_empty_))); | 232 OnPolicyUpdatePtr(IsPolicies( |
| 233 &nat_true_domain_empty_others_default_))); |
225 EXPECT_CALL(mock_policy_callback_, | 234 EXPECT_CALL(mock_policy_callback_, |
226 OnPolicyUpdatePtr(IsPolicies(&domain_full_))); | 235 OnPolicyUpdatePtr(IsPolicies(&domain_full_))); |
227 EXPECT_CALL(mock_policy_callback_, | 236 EXPECT_CALL(mock_policy_callback_, |
228 OnPolicyUpdatePtr(IsPolicies(&nat_false_))); | 237 OnPolicyUpdatePtr(IsPolicies(&nat_false_))); |
229 EXPECT_CALL(mock_policy_callback_, | 238 EXPECT_CALL(mock_policy_callback_, |
230 OnPolicyUpdatePtr(IsPolicies(&domain_empty_))); | 239 OnPolicyUpdatePtr(IsPolicies(&domain_empty_))); |
231 EXPECT_CALL(mock_policy_callback_, | 240 EXPECT_CALL(mock_policy_callback_, |
232 OnPolicyUpdatePtr(IsPolicies(&nat_true_domain_full_))); | 241 OnPolicyUpdatePtr(IsPolicies(&nat_true_domain_full_))); |
233 | 242 |
234 StartWatching(); | 243 StartWatching(); |
235 policy_watcher_->SetPolicies(&nat_true_domain_empty_); | 244 policy_watcher_->SetPolicies(&nat_true_domain_empty_); |
236 policy_watcher_->SetPolicies(&nat_true_domain_full_); | 245 policy_watcher_->SetPolicies(&nat_true_domain_full_); |
237 policy_watcher_->SetPolicies(&nat_false_domain_full_); | 246 policy_watcher_->SetPolicies(&nat_false_domain_full_); |
238 policy_watcher_->SetPolicies(&nat_false_domain_empty_); | 247 policy_watcher_->SetPolicies(&nat_false_domain_empty_); |
239 policy_watcher_->SetPolicies(&nat_true_domain_full_); | 248 policy_watcher_->SetPolicies(&nat_true_domain_full_); |
240 StopWatching(); | 249 StopWatching(); |
241 } | 250 } |
242 | 251 |
243 } // namespace policy_hack | 252 } // namespace policy_hack |
244 } // namespace remoting | 253 } // namespace remoting |
OLD | NEW |