Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / components / sync_driver / sync_policy_handler_unittest.cc
blob2d95ec1c1cf71da2dadc0e53bbc957c863efe07e
1 // Copyright 2013 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.
5 #include "base/prefs/pref_value_map.h"
6 #include "base/values.h"
7 #include "components/policy/core/common/policy_map.h"
8 #include "components/policy/core/common/policy_types.h"
9 #include "components/sync_driver/pref_names.h"
10 #include "components/sync_driver/sync_policy_handler.h"
11 #include "policy/policy_constants.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace sync_driver {
16 // Test cases for the Sync policy setting.
17 class SyncPolicyHandlerTest : public testing::Test {};
19 TEST_F(SyncPolicyHandlerTest, Default) {
20 policy::PolicyMap policy;
21 SyncPolicyHandler handler;
22 PrefValueMap prefs;
23 handler.ApplyPolicySettings(policy, &prefs);
24 EXPECT_FALSE(prefs.GetValue(sync_driver::prefs::kSyncManaged, NULL));
27 TEST_F(SyncPolicyHandlerTest, Enabled) {
28 policy::PolicyMap policy;
29 policy.Set(policy::key::kSyncDisabled,
30 policy::POLICY_LEVEL_MANDATORY,
31 policy::POLICY_SCOPE_USER,
32 policy::POLICY_SOURCE_CLOUD,
33 new base::FundamentalValue(false),
34 NULL);
35 SyncPolicyHandler handler;
36 PrefValueMap prefs;
37 handler.ApplyPolicySettings(policy, &prefs);
39 // Enabling Sync should not set the pref.
40 EXPECT_FALSE(prefs.GetValue(sync_driver::prefs::kSyncManaged, NULL));
43 TEST_F(SyncPolicyHandlerTest, Disabled) {
44 policy::PolicyMap policy;
45 policy.Set(policy::key::kSyncDisabled,
46 policy::POLICY_LEVEL_MANDATORY,
47 policy::POLICY_SCOPE_USER,
48 policy::POLICY_SOURCE_CLOUD,
49 new base::FundamentalValue(true),
50 NULL);
51 SyncPolicyHandler handler;
52 PrefValueMap prefs;
53 handler.ApplyPolicySettings(policy, &prefs);
55 // Sync should be flagged as managed.
56 const base::Value* value = NULL;
57 EXPECT_TRUE(prefs.GetValue(sync_driver::prefs::kSyncManaged, &value));
58 ASSERT_TRUE(value);
59 bool sync_managed = false;
60 bool result = value->GetAsBoolean(&sync_managed);
61 ASSERT_TRUE(result);
62 EXPECT_TRUE(sync_managed);
65 } // namespace sync_driver