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/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "remoting/host/dns_blackhole_checker.h" | 10 #include "remoting/host/dns_blackhole_checker.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #endif | 92 #endif |
93 } | 93 } |
94 | 94 |
95 protected: | 95 protected: |
96 void StartWatching() { | 96 void StartWatching() { |
97 policy_watcher_->StartWatching(policy_callback_); | 97 policy_watcher_->StartWatching(policy_callback_); |
98 base::RunLoop().RunUntilIdle(); | 98 base::RunLoop().RunUntilIdle(); |
99 } | 99 } |
100 | 100 |
101 void StopWatching() { | 101 void StopWatching() { |
102 EXPECT_CALL(*this, PostPolicyWatcherShutdown()).Times(1); | 102 base::WaitableEvent stop_event(false, false); |
103 policy_watcher_->StopWatching(base::Bind( | 103 policy_watcher_->StopWatching(&stop_event); |
104 &PolicyWatcherTest::PostPolicyWatcherShutdown, base::Unretained(this))); | |
105 base::RunLoop().RunUntilIdle(); | 104 base::RunLoop().RunUntilIdle(); |
| 105 EXPECT_EQ(true, stop_event.IsSignaled()); |
106 } | 106 } |
107 | 107 |
108 MOCK_METHOD0(PostPolicyWatcherShutdown, void()); | |
109 | |
110 static const char* kHostDomain; | 108 static const char* kHostDomain; |
111 static const char* kPortRange; | 109 static const char* kPortRange; |
112 base::MessageLoop message_loop_; | 110 base::MessageLoop message_loop_; |
113 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 111 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
114 MockPolicyCallback mock_policy_callback_; | 112 MockPolicyCallback mock_policy_callback_; |
115 PolicyWatcher::PolicyCallback policy_callback_; | 113 PolicyWatcher::PolicyCallback policy_callback_; |
116 scoped_ptr<FakePolicyWatcher> policy_watcher_; | 114 scoped_ptr<FakePolicyWatcher> policy_watcher_; |
117 base::DictionaryValue empty_; | 115 base::DictionaryValue empty_; |
118 base::DictionaryValue nat_true_; | 116 base::DictionaryValue nat_true_; |
119 base::DictionaryValue nat_false_; | 117 base::DictionaryValue nat_false_; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 397 |
400 StartWatching(); | 398 StartWatching(); |
401 policy_watcher_->SetPolicies(&empty_); | 399 policy_watcher_->SetPolicies(&empty_); |
402 policy_watcher_->SetPolicies(&port_range_full_); | 400 policy_watcher_->SetPolicies(&port_range_full_); |
403 policy_watcher_->SetPolicies(&port_range_empty_); | 401 policy_watcher_->SetPolicies(&port_range_empty_); |
404 StopWatching(); | 402 StopWatching(); |
405 } | 403 } |
406 | 404 |
407 } // namespace policy_hack | 405 } // namespace policy_hack |
408 } // namespace remoting | 406 } // namespace remoting |
OLD | NEW |