OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/sync/profile_signin_confirmation_helper.h" | 5 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 // A pref store that can have its read_error property changed for testing. | 71 // A pref store that can have its read_error property changed for testing. |
72 class TestingPrefStoreWithCustomReadError : public TestingPrefStore { | 72 class TestingPrefStoreWithCustomReadError : public TestingPrefStore { |
73 public: | 73 public: |
74 TestingPrefStoreWithCustomReadError() | 74 TestingPrefStoreWithCustomReadError() |
75 : read_error_(PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { | 75 : read_error_(PersistentPrefStore::PREF_READ_ERROR_NO_FILE) { |
76 // By default the profile is "new" (NO_FILE means that the profile | 76 // By default the profile is "new" (NO_FILE means that the profile |
77 // wasn't found on disk, so it was created). | 77 // wasn't found on disk, so it was created). |
78 } | 78 } |
79 virtual PrefReadError GetReadError() const OVERRIDE { | 79 virtual PrefReadError GetReadError() const override { |
80 return read_error_; | 80 return read_error_; |
81 } | 81 } |
82 virtual bool IsInitializationComplete() const OVERRIDE { | 82 virtual bool IsInitializationComplete() const override { |
83 return true; | 83 return true; |
84 } | 84 } |
85 void set_read_error(PrefReadError read_error) { | 85 void set_read_error(PrefReadError read_error) { |
86 read_error_ = read_error; | 86 read_error_ = read_error; |
87 } | 87 } |
88 private: | 88 private: |
89 virtual ~TestingPrefStoreWithCustomReadError() {} | 89 virtual ~TestingPrefStoreWithCustomReadError() {} |
90 PrefReadError read_error_; | 90 PrefReadError read_error_; |
91 }; | 91 }; |
92 | 92 |
(...skipping 27 matching lines...) Expand all Loading... |
120 | 120 |
121 } // namespace | 121 } // namespace |
122 | 122 |
123 class ProfileSigninConfirmationHelperTest : public testing::Test { | 123 class ProfileSigninConfirmationHelperTest : public testing::Test { |
124 public: | 124 public: |
125 ProfileSigninConfirmationHelperTest() | 125 ProfileSigninConfirmationHelperTest() |
126 : user_prefs_(NULL), | 126 : user_prefs_(NULL), |
127 model_(NULL) { | 127 model_(NULL) { |
128 } | 128 } |
129 | 129 |
130 virtual void SetUp() OVERRIDE { | 130 virtual void SetUp() override { |
131 // Create the profile. | 131 // Create the profile. |
132 TestingProfile::Builder builder; | 132 TestingProfile::Builder builder; |
133 user_prefs_ = new TestingPrefStoreWithCustomReadError; | 133 user_prefs_ = new TestingPrefStoreWithCustomReadError; |
134 TestingPrefServiceSyncable* pref_service = new TestingPrefServiceSyncable( | 134 TestingPrefServiceSyncable* pref_service = new TestingPrefServiceSyncable( |
135 new TestingPrefStore(), | 135 new TestingPrefStore(), |
136 user_prefs_, | 136 user_prefs_, |
137 new TestingPrefStore(), | 137 new TestingPrefStore(), |
138 new user_prefs::PrefRegistrySyncable(), | 138 new user_prefs::PrefRegistrySyncable(), |
139 new PrefNotifierImpl()); | 139 new PrefNotifierImpl()); |
140 chrome::RegisterUserProfilePrefs(pref_service->registry()); | 140 chrome::RegisterUserProfilePrefs(pref_service->registry()); |
141 builder.SetPrefService(make_scoped_ptr<PrefServiceSyncable>(pref_service)); | 141 builder.SetPrefService(make_scoped_ptr<PrefServiceSyncable>(pref_service)); |
142 profile_ = builder.Build(); | 142 profile_ = builder.Build(); |
143 | 143 |
144 // Initialize the services we check. | 144 // Initialize the services we check. |
145 profile_->CreateBookmarkModel(true); | 145 profile_->CreateBookmarkModel(true); |
146 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); | 146 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); |
147 test::WaitForBookmarkModelToLoad(model_); | 147 test::WaitForBookmarkModelToLoad(model_); |
148 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 148 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
149 #if defined(ENABLE_EXTENSIONS) | 149 #if defined(ENABLE_EXTENSIONS) |
150 extensions::TestExtensionSystem* system = | 150 extensions::TestExtensionSystem* system = |
151 static_cast<extensions::TestExtensionSystem*>( | 151 static_cast<extensions::TestExtensionSystem*>( |
152 extensions::ExtensionSystem::Get(profile_.get())); | 152 extensions::ExtensionSystem::Get(profile_.get())); |
153 CommandLine command_line(CommandLine::NO_PROGRAM); | 153 CommandLine command_line(CommandLine::NO_PROGRAM); |
154 system->CreateExtensionService(&command_line, | 154 system->CreateExtensionService(&command_line, |
155 base::FilePath(kExtensionFilePath), | 155 base::FilePath(kExtensionFilePath), |
156 false); | 156 false); |
157 #endif | 157 #endif |
158 } | 158 } |
159 | 159 |
160 virtual void TearDown() OVERRIDE { | 160 virtual void TearDown() override { |
161 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile | 161 // TestExtensionSystem uses DeleteSoon, so we need to delete the profile |
162 // and then run the message queue to clean up. | 162 // and then run the message queue to clean up. |
163 profile_.reset(); | 163 profile_.reset(); |
164 base::RunLoop().RunUntilIdle(); | 164 base::RunLoop().RunUntilIdle(); |
165 } | 165 } |
166 | 166 |
167 protected: | 167 protected: |
168 content::TestBrowserThreadBundle thread_bundle_; | 168 content::TestBrowserThreadBundle thread_bundle_; |
169 scoped_ptr<TestingProfile> profile_; | 169 scoped_ptr<TestingProfile> profile_; |
170 TestingPrefStoreWithCustomReadError* user_prefs_; | 170 TestingPrefStoreWithCustomReadError* user_prefs_; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { | 276 TEST_F(ProfileSigninConfirmationHelperTest, PromptForNewProfile_Restarted) { |
277 // Browser has been shut down since profile was created. | 277 // Browser has been shut down since profile was created. |
278 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); | 278 user_prefs_->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NONE); |
279 EXPECT_TRUE( | 279 EXPECT_TRUE( |
280 GetCallbackResult( | 280 GetCallbackResult( |
281 base::Bind( | 281 base::Bind( |
282 &ui::CheckShouldPromptForNewProfile, | 282 &ui::CheckShouldPromptForNewProfile, |
283 profile_.get()))); | 283 profile_.get()))); |
284 } | 284 } |
OLD | NEW |