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