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

Unified Diff: chrome/browser/signin/dice_response_handler_unittest.cc

Issue 2953673003: [signin] Add unit test for Gaia error in DiceResponseHandler (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/dice_response_handler_unittest.cc
diff --git a/chrome/browser/signin/dice_response_handler_unittest.cc b/chrome/browser/signin/dice_response_handler_unittest.cc
index d3f5eeaa93ac42fa8142758afa352fdeb1aa5f2c..396a282e899379a52b00538aeaad478bc4e3d7d7 100644
--- a/chrome/browser/signin/dice_response_handler_unittest.cc
+++ b/chrome/browser/signin/dice_response_handler_unittest.cc
@@ -112,6 +112,24 @@ TEST_F(DiceResponseHandlerTest, Signin) {
EXPECT_TRUE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
}
+// Checks that a GaiaAuthFetcher failure is handled correctly.
+TEST_F(DiceResponseHandlerTest, SigninFailure) {
+ DiceResponseParams dice_params = MakeDiceParams(DiceAction::SIGNIN);
+ ASSERT_FALSE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
+ dice_response_handler_.ProcessDiceHeader(dice_params);
+ // Check that a GaiaAuthFetcher has been created.
+ ASSERT_THAT(signin_client_.consumer_, testing::NotNull());
+ EXPECT_EQ(
+ 1u, dice_response_handler_.GetPendingDiceTokenFetchersCountForTesting());
+ // Simulate GaiaAuthFetcher failure.
+ signin_client_.consumer_->OnClientOAuthFailure(
+ GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
+ EXPECT_EQ(
+ 0u, dice_response_handler_.GetPendingDiceTokenFetchersCountForTesting());
+ // Check that the token has not been inserted in the token service.
+ EXPECT_FALSE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
+}
+
// Checks that a second token for the same account is not requested when a
// request is already in flight.
TEST_F(DiceResponseHandlerTest, SigninRepeatedWithSameAccount) {
@@ -176,6 +194,8 @@ TEST_F(DiceResponseHandlerTest, Timeout) {
base::TimeDelta::FromSeconds(kDiceTokenFetchTimeoutSeconds + 1));
EXPECT_EQ(
0u, dice_response_handler_.GetPendingDiceTokenFetchersCountForTesting());
+ // Check that the token has not been inserted in the token service.
+ EXPECT_FALSE(token_service_.RefreshTokenIsAvailable(dice_params.gaia_id));
}
// Tests that the DiceResponseHandler is created for a normal profile but not
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698