| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 void OnDidGetRealPan(AutofillClient::PaymentsRpcResult result, | 53 void OnDidGetRealPan(AutofillClient::PaymentsRpcResult result, |
| 54 const std::string& real_pan) override { | 54 const std::string& real_pan) override { |
| 55 result_ = result; | 55 result_ = result; |
| 56 real_pan_ = real_pan; | 56 real_pan_ = real_pan; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void OnDidGetUploadDetails( | 59 void OnDidGetUploadDetails( |
| 60 AutofillClient::PaymentsRpcResult result, | 60 AutofillClient::PaymentsRpcResult result, |
| 61 const base::string16& context_token, | 61 const base::string16& context_token, |
| 62 scoped_ptr<base::DictionaryValue> legal_message) override { | 62 std::unique_ptr<base::DictionaryValue> legal_message) override { |
| 63 result_ = result; | 63 result_ = result; |
| 64 legal_message_ = std::move(legal_message); | 64 legal_message_ = std::move(legal_message); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void OnDidUploadCard(AutofillClient::PaymentsRpcResult result) override { | 67 void OnDidUploadCard(AutofillClient::PaymentsRpcResult result) override { |
| 68 result_ = result; | 68 result_ = result; |
| 69 } | 69 } |
| 70 | 70 |
| 71 protected: | 71 protected: |
| 72 void StartUnmasking() { | 72 void StartUnmasking() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 const std::string& response_body) { | 117 const std::string& response_body) { |
| 118 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); | 118 net::TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
| 119 ASSERT_TRUE(fetcher); | 119 ASSERT_TRUE(fetcher); |
| 120 fetcher->set_response_code(response_code); | 120 fetcher->set_response_code(response_code); |
| 121 fetcher->SetResponseString(response_body); | 121 fetcher->SetResponseString(response_body); |
| 122 fetcher->delegate()->OnURLFetchComplete(fetcher); | 122 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 123 } | 123 } |
| 124 | 124 |
| 125 AutofillClient::PaymentsRpcResult result_; | 125 AutofillClient::PaymentsRpcResult result_; |
| 126 std::string real_pan_; | 126 std::string real_pan_; |
| 127 scoped_ptr<base::DictionaryValue> legal_message_; | 127 std::unique_ptr<base::DictionaryValue> legal_message_; |
| 128 | 128 |
| 129 content::TestBrowserThreadBundle thread_bundle_; | 129 content::TestBrowserThreadBundle thread_bundle_; |
| 130 net::TestURLFetcherFactory factory_; | 130 net::TestURLFetcherFactory factory_; |
| 131 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 131 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
| 132 scoped_ptr<FakeOAuth2TokenService> token_service_; | 132 std::unique_ptr<FakeOAuth2TokenService> token_service_; |
| 133 scoped_ptr<FakeIdentityProvider> identity_provider_; | 133 std::unique_ptr<FakeIdentityProvider> identity_provider_; |
| 134 scoped_ptr<PaymentsClient> client_; | 134 std::unique_ptr<PaymentsClient> client_; |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 DISALLOW_COPY_AND_ASSIGN(PaymentsClientTest); | 137 DISALLOW_COPY_AND_ASSIGN(PaymentsClientTest); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 TEST_F(PaymentsClientTest, OAuthError) { | 140 TEST_F(PaymentsClientTest, OAuthError) { |
| 141 StartUnmasking(); | 141 StartUnmasking(); |
| 142 token_service_->IssueErrorForAllPendingRequestsForAccount( | 142 token_service_->IssueErrorForAllPendingRequestsForAccount( |
| 143 "example@gmail.com", | 143 "example@gmail.com", |
| 144 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); | 144 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 TEST_F(PaymentsClientTest, OtherError) { | 275 TEST_F(PaymentsClientTest, OtherError) { |
| 276 StartUnmasking(); | 276 StartUnmasking(); |
| 277 IssueOAuthToken(); | 277 IssueOAuthToken(); |
| 278 ReturnResponse(net::HTTP_FORBIDDEN, std::string()); | 278 ReturnResponse(net::HTTP_FORBIDDEN, std::string()); |
| 279 EXPECT_EQ(AutofillClient::PERMANENT_FAILURE, result_); | 279 EXPECT_EQ(AutofillClient::PERMANENT_FAILURE, result_); |
| 280 EXPECT_EQ("", real_pan_); | 280 EXPECT_EQ("", real_pan_); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace autofill | 283 } // namespace autofill |
| 284 } // namespace payments | 284 } // namespace payments |
| OLD | NEW |