OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/policy/default_geolocation_policy_handler.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/common/pref_names.h" |
| 9 #include "components/policy/core/browser/configuration_policy_pref_store.h" |
| 10 #include "components/policy/core/browser/configuration_policy_pref_store_test.h" |
| 11 #include "components/policy/core/common/policy_map.h" |
| 12 #include "policy/policy_constants.h" |
| 13 |
| 14 namespace policy { |
| 15 |
| 16 #if defined(OS_CHROMEOS) |
| 17 class DefaultGeolocationPolicyHandlerTest |
| 18 : public ConfigurationPolicyPrefStoreTest { |
| 19 void SetUp() override { |
| 20 handler_list_.AddHandler(base::WrapUnique<ConfigurationPolicyHandler>( |
| 21 new DefaultGeolocationPolicyHandler)); |
| 22 } |
| 23 }; |
| 24 |
| 25 TEST_F(DefaultGeolocationPolicyHandlerTest, AllowGeolocation) { |
| 26 // DefaultGeolocationSetting of 1 (AllowGeolocation) should not translate to |
| 27 // the ArcLocationServiceEnabled preference. |
| 28 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, NULL)); |
| 29 PolicyMap policy; |
| 30 policy.Set(key::kDefaultGeolocationSetting, |
| 31 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 32 POLICY_SOURCE_CLOUD, |
| 33 base::WrapUnique(new base::FundamentalValue(1)), nullptr); |
| 34 UpdateProviderPolicy(policy); |
| 35 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, NULL)); |
| 36 } |
| 37 |
| 38 TEST_F(DefaultGeolocationPolicyHandlerTest, BlockGeolocation) { |
| 39 // DefaultGeolocationSetting of 2 (BlockGeolocation) should set |
| 40 // the ArcLocationServiceEnabled preference to false. |
| 41 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, NULL)); |
| 42 PolicyMap policy; |
| 43 policy.Set(key::kDefaultGeolocationSetting, |
| 44 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 45 POLICY_SOURCE_CLOUD, |
| 46 base::WrapUnique(new base::FundamentalValue(2)), nullptr); |
| 47 UpdateProviderPolicy(policy); |
| 48 const base::Value* value = NULL; |
| 49 EXPECT_TRUE(store_->GetValue(prefs::kArcLocationServiceEnabled, &value)); |
| 50 EXPECT_TRUE(base::FundamentalValue(false).Equals(value)); |
| 51 } |
| 52 |
| 53 TEST_F(DefaultGeolocationPolicyHandlerTest, AskGeolocation) { |
| 54 // DefaultGeolocationSetting of 3 (AskGeolocation) should not translate to |
| 55 // the ArcLocationServiceEnabled preference. |
| 56 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, NULL)); |
| 57 PolicyMap policy; |
| 58 policy.Set(key::kDefaultGeolocationSetting, |
| 59 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| 60 POLICY_SOURCE_CLOUD, |
| 61 base::WrapUnique(new base::FundamentalValue(3)), nullptr); |
| 62 UpdateProviderPolicy(policy); |
| 63 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, NULL)); |
| 64 } |
| 65 #endif |
| 66 |
| 67 } // namespace policy |
| 68 |
OLD | NEW |