Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/policy/default_geolocation_policy_handler_unittest.cc

Issue 2243513002: arc: Make Location Service manageable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "base/values.h"
9 #include "chrome/common/pref_names.h"
10 #include "components/content_settings/core/common/content_settings.h"
11 #include "components/policy/core/browser/configuration_policy_pref_store.h"
12 #include "components/policy/core/browser/configuration_policy_pref_store_test.h"
13 #include "components/policy/core/common/policy_map.h"
14 #include "components/policy/core/common/policy_types.h"
15 #include "policy/policy_constants.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace policy {
19
20 class DefaultGeolocationPolicyHandlerTest
21 : public ConfigurationPolicyPrefStoreTest {
22 void SetUp() override {
23 handler_list_.AddHandler(base::WrapUnique<ConfigurationPolicyHandler>(
24 new DefaultGeolocationPolicyHandler));
25 }
26 };
27
28 TEST_F(DefaultGeolocationPolicyHandlerTest, AllowGeolocation) {
29 // DefaultGeolocationSetting of CONTENT_SETTING_ALLOW (AllowGeolocation)
30 // should not translate to the ArcLocationServiceEnabled preference.
31 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr));
32 PolicyMap policy;
33 policy.Set(key::kDefaultGeolocationSetting,
34 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
35 POLICY_SOURCE_CLOUD,
36 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_ALLOW)),
37 nullptr);
38 UpdateProviderPolicy(policy);
39 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr));
40 }
41
42 TEST_F(DefaultGeolocationPolicyHandlerTest, BlockGeolocation) {
43 // DefaultGeolocationSetting of CONTENT_SETTING_BLOCK (BlockGeolocation)
44 // should set the ArcLocationServiceEnabled preference to false.
45 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr));
46 PolicyMap policy;
47 policy.Set(key::kDefaultGeolocationSetting,
48 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
49 POLICY_SOURCE_CLOUD,
50 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_BLOCK)),
51 nullptr);
52 UpdateProviderPolicy(policy);
53 const base::Value* value = nullptr;
54 EXPECT_TRUE(store_->GetValue(prefs::kArcLocationServiceEnabled, &value));
55 EXPECT_TRUE(base::FundamentalValue(false).Equals(value));
56 }
57
58 TEST_F(DefaultGeolocationPolicyHandlerTest, AskGeolocation) {
59 // DefaultGeolocationSetting of CONTENT_SETTING_ASK (AskGeolocation) should
60 // not translate to the ArcLocationServiceEnabled preference.
61 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr));
62 PolicyMap policy;
63 policy.Set(key::kDefaultGeolocationSetting,
64 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
65 POLICY_SOURCE_CLOUD,
66 base::WrapUnique(new base::FundamentalValue(CONTENT_SETTING_ASK)),
67 nullptr);
68 UpdateProviderPolicy(policy);
69 EXPECT_FALSE(store_->GetValue(prefs::kArcLocationServiceEnabled, nullptr));
70 }
71
72 } // namespace policy
73
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698