| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/prefs/testing_pref_store.h" | 8 #include "base/prefs/testing_pref_store.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 10 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
| 11 #include "content/public/test/test_browser_thread_bundle.h" |
| 11 #include "sync/api/fake_sync_change_processor.h" | 12 #include "sync/api/fake_sync_change_processor.h" |
| 12 #include "sync/api/sync_change.h" | 13 #include "sync/api/sync_change.h" |
| 13 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 14 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
| 14 #include "sync/api/sync_error_factory_mock.h" | 15 #include "sync/api/sync_error_factory_mock.h" |
| 15 #include "sync/protocol/sync.pb.h" | 16 #include "sync/protocol/sync.pb.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 class MockSyncErrorFactory : public syncer::SyncErrorFactory { | 21 class MockSyncErrorFactory : public syncer::SyncErrorFactory { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 base::Bind(&SupervisedUserSettingsServiceTest::OnNewSettingsAvailable, | 127 base::Bind(&SupervisedUserSettingsServiceTest::OnNewSettingsAvailable, |
| 127 base::Unretained(this))); | 128 base::Unretained(this))); |
| 128 pref_store->SetInitializationCompleted(); | 129 pref_store->SetInitializationCompleted(); |
| 129 ASSERT_FALSE(settings_); | 130 ASSERT_FALSE(settings_); |
| 130 settings_service_.SetActive(true); | 131 settings_service_.SetActive(true); |
| 131 ASSERT_TRUE(settings_); | 132 ASSERT_TRUE(settings_); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void TearDown() override { settings_service_.Shutdown(); } | 135 void TearDown() override { settings_service_.Shutdown(); } |
| 135 | 136 |
| 137 content::TestBrowserThreadBundle thread_bundle_; |
| 136 base::DictionaryValue split_items_; | 138 base::DictionaryValue split_items_; |
| 137 scoped_ptr<base::Value> atomic_setting_value_; | 139 scoped_ptr<base::Value> atomic_setting_value_; |
| 138 SupervisedUserSettingsService settings_service_; | 140 SupervisedUserSettingsService settings_service_; |
| 139 scoped_ptr<base::DictionaryValue> settings_; | 141 scoped_ptr<base::DictionaryValue> settings_; |
| 140 | 142 |
| 141 scoped_ptr<syncer::FakeSyncChangeProcessor> sync_processor_; | 143 scoped_ptr<syncer::FakeSyncChangeProcessor> sync_processor_; |
| 142 }; | 144 }; |
| 143 | 145 |
| 144 TEST_F(SupervisedUserSettingsServiceTest, ProcessAtomicSetting) { | 146 TEST_F(SupervisedUserSettingsServiceTest, ProcessAtomicSetting) { |
| 145 StartSyncing(syncer::SyncDataList()); | 147 StartSyncing(syncer::SyncDataList()); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // The uploaded items should not show up as settings. | 282 // The uploaded items should not show up as settings. |
| 281 const base::Value* value = NULL; | 283 const base::Value* value = NULL; |
| 282 EXPECT_FALSE(settings_->GetWithoutPathExpansion(kAtomicItemName, &value)); | 284 EXPECT_FALSE(settings_->GetWithoutPathExpansion(kAtomicItemName, &value)); |
| 283 EXPECT_FALSE(settings_->GetWithoutPathExpansion(kSplitItemName, &value)); | 285 EXPECT_FALSE(settings_->GetWithoutPathExpansion(kSplitItemName, &value)); |
| 284 | 286 |
| 285 // Restarting sync should not create any new changes. | 287 // Restarting sync should not create any new changes. |
| 286 settings_service_.StopSyncing(syncer::SUPERVISED_USER_SETTINGS); | 288 settings_service_.StopSyncing(syncer::SUPERVISED_USER_SETTINGS); |
| 287 StartSyncing(sync_data); | 289 StartSyncing(sync_data); |
| 288 ASSERT_EQ(0u, sync_processor_->changes().size()); | 290 ASSERT_EQ(0u, sync_processor_->changes().size()); |
| 289 } | 291 } |
| OLD | NEW |