Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc

Issue 14141006: [components] Switch {RefCounted}ProfileKeyedService to use BrowserContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for review Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/content_settings/cookie_settings.h" 8 #include "chrome/browser/content_settings/cookie_settings.h"
9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
10 #include "chrome/browser/prefs/scoped_user_pref_update.h" 10 #include "chrome/browser/prefs/scoped_user_pref_update.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 TestURLRequest() {} 148 TestURLRequest() {}
149 virtual ~TestURLRequest() {} 149 virtual ~TestURLRequest() {}
150 }; 150 };
151 151
152 class OneClickTestProfileSyncService : public TestProfileSyncService { 152 class OneClickTestProfileSyncService : public TestProfileSyncService {
153 public: 153 public:
154 virtual ~OneClickTestProfileSyncService() {} 154 virtual ~OneClickTestProfileSyncService() {}
155 155
156 // Helper routine to be used in conjunction with 156 // Helper routine to be used in conjunction with
157 // ProfileKeyedServiceFactory::SetTestingFactory(). 157 // ProfileKeyedServiceFactory::SetTestingFactory().
158 static ProfileKeyedService* Build(Profile* profile) { 158 static ProfileKeyedService* Build(content::BrowserContext* profile) {
159 return new OneClickTestProfileSyncService(profile); 159 return new OneClickTestProfileSyncService(static_cast<Profile*>(profile));
160 } 160 }
161 161
162 // Need to control this for certain tests. 162 // Need to control this for certain tests.
163 virtual bool FirstSetupInProgress() const OVERRIDE { 163 virtual bool FirstSetupInProgress() const OVERRIDE {
164 return first_setup_in_progress_; 164 return first_setup_in_progress_;
165 } 165 }
166 166
167 // Controls return value of FirstSetupInProgress. Because some bits 167 // Controls return value of FirstSetupInProgress. Because some bits
168 // of UI depend on that value, it's useful to control it separately 168 // of UI depend on that value, it's useful to control it separately
169 // from the internal work and components that are triggered (such as 169 // from the internal work and components that are triggered (such as
(...skipping 11 matching lines...) Expand all
181 : TestProfileSyncService(NULL, 181 : TestProfileSyncService(NULL,
182 profile, 182 profile,
183 NULL, 183 NULL,
184 ProfileSyncService::MANUAL_START, 184 ProfileSyncService::MANUAL_START,
185 false), // synchronous_backend_init 185 false), // synchronous_backend_init
186 first_setup_in_progress_(false) {} 186 first_setup_in_progress_(false) {}
187 187
188 bool first_setup_in_progress_; 188 bool first_setup_in_progress_;
189 }; 189 };
190 190
191 static ProfileKeyedService* BuildSigninManagerMock(Profile* profile) { 191 static ProfileKeyedService* BuildSigninManagerMock(
192 return new SigninManagerMock(profile); 192 content::BrowserContext* profile) {
193 return new SigninManagerMock(static_cast<Profile*>(profile));
193 } 194 }
194 195
195 } // namespace 196 } // namespace
196 197
197 class OneClickSigninHelperTest : public content::RenderViewHostTestHarness { 198 class OneClickSigninHelperTest : public content::RenderViewHostTestHarness {
198 public: 199 public:
199 OneClickSigninHelperTest(); 200 OneClickSigninHelperTest();
200 201
201 virtual void SetUp() OVERRIDE; 202 virtual void SetUp() OVERRIDE;
202 virtual void TearDown() OVERRIDE; 203 virtual void TearDown() OVERRIDE;
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); 893 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
893 894
894 // Simulate a policy disabling sync by writing kSyncManaged directly. 895 // Simulate a policy disabling sync by writing kSyncManaged directly.
895 // We should still offer to sign in the browser. 896 // We should still offer to sign in the browser.
896 profile_->GetTestingPrefService()->SetManagedPref( 897 profile_->GetTestingPrefService()->SetManagedPref(
897 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); 898 prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
898 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, 899 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER,
899 OneClickSigninHelper::CanOfferOnIOThreadImpl( 900 OneClickSigninHelper::CanOfferOnIOThreadImpl(
900 valid_gaia_url_, std::string(), &request_, io_data.get())); 901 valid_gaia_url_, std::string(), &request_, io_data.get()));
901 } 902 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698