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/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/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
11 #include "components/policy/core/common/fake_async_policy_loader.h" | 11 #include "components/policy/core/common/fake_async_policy_loader.h" |
12 #include "policy/policy_constants.h" | 12 #include "policy/policy_constants.h" |
13 #include "remoting/host/dns_blackhole_checker.h" | 13 #include "remoting/host/dns_blackhole_checker.h" |
14 #include "remoting/host/policy_hack/mock_policy_callback.h" | 14 #include "remoting/host/policy_hack/mock_policy_callback.h" |
15 #include "remoting/host/policy_hack/policy_service_watcher.h" | |
16 #include "remoting/host/policy_hack/policy_watcher.h" | 15 #include "remoting/host/policy_hack/policy_watcher.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 | 18 |
20 namespace remoting { | 19 namespace remoting { |
21 namespace policy_hack { | 20 namespace policy_hack { |
22 | 21 |
23 class PolicyWatcherTest : public testing::Test { | 22 class PolicyWatcherTest : public testing::Test { |
24 public: | 23 public: |
25 PolicyWatcherTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 24 PolicyWatcherTest() : message_loop_(base::MessageLoop::TYPE_IO) {} |
26 | 25 |
27 void SetUp() override { | 26 void SetUp() override { |
28 message_loop_proxy_ = base::MessageLoopProxy::current(); | 27 message_loop_proxy_ = base::MessageLoopProxy::current(); |
29 policy_updated_callback_ = base::Bind( | 28 policy_updated_callback_ = base::Bind( |
30 &MockPolicyCallback::OnPolicyUpdate, | 29 &MockPolicyCallback::OnPolicyUpdate, |
31 base::Unretained(&mock_policy_callback_)); | 30 base::Unretained(&mock_policy_callback_)); |
32 policy_error_callback_ = base::Bind( | 31 policy_error_callback_ = base::Bind( |
33 &MockPolicyCallback::OnPolicyError, | 32 &MockPolicyCallback::OnPolicyError, |
34 base::Unretained(&mock_policy_callback_)); | 33 base::Unretained(&mock_policy_callback_)); |
35 | 34 |
36 // Retaining a raw pointer to keep control over policy contents. | 35 // Retaining a raw pointer to keep control over policy contents. |
37 policy_loader_ = new policy::FakeAsyncPolicyLoader(message_loop_proxy_); | 36 policy_loader_ = new policy::FakeAsyncPolicyLoader(message_loop_proxy_); |
38 policy_watcher_ = PolicyServiceWatcher::CreateFromPolicyLoader( | 37 policy_watcher_ = PolicyWatcher::CreateFromPolicyLoader( |
39 message_loop_proxy_, make_scoped_ptr(policy_loader_)); | 38 message_loop_proxy_, make_scoped_ptr(policy_loader_)); |
40 | 39 |
41 nat_true_.SetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, true); | 40 nat_true_.SetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, true); |
42 nat_false_.SetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, | 41 nat_false_.SetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, |
43 false); | 42 false); |
44 nat_one_.SetInteger(policy::key::kRemoteAccessHostFirewallTraversal, 1); | 43 nat_one_.SetInteger(policy::key::kRemoteAccessHostFirewallTraversal, 1); |
45 domain_empty_.SetString(policy::key::kRemoteAccessHostDomain, | 44 domain_empty_.SetString(policy::key::kRemoteAccessHostDomain, |
46 std::string()); | 45 std::string()); |
47 domain_full_.SetString(policy::key::kRemoteAccessHostDomain, kHostDomain); | 46 domain_full_.SetString(policy::key::kRemoteAccessHostDomain, kHostDomain); |
48 SetDefaults(nat_true_others_default_); | 47 SetDefaults(nat_true_others_default_); |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 576 |
578 // Today, the only verification offered by this test is: | 577 // Today, the only verification offered by this test is: |
579 // - Manual verification of policy values dumped by OnPolicyUpdatedDumpPolicy | 578 // - Manual verification of policy values dumped by OnPolicyUpdatedDumpPolicy |
580 // - Automated verification that nothing crashed | 579 // - Automated verification that nothing crashed |
581 } | 580 } |
582 | 581 |
583 #endif | 582 #endif |
584 | 583 |
585 } // namespace policy_hack | 584 } // namespace policy_hack |
586 } // namespace remoting | 585 } // namespace remoting |
OLD | NEW |