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

Side by Side Diff: components/sync/driver/sync_policy_handler_unittest.cc

Issue 2388163002: [Sync] Move //components/sync to the syncer namespace, take 2. (Closed)
Patch Set: Rebase. Created 4 years, 2 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
« no previous file with comments | « components/sync/driver/sync_policy_handler.cc ('k') | components/sync/driver/sync_prefs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "components/sync/driver/sync_policy_handler.h" 5 #include "components/sync/driver/sync_policy_handler.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "components/policy/core/common/policy_map.h" 9 #include "components/policy/core/common/policy_map.h"
10 #include "components/policy/core/common/policy_types.h" 10 #include "components/policy/core/common/policy_types.h"
11 #include "components/policy/policy_constants.h" 11 #include "components/policy/policy_constants.h"
12 #include "components/prefs/pref_value_map.h" 12 #include "components/prefs/pref_value_map.h"
13 #include "components/sync/driver/pref_names.h" 13 #include "components/sync/driver/pref_names.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace sync_driver { 16 namespace syncer {
17 17
18 // Test cases for the Sync policy setting. 18 // Test cases for the Sync policy setting.
19 class SyncPolicyHandlerTest : public testing::Test {}; 19 class SyncPolicyHandlerTest : public testing::Test {};
20 20
21 TEST_F(SyncPolicyHandlerTest, Default) { 21 TEST_F(SyncPolicyHandlerTest, Default) {
22 policy::PolicyMap policy; 22 policy::PolicyMap policy;
23 SyncPolicyHandler handler; 23 SyncPolicyHandler handler;
24 PrefValueMap prefs; 24 PrefValueMap prefs;
25 handler.ApplyPolicySettings(policy, &prefs); 25 handler.ApplyPolicySettings(policy, &prefs);
26 EXPECT_FALSE(prefs.GetValue(sync_driver::prefs::kSyncManaged, NULL)); 26 EXPECT_FALSE(prefs.GetValue(prefs::kSyncManaged, NULL));
27 } 27 }
28 28
29 TEST_F(SyncPolicyHandlerTest, Enabled) { 29 TEST_F(SyncPolicyHandlerTest, Enabled) {
30 policy::PolicyMap policy; 30 policy::PolicyMap policy;
31 policy.Set(policy::key::kSyncDisabled, policy::POLICY_LEVEL_MANDATORY, 31 policy.Set(policy::key::kSyncDisabled, policy::POLICY_LEVEL_MANDATORY,
32 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, 32 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
33 base::MakeUnique<base::FundamentalValue>(false), nullptr); 33 base::MakeUnique<base::FundamentalValue>(false), nullptr);
34 SyncPolicyHandler handler; 34 SyncPolicyHandler handler;
35 PrefValueMap prefs; 35 PrefValueMap prefs;
36 handler.ApplyPolicySettings(policy, &prefs); 36 handler.ApplyPolicySettings(policy, &prefs);
37 37
38 // Enabling Sync should not set the pref. 38 // Enabling Sync should not set the pref.
39 EXPECT_FALSE(prefs.GetValue(sync_driver::prefs::kSyncManaged, NULL)); 39 EXPECT_FALSE(prefs.GetValue(prefs::kSyncManaged, NULL));
40 } 40 }
41 41
42 TEST_F(SyncPolicyHandlerTest, Disabled) { 42 TEST_F(SyncPolicyHandlerTest, Disabled) {
43 policy::PolicyMap policy; 43 policy::PolicyMap policy;
44 policy.Set(policy::key::kSyncDisabled, policy::POLICY_LEVEL_MANDATORY, 44 policy.Set(policy::key::kSyncDisabled, policy::POLICY_LEVEL_MANDATORY,
45 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, 45 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
46 base::MakeUnique<base::FundamentalValue>(true), nullptr); 46 base::MakeUnique<base::FundamentalValue>(true), nullptr);
47 SyncPolicyHandler handler; 47 SyncPolicyHandler handler;
48 PrefValueMap prefs; 48 PrefValueMap prefs;
49 handler.ApplyPolicySettings(policy, &prefs); 49 handler.ApplyPolicySettings(policy, &prefs);
50 50
51 // Sync should be flagged as managed. 51 // Sync should be flagged as managed.
52 const base::Value* value = NULL; 52 const base::Value* value = NULL;
53 EXPECT_TRUE(prefs.GetValue(sync_driver::prefs::kSyncManaged, &value)); 53 EXPECT_TRUE(prefs.GetValue(prefs::kSyncManaged, &value));
54 ASSERT_TRUE(value); 54 ASSERT_TRUE(value);
55 bool sync_managed = false; 55 bool sync_managed = false;
56 bool result = value->GetAsBoolean(&sync_managed); 56 bool result = value->GetAsBoolean(&sync_managed);
57 ASSERT_TRUE(result); 57 ASSERT_TRUE(result);
58 EXPECT_TRUE(sync_managed); 58 EXPECT_TRUE(sync_managed);
59 } 59 }
60 60
61 } // namespace sync_driver 61 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/sync_policy_handler.cc ('k') | components/sync/driver/sync_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698