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

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

Issue 19705013: [password autofill] Remove references to PasswordForm from RenderViewImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/utf_string_conversions.h" 6 #include "base/strings/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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(true)); 318 EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(true));
319 return sync_service; 319 return sync_service;
320 } 320 }
321 321
322 void OneClickSigninHelperTest::SubmitGAIAPassword( 322 void OneClickSigninHelperTest::SubmitGAIAPassword(
323 OneClickSigninHelper* helper) { 323 OneClickSigninHelper* helper) {
324 content::PasswordForm password_form; 324 content::PasswordForm password_form;
325 password_form.origin = GURL("https://accounts.google.com"); 325 password_form.origin = GURL("https://accounts.google.com");
326 password_form.signon_realm = "https://accounts.google.com"; 326 password_form.signon_realm = "https://accounts.google.com";
327 password_form.password_value = UTF8ToUTF16("password"); 327 password_form.password_value = UTF8ToUTF16("password");
328 helper->OnFormSubmitted(password_form); 328 helper->PasswordSubmitted(password_form);
329 } 329 }
330 330
331 class OneClickSigninHelperIOTest : public OneClickSigninHelperTest { 331 class OneClickSigninHelperIOTest : public OneClickSigninHelperTest {
332 public: 332 public:
333 OneClickSigninHelperIOTest(); 333 OneClickSigninHelperIOTest();
334 334
335 virtual void SetUp() OVERRIDE; 335 virtual void SetUp() OVERRIDE;
336 336
337 TestProfileIOData* CreateTestProfileIOData(bool is_incognito); 337 TestProfileIOData* CreateTestProfileIOData(bool is_incognito);
338 338
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // and upon successful setup, redirect back to webstore. 643 // and upon successful setup, redirect back to webstore.
644 TEST_F(OneClickSigninHelperTest, SigninFromWebstoreWithConfigSyncfirst) { 644 TEST_F(OneClickSigninHelperTest, SigninFromWebstoreWithConfigSyncfirst) {
645 CreateSigninManager(false, std::string()); 645 CreateSigninManager(false, std::string());
646 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)) 646 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_))
647 .WillRepeatedly(Return(true)); 647 .WillRepeatedly(Return(true));
648 648
649 CreateProfileSyncServiceMock(); 649 CreateProfileSyncServiceMock();
650 650
651 content::WebContents* contents = web_contents(); 651 content::WebContents* contents = web_contents();
652 652
653 OneClickSigninHelper::CreateForWebContents(contents); 653 OneClickSigninHelper::CreateForWebContentsWithPasswordManager(contents, NULL);
654 OneClickSigninHelper* helper = 654 OneClickSigninHelper* helper =
655 OneClickSigninHelper::FromWebContents(contents); 655 OneClickSigninHelper::FromWebContents(contents);
656 helper->SetDoNotClearPendingEmailForTesting(); 656 helper->SetDoNotClearPendingEmailForTesting();
657 657
658 GURL continueUrl("https://chrome.google.com/webstore?source=5"); 658 GURL continueUrl("https://chrome.google.com/webstore?source=5");
659 OneClickSigninHelper::ShowInfoBarUIThread( 659 OneClickSigninHelper::ShowInfoBarUIThread(
660 "session_index", "user@gmail.com", 660 "session_index", "user@gmail.com",
661 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT, 661 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT,
662 signin::SOURCE_WEBSTORE_INSTALL, 662 signin::SOURCE_WEBSTORE_INSTALL,
663 continueUrl, process()->GetID(), rvh()->GetRoutingID()); 663 continueUrl, process()->GetID(), rvh()->GetRoutingID());
664 664
665 SubmitGAIAPassword(helper); 665 SubmitGAIAPassword(helper);
666 666
667 NavigateAndCommit(GURL("https://chrome.google.com/webstore?source=3")); 667 NavigateAndCommit(GURL("https://chrome.google.com/webstore?source=3"));
668 helper->DidStopLoading(rvh()); 668 helper->DidStopLoading(rvh());
669 669
670 helper->OnStateChanged(); 670 helper->OnStateChanged();
671 EXPECT_EQ(GURL(continueUrl), contents->GetURL()); 671 EXPECT_EQ(GURL(continueUrl), contents->GetURL());
672 EXPECT_EQ("user@gmail.com", signin_manager_->GetAuthenticatedUsername()); 672 EXPECT_EQ("user@gmail.com", signin_manager_->GetAuthenticatedUsername());
673 } 673 }
674 674
675 // Checks that the state of OneClickSigninHelper is cleaned when there is a 675 // Checks that the state of OneClickSigninHelper is cleaned when there is a
676 // navigation away from the sign in flow that is not triggered by the 676 // navigation away from the sign in flow that is not triggered by the
677 // web contents. 677 // web contents.
678 TEST_F(OneClickSigninHelperTest, CleanTransientStateOnNavigate) { 678 TEST_F(OneClickSigninHelperTest, CleanTransientStateOnNavigate) {
679 content::WebContents* contents = web_contents(); 679 content::WebContents* contents = web_contents();
680 680
681 OneClickSigninHelper::CreateForWebContents(contents); 681 OneClickSigninHelper::CreateForWebContentsWithPasswordManager(contents, NULL);
682 OneClickSigninHelper* helper = 682 OneClickSigninHelper* helper =
683 OneClickSigninHelper::FromWebContents(contents); 683 OneClickSigninHelper::FromWebContents(contents);
684 helper->SetDoNotClearPendingEmailForTesting(); 684 helper->SetDoNotClearPendingEmailForTesting();
685 helper->auto_accept_ = OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT; 685 helper->auto_accept_ = OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT;
686 686
687 content::LoadCommittedDetails details; 687 content::LoadCommittedDetails details;
688 content::FrameNavigateParams params; 688 content::FrameNavigateParams params;
689 params.url = GURL("http://crbug.com"); 689 params.url = GURL("http://crbug.com");
690 params.transition = content::PAGE_TRANSITION_TYPED; 690 params.transition = content::PAGE_TRANSITION_TYPED;
691 helper->DidNavigateMainFrame(details, params); 691 helper->DidNavigateMainFrame(details, params);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); 842 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
843 843
844 // Simulate a policy disabling sync by writing kSyncManaged directly. 844 // Simulate a policy disabling sync by writing kSyncManaged directly.
845 // We should still offer to sign in the browser. 845 // We should still offer to sign in the browser.
846 profile()->GetTestingPrefService()->SetManagedPref( 846 profile()->GetTestingPrefService()->SetManagedPref(
847 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); 847 prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
848 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, 848 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER,
849 OneClickSigninHelper::CanOfferOnIOThreadImpl( 849 OneClickSigninHelper::CanOfferOnIOThreadImpl(
850 valid_gaia_url_, std::string(), &request_, io_data.get())); 850 valid_gaia_url_, std::string(), &request_, io_data.get()));
851 } 851 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698