| 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 25 matching lines...) Expand all Loading... |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 class MockSyncErrorFactory : public syncer::SyncErrorFactory { | 38 class MockSyncErrorFactory : public syncer::SyncErrorFactory { |
| 39 public: | 39 public: |
| 40 explicit MockSyncErrorFactory(syncer::ModelType type); | 40 explicit MockSyncErrorFactory(syncer::ModelType type); |
| 41 virtual ~MockSyncErrorFactory(); | 41 virtual ~MockSyncErrorFactory(); |
| 42 | 42 |
| 43 // SyncErrorFactory implementation: | 43 // SyncErrorFactory implementation: |
| 44 virtual syncer::SyncError CreateAndUploadError( | 44 virtual syncer::SyncError CreateAndUploadError( |
| 45 const tracked_objects::Location& location, | 45 const tracked_objects::Location& location, |
| 46 const std::string& message) OVERRIDE; | 46 const std::string& message) override; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 syncer::ModelType type_; | 49 syncer::ModelType type_; |
| 50 | 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(MockSyncErrorFactory); | 51 DISALLOW_COPY_AND_ASSIGN(MockSyncErrorFactory); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 MockSyncErrorFactory::MockSyncErrorFactory(syncer::ModelType type) | 54 MockSyncErrorFactory::MockSyncErrorFactory(syncer::ModelType type) |
| 55 : type_(type) {} | 55 : type_(type) {} |
| 56 | 56 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 virtual 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 virtual 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 |