| 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 "google_apis/gaia/oauth2_mint_token_flow.h" | 7 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 std::vector<std::string> scopes(CreateTestScopes()); | 173 std::vector<std::string> scopes(CreateTestScopes()); |
| 174 flow_.reset(new MockMintTokenFlow( | 174 flow_.reset(new MockMintTokenFlow( |
| 175 delegate, OAuth2MintTokenFlow::Parameters(ext_id, client_id, scopes, | 175 delegate, OAuth2MintTokenFlow::Parameters(ext_id, client_id, scopes, |
| 176 device_id, mode))); | 176 device_id, mode))); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Helper to parse the given string to DictionaryValue. | 179 // Helper to parse the given string to DictionaryValue. |
| 180 static base::DictionaryValue* ParseJson(const std::string& str) { | 180 static base::DictionaryValue* ParseJson(const std::string& str) { |
| 181 std::unique_ptr<base::Value> value = base::JSONReader::Read(str); | 181 std::unique_ptr<base::Value> value = base::JSONReader::Read(str); |
| 182 EXPECT_TRUE(value.get()); | 182 EXPECT_TRUE(value.get()); |
| 183 EXPECT_EQ(base::Value::TYPE_DICTIONARY, value->GetType()); | 183 EXPECT_EQ(base::Value::Type::DICTIONARY, value->GetType()); |
| 184 return static_cast<base::DictionaryValue*>(value.release()); | 184 return static_cast<base::DictionaryValue*>(value.release()); |
| 185 } | 185 } |
| 186 | 186 |
| 187 std::unique_ptr<MockMintTokenFlow> flow_; | 187 std::unique_ptr<MockMintTokenFlow> flow_; |
| 188 StrictMock<MockDelegate> delegate_; | 188 StrictMock<MockDelegate> delegate_; |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBody) { | 191 TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBody) { |
| 192 { // Issue advice mode. | 192 { // Issue advice mode. |
| 193 CreateFlow(OAuth2MintTokenFlow::MODE_ISSUE_ADVICE); | 193 CreateFlow(OAuth2MintTokenFlow::MODE_ISSUE_ADVICE); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 | 361 |
| 362 { // Non-null delegate. | 362 { // Non-null delegate. |
| 363 TestURLFetcher url_fetcher(1, GURL("http://www.google.com"), NULL); | 363 TestURLFetcher url_fetcher(1, GURL("http://www.google.com"), NULL); |
| 364 url_fetcher.set_status(URLRequestStatus::FromError(net::ERR_FAILED)); | 364 url_fetcher.set_status(URLRequestStatus::FromError(net::ERR_FAILED)); |
| 365 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); | 365 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); |
| 366 EXPECT_CALL(delegate_, OnMintTokenFailure(_)); | 366 EXPECT_CALL(delegate_, OnMintTokenFailure(_)); |
| 367 flow_->ProcessApiCallFailure(&url_fetcher); | 367 flow_->ProcessApiCallFailure(&url_fetcher); |
| 368 } | 368 } |
| 369 } | 369 } |
| OLD | NEW |