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/legacy/supervised_user_shared_settings_
service.h" | 10 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" |
13 #include "sync/api/fake_sync_change_processor.h" | 14 #include "sync/api/fake_sync_change_processor.h" |
14 #include "sync/api/sync_change.h" | 15 #include "sync/api/sync_change.h" |
15 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 16 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
16 #include "sync/api/sync_error_factory_mock.h" | 17 #include "sync/api/sync_error_factory_mock.h" |
17 #include "sync/protocol/sync.pb.h" | 18 #include "sync/protocol/sync.pb.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 using base::DictionaryValue; | 21 using base::DictionaryValue; |
21 using base::FundamentalValue; | 22 using base::FundamentalValue; |
22 using base::StringValue; | 23 using base::StringValue; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 void TearDown() override { settings_service_.Shutdown(); } | 124 void TearDown() override { settings_service_.Shutdown(); } |
124 | 125 |
125 void OnSettingChanged(const std::string& su_id, const std::string& key) { | 126 void OnSettingChanged(const std::string& su_id, const std::string& key) { |
126 const Value* value = settings_service_.GetValue(su_id, key); | 127 const Value* value = settings_service_.GetValue(su_id, key); |
127 ASSERT_TRUE(value); | 128 ASSERT_TRUE(value); |
128 changed_settings_.push_back( | 129 changed_settings_.push_back( |
129 SupervisedUserSharedSettingsService::CreateSyncDataForSetting( | 130 SupervisedUserSharedSettingsService::CreateSyncDataForSetting( |
130 su_id, key, *value, true)); | 131 su_id, key, *value, true)); |
131 } | 132 } |
132 | 133 |
| 134 content::TestBrowserThreadBundle thread_bundle_; |
133 TestingProfile profile_; | 135 TestingProfile profile_; |
134 SupervisedUserSharedSettingsService settings_service_; | 136 SupervisedUserSharedSettingsService settings_service_; |
135 SyncDataList changed_settings_; | 137 SyncDataList changed_settings_; |
136 | 138 |
137 scoped_ptr<CallbackList::Subscription> subscription_; | 139 scoped_ptr<CallbackList::Subscription> subscription_; |
138 | 140 |
139 scoped_ptr<syncer::FakeSyncChangeProcessor> sync_processor_; | 141 scoped_ptr<syncer::FakeSyncChangeProcessor> sync_processor_; |
140 }; | 142 }; |
141 | 143 |
142 TEST_F(SupervisedUserSharedSettingsServiceTest, Empty) { | 144 TEST_F(SupervisedUserSharedSettingsServiceTest, Empty) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 settings_service_.GetAllSyncData(SUPERVISED_USER_SHARED_SETTINGS).size()); | 265 settings_service_.GetAllSyncData(SUPERVISED_USER_SHARED_SETTINGS).size()); |
264 EXPECT_EQ(ToJson(&name), | 266 EXPECT_EQ(ToJson(&name), |
265 ToJson(settings_service_.GetValue(kIdA, "name"))); | 267 ToJson(settings_service_.GetValue(kIdA, "name"))); |
266 EXPECT_EQ(ToJson(&age), ToJson(settings_service_.GetValue(kIdA, "age"))); | 268 EXPECT_EQ(ToJson(&age), ToJson(settings_service_.GetValue(kIdA, "age"))); |
267 EXPECT_EQ(ToJson(&bar), ToJson(settings_service_.GetValue(kIdB, "foo"))); | 269 EXPECT_EQ(ToJson(&bar), ToJson(settings_service_.GetValue(kIdB, "foo"))); |
268 EXPECT_EQ(ToJson(&blurp), ToJson(settings_service_.GetValue(kIdC, "baz"))); | 270 EXPECT_EQ(ToJson(&blurp), ToJson(settings_service_.GetValue(kIdC, "baz"))); |
269 EXPECT_FALSE(settings_service_.GetValue(kIdA, "foo")); | 271 EXPECT_FALSE(settings_service_.GetValue(kIdA, "foo")); |
270 EXPECT_FALSE(settings_service_.GetValue(kIdB, "name")); | 272 EXPECT_FALSE(settings_service_.GetValue(kIdB, "name")); |
271 EXPECT_FALSE(settings_service_.GetValue(kIdC, "name")); | 273 EXPECT_FALSE(settings_service_.GetValue(kIdC, "name")); |
272 } | 274 } |
OLD | NEW |