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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 4150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4161 SetArcEnabledByPolicy(true); | 4161 SetArcEnabledByPolicy(true); |
4162 EXPECT_TRUE(arc_session_manager->IsSessionRunning()); | 4162 EXPECT_TRUE(arc_session_manager->IsSessionRunning()); |
4163 | 4163 |
4164 // Disable ARC. | 4164 // Disable ARC. |
4165 SetArcEnabledByPolicy(false); | 4165 SetArcEnabledByPolicy(false); |
4166 EXPECT_TRUE(arc_session_manager->IsSessionStopped()); | 4166 EXPECT_TRUE(arc_session_manager->IsSessionStopped()); |
4167 } | 4167 } |
4168 | 4168 |
4169 // Test ArcBackupRestoreEnabled policy. | 4169 // Test ArcBackupRestoreEnabled policy. |
4170 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { | 4170 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcBackupRestoreEnabled) { |
4171 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4171 PrefService* const pref = browser()->profile()->GetPrefs(); |
4172 | 4172 |
4173 // ARC Backup & Restore is switched on by default. | 4173 // ARC Backup & Restore is switched off by default. |
4174 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4174 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
4175 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4175 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
4176 | 4176 |
4177 // Disable ARC Backup & Restore. | 4177 // Switch on ARC Backup & Restore in the user prefs. |
| 4178 pref->SetBoolean(prefs::kArcBackupRestoreEnabled, true); |
| 4179 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
| 4180 |
| 4181 // Disable ARC Backup & Restore through the policy. |
4178 PolicyMap policies; | 4182 PolicyMap policies; |
4179 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, | 4183 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, |
4180 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4184 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
4181 base::MakeUnique<base::FundamentalValue>(false), nullptr); | 4185 base::MakeUnique<base::FundamentalValue>(false), nullptr); |
4182 UpdateProviderPolicy(policies); | 4186 UpdateProviderPolicy(policies); |
4183 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4187 EXPECT_FALSE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
4184 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4188 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
4185 | 4189 |
4186 // Enable ARC Backup & Restore. | 4190 // Enable ARC Backup & Restore through the policy. |
4187 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, | 4191 policies.Set(key::kArcBackupRestoreEnabled, POLICY_LEVEL_MANDATORY, |
4188 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4192 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
4189 base::MakeUnique<base::FundamentalValue>(true), nullptr); | 4193 base::MakeUnique<base::FundamentalValue>(true), nullptr); |
4190 UpdateProviderPolicy(policies); | 4194 UpdateProviderPolicy(policies); |
4191 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); | 4195 EXPECT_TRUE(pref->GetBoolean(prefs::kArcBackupRestoreEnabled)); |
4192 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); | 4196 EXPECT_TRUE(pref->IsManagedPreference(prefs::kArcBackupRestoreEnabled)); |
4193 } | 4197 } |
4194 | 4198 |
4195 // Test ArcLocationServiceEnabled policy and its interplay with the | 4199 // Test ArcLocationServiceEnabled policy and its interplay with the |
4196 // DefaultGeolocationSetting policy. | 4200 // DefaultGeolocationSetting policy. |
4197 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) { | 4201 IN_PROC_BROWSER_TEST_F(ArcPolicyTest, ArcLocationServiceEnabled) { |
4198 const PrefService* const pref = browser()->profile()->GetPrefs(); | 4202 PrefService* const pref = browser()->profile()->GetPrefs(); |
4199 | 4203 |
4200 // Values of the ArcLocationServiceEnabled policy to be tested. | 4204 // Values of the ArcLocationServiceEnabled policy to be tested. |
4201 const std::vector<base::Value> test_policy_values = { | 4205 const std::vector<base::Value> test_policy_values = { |
4202 base::Value(), // unset | 4206 base::Value(), // unset |
4203 base::FundamentalValue(false), // disabled | 4207 base::FundamentalValue(false), // disabled |
4204 base::FundamentalValue(true), // enabled | 4208 base::FundamentalValue(true), // enabled |
4205 }; | 4209 }; |
4206 // Values of the DefaultGeolocationSetting policy to be tested. | 4210 // Values of the DefaultGeolocationSetting policy to be tested. |
4207 const std::vector<base::Value> test_default_geo_policy_values = { | 4211 const std::vector<base::Value> test_default_geo_policy_values = { |
4208 base::Value(), // unset | 4212 base::Value(), // unset |
4209 base::FundamentalValue(1), // 'AllowGeolocation' | 4213 base::FundamentalValue(1), // 'AllowGeolocation' |
4210 base::FundamentalValue(2), // 'BlockGeolocation' | 4214 base::FundamentalValue(2), // 'BlockGeolocation' |
4211 base::FundamentalValue(3), // 'AskGeolocation' | 4215 base::FundamentalValue(3), // 'AskGeolocation' |
4212 }; | 4216 }; |
4213 | 4217 |
| 4218 // The pref is switched off by default. |
| 4219 EXPECT_FALSE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4220 EXPECT_FALSE(pref->IsManagedPreference(prefs::kArcLocationServiceEnabled)); |
| 4221 |
| 4222 // Switch on the pref in the user prefs. |
| 4223 pref->SetBoolean(prefs::kArcLocationServiceEnabled, true); |
| 4224 EXPECT_TRUE(pref->GetBoolean(prefs::kArcLocationServiceEnabled)); |
| 4225 |
4214 for (const auto& test_policy_value : test_policy_values) { | 4226 for (const auto& test_policy_value : test_policy_values) { |
4215 for (const auto& test_default_geo_policy_value : | 4227 for (const auto& test_default_geo_policy_value : |
4216 test_default_geo_policy_values) { | 4228 test_default_geo_policy_values) { |
4217 PolicyMap policies; | 4229 PolicyMap policies; |
4218 if (test_policy_value.is_bool()) { | 4230 if (test_policy_value.is_bool()) { |
4219 policies.Set(key::kArcLocationServiceEnabled, POLICY_LEVEL_MANDATORY, | 4231 policies.Set(key::kArcLocationServiceEnabled, POLICY_LEVEL_MANDATORY, |
4220 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 4232 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
4221 test_policy_value.CreateDeepCopy(), nullptr); | 4233 test_policy_value.CreateDeepCopy(), nullptr); |
4222 } | 4234 } |
4223 if (test_default_geo_policy_value.is_int()) { | 4235 if (test_default_geo_policy_value.is_int()) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4393 | 4405 |
4394 SetEmptyPolicy(); | 4406 SetEmptyPolicy(); |
4395 // Policy not set. | 4407 // Policy not set. |
4396 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); | 4408 CheckSystemTimezoneAutomaticDetectionPolicyUnset(); |
4397 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); | 4409 EXPECT_TRUE(CheckResolveTimezoneByGeolocation(true, false)); |
4398 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); | 4410 EXPECT_TRUE(manager->TimeZoneResolverShouldBeRunningForTests()); |
4399 } | 4411 } |
4400 #endif // defined(OS_CHROMEOS) | 4412 #endif // defined(OS_CHROMEOS) |
4401 | 4413 |
4402 } // namespace policy | 4414 } // namespace policy |
OLD | NEW |