| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/prefs/preferences_manager.h" | 5 #include "chrome/browser/prefs/preferences_manager.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 registry_ = service->registry(); | 155 registry_ = service->registry(); |
| 156 chrome::RegisterUserProfilePrefs(registry_); | 156 chrome::RegisterUserProfilePrefs(registry_); |
| 157 | 157 |
| 158 const std::string kName = "navi"; | 158 const std::string kName = "navi"; |
| 159 profile_ = testing_profile_manager_.CreateTestingProfile( | 159 profile_ = testing_profile_manager_.CreateTestingProfile( |
| 160 kName, std::move(service), base::UTF8ToUTF16(kName), 0, std::string(), | 160 kName, std::move(service), base::UTF8ToUTF16(kName), 0, std::string(), |
| 161 TestingProfile::TestingFactories()); | 161 TestingProfile::TestingFactories()); |
| 162 ASSERT_NE(nullptr, profile_->GetPrefs()); | 162 ASSERT_NE(nullptr, profile_->GetPrefs()); |
| 163 | 163 |
| 164 observer_.reset(new TestPreferencesObserver(mojo::MakeRequest(&proxy_))); | 164 observer_.reset(new TestPreferencesObserver(mojo::MakeRequest(&proxy_))); |
| 165 manager_ = base::MakeUnique<PreferencesManager>(profile_); | 165 manager_ = base::MakeUnique<PreferencesManager>(std::move(proxy_), profile_); |
| 166 ASSERT_TRUE(manager_->preferences_change_registrar_->IsEmpty()); | 166 ASSERT_TRUE(manager_->preferences_change_registrar_->IsEmpty()); |
| 167 manager_->AddObserver(std::move(proxy_)); | |
| 168 } | 167 } |
| 169 | 168 |
| 170 void PreferencesManagerTest::TearDown() { | 169 void PreferencesManagerTest::TearDown() { |
| 171 testing_profile_manager_.DeleteAllTestingProfiles(); | 170 testing_profile_manager_.DeleteAllTestingProfiles(); |
| 172 } | 171 } |
| 173 | 172 |
| 174 // Tests that when the PrefService is empty that no subscriptions are made. | 173 // Tests that when the PrefService is empty that no subscriptions are made. |
| 175 TEST_F(PreferencesManagerTest, EmptyService) { | 174 TEST_F(PreferencesManagerTest, EmptyService) { |
| 176 const std::string kKey = "hey"; | 175 const std::string kKey = "hey"; |
| 177 std::vector<std::string> preferences; | 176 std::vector<std::string> preferences; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 std::unique_ptr<base::DictionaryValue> dictionary = | 297 std::unique_ptr<base::DictionaryValue> dictionary = |
| 299 base::MakeUnique<base::DictionaryValue>(); | 298 base::MakeUnique<base::DictionaryValue>(); |
| 300 dictionary->SetInteger(kKey, kNewValue); | 299 dictionary->SetInteger(kKey, kNewValue); |
| 301 SetPreferences(std::move(dictionary)); | 300 SetPreferences(std::move(dictionary)); |
| 302 | 301 |
| 303 EXPECT_FALSE(observer()->on_preferences_changed_called()); | 302 EXPECT_FALSE(observer()->on_preferences_changed_called()); |
| 304 EXPECT_EQ(kNewValue, service()->GetInteger(kKey)); | 303 EXPECT_EQ(kNewValue, service()->GetInteger(kKey)); |
| 305 } | 304 } |
| 306 | 305 |
| 307 } // namespace test | 306 } // namespace test |
| OLD | NEW |