| 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 "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" |
| 6 |
| 5 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 6 | 9 |
| 7 #include "base/bind.h" | 10 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 9 #include "base/macros.h" | 12 #include "base/macros.h" |
| 10 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 11 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" | |
| 12 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
| 15 #include "sync/api/fake_sync_change_processor.h" | 17 #include "sync/api/fake_sync_change_processor.h" |
| 16 #include "sync/api/sync_change.h" | 18 #include "sync/api/sync_change.h" |
| 17 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 19 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
| 18 #include "sync/api/sync_error_factory_mock.h" | 20 #include "sync/api/sync_error_factory_mock.h" |
| 19 #include "sync/protocol/sync.pb.h" | 21 #include "sync/protocol/sync.pb.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 23 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 85 |
| 84 SupervisedUserSharedSettingsServiceTest() | 86 SupervisedUserSharedSettingsServiceTest() |
| 85 : settings_service_(profile_.GetPrefs()) {} | 87 : settings_service_(profile_.GetPrefs()) {} |
| 86 ~SupervisedUserSharedSettingsServiceTest() override {} | 88 ~SupervisedUserSharedSettingsServiceTest() override {} |
| 87 | 89 |
| 88 void StartSyncing(const syncer::SyncDataList& initial_sync_data) { | 90 void StartSyncing(const syncer::SyncDataList& initial_sync_data) { |
| 89 sync_processor_.reset(new syncer::FakeSyncChangeProcessor); | 91 sync_processor_.reset(new syncer::FakeSyncChangeProcessor); |
| 90 scoped_ptr<syncer::SyncErrorFactory> error_handler( | 92 scoped_ptr<syncer::SyncErrorFactory> error_handler( |
| 91 new MockSyncErrorFactory(SUPERVISED_USER_SHARED_SETTINGS)); | 93 new MockSyncErrorFactory(SUPERVISED_USER_SHARED_SETTINGS)); |
| 92 SyncMergeResult result = settings_service_.MergeDataAndStartSyncing( | 94 SyncMergeResult result = settings_service_.MergeDataAndStartSyncing( |
| 93 SUPERVISED_USER_SHARED_SETTINGS, | 95 SUPERVISED_USER_SHARED_SETTINGS, initial_sync_data, |
| 94 initial_sync_data, | |
| 95 scoped_ptr<SyncChangeProcessor>( | 96 scoped_ptr<SyncChangeProcessor>( |
| 96 new SyncChangeProcessorWrapperForTest(sync_processor_.get())), | 97 new SyncChangeProcessorWrapperForTest(sync_processor_.get())), |
| 97 error_handler.Pass()); | 98 std::move(error_handler)); |
| 98 EXPECT_FALSE(result.error().IsSet()); | 99 EXPECT_FALSE(result.error().IsSet()); |
| 99 } | 100 } |
| 100 | 101 |
| 101 const base::DictionaryValue* GetAllSettings() { | 102 const base::DictionaryValue* GetAllSettings() { |
| 102 return profile_.GetPrefs()->GetDictionary( | 103 return profile_.GetPrefs()->GetDictionary( |
| 103 prefs::kSupervisedUserSharedSettings); | 104 prefs::kSupervisedUserSharedSettings); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void VerifySyncChangesAndClear() { | 107 void VerifySyncChangesAndClear() { |
| 107 SyncChangeList& changes = sync_processor_->changes(); | 108 SyncChangeList& changes = sync_processor_->changes(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 settings_service_.GetAllSyncData(SUPERVISED_USER_SHARED_SETTINGS).size()); | 267 settings_service_.GetAllSyncData(SUPERVISED_USER_SHARED_SETTINGS).size()); |
| 267 EXPECT_EQ(ToJson(&name), | 268 EXPECT_EQ(ToJson(&name), |
| 268 ToJson(settings_service_.GetValue(kIdA, "name"))); | 269 ToJson(settings_service_.GetValue(kIdA, "name"))); |
| 269 EXPECT_EQ(ToJson(&age), ToJson(settings_service_.GetValue(kIdA, "age"))); | 270 EXPECT_EQ(ToJson(&age), ToJson(settings_service_.GetValue(kIdA, "age"))); |
| 270 EXPECT_EQ(ToJson(&bar), ToJson(settings_service_.GetValue(kIdB, "foo"))); | 271 EXPECT_EQ(ToJson(&bar), ToJson(settings_service_.GetValue(kIdB, "foo"))); |
| 271 EXPECT_EQ(ToJson(&blurp), ToJson(settings_service_.GetValue(kIdC, "baz"))); | 272 EXPECT_EQ(ToJson(&blurp), ToJson(settings_service_.GetValue(kIdC, "baz"))); |
| 272 EXPECT_FALSE(settings_service_.GetValue(kIdA, "foo")); | 273 EXPECT_FALSE(settings_service_.GetValue(kIdA, "foo")); |
| 273 EXPECT_FALSE(settings_service_.GetValue(kIdB, "name")); | 274 EXPECT_FALSE(settings_service_.GetValue(kIdB, "name")); |
| 274 EXPECT_FALSE(settings_service_.GetValue(kIdC, "name")); | 275 EXPECT_FALSE(settings_service_.GetValue(kIdC, "name")); |
| 275 } | 276 } |
| OLD | NEW |