| OLD | NEW |
| 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "base/values.h" | 6 #include "base/values.h" |
| 7 #include "chrome/browser/content_settings/cookie_settings.h" | 7 #include "chrome/browser/content_settings/cookie_settings.h" |
| 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable.h" | 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 public: | 58 public: |
| 59 TestProfileIOData(bool is_incognito, PrefService* pref_service, | 59 TestProfileIOData(bool is_incognito, PrefService* pref_service, |
| 60 PrefService* local_state, CookieSettings* cookie_settings) | 60 PrefService* local_state, CookieSettings* cookie_settings) |
| 61 : ProfileIOData(is_incognito) { | 61 : ProfileIOData(is_incognito) { |
| 62 // Initialize the IO members required for these tests, but keep them on | 62 // Initialize the IO members required for these tests, but keep them on |
| 63 // this thread since we don't use a background thread here. | 63 // this thread since we don't use a background thread here. |
| 64 google_services_username()->Init(prefs::kGoogleServicesUsername, | 64 google_services_username()->Init(prefs::kGoogleServicesUsername, |
| 65 pref_service); | 65 pref_service); |
| 66 reverse_autologin_enabled()->Init(prefs::kReverseAutologinEnabled, | 66 reverse_autologin_enabled()->Init(prefs::kReverseAutologinEnabled, |
| 67 pref_service); | 67 pref_service); |
| 68 reverse_autologin_pending_email()->Init( |
| 69 prefs::kReverseAutologinPendingEmail, pref_service); |
| 68 one_click_signin_rejected_email_list()->Init( | 70 one_click_signin_rejected_email_list()->Init( |
| 69 prefs::kReverseAutologinRejectedEmailList, pref_service); | 71 prefs::kReverseAutologinRejectedEmailList, pref_service); |
| 70 | 72 |
| 71 google_services_username_pattern()->Init( | 73 google_services_username_pattern()->Init( |
| 72 prefs::kGoogleServicesUsernamePattern, local_state); | 74 prefs::kGoogleServicesUsernamePattern, local_state); |
| 73 | 75 |
| 74 sync_disabled()->Init(prefs::kSyncManaged, pref_service); | 76 sync_disabled()->Init(prefs::kSyncManaged, pref_service); |
| 75 | 77 |
| 76 set_signin_names_for_testing(new SigninNamesOnIOThread()); | 78 set_signin_names_for_testing(new SigninNamesOnIOThread()); |
| 77 SetCookieSettingsForTesting(cookie_settings); | 79 SetCookieSettingsForTesting(cookie_settings); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 fub_thread_(content::BrowserThread::FILE_USER_BLOCKING, &message_loop_), | 306 fub_thread_(content::BrowserThread::FILE_USER_BLOCKING, &message_loop_), |
| 305 io_thread_(content::BrowserThread::IO, &message_loop_) { | 307 io_thread_(content::BrowserThread::IO, &message_loop_) { |
| 306 } | 308 } |
| 307 | 309 |
| 308 OneClickSigninHelperIOTest::~OneClickSigninHelperIOTest() { | 310 OneClickSigninHelperIOTest::~OneClickSigninHelperIOTest() { |
| 309 } | 311 } |
| 310 | 312 |
| 311 void OneClickSigninHelperIOTest::SetUp() { | 313 void OneClickSigninHelperIOTest::SetUp() { |
| 312 OneClickSigninHelperTest::SetUp(); | 314 OneClickSigninHelperTest::SetUp(); |
| 313 ASSERT_TRUE(testing_profile_manager_.SetUp()); | 315 ASSERT_TRUE(testing_profile_manager_.SetUp()); |
| 314 OneClickSigninHelper::AssociateWithRequestForTesting(&request_, | |
| 315 "user@gmail.com"); | |
| 316 } | 316 } |
| 317 | 317 |
| 318 TestProfileIOData* OneClickSigninHelperIOTest::CreateTestProfileIOData( | 318 TestProfileIOData* OneClickSigninHelperIOTest::CreateTestProfileIOData( |
| 319 bool is_incognito) { | 319 bool is_incognito) { |
| 320 PrefService* pref_service = profile_->GetPrefs(); | 320 PrefService* pref_service = profile_->GetPrefs(); |
| 321 PrefService* local_state = g_browser_process->local_state(); | 321 PrefService* local_state = g_browser_process->local_state(); |
| 322 CookieSettings* cookie_settings = | 322 CookieSettings* cookie_settings = |
| 323 CookieSettings::Factory::GetForProfile(profile_); | 323 CookieSettings::Factory::GetForProfile(profile_); |
| 324 TestProfileIOData* io_data = new TestProfileIOData( | 324 TestProfileIOData* io_data = new TestProfileIOData( |
| 325 is_incognito, pref_service, local_state, cookie_settings); | 325 is_incognito, pref_service, local_state, cookie_settings); |
| 326 io_data->reverse_autologin_pending_email()->SetValue("user@gmail.com"); |
| 326 return io_data; | 327 return io_data; |
| 327 } | 328 } |
| 328 | 329 |
| 329 TEST_F(OneClickSigninHelperTest, CanOfferNoContents) { | 330 TEST_F(OneClickSigninHelperTest, CanOfferNoContents) { |
| 330 int error_message_id = 0; | 331 int error_message_id = 0; |
| 331 EXPECT_FALSE(OneClickSigninHelper::CanOffer( | 332 EXPECT_FALSE(OneClickSigninHelper::CanOffer( |
| 332 NULL, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, | 333 NULL, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, |
| 333 "user@gmail.com", &error_message_id)); | 334 "user@gmail.com", &error_message_id)); |
| 334 EXPECT_EQ(0, error_message_id); | 335 EXPECT_EQ(0, error_message_id); |
| 335 EXPECT_FALSE(OneClickSigninHelper::CanOffer( | 336 EXPECT_FALSE(OneClickSigninHelper::CanOffer( |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 691 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
| 691 valid_gaia_url_, "", &request_, io_data.get())); | 692 valid_gaia_url_, "", &request_, io_data.get())); |
| 692 | 693 |
| 693 // Simulate a policy disabling sync by writing kSyncManaged directly. | 694 // Simulate a policy disabling sync by writing kSyncManaged directly. |
| 694 profile_->GetTestingPrefService()->SetManagedPref( | 695 profile_->GetTestingPrefService()->SetManagedPref( |
| 695 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 696 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); |
| 696 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER, | 697 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER, |
| 697 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 698 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
| 698 valid_gaia_url_, "", &request_, io_data.get())); | 699 valid_gaia_url_, "", &request_, io_data.get())); |
| 699 } | 700 } |
| OLD | NEW |