| 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 // A complete set of unit tests for OAuth2MintTokenFlow. | 5 // A complete set of unit tests for OAuth2MintTokenFlow. |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 EXPECT_TRUE(OAuth2MintTokenFlow::ParseIssueAdviceResponse( | 265 EXPECT_TRUE(OAuth2MintTokenFlow::ParseIssueAdviceResponse( |
| 266 json.get(), &ia)); | 266 json.get(), &ia)); |
| 267 IssueAdviceInfo ia_expected(CreateIssueAdvice()); | 267 IssueAdviceInfo ia_expected(CreateIssueAdvice()); |
| 268 EXPECT_EQ(ia_expected, ia); | 268 EXPECT_EQ(ia_expected, ia); |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess) { | 272 TEST_F(OAuth2MintTokenFlowTest, ProcessApiCallSuccess) { |
| 273 { // No body. | 273 { // No body. |
| 274 TestURLFetcher url_fetcher(1, GURL("http://www.google.com"), NULL); | 274 TestURLFetcher url_fetcher(1, GURL("http://www.google.com"), NULL); |
| 275 url_fetcher.SetResponseString(""); | 275 url_fetcher.SetResponseString(std::string()); |
| 276 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); | 276 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); |
| 277 EXPECT_CALL(delegate_, OnMintTokenFailure(_)); | 277 EXPECT_CALL(delegate_, OnMintTokenFailure(_)); |
| 278 flow_->ProcessApiCallSuccess(&url_fetcher); | 278 flow_->ProcessApiCallSuccess(&url_fetcher); |
| 279 } | 279 } |
| 280 { // Bad json. | 280 { // Bad json. |
| 281 TestURLFetcher url_fetcher(1, GURL("http://www.google.com"), NULL); | 281 TestURLFetcher url_fetcher(1, GURL("http://www.google.com"), NULL); |
| 282 url_fetcher.SetResponseString("foo"); | 282 url_fetcher.SetResponseString("foo"); |
| 283 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); | 283 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); |
| 284 EXPECT_CALL(delegate_, OnMintTokenFailure(_)); | 284 EXPECT_CALL(delegate_, OnMintTokenFailure(_)); |
| 285 flow_->ProcessApiCallSuccess(&url_fetcher); | 285 flow_->ProcessApiCallSuccess(&url_fetcher); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 348 } |
| 349 | 349 |
| 350 { // Non-null delegate. | 350 { // Non-null delegate. |
| 351 GoogleServiceAuthError error( | 351 GoogleServiceAuthError error( |
| 352 GoogleServiceAuthError::FromConnectionError(101)); | 352 GoogleServiceAuthError::FromConnectionError(101)); |
| 353 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); | 353 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); |
| 354 EXPECT_CALL(delegate_, OnMintTokenFailure(error)); | 354 EXPECT_CALL(delegate_, OnMintTokenFailure(error)); |
| 355 flow_->ProcessMintAccessTokenFailure(error); | 355 flow_->ProcessMintAccessTokenFailure(error); |
| 356 } | 356 } |
| 357 } | 357 } |
| OLD | NEW |