Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "components/payments/mojom/payment_app.mojom.h" | 9 #include "components/payments/mojom/payment_app.mojom.h" |
| 10 #include "content/browser/payments/payment_app_content_unittest_base.h" | 10 #include "content/browser/payments/payment_app_content_unittest_base.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 void DeletePaymentInstrumentCallback(PaymentHandlerStatus* out_status, | 43 void DeletePaymentInstrumentCallback(PaymentHandlerStatus* out_status, |
| 44 PaymentHandlerStatus status) { | 44 PaymentHandlerStatus status) { |
| 45 *out_status = status; | 45 *out_status = status; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void SetPaymentInstrumentCallback(PaymentHandlerStatus* out_status, | 48 void SetPaymentInstrumentCallback(PaymentHandlerStatus* out_status, |
| 49 PaymentHandlerStatus status) { | 49 PaymentHandlerStatus status) { |
| 50 *out_status = status; | 50 *out_status = status; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void HasPaymentInstrumentCallback(PaymentHandlerStatus* out_status, | |
| 54 PaymentHandlerStatus status) { | |
| 55 *out_status = status; | |
| 56 } | |
| 57 | |
| 53 void GetPaymentInstrumentCallback(PaymentInstrumentPtr* out_instrument, | 58 void GetPaymentInstrumentCallback(PaymentInstrumentPtr* out_instrument, |
| 54 PaymentHandlerStatus* out_status, | 59 PaymentHandlerStatus* out_status, |
| 55 PaymentInstrumentPtr instrument, | 60 PaymentInstrumentPtr instrument, |
| 56 PaymentHandlerStatus status) { | 61 PaymentHandlerStatus status) { |
| 57 *out_instrument = std::move(instrument); | 62 *out_instrument = std::move(instrument); |
| 58 *out_status = status; | 63 *out_status = status; |
| 59 } | 64 } |
| 60 | 65 |
| 61 } // namespace | 66 } // namespace |
| 62 | 67 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 80 | 85 |
| 81 void SetPaymentInstrument(const std::string& instrument_key, | 86 void SetPaymentInstrument(const std::string& instrument_key, |
| 82 PaymentInstrumentPtr instrument, | 87 PaymentInstrumentPtr instrument, |
| 83 PaymentHandlerStatus* out_status) { | 88 PaymentHandlerStatus* out_status) { |
| 84 manager_->SetPaymentInstrument( | 89 manager_->SetPaymentInstrument( |
| 85 instrument_key, std::move(instrument), | 90 instrument_key, std::move(instrument), |
| 86 base::Bind(&SetPaymentInstrumentCallback, out_status)); | 91 base::Bind(&SetPaymentInstrumentCallback, out_status)); |
| 87 base::RunLoop().RunUntilIdle(); | 92 base::RunLoop().RunUntilIdle(); |
| 88 } | 93 } |
| 89 | 94 |
| 95 void HasPaymentInstrument(const std::string& instrument_key, | |
| 96 PaymentHandlerStatus* out_status) { | |
| 97 manager_->HasPaymentInstrument( | |
| 98 instrument_key, base::Bind(&HasPaymentInstrumentCallback, out_status)); | |
| 99 base::RunLoop().RunUntilIdle(); | |
| 100 } | |
| 101 | |
| 90 void GetPaymentInstrument(const std::string& instrument_key, | 102 void GetPaymentInstrument(const std::string& instrument_key, |
| 91 PaymentInstrumentPtr* out_instrument, | 103 PaymentInstrumentPtr* out_instrument, |
| 92 PaymentHandlerStatus* out_status) { | 104 PaymentHandlerStatus* out_status) { |
| 93 manager_->GetPaymentInstrument( | 105 manager_->GetPaymentInstrument( |
| 94 instrument_key, | 106 instrument_key, |
| 95 base::Bind(&GetPaymentInstrumentCallback, out_instrument, out_status)); | 107 base::Bind(&GetPaymentInstrumentCallback, out_instrument, out_status)); |
| 96 base::RunLoop().RunUntilIdle(); | 108 base::RunLoop().RunUntilIdle(); |
| 97 } | 109 } |
| 98 | 110 |
| 99 private: | 111 private: |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 228 |
| 217 PaymentHandlerStatus delete_status = PaymentHandlerStatus::NOT_FOUND; | 229 PaymentHandlerStatus delete_status = PaymentHandlerStatus::NOT_FOUND; |
| 218 DeletePaymentInstrument("test_key", &delete_status); | 230 DeletePaymentInstrument("test_key", &delete_status); |
| 219 ASSERT_EQ(PaymentHandlerStatus::SUCCESS, delete_status); | 231 ASSERT_EQ(PaymentHandlerStatus::SUCCESS, delete_status); |
| 220 | 232 |
| 221 read_status = PaymentHandlerStatus::NOT_FOUND; | 233 read_status = PaymentHandlerStatus::NOT_FOUND; |
| 222 GetPaymentInstrument("test_key", &read_details, &read_status); | 234 GetPaymentInstrument("test_key", &read_details, &read_status); |
| 223 ASSERT_EQ(PaymentHandlerStatus::NOT_FOUND, read_status); | 235 ASSERT_EQ(PaymentHandlerStatus::NOT_FOUND, read_status); |
| 224 } | 236 } |
| 225 | 237 |
| 238 TEST_F(PaymentManagerTest, HasPaymentInstrument) { | |
| 239 PaymentHandlerStatus write_status = PaymentHandlerStatus::NOT_FOUND; | |
| 240 PaymentInstrumentPtr write_details = PaymentInstrument::New(); | |
| 241 write_details->name = "Visa ending ****4756", | |
| 242 write_details->enabled_methods.push_back("visa"); | |
| 243 write_details->stringified_capabilities = "{}"; | |
| 244 ASSERT_EQ(PaymentHandlerStatus::NOT_FOUND, write_status); | |
|
please use gerrit instead
2017/04/26 15:18:26
Here and everywhere: There's no need to ASSERT_EQ(
| |
| 245 SetPaymentInstrument("test_key", std::move(write_details), &write_status); | |
| 246 ASSERT_EQ(PaymentHandlerStatus::SUCCESS, write_status); | |
| 247 | |
| 248 PaymentHandlerStatus has_status = PaymentHandlerStatus::NOT_FOUND; | |
| 249 ASSERT_EQ(PaymentHandlerStatus::NOT_FOUND, has_status); | |
| 250 HasPaymentInstrument("test_key", &has_status); | |
| 251 ASSERT_EQ(PaymentHandlerStatus::SUCCESS, has_status); | |
| 252 | |
| 253 HasPaymentInstrument("unstored_test_key", &has_status); | |
| 254 ASSERT_EQ(PaymentHandlerStatus::NOT_FOUND, has_status); | |
| 255 } | |
| 256 | |
| 226 } // namespace content | 257 } // namespace content |
| OLD | NEW |