| 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_api_call_flow.h" | 7 #include "google_apis/gaia/oauth2_api_call_flow.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 MOCK_METHOD0(CreateApiCallUrl, GURL ()); | 91 MOCK_METHOD0(CreateApiCallUrl, GURL ()); |
| 92 MOCK_METHOD0(CreateApiCallBody, std::string ()); | 92 MOCK_METHOD0(CreateApiCallBody, std::string ()); |
| 93 MOCK_METHOD1(ProcessApiCallSuccess, | 93 MOCK_METHOD1(ProcessApiCallSuccess, |
| 94 void (const URLFetcher* source)); | 94 void (const URLFetcher* source)); |
| 95 MOCK_METHOD1(ProcessApiCallFailure, | 95 MOCK_METHOD1(ProcessApiCallFailure, |
| 96 void (const URLFetcher* source)); | 96 void (const URLFetcher* source)); |
| 97 MOCK_METHOD1(ProcessNewAccessToken, | 97 MOCK_METHOD1(ProcessNewAccessToken, |
| 98 void (const std::string& access_token)); | 98 void (const std::string& access_token)); |
| 99 MOCK_METHOD1(ProcessMintAccessTokenFailure, | 99 MOCK_METHOD1(ProcessMintAccessTokenFailure, |
| 100 void (const GoogleServiceAuthError& error)); | 100 void (const GoogleServiceAuthError& error)); |
| 101 |
| 102 net::PartialNetworkTrafficAnnotationTag GetNetworkTrafficAnnotationTag() { |
| 103 return PARTIAL_TRAFFIC_ANNOTATION_FOR_TESTS; |
| 104 } |
| 101 }; | 105 }; |
| 102 | 106 |
| 103 } // namespace | 107 } // namespace |
| 104 | 108 |
| 105 class OAuth2ApiCallFlowTest : public testing::Test { | 109 class OAuth2ApiCallFlowTest : public testing::Test { |
| 106 protected: | 110 protected: |
| 107 OAuth2ApiCallFlowTest() | 111 OAuth2ApiCallFlowTest() |
| 108 : request_context_getter_(new net::TestURLRequestContextGetter( | 112 : request_context_getter_(new net::TestURLRequestContextGetter( |
| 109 message_loop_.task_runner())) {} | 113 message_loop_.task_runner())) {} |
| 110 | 114 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 TestURLFetcher* url_fetcher = SetupApiCall(true, net::HTTP_OK); | 174 TestURLFetcher* url_fetcher = SetupApiCall(true, net::HTTP_OK); |
| 171 flow_.Start(request_context_getter_.get(), kAccessToken); | 175 flow_.Start(request_context_getter_.get(), kAccessToken); |
| 172 HttpRequestHeaders headers; | 176 HttpRequestHeaders headers; |
| 173 url_fetcher->GetExtraRequestHeaders(&headers); | 177 url_fetcher->GetExtraRequestHeaders(&headers); |
| 174 std::string auth_header; | 178 std::string auth_header; |
| 175 EXPECT_TRUE(headers.GetHeader("Authorization", &auth_header)); | 179 EXPECT_TRUE(headers.GetHeader("Authorization", &auth_header)); |
| 176 EXPECT_EQ("Bearer access_token", auth_header); | 180 EXPECT_EQ("Bearer access_token", auth_header); |
| 177 EXPECT_EQ(url, url_fetcher->GetOriginalURL()); | 181 EXPECT_EQ(url, url_fetcher->GetOriginalURL()); |
| 178 EXPECT_EQ(body, url_fetcher->upload_data()); | 182 EXPECT_EQ(body, url_fetcher->upload_data()); |
| 179 } | 183 } |
| OLD | NEW |