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