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/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "base/prefs/scoped_user_pref_update.h" | 6 #include "base/prefs/scoped_user_pref_update.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/content_settings/cookie_settings.h" | 11 #include "chrome/browser/content_settings/cookie_settings.h" |
12 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 12 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_info_cache.h" | 14 #include "chrome/browser/profiles/profile_info_cache.h" |
15 #include "chrome/browser/profiles/profile_io_data.h" | 15 #include "chrome/browser/profiles/profile_io_data.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/signin/chrome_signin_client.h" | 17 #include "chrome/browser/signin/chrome_signin_client.h" |
18 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 18 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
19 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 19 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
20 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 20 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
21 #include "chrome/browser/signin/fake_signin_manager.h" | 21 #include "chrome/browser/signin/fake_signin_manager.h" |
22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
23 #include "chrome/browser/signin/signin_manager_factory.h" | 23 #include "chrome/browser/signin/signin_manager_factory.h" |
24 #include "chrome/browser/signin/signin_names_io_thread.h" | 24 #include "chrome/browser/signin/signin_names_io_thread.h" |
25 #include "chrome/browser/signin/signin_promo.h" | 25 #include "chrome/browser/signin/signin_promo.h" |
26 #include "chrome/browser/sync/profile_sync_service_factory.h" | 26 #include "chrome/browser/sync/profile_sync_service_factory.h" |
27 #include "chrome/browser/sync/profile_sync_service_mock.h" | |
28 #include "chrome/browser/sync/test_profile_sync_service.h" | 27 #include "chrome/browser/sync/test_profile_sync_service.h" |
29 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 28 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
30 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 29 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
31 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 30 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
32 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
33 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 32 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
34 #include "chrome/test/base/testing_browser_process.h" | 33 #include "chrome/test/base/testing_browser_process.h" |
35 #include "chrome/test/base/testing_pref_service_syncable.h" | 34 #include "chrome/test/base/testing_pref_service_syncable.h" |
36 #include "chrome/test/base/testing_profile.h" | 35 #include "chrome/test/base/testing_profile.h" |
37 #include "chrome/test/base/testing_profile_manager.h" | 36 #include "chrome/test/base/testing_profile_manager.h" |
38 #include "components/autofill/core/common/password_form.h" | 37 #include "components/autofill/core/common/password_form.h" |
39 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 38 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
40 #include "components/signin/core/browser/signin_manager.h" | 39 #include "components/signin/core/browser/signin_manager.h" |
41 #include "components/sync_driver/pref_names.h" | 40 #include "components/sync_driver/pref_names.h" |
42 #include "content/public/browser/browser_context.h" | 41 #include "content/public/browser/browser_context.h" |
43 #include "content/public/browser/navigation_details.h" | 42 #include "content/public/browser/navigation_details.h" |
44 #include "content/public/browser/navigation_entry.h" | 43 #include "content/public/browser/navigation_entry.h" |
45 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
46 #include "content/public/browser/web_contents_delegate.h" | 45 #include "content/public/browser/web_contents_delegate.h" |
47 #include "content/public/common/frame_navigate_params.h" | 46 #include "content/public/common/frame_navigate_params.h" |
48 #include "content/public/common/url_constants.h" | 47 #include "content/public/common/url_constants.h" |
49 #include "content/public/test/mock_render_process_host.h" | 48 #include "content/public/test/mock_render_process_host.h" |
50 #include "grit/chromium_strings.h" | 49 #include "grit/chromium_strings.h" |
51 #include "grit/generated_resources.h" | 50 #include "grit/generated_resources.h" |
| 51 #include "testing/gmock/include/gmock/gmock.h" |
52 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
53 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
54 | 54 |
55 using ::testing::_; | 55 using ::testing::_; |
56 using ::testing::AtLeast; | 56 using ::testing::AtLeast; |
57 using ::testing::Return; | 57 using ::testing::Return; |
58 | 58 |
59 namespace { | 59 namespace { |
60 | 60 |
61 // Used to confirm OneClickSigninHelper does not trigger redirect when there is | 61 // Used to confirm OneClickSigninHelper does not trigger redirect when there is |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 }; | 165 }; |
166 | 166 |
167 class TestURLRequest : public base::SupportsUserData { | 167 class TestURLRequest : public base::SupportsUserData { |
168 public: | 168 public: |
169 TestURLRequest() {} | 169 TestURLRequest() {} |
170 virtual ~TestURLRequest() {} | 170 virtual ~TestURLRequest() {} |
171 }; | 171 }; |
172 | 172 |
173 class OneClickTestProfileSyncService : public TestProfileSyncService { | 173 class OneClickTestProfileSyncService : public TestProfileSyncService { |
174 public: | 174 public: |
175 virtual ~OneClickTestProfileSyncService() {} | 175 virtual ~OneClickTestProfileSyncService() {} |
176 | 176 |
177 // Helper routine to be used in conjunction with | 177 // Helper routine to be used in conjunction with |
178 // BrowserContextKeyedServiceFactory::SetTestingFactory(). | 178 // BrowserContextKeyedServiceFactory::SetTestingFactory(). |
179 static KeyedService* Build(content::BrowserContext* profile) { | 179 static KeyedService* Build(content::BrowserContext* profile) { |
180 return new OneClickTestProfileSyncService(static_cast<Profile*>(profile)); | 180 return new OneClickTestProfileSyncService(static_cast<Profile*>(profile)); |
181 } | 181 } |
182 | 182 |
183 // Need to control this for certain tests. | 183 // Need to control this for certain tests. |
184 virtual bool FirstSetupInProgress() const OVERRIDE { | 184 virtual bool FirstSetupInProgress() const OVERRIDE { |
185 return first_setup_in_progress_; | 185 return first_setup_in_progress_; |
186 } | 186 } |
187 | 187 |
188 // Controls return value of FirstSetupInProgress. Because some bits | 188 virtual bool sync_initialized() const OVERRIDE { return sync_initialized_; } |
189 // of UI depend on that value, it's useful to control it separately | |
190 // from the internal work and components that are triggered (such as | |
191 // ReconfigureDataTypeManager) to facilitate unit tests. | |
192 void set_first_setup_in_progress(bool in_progress) { | |
193 first_setup_in_progress_ = in_progress; | |
194 } | |
195 | 189 |
196 private: | 190 // Controls return value of FirstSetupInProgress. Because some bits |
197 explicit OneClickTestProfileSyncService(Profile* profile) | 191 // of UI depend on that value, it's useful to control it separately |
198 : TestProfileSyncService( | 192 // from the internal work and components that are triggered (such as |
199 NULL, | 193 // ReconfigureDataTypeManager) to facilitate unit tests. |
200 profile, | 194 void set_first_setup_in_progress(bool in_progress) { |
201 SigninManagerFactory::GetForProfile(profile), | 195 first_setup_in_progress_ = in_progress; |
202 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 196 } |
203 browser_sync::MANUAL_START), | |
204 first_setup_in_progress_(false) {} | |
205 | 197 |
206 bool first_setup_in_progress_; | 198 void set_sync_initialized(bool initialized) { |
| 199 sync_initialized_ = initialized; |
| 200 } |
| 201 |
| 202 private: |
| 203 explicit OneClickTestProfileSyncService(Profile* profile) |
| 204 : TestProfileSyncService( |
| 205 NULL, |
| 206 profile, |
| 207 SigninManagerFactory::GetForProfile(profile), |
| 208 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 209 browser_sync::MANUAL_START), |
| 210 first_setup_in_progress_(false), |
| 211 sync_initialized_(false) {} |
| 212 |
| 213 bool first_setup_in_progress_; |
| 214 bool sync_initialized_; |
207 }; | 215 }; |
208 | 216 |
209 } // namespace | 217 } // namespace |
210 | 218 |
211 class OneClickSigninHelperTest : public ChromeRenderViewHostTestHarness { | 219 class OneClickSigninHelperTest : public ChromeRenderViewHostTestHarness { |
212 public: | 220 public: |
213 OneClickSigninHelperTest(); | 221 OneClickSigninHelperTest(); |
214 | 222 |
215 virtual void SetUp() OVERRIDE; | 223 virtual void SetUp() OVERRIDE; |
216 virtual void TearDown() OVERRIDE; | 224 virtual void TearDown() OVERRIDE; |
217 | 225 |
218 // Sets up the sign-in manager for tests. If |username| is | 226 // Sets up the sign-in manager for tests. If |username| is |
219 // is not empty, the profile of the mock WebContents will be connected to | 227 // is not empty, the profile of the mock WebContents will be connected to |
220 // the given account. | 228 // the given account. |
221 void SetUpSigninManager(const std::string& username); | 229 void SetUpSigninManager(const std::string& username); |
222 | 230 |
223 // Set the ID of the signin process that the test will assume to be the | 231 // Set the ID of the signin process that the test will assume to be the |
224 // only process allowed to sign the user in to Chrome. | 232 // only process allowed to sign the user in to Chrome. |
225 void SetTrustedSigninProcessID(int id); | 233 void SetTrustedSigninProcessID(int id); |
226 | 234 |
227 void AddEmailToOneClickRejectedList(const std::string& email); | 235 void AddEmailToOneClickRejectedList(const std::string& email); |
228 void EnableOneClick(bool enable); | 236 void EnableOneClick(bool enable); |
229 void AllowSigninCookies(bool enable); | 237 void AllowSigninCookies(bool enable); |
230 void SetAllowedUsernamePattern(const std::string& pattern); | 238 void SetAllowedUsernamePattern(const std::string& pattern); |
231 ProfileSyncServiceMock* CreateProfileSyncServiceMock(); | |
232 void SubmitGAIAPassword(OneClickSigninHelper* helper); | 239 void SubmitGAIAPassword(OneClickSigninHelper* helper); |
233 | 240 |
234 SigninManagerMock* signin_manager_; | 241 SigninManagerMock* signin_manager_; |
235 FakeProfileOAuth2TokenService* fake_oauth2_token_service_; | 242 FakeProfileOAuth2TokenService* fake_oauth2_token_service_; |
236 | 243 |
237 protected: | 244 protected: |
238 GoogleServiceAuthError no_error_; | 245 GoogleServiceAuthError no_error_; |
239 | 246 |
240 private: | 247 private: |
241 // ChromeRenderViewHostTestHarness overrides: | 248 // ChromeRenderViewHostTestHarness overrides: |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 cookie_settings->SetDefaultCookieSetting(enable ? CONTENT_SETTING_ALLOW | 311 cookie_settings->SetDefaultCookieSetting(enable ? CONTENT_SETTING_ALLOW |
305 : CONTENT_SETTING_BLOCK); | 312 : CONTENT_SETTING_BLOCK); |
306 } | 313 } |
307 | 314 |
308 void OneClickSigninHelperTest::SetAllowedUsernamePattern( | 315 void OneClickSigninHelperTest::SetAllowedUsernamePattern( |
309 const std::string& pattern) { | 316 const std::string& pattern) { |
310 PrefService* local_state = g_browser_process->local_state(); | 317 PrefService* local_state = g_browser_process->local_state(); |
311 local_state->SetString(prefs::kGoogleServicesUsernamePattern, pattern); | 318 local_state->SetString(prefs::kGoogleServicesUsernamePattern, pattern); |
312 } | 319 } |
313 | 320 |
314 ProfileSyncServiceMock* | |
315 OneClickSigninHelperTest::CreateProfileSyncServiceMock() { | |
316 ProfileSyncServiceMock* sync_service = static_cast<ProfileSyncServiceMock*>( | |
317 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | |
318 profile(), | |
319 ProfileSyncServiceMock::BuildMockProfileSyncService)); | |
320 EXPECT_CALL(*sync_service, FirstSetupInProgress()).WillRepeatedly( | |
321 Return(false)); | |
322 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(true)); | |
323 EXPECT_CALL(*sync_service, GetAuthError()). | |
324 WillRepeatedly(::testing::ReturnRef(no_error_)); | |
325 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(false)); | |
326 ON_CALL(*sync_service, GetRegisteredDataTypes()) | |
327 .WillByDefault(Return(syncer::ModelTypeSet())); | |
328 sync_service->Initialize(); | |
329 return sync_service; | |
330 } | |
331 | |
332 void OneClickSigninHelperTest::SubmitGAIAPassword( | 321 void OneClickSigninHelperTest::SubmitGAIAPassword( |
333 OneClickSigninHelper* helper) { | 322 OneClickSigninHelper* helper) { |
334 autofill::PasswordForm password_form; | 323 autofill::PasswordForm password_form; |
335 password_form.origin = GURL("https://accounts.google.com"); | 324 password_form.origin = GURL("https://accounts.google.com"); |
336 password_form.signon_realm = "https://accounts.google.com"; | 325 password_form.signon_realm = "https://accounts.google.com"; |
337 password_form.password_value = base::UTF8ToUTF16("password"); | 326 password_form.password_value = base::UTF8ToUTF16("password"); |
338 helper->PasswordSubmitted(password_form); | 327 helper->PasswordSubmitted(password_form); |
339 } | 328 } |
340 | 329 |
341 content::BrowserContext* OneClickSigninHelperTest::CreateBrowserContext() { | 330 content::BrowserContext* OneClickSigninHelperTest::CreateBrowserContext() { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 TEST_F(OneClickSigninHelperTest, CanOfferFirstSetup) { | 455 TEST_F(OneClickSigninHelperTest, CanOfferFirstSetup) { |
467 SetUpSigninManager(std::string()); | 456 SetUpSigninManager(std::string()); |
468 | 457 |
469 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). | 458 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). |
470 WillRepeatedly(Return(true)); | 459 WillRepeatedly(Return(true)); |
471 | 460 |
472 // Invoke OneClickTestProfileSyncService factory function and grab result. | 461 // Invoke OneClickTestProfileSyncService factory function and grab result. |
473 OneClickTestProfileSyncService* sync = | 462 OneClickTestProfileSyncService* sync = |
474 static_cast<OneClickTestProfileSyncService*>( | 463 static_cast<OneClickTestProfileSyncService*>( |
475 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 464 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
476 static_cast<Profile*>(browser_context()), | 465 profile(), OneClickTestProfileSyncService::Build)); |
477 OneClickTestProfileSyncService::Build)); | 466 sync->set_sync_initialized(false); |
478 sync->Initialize(); | 467 sync->Initialize(); |
| 468 sync->set_sync_initialized(true); |
479 sync->set_first_setup_in_progress(true); | 469 sync->set_first_setup_in_progress(true); |
480 | 470 |
481 EXPECT_TRUE(OneClickSigninHelper::CanOffer( | 471 EXPECT_TRUE(OneClickSigninHelper::CanOffer( |
482 web_contents(), | 472 web_contents(), |
483 OneClickSigninHelper::CAN_OFFER_FOR_ALL, | 473 OneClickSigninHelper::CAN_OFFER_FOR_ALL, |
484 "foo@gmail.com", NULL)); | 474 "foo@gmail.com", NULL)); |
485 EXPECT_TRUE(OneClickSigninHelper::CanOffer( | 475 EXPECT_TRUE(OneClickSigninHelper::CanOffer( |
486 web_contents(), | 476 web_contents(), |
487 OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, | 477 OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, |
488 "foo@gmail.com", NULL)); | 478 "foo@gmail.com", NULL)); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 } | 668 } |
679 | 669 |
680 // If Chrome signin is triggered from a webstore install, and user chooses to | 670 // If Chrome signin is triggered from a webstore install, and user chooses to |
681 // config sync, then Chrome should redirect immediately to sync settings page, | 671 // config sync, then Chrome should redirect immediately to sync settings page, |
682 // and upon successful setup, redirect back to webstore. | 672 // and upon successful setup, redirect back to webstore. |
683 TEST_F(OneClickSigninHelperTest, SigninFromWebstoreWithConfigSyncfirst) { | 673 TEST_F(OneClickSigninHelperTest, SigninFromWebstoreWithConfigSyncfirst) { |
684 SetUpSigninManager(std::string()); | 674 SetUpSigninManager(std::string()); |
685 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)) | 675 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)) |
686 .WillRepeatedly(Return(true)); | 676 .WillRepeatedly(Return(true)); |
687 | 677 |
688 ProfileSyncServiceMock* sync_service = CreateProfileSyncServiceMock(); | 678 OneClickTestProfileSyncService* sync_service = |
689 EXPECT_CALL(*sync_service, AddObserver(_)).Times(AtLeast(1)); | 679 static_cast<OneClickTestProfileSyncService*>( |
690 EXPECT_CALL(*sync_service, RemoveObserver(_)).Times(AtLeast(1)); | 680 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
691 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(true)); | 681 profile(), OneClickTestProfileSyncService::Build)); |
| 682 sync_service->set_sync_initialized(true); |
692 | 683 |
693 content::WebContents* contents = web_contents(); | 684 content::WebContents* contents = web_contents(); |
694 | 685 |
695 OneClickSigninHelper::CreateForWebContentsWithPasswordManager(contents, NULL); | 686 OneClickSigninHelper::CreateForWebContentsWithPasswordManager(contents, NULL); |
696 OneClickSigninHelper* helper = | 687 OneClickSigninHelper* helper = |
697 OneClickSigninHelper::FromWebContents(contents); | 688 OneClickSigninHelper::FromWebContents(contents); |
698 helper->SetDoNotClearPendingEmailForTesting(); | 689 helper->SetDoNotClearPendingEmailForTesting(); |
699 helper->set_do_not_start_sync_for_testing(); | 690 helper->set_do_not_start_sync_for_testing(); |
700 | 691 |
701 GURL continueUrl("https://chrome.google.com/webstore?source=5"); | 692 GURL continueUrl("https://chrome.google.com/webstore?source=5"); |
702 OneClickSigninHelper::ShowInfoBarUIThread( | 693 OneClickSigninHelper::ShowInfoBarUIThread( |
703 "session_index", "user@gmail.com", | 694 "session_index", "user@gmail.com", |
704 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT, | 695 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT, |
705 signin::SOURCE_WEBSTORE_INSTALL, | 696 signin::SOURCE_WEBSTORE_INSTALL, |
706 continueUrl, process()->GetID(), rvh()->GetRoutingID()); | 697 continueUrl, process()->GetID(), rvh()->GetRoutingID()); |
707 | 698 |
708 SubmitGAIAPassword(helper); | 699 SubmitGAIAPassword(helper); |
709 | 700 |
710 NavigateAndCommit(GURL("https://chrome.google.com/webstore?source=3")); | 701 NavigateAndCommit(GURL("https://chrome.google.com/webstore?source=3")); |
711 helper->DidStopLoading(rvh()); | 702 helper->DidStopLoading(rvh()); |
712 helper->OnStateChanged(); | 703 sync_service->NotifyObservers(); |
713 EXPECT_EQ(GURL(continueUrl), contents->GetURL()); | 704 EXPECT_EQ(GURL(continueUrl), contents->GetVisibleURL()); |
714 } | 705 } |
715 | 706 |
716 // Checks that the state of OneClickSigninHelper is cleaned when there is a | 707 // Checks that the state of OneClickSigninHelper is cleaned when there is a |
717 // navigation away from the sign in flow that is not triggered by the | 708 // navigation away from the sign in flow that is not triggered by the |
718 // web contents. | 709 // web contents. |
719 TEST_F(OneClickSigninHelperTest, CleanTransientStateOnNavigate) { | 710 TEST_F(OneClickSigninHelperTest, CleanTransientStateOnNavigate) { |
720 content::WebContents* contents = web_contents(); | 711 content::WebContents* contents = web_contents(); |
721 | 712 |
722 OneClickSigninHelper::CreateForWebContentsWithPasswordManager(contents, NULL); | 713 OneClickSigninHelper::CreateForWebContentsWithPasswordManager(contents, NULL); |
723 OneClickSigninHelper* helper = | 714 OneClickSigninHelper* helper = |
724 OneClickSigninHelper::FromWebContents(contents); | 715 OneClickSigninHelper::FromWebContents(contents); |
725 helper->SetDoNotClearPendingEmailForTesting(); | 716 helper->SetDoNotClearPendingEmailForTesting(); |
726 helper->auto_accept_ = OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT; | 717 helper->auto_accept_ = OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT; |
727 | 718 |
728 content::LoadCommittedDetails details; | 719 content::LoadCommittedDetails details; |
729 content::FrameNavigateParams params; | 720 content::FrameNavigateParams params; |
730 params.url = GURL("http://crbug.com"); | 721 params.url = GURL("http://crbug.com"); |
731 params.transition = content::PAGE_TRANSITION_TYPED; | 722 params.transition = content::PAGE_TRANSITION_TYPED; |
732 helper->DidNavigateMainFrame(details, params); | 723 helper->DidNavigateMainFrame(details, params); |
733 | 724 |
734 EXPECT_EQ(OneClickSigninHelper::AUTO_ACCEPT_NONE, helper->auto_accept_); | 725 EXPECT_EQ(OneClickSigninHelper::AUTO_ACCEPT_NONE, helper->auto_accept_); |
735 } | 726 } |
736 | 727 |
737 // Checks that OneClickSigninHelper doesn't stay an observer of the profile | |
738 // sync service after it's deleted. | |
739 TEST_F(OneClickSigninHelperTest, RemoveObserverFromProfileSyncService) { | |
740 content::WebContents* contents = web_contents(); | |
741 | |
742 ProfileSyncServiceMock* sync_service = CreateProfileSyncServiceMock(); | |
743 | |
744 OneClickSigninHelper::CreateForWebContentsWithPasswordManager(contents, NULL); | |
745 OneClickSigninHelper* helper = | |
746 OneClickSigninHelper::FromWebContents(contents); | |
747 helper->SetDoNotClearPendingEmailForTesting(); | |
748 | |
749 // Need to expect two calls, because sync service also tears down observers. | |
750 // TODO(signin): gmock probably isn't the best solution here. | |
751 EXPECT_CALL(*sync_service, RemoveObserver(_)); | |
752 EXPECT_CALL(*sync_service, RemoveObserver(helper)); | |
753 SetContents(NULL); | |
754 } | |
755 | |
756 TEST_F(OneClickSigninHelperTest, NoRedirectToNTPWithPendingEntry) { | 728 TEST_F(OneClickSigninHelperTest, NoRedirectToNTPWithPendingEntry) { |
757 content::NavigationController& controller = web_contents()->GetController(); | 729 content::NavigationController& controller = web_contents()->GetController(); |
758 EXPECT_FALSE(controller.GetPendingEntry()); | 730 EXPECT_FALSE(controller.GetPendingEntry()); |
759 | 731 |
760 const GURL fooWebUIURL("chrome://foo"); | 732 const GURL fooWebUIURL("chrome://foo"); |
761 controller.LoadURL(fooWebUIURL, content::Referrer(), | 733 controller.LoadURL(fooWebUIURL, content::Referrer(), |
762 content::PAGE_TRANSITION_TYPED, std::string()); | 734 content::PAGE_TRANSITION_TYPED, std::string()); |
763 EXPECT_EQ(fooWebUIURL, controller.GetPendingEntry()->GetURL()); | 735 EXPECT_EQ(fooWebUIURL, controller.GetPendingEntry()->GetURL()); |
764 | 736 |
765 MockWebContentsDelegate delegate; | 737 MockWebContentsDelegate delegate; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 args.email = "foo@gmail.com"; | 1012 args.email = "foo@gmail.com"; |
1041 args.profile = profile(); | 1013 args.profile = profile(); |
1042 MockStarterWrapper* wrapper = new MockStarterWrapper( | 1014 MockStarterWrapper* wrapper = new MockStarterWrapper( |
1043 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 1015 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
1044 SetCookie("LSID=1234; domain=google.com; secure; httponly"); | 1016 SetCookie("LSID=1234; domain=google.com; secure; httponly"); |
1045 | 1017 |
1046 EXPECT_CALL(*wrapper, DisplayErrorBubble(_)); | 1018 EXPECT_CALL(*wrapper, DisplayErrorBubble(_)); |
1047 wrapper->Start(); | 1019 wrapper->Start(); |
1048 base::RunLoop().RunUntilIdle(); | 1020 base::RunLoop().RunUntilIdle(); |
1049 } | 1021 } |
OLD | NEW |