| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/thread_task_runner_handle.h" |
| 6 #include "components/autofill/core/browser/autofill_test_utils.h" | 7 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 7 #include "components/autofill/core/browser/wallet/real_pan_wallet_client.h" | 8 #include "components/autofill/core/browser/wallet/real_pan_wallet_client.h" |
| 8 #include "components/autofill/core/common/autofill_switches.h" | 9 #include "components/autofill/core/common/autofill_switches.h" |
| 9 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| 10 #include "google_apis/gaia/fake_identity_provider.h" | 11 #include "google_apis/gaia/fake_identity_provider.h" |
| 11 #include "google_apis/gaia/fake_oauth2_token_service.h" | 12 #include "google_apis/gaia/fake_oauth2_token_service.h" |
| 12 #include "net/url_request/test_url_fetcher_factory.h" | 13 #include "net/url_request/test_url_fetcher_factory.h" |
| 13 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace autofill { | 17 namespace autofill { |
| 17 namespace wallet { | 18 namespace wallet { |
| 18 | 19 |
| 19 class RealPanWalletClientTest : public testing::Test, | 20 class RealPanWalletClientTest : public testing::Test, |
| 20 public RealPanWalletClient::Delegate { | 21 public RealPanWalletClient::Delegate { |
| 21 public: | 22 public: |
| 22 RealPanWalletClientTest() : result_(AutofillClient::SUCCESS) {} | 23 RealPanWalletClientTest() : result_(AutofillClient::SUCCESS) {} |
| 23 ~RealPanWalletClientTest() override {} | 24 ~RealPanWalletClientTest() override {} |
| 24 | 25 |
| 25 void SetUp() override { | 26 void SetUp() override { |
| 26 // Silence the warning for mismatching sync and wallet servers. | 27 // Silence the warning for mismatching sync and wallet servers. |
| 27 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 28 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 28 switches::kWalletServiceUseSandbox, "0"); | 29 switches::kWalletServiceUseSandbox, "0"); |
| 29 | 30 |
| 30 request_context_ = new net::TestURLRequestContextGetter( | 31 request_context_ = new net::TestURLRequestContextGetter( |
| 31 base::MessageLoopProxy::current()); | 32 base::ThreadTaskRunnerHandle::Get()); |
| 32 token_service_.reset(new FakeOAuth2TokenService()); | 33 token_service_.reset(new FakeOAuth2TokenService()); |
| 33 identity_provider_.reset(new FakeIdentityProvider(token_service_.get())); | 34 identity_provider_.reset(new FakeIdentityProvider(token_service_.get())); |
| 34 client_.reset(new RealPanWalletClient(request_context_.get(), this)); | 35 client_.reset(new RealPanWalletClient(request_context_.get(), this)); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void TearDown() override { client_.reset(); } | 38 void TearDown() override { client_.reset(); } |
| 38 | 39 |
| 39 // RealPanWalletClient::Delegate | 40 // RealPanWalletClient::Delegate |
| 40 | 41 |
| 41 IdentityProvider* GetIdentityProvider() override { | 42 IdentityProvider* GetIdentityProvider() override { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 TEST_F(RealPanWalletClientTest, OtherError) { | 188 TEST_F(RealPanWalletClientTest, OtherError) { |
| 188 StartUnmasking(); | 189 StartUnmasking(); |
| 189 IssueOAuthToken(); | 190 IssueOAuthToken(); |
| 190 ReturnResponse(net::HTTP_FORBIDDEN, std::string()); | 191 ReturnResponse(net::HTTP_FORBIDDEN, std::string()); |
| 191 EXPECT_EQ(AutofillClient::PERMANENT_FAILURE, result_); | 192 EXPECT_EQ(AutofillClient::PERMANENT_FAILURE, result_); |
| 192 EXPECT_EQ("", real_pan_); | 193 EXPECT_EQ("", real_pan_); |
| 193 } | 194 } |
| 194 | 195 |
| 195 } // namespace autofill | 196 } // namespace autofill |
| 196 } // namespace wallet | 197 } // namespace wallet |
| OLD | NEW |