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

Unified Diff: components/signin/core/browser/gaia_cookie_manager_service_unittest.cc

Issue 1070563004: GCMS has automatic checks for CheckExternalConnections. It will be (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AccountReconcilor tests need a fake list_accounts response, not a fake check_cc_results response. Created 5 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 | « components/signin/core/browser/gaia_cookie_manager_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/signin/core/browser/gaia_cookie_manager_service_unittest.cc
diff --git a/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc b/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc
index 9b584b075bc66812ac9c3de8804bfac2cbcc163e..cc0445220f596c801886af3f181d4e70f6ff2d12 100644
--- a/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc
+++ b/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc
@@ -76,6 +76,11 @@ class GaiaCookieManagerServiceTest : public testing::Test {
OAuth2TokenService* token_service() { return &token_service_; }
SigninClient* signin_client() { return &signin_client_; }
+ void SimulateUbertokenSuccess(UbertokenConsumer* consumer,
+ const std::string& uber_token) {
+ consumer->OnUbertokenSuccess(uber_token);
+ }
+
void SimulateUbertokenFailure(UbertokenConsumer* consumer,
const GoogleServiceAuthError& error) {
consumer->OnUbertokenFailure(error);
@@ -460,8 +465,7 @@ TEST_F(GaiaCookieManagerServiceTest, CancelSignIn) {
TEST_F(GaiaCookieManagerServiceTest, ExternalCcResultFetcher) {
InstrumentedGaiaCookieManagerService helper(token_service(), signin_client());
GaiaCookieManagerService::ExternalCcResultFetcher result_fetcher(&helper);
- MockObserver observer(&helper);
- EXPECT_CALL(observer, GetCheckConnectionInfoCompleted(true));
+ EXPECT_CALL(helper, StartFetchingMergeSession());
result_fetcher.Start();
// Simulate a successful completion of GetCheckConnctionInfo.
@@ -491,8 +495,7 @@ TEST_F(GaiaCookieManagerServiceTest, ExternalCcResultFetcher) {
TEST_F(GaiaCookieManagerServiceTest, ExternalCcResultFetcherTimeout) {
InstrumentedGaiaCookieManagerService helper(token_service(), signin_client());
GaiaCookieManagerService::ExternalCcResultFetcher result_fetcher(&helper);
- MockObserver observer(&helper);
- EXPECT_CALL(observer, GetCheckConnectionInfoCompleted(false));
+ EXPECT_CALL(helper, StartFetchingMergeSession());
result_fetcher.Start();
// Simulate a successful completion of GetCheckConnctionInfo.
@@ -525,6 +528,7 @@ TEST_F(GaiaCookieManagerServiceTest, ExternalCcResultFetcherTimeout) {
TEST_F(GaiaCookieManagerServiceTest, ExternalCcResultFetcherTruncate) {
InstrumentedGaiaCookieManagerService helper(token_service(), signin_client());
GaiaCookieManagerService::ExternalCcResultFetcher result_fetcher(&helper);
+ EXPECT_CALL(helper, StartFetchingMergeSession());
result_fetcher.Start();
// Simulate a successful completion of GetCheckConnctionInfo.
@@ -544,3 +548,39 @@ TEST_F(GaiaCookieManagerServiceTest, ExternalCcResultFetcherTruncate) {
fetchers[GURL("http://www.yt.com")].second, "1234567890123456trunc");
ASSERT_EQ("yt:1234567890123456", result_fetcher.GetExternalCcResult());
}
+
+TEST_F(GaiaCookieManagerServiceTest, UbertokenSuccessFetchesExternalCC) {
+ InstrumentedGaiaCookieManagerService helper(token_service(), signin_client());
+
+ EXPECT_CALL(helper, StartFetchingUbertoken());
+ helper.AddAccountToCookie("acc1@gmail.com");
+
+ ASSERT_FALSE(factory()->GetFetcherByID(0));
+ SimulateUbertokenSuccess(&helper, "token");
+
+ // Check there is now a fetcher that belongs to the ExternalCCResultFetcher.
+ net::TestURLFetcher* fetcher = factory()->GetFetcherByID(0);
+ ASSERT_TRUE(NULL != fetcher);
+ SimulateGetCheckConnctionInfoSuccess(
+ fetcher,
+ "[{\"carryBackToken\": \"bl\", \"url\": \"http://www.bl.com\"}]");
+ GaiaCookieManagerService::ExternalCcResultFetcher* result_fetcher =
+ helper.external_cc_result_fetcher_for_testing();
+ GaiaCookieManagerService::ExternalCcResultFetcher::URLToTokenAndFetcher
+ fetchers = result_fetcher->get_fetcher_map_for_testing();
+ ASSERT_EQ(1u, fetchers.size());
+ ASSERT_EQ(1u, fetchers.count(GURL("http://www.bl.com")));
+}
+
+TEST_F(GaiaCookieManagerServiceTest, UbertokenSuccessFetchesExternalCCOnce) {
+ InstrumentedGaiaCookieManagerService helper(token_service(), signin_client());
+
+ helper.external_cc_result_fetcher_for_testing()->Start();
+
+ EXPECT_CALL(helper, StartFetchingUbertoken());
+ helper.AddAccountToCookie("acc2@gmail.com");
+ // There is already a ExternalCCResultFetch underway. This will trigger
+ // StartFetchingMergeSession.
+ EXPECT_CALL(helper, StartFetchingMergeSession());
+ SimulateUbertokenSuccess(&helper, "token3");
+}
« no previous file with comments | « components/signin/core/browser/gaia_cookie_manager_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698