OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/supervised_user/supervised_user_creation_policy_handler
.h" | 5 #include "chrome/browser/supervised_user/supervised_user_creation_policy_handler
.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 #include "components/policy/core/common/policy_map.h" | 10 #include "components/policy/core/common/policy_map.h" |
11 #include "components/policy/policy_constants.h" | 11 #include "components/policy/policy_constants.h" |
12 #include "components/prefs/pref_value_map.h" | 12 #include "components/prefs/pref_value_map.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace policy { | 15 namespace policy { |
16 | 16 |
17 class SupervisedUserCreationPolicyHandlerTest : public ::testing::Test { | 17 class SupervisedUserCreationPolicyHandlerTest : public ::testing::Test { |
18 protected: | 18 protected: |
19 void SetUpPolicyAndApply(const char* policy_name, bool value) { | 19 void SetUpPolicyAndApply(const char* policy_name, bool value) { |
20 policies_.Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 20 policies_.Set(policy_name, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
21 POLICY_SOURCE_PLATFORM, | 21 POLICY_SOURCE_PLATFORM, base::MakeUnique<base::Value>(value), |
22 base::MakeUnique<base::FundamentalValue>(value), nullptr); | 22 nullptr); |
23 ApplyPolicySettings(); | 23 ApplyPolicySettings(); |
24 } | 24 } |
25 | 25 |
26 void ApplyPolicySettings() { | 26 void ApplyPolicySettings() { |
27 handler_.ApplyPolicySettings(policies_, &prefs_); | 27 handler_.ApplyPolicySettings(policies_, &prefs_); |
28 } | 28 } |
29 | 29 |
30 PrefValueMap* prefs() { return &prefs_; } | 30 PrefValueMap* prefs() { return &prefs_; } |
31 | 31 |
32 private: | 32 private: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 prefs()->GetBoolean(prefs::kSupervisedUserCreationAllowed, &value)); | 83 prefs()->GetBoolean(prefs::kSupervisedUserCreationAllowed, &value)); |
84 EXPECT_FALSE(value); | 84 EXPECT_FALSE(value); |
85 | 85 |
86 SetUpPolicyAndApply(key::kSupervisedUserCreationEnabled, false); | 86 SetUpPolicyAndApply(key::kSupervisedUserCreationEnabled, false); |
87 EXPECT_TRUE( | 87 EXPECT_TRUE( |
88 prefs()->GetBoolean(prefs::kSupervisedUserCreationAllowed, &value)); | 88 prefs()->GetBoolean(prefs::kSupervisedUserCreationAllowed, &value)); |
89 EXPECT_FALSE(value); | 89 EXPECT_FALSE(value); |
90 } | 90 } |
91 | 91 |
92 } // namespace policy | 92 } // namespace policy |
OLD | NEW |