OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
.h" | 10 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 } // namespace | 75 } // namespace |
76 | 76 |
77 class SupervisedUserSharedSettingsServiceTest : public ::testing::Test { | 77 class SupervisedUserSharedSettingsServiceTest : public ::testing::Test { |
78 protected: | 78 protected: |
79 typedef base::CallbackList<void(const std::string&, const std::string&)> | 79 typedef base::CallbackList<void(const std::string&, const std::string&)> |
80 CallbackList; | 80 CallbackList; |
81 | 81 |
82 SupervisedUserSharedSettingsServiceTest() | 82 SupervisedUserSharedSettingsServiceTest() |
83 : settings_service_(profile_.GetPrefs()) {} | 83 : settings_service_(profile_.GetPrefs()) {} |
84 virtual ~SupervisedUserSharedSettingsServiceTest() {} | 84 ~SupervisedUserSharedSettingsServiceTest() override {} |
85 | 85 |
86 void StartSyncing(const syncer::SyncDataList& initial_sync_data) { | 86 void StartSyncing(const syncer::SyncDataList& initial_sync_data) { |
87 sync_processor_.reset(new syncer::FakeSyncChangeProcessor); | 87 sync_processor_.reset(new syncer::FakeSyncChangeProcessor); |
88 scoped_ptr<syncer::SyncErrorFactory> error_handler( | 88 scoped_ptr<syncer::SyncErrorFactory> error_handler( |
89 new MockSyncErrorFactory(SUPERVISED_USER_SHARED_SETTINGS)); | 89 new MockSyncErrorFactory(SUPERVISED_USER_SHARED_SETTINGS)); |
90 SyncMergeResult result = settings_service_.MergeDataAndStartSyncing( | 90 SyncMergeResult result = settings_service_.MergeDataAndStartSyncing( |
91 SUPERVISED_USER_SHARED_SETTINGS, | 91 SUPERVISED_USER_SHARED_SETTINGS, |
92 initial_sync_data, | 92 initial_sync_data, |
93 scoped_ptr<SyncChangeProcessor>( | 93 scoped_ptr<SyncChangeProcessor>( |
94 new SyncChangeProcessorWrapperForTest(sync_processor_.get())), | 94 new SyncChangeProcessorWrapperForTest(sync_processor_.get())), |
(...skipping 12 matching lines...) Expand all Loading... |
107 const sync_pb::ManagedUserSharedSettingSpecifics& setting = | 107 const sync_pb::ManagedUserSharedSettingSpecifics& setting = |
108 sync_change.sync_data().GetSpecifics().managed_user_shared_setting(); | 108 sync_change.sync_data().GetSpecifics().managed_user_shared_setting(); |
109 EXPECT_EQ( | 109 EXPECT_EQ( |
110 setting.value(), | 110 setting.value(), |
111 ToJson(settings_service_.GetValue(setting.mu_id(), setting.key()))); | 111 ToJson(settings_service_.GetValue(setting.mu_id(), setting.key()))); |
112 } | 112 } |
113 changes.clear(); | 113 changes.clear(); |
114 } | 114 } |
115 | 115 |
116 // testing::Test overrides: | 116 // testing::Test overrides: |
117 virtual void SetUp() override { | 117 void SetUp() override { |
118 subscription_ = settings_service_.Subscribe( | 118 subscription_ = settings_service_.Subscribe( |
119 base::Bind(&SupervisedUserSharedSettingsServiceTest::OnSettingChanged, | 119 base::Bind(&SupervisedUserSharedSettingsServiceTest::OnSettingChanged, |
120 base::Unretained(this))); | 120 base::Unretained(this))); |
121 } | 121 } |
122 | 122 |
123 virtual void TearDown() override { settings_service_.Shutdown(); } | 123 void TearDown() override { settings_service_.Shutdown(); } |
124 | 124 |
125 void OnSettingChanged(const std::string& su_id, const std::string& key) { | 125 void OnSettingChanged(const std::string& su_id, const std::string& key) { |
126 const Value* value = settings_service_.GetValue(su_id, key); | 126 const Value* value = settings_service_.GetValue(su_id, key); |
127 ASSERT_TRUE(value); | 127 ASSERT_TRUE(value); |
128 changed_settings_.push_back( | 128 changed_settings_.push_back( |
129 SupervisedUserSharedSettingsService::CreateSyncDataForSetting( | 129 SupervisedUserSharedSettingsService::CreateSyncDataForSetting( |
130 su_id, key, *value, true)); | 130 su_id, key, *value, true)); |
131 } | 131 } |
132 | 132 |
133 TestingProfile profile_; | 133 TestingProfile profile_; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 settings_service_.GetAllSyncData(SUPERVISED_USER_SHARED_SETTINGS).size()); | 263 settings_service_.GetAllSyncData(SUPERVISED_USER_SHARED_SETTINGS).size()); |
264 EXPECT_EQ(ToJson(&name), | 264 EXPECT_EQ(ToJson(&name), |
265 ToJson(settings_service_.GetValue(kIdA, "name"))); | 265 ToJson(settings_service_.GetValue(kIdA, "name"))); |
266 EXPECT_EQ(ToJson(&age), ToJson(settings_service_.GetValue(kIdA, "age"))); | 266 EXPECT_EQ(ToJson(&age), ToJson(settings_service_.GetValue(kIdA, "age"))); |
267 EXPECT_EQ(ToJson(&bar), ToJson(settings_service_.GetValue(kIdB, "foo"))); | 267 EXPECT_EQ(ToJson(&bar), ToJson(settings_service_.GetValue(kIdB, "foo"))); |
268 EXPECT_EQ(ToJson(&blurp), ToJson(settings_service_.GetValue(kIdC, "baz"))); | 268 EXPECT_EQ(ToJson(&blurp), ToJson(settings_service_.GetValue(kIdC, "baz"))); |
269 EXPECT_FALSE(settings_service_.GetValue(kIdA, "foo")); | 269 EXPECT_FALSE(settings_service_.GetValue(kIdA, "foo")); |
270 EXPECT_FALSE(settings_service_.GetValue(kIdB, "name")); | 270 EXPECT_FALSE(settings_service_.GetValue(kIdB, "name")); |
271 EXPECT_FALSE(settings_service_.GetValue(kIdC, "name")); | 271 EXPECT_FALSE(settings_service_.GetValue(kIdC, "name")); |
272 } | 272 } |
OLD | NEW |