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

Unified Diff: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc

Issue 14029006: Properly handle user cancellation of signin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | chrome/browser/ui/webui/sync_setup_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
index 4892ab65bc936eb55aaff11a00b598eaf9942782..5cf366e00a4dcf6d29a1856302add799e3452b8f 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
@@ -216,6 +216,7 @@ class OneClickSigninHelperTest : public content::RenderViewHostTestHarness {
void SetAllowedUsernamePattern(const std::string& pattern);
ProfileSyncServiceMock* CreateProfileSyncServiceMock();
void SubmitGAIAPassword(OneClickSigninHelper* helper);
+ OneClickSigninHelper* SetupHelperForSignin();
SigninManagerMock* signin_manager_;
@@ -273,6 +274,35 @@ void OneClickSigninHelperTest::CreateSigninManager(
}
}
+OneClickSigninHelper* OneClickSigninHelperTest::SetupHelperForSignin() {
+ CreateSigninManager(false, "");
+ EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)).
+ WillRepeatedly(Return(true));
+
+ CreateProfileSyncServiceMock();
+
+ content::WebContents* contents = web_contents();
+
+ OneClickSigninHelper::CreateForWebContents(contents);
+ OneClickSigninHelper* helper =
+ OneClickSigninHelper::FromWebContents(contents);
+
+ GURL continueUrl(
+ "https://www.google.com/intl/en-US/chrome/blank.html?source=1");
+ OneClickSigninHelper::ShowInfoBarUIThread(
+ "session_index", "user@gmail.com",
+ OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT,
+ SyncPromoUI::SOURCE_NTP_LINK,
+ continueUrl, process()->GetID(), rvh()->GetRoutingID());
+
+ SubmitGAIAPassword(helper);
+
+ NavigateAndCommit(continueUrl);
+ helper->DidStopLoading(rvh());
+ helper->OnStateChanged();
+ return helper;
+}
+
void OneClickSigninHelperTest::EnableOneClick(bool enable) {
PrefService* pref_service = Profile::FromBrowserContext(
browser_context_.get())->GetPrefs();
@@ -698,35 +728,33 @@ TEST_F(OneClickSigninHelperTest, SigninFromWebstoreWithConfigSyncfirst) {
}
TEST_F(OneClickSigninHelperTest, ShowSigninBubbleAfterSigninComplete) {
- CreateSigninManager(false, std::string());
- EXPECT_CALL(*signin_manager_, IsAllowedUsername(_))
- .WillRepeatedly(Return(true));
-
- CreateProfileSyncServiceMock();
-
- content::WebContents* contents = web_contents();
+ OneClickSigninHelper* helper = SetupHelperForSignin();
+ PrefService* pref_service = profile_->GetPrefs();
+ EXPECT_EQ(pref_service->GetBoolean(prefs::kSyncPromoShowNTPBubble), false);
+ helper->SigninSuccess();
+ EXPECT_EQ(pref_service->GetBoolean(prefs::kSyncPromoShowNTPBubble), true);
+}
- OneClickSigninHelper::CreateForWebContents(contents);
- OneClickSigninHelper* helper =
- OneClickSigninHelper::FromWebContents(contents);
+TEST_F(OneClickSigninHelperTest, SigninCancelled) {
+ OneClickSigninHelper* helper = SetupHelperForSignin();
- GURL continueUrl(
- "https://www.google.com/intl/en-US/chrome/blank.html?source=1");
- OneClickSigninHelper::ShowInfoBarUIThread(
- "session_index", "user@gmail.com",
- OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT,
- SyncPromoUI::SOURCE_NTP_LINK,
- continueUrl, process()->GetID(), rvh()->GetRoutingID());
-
- SubmitGAIAPassword(helper);
+ PrefService* pref_service = profile_->GetPrefs();
+ EXPECT_EQ(pref_service->GetBoolean(prefs::kSyncPromoShowNTPBubble), false);
+ GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
+ helper->SigninFailed(error);
+ // Should not show the NTP bubble on user cancellation.
+ EXPECT_EQ(pref_service->GetBoolean(prefs::kSyncPromoShowNTPBubble), false);
+}
- NavigateAndCommit(continueUrl);
- helper->DidStopLoading(rvh());
- helper->OnStateChanged();
+TEST_F(OneClickSigninHelperTest, SigninFailed) {
+ OneClickSigninHelper* helper = SetupHelperForSignin();
PrefService* pref_service = profile_->GetPrefs();
EXPECT_EQ(pref_service->GetBoolean(prefs::kSyncPromoShowNTPBubble), false);
- helper->SigninSuccess();
+ GoogleServiceAuthError error(
+ GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
+ helper->SigninFailed(error);
+ // Should show the NTP bubble with an error.
EXPECT_EQ(pref_service->GetBoolean(prefs::kSyncPromoShowNTPBubble), true);
}
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | chrome/browser/ui/webui/sync_setup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698