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

Side by Side Diff: chrome/browser/search/contextual_search_policy_handler_android_unittest.cc

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chrome/browser/search/contextual_search_policy_handler_android.h" 7 #include "chrome/browser/search/contextual_search_policy_handler_android.h"
8 #include "chrome/common/pref_names.h" 8 #include "chrome/common/pref_names.h"
9 #include "components/policy/core/common/policy_map.h" 9 #include "components/policy/core/common/policy_map.h"
10 #include "components/policy/policy_constants.h" 10 #include "components/policy/policy_constants.h"
11 #include "components/prefs/pref_value_map.h" 11 #include "components/prefs/pref_value_map.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace policy { 14 namespace policy {
15 15
16 TEST(ContextualSearchPolicyHandlerAndroidTest, Default) { 16 TEST(ContextualSearchPolicyHandlerAndroidTest, Default) {
17 PolicyMap policy; 17 PolicyMap policy;
18 PrefValueMap prefs; 18 PrefValueMap prefs;
19 ContextualSearchPolicyHandlerAndroid handler; 19 ContextualSearchPolicyHandlerAndroid handler;
20 handler.ApplyPolicySettings(policy, &prefs); 20 handler.ApplyPolicySettings(policy, &prefs);
21 std::string pref_value; 21 std::string pref_value;
22 EXPECT_FALSE(prefs.GetString(prefs::kContextualSearchEnabled, &pref_value)); 22 EXPECT_FALSE(prefs.GetString(prefs::kContextualSearchEnabled, &pref_value));
23 EXPECT_EQ("", pref_value); 23 EXPECT_EQ("", pref_value);
24 } 24 }
25 25
26 TEST(ContextualSearchPolicyHandlerAndroidTest, Enabled) { 26 TEST(ContextualSearchPolicyHandlerAndroidTest, Enabled) {
27 PolicyMap policy; 27 PolicyMap policy;
28 policy.Set(key::kContextualSearchEnabled, POLICY_LEVEL_MANDATORY, 28 policy.Set(key::kContextualSearchEnabled, POLICY_LEVEL_MANDATORY,
29 POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM, 29 POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM,
30 base::MakeUnique<base::FundamentalValue>(true), nullptr); 30 base::MakeUnique<base::Value>(true), nullptr);
31 PrefValueMap prefs; 31 PrefValueMap prefs;
32 ContextualSearchPolicyHandlerAndroid handler; 32 ContextualSearchPolicyHandlerAndroid handler;
33 handler.ApplyPolicySettings(policy, &prefs); 33 handler.ApplyPolicySettings(policy, &prefs);
34 34
35 // Enabling Contextual Search policy should not set the pref. 35 // Enabling Contextual Search policy should not set the pref.
36 std::string pref_value; 36 std::string pref_value;
37 EXPECT_FALSE(prefs.GetString(prefs::kContextualSearchEnabled, &pref_value)); 37 EXPECT_FALSE(prefs.GetString(prefs::kContextualSearchEnabled, &pref_value));
38 EXPECT_EQ("", pref_value); 38 EXPECT_EQ("", pref_value);
39 } 39 }
40 40
41 TEST(ContextualSearchPolicyHandlerAndroidTest, Disabled) { 41 TEST(ContextualSearchPolicyHandlerAndroidTest, Disabled) {
42 PolicyMap policy; 42 PolicyMap policy;
43 policy.Set(key::kContextualSearchEnabled, POLICY_LEVEL_MANDATORY, 43 policy.Set(key::kContextualSearchEnabled, POLICY_LEVEL_MANDATORY,
44 POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM, 44 POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM,
45 base::MakeUnique<base::FundamentalValue>(false), nullptr); 45 base::MakeUnique<base::Value>(false), nullptr);
46 PrefValueMap prefs; 46 PrefValueMap prefs;
47 ContextualSearchPolicyHandlerAndroid handler; 47 ContextualSearchPolicyHandlerAndroid handler;
48 handler.ApplyPolicySettings(policy, &prefs); 48 handler.ApplyPolicySettings(policy, &prefs);
49 49
50 // Disabling Contextual Search should switch the pref to managed. 50 // Disabling Contextual Search should switch the pref to managed.
51 std::string pref_value; 51 std::string pref_value;
52 EXPECT_TRUE(prefs.GetString(prefs::kContextualSearchEnabled, &pref_value)); 52 EXPECT_TRUE(prefs.GetString(prefs::kContextualSearchEnabled, &pref_value));
53 EXPECT_EQ("false", pref_value); 53 EXPECT_EQ("false", pref_value);
54 } 54 }
55 55
56 } // namespace policy 56 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698