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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | |
10 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
11 #include "base/test/mock_log.h" | 12 #include "base/test/mock_log.h" |
13 #include "base/thread_task_runner_handle.h" | |
12 #include "components/policy/core/common/fake_async_policy_loader.h" | 14 #include "components/policy/core/common/fake_async_policy_loader.h" |
13 #include "policy/policy_constants.h" | 15 #include "policy/policy_constants.h" |
14 #include "remoting/host/dns_blackhole_checker.h" | 16 #include "remoting/host/dns_blackhole_checker.h" |
15 #include "remoting/host/policy_watcher.h" | 17 #include "remoting/host/policy_watcher.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 | 20 |
19 namespace remoting { | 21 namespace remoting { |
20 | 22 |
21 namespace key = ::policy::key; | 23 namespace key = ::policy::key; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 | 58 |
57 class PolicyWatcherTest : public testing::Test { | 59 class PolicyWatcherTest : public testing::Test { |
58 public: | 60 public: |
59 PolicyWatcherTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 61 PolicyWatcherTest() : message_loop_(base::MessageLoop::TYPE_IO) {} |
60 | 62 |
61 void SetUp() override { | 63 void SetUp() override { |
62 // We expect no callbacks unless explicitly specified by individual tests. | 64 // We expect no callbacks unless explicitly specified by individual tests. |
63 EXPECT_CALL(mock_policy_callback_, OnPolicyUpdatePtr(testing::_)).Times(0); | 65 EXPECT_CALL(mock_policy_callback_, OnPolicyUpdatePtr(testing::_)).Times(0); |
64 EXPECT_CALL(mock_policy_callback_, OnPolicyError()).Times(0); | 66 EXPECT_CALL(mock_policy_callback_, OnPolicyError()).Times(0); |
65 | 67 |
66 message_loop_proxy_ = base::MessageLoopProxy::current(); | 68 message_loop_proxy_ = base::ThreadTaskRunnerHandle::Get(); |
67 | 69 |
68 // Retaining a raw pointer to keep control over policy contents. | 70 // Retaining a raw pointer to keep control over policy contents. |
69 policy_loader_ = new policy::FakeAsyncPolicyLoader(message_loop_proxy_); | 71 policy_loader_ = new policy::FakeAsyncPolicyLoader(message_loop_proxy_); |
Sergey Ulanov
2015/04/28 17:03:22
I think you can replace message_loop_proxy_ here w
anujsharma
2015/05/04 12:38:21
Done.
| |
70 policy_watcher_ = | 72 policy_watcher_ = |
71 PolicyWatcher::CreateFromPolicyLoader(make_scoped_ptr(policy_loader_)); | 73 PolicyWatcher::CreateFromPolicyLoader(make_scoped_ptr(policy_loader_)); |
72 | 74 |
73 nat_true_.SetBoolean(key::kRemoteAccessHostFirewallTraversal, true); | 75 nat_true_.SetBoolean(key::kRemoteAccessHostFirewallTraversal, true); |
74 nat_false_.SetBoolean(key::kRemoteAccessHostFirewallTraversal, false); | 76 nat_false_.SetBoolean(key::kRemoteAccessHostFirewallTraversal, false); |
75 nat_one_.SetInteger(key::kRemoteAccessHostFirewallTraversal, 1); | 77 nat_one_.SetInteger(key::kRemoteAccessHostFirewallTraversal, 1); |
76 nat_one_domain_full_.SetInteger(key::kRemoteAccessHostFirewallTraversal, 1); | 78 nat_one_domain_full_.SetInteger(key::kRemoteAccessHostFirewallTraversal, 1); |
77 nat_one_domain_full_.SetString(key::kRemoteAccessHostDomain, kHostDomain); | 79 nat_one_domain_full_.SetString(key::kRemoteAccessHostDomain, kHostDomain); |
78 domain_empty_.SetString(key::kRemoteAccessHostDomain, std::string()); | 80 domain_empty_.SetString(key::kRemoteAccessHostDomain, std::string()); |
79 domain_full_.SetString(key::kRemoteAccessHostDomain, kHostDomain); | 81 domain_full_.SetString(key::kRemoteAccessHostDomain, kHostDomain); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 | 201 |
200 const base::DictionaryValue& GetDefaultValues() { | 202 const base::DictionaryValue& GetDefaultValues() { |
201 return *(policy_watcher_->default_values_); | 203 return *(policy_watcher_->default_values_); |
202 } | 204 } |
203 | 205 |
204 MOCK_METHOD0(PostPolicyWatcherShutdown, void()); | 206 MOCK_METHOD0(PostPolicyWatcherShutdown, void()); |
205 | 207 |
206 static const char* kHostDomain; | 208 static const char* kHostDomain; |
207 static const char* kPortRange; | 209 static const char* kPortRange; |
208 base::MessageLoop message_loop_; | 210 base::MessageLoop message_loop_; |
209 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 211 scoped_refptr<base::SingleThreadTaskRunner> message_loop_proxy_; |
210 MockPolicyCallback mock_policy_callback_; | 212 MockPolicyCallback mock_policy_callback_; |
211 | 213 |
212 // |policy_loader_| is owned by |policy_watcher_|. PolicyWatcherTest retains | 214 // |policy_loader_| is owned by |policy_watcher_|. PolicyWatcherTest retains |
213 // a raw pointer to |policy_loader_| in order to control the simulated / faked | 215 // a raw pointer to |policy_loader_| in order to control the simulated / faked |
214 // policy contents. | 216 // policy contents. |
215 policy::FakeAsyncPolicyLoader* policy_loader_; | 217 policy::FakeAsyncPolicyLoader* policy_loader_; |
216 scoped_ptr<PolicyWatcher> policy_watcher_; | 218 scoped_ptr<PolicyWatcher> policy_watcher_; |
217 | 219 |
218 base::DictionaryValue empty_; | 220 base::DictionaryValue empty_; |
219 base::DictionaryValue nat_true_; | 221 base::DictionaryValue nat_true_; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
743 } | 745 } |
744 | 746 |
745 // Today, the only verification offered by this test is: | 747 // Today, the only verification offered by this test is: |
746 // - Manual verification of policy values dumped by OnPolicyUpdatedDumpPolicy | 748 // - Manual verification of policy values dumped by OnPolicyUpdatedDumpPolicy |
747 // - Automated verification that nothing crashed | 749 // - Automated verification that nothing crashed |
748 } | 750 } |
749 | 751 |
750 #endif | 752 #endif |
751 | 753 |
752 } // namespace remoting | 754 } // namespace remoting |
OLD | NEW |